/* Desktop Web workspace. The mobile H5 layout remains in styles.css. */
.desktop-nav-brand {
  display: none;
}

@media (max-width: 360px) and (max-height: 760px) {
  .city-summary {
    position: relative;
    z-index: 6;
    margin-top: 10px;
    background: var(--bg);
  }
}

@media (min-width: 900px) {
  :root {
    --desktop-topbar-height: 72px;
    --desktop-content-width: 1440px;
    --desktop-page-padding: clamp(24px, 3vw, 48px);
  }

  html,
  body {
    min-height: 100%;
    background: var(--bg);
  }

  body {
    min-height: 100vh;
    overflow-x: hidden;
  }

  .app-shell {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--bg);
    box-shadow: none;
  }

  /* The existing mobile navigation becomes a single desktop top bar. */
  .bottom-nav {
    position: fixed;
    z-index: 20;
    inset: 0 0 auto 0;
    width: 100%;
    height: var(--desktop-topbar-height);
    min-height: var(--desktop-topbar-height);
    padding: 0 clamp(20px, 3vw, 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: none;
    transform: none;
    backdrop-filter: blur(14px);
  }

  .bottom-nav::after {
    content: "";
    flex: 0 0 230px;
  }

  .desktop-nav-brand {
    flex: 0 0 230px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    white-space: nowrap;
  }

  .desktop-nav-brand span {
    width: 38px;
    height: 38px;
    display: grid;
    flex: 0 0 38px;
    place-items: center;
    border-radius: 8px;
    background: #d7eee4;
    color: #176b59;
    font-size: 1rem;
    font-weight: 700;
  }

  .desktop-nav-brand strong {
    font-size: 1rem;
    font-weight: 650;
  }

  .nav-button {
    width: auto;
    min-width: 88px;
    min-height: 44px;
    position: relative;
    padding: 0 14px;
    flex-direction: row;
    gap: 8px;
    border-radius: 8px;
    color: #617a73;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease;
  }

  .nav-button:hover {
    background: #edf6f2;
    color: #176b59;
  }

  .nav-button.is-active {
    border-radius: 8px;
    background: #d7eee4;
    color: #176b59;
  }

  .nav-button.is-active::after {
    content: "";
    position: absolute;
    right: 14px;
    bottom: -14px;
    left: 14px;
    height: 2px;
    background: #176b59;
  }

  .nav-button svg {
    width: 18px;
    height: 18px;
  }

  .view.is-active {
    width: min(100%, var(--desktop-content-width));
    min-width: 0;
    min-height: calc(100dvh - var(--desktop-topbar-height));
    margin: var(--desktop-topbar-height) auto 0;
    padding: 28px var(--desktop-page-padding);
  }

  .page-header,
  .section-header {
    min-height: 58px;
    align-items: flex-start;
  }

  .section-header h2 {
    margin-bottom: 0;
    font-size: 1.75rem;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 0.8rem;
  }

  .icon-button {
    cursor: pointer;
  }

  /* Home: greeting, personal merit, woodfish, shared metrics, then settlement. */
  #home-view.is-active {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: auto auto minmax(250px, 1fr) auto auto;
    min-height: 100dvh;
    margin-top: 0;
    padding-top: calc(var(--desktop-topbar-height) + 28px);
    align-items: stretch;
    gap: 16px 20px;
    overflow: hidden;
  }

  #home-view .page-header {
    min-height: 0;
    position: absolute;
  }

  #home-view .page-header h1 {
    width: 1px;
    height: 1px;
    position: absolute;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  #home-view #sound-toggle {
    position: fixed;
    z-index: 30;
    top: 14px;
    right: clamp(20px, 3vw, 40px);
  }

  #home-view .home-presence {
    height: var(--desktop-topbar-height);
    position: fixed;
    z-index: 29;
    top: 0;
    right: clamp(78px, 7vw, 102px);
    display: flex;
    align-items: center;
    margin: 0;
  }

  #home-view .home-presence .presence {
    margin: 0;
    font-size: 0.875rem;
    white-space: nowrap;
  }

  #home-view .home-presence .company-pill {
    display: none;
  }

  #home-view .home-greeting {
    grid-column: 1 / -1;
    grid-row: 1;
    align-self: center;
    margin: 0;
    text-align: center;
  }

  #home-view .home-greeting h2 {
    margin: 0 0 8px;
    font-size: clamp(1.75rem, 2.15vw, 2.25rem);
    line-height: 1.22;
  }

  #home-view .home-greeting br {
    display: none;
  }

  #home-view .home-greeting p {
    margin: 0;
    font-size: 0.95rem;
  }

  #home-view .merit-summary {
    grid-column: 5 / 9;
    grid-row: 2;
    align-self: center;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin: 0;
    min-height: 44px;
    padding: 2px 12px;
    border: 0;
    background: transparent;
    text-align: center;
  }

  #home-view .merit-summary p {
    font-size: 0.875rem;
  }

  #home-view .merit-summary strong {
    margin-top: 0;
    font-size: clamp(1.8rem, 2.4vw, 2.25rem);
    line-height: 1;
  }

  #home-view .merit-summary > span {
    font-size: 0.9rem;
  }

  #home-view .city-summary {
    grid-column: 4 / 10;
    grid-row: 4;
    align-self: center;
    margin: 0;
    min-height: 70px;
    border: 0;
    background: transparent;
  }

  #home-view .metric-row {
    width: min(100%, 620px);
    margin: 0;
    margin-inline: auto;
    border: 0;
  }

  #home-view .metric-row > div {
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px 20px;
  }

  #home-view .metric-row > div:first-child {
    border-left: 0;
  }

  #home-view .metric-row b {
    font-size: clamp(1.75rem, 2.25vw, 2rem);
    line-height: 1.1;
  }

  #home-view .metric-row small {
    margin-top: 6px;
    font-size: 0.875rem;
  }

  #home-view .woodfish-stage {
    grid-column: 1 / -1;
    grid-row: 3;
    min-height: clamp(250px, calc(100dvh - 610px), 430px);
    max-height: 430px;
    height: 100%;
    align-self: center;
    justify-content: center;
    padding: 4px 0 10px;
  }

  #home-view .woodfish-stage::before {
    top: 50%;
    width: clamp(390px, 36vw, 540px);
    height: clamp(250px, 24vw, 340px);
    margin-top: 0;
    transform: translate(-50%, -44%);
  }

  #home-view .woodfish-button {
    width: 340px;
    height: 250px;
    margin: 0;
    transform: scale(1.35);
  }

  #home-view .woodfish-body {
    left: 50%;
    margin-left: -90px;
  }

  #home-view .gummy-ripple {
    left: 50%;
    margin-left: -97px;
  }

  #home-view .woodfish-stage > p {
    margin-top: 18px;
    font-size: 0.875rem;
  }

  #home-view .home-actions {
    --desktop-action-width: clamp(190px, 16vw, 240px);
    grid-column: 2 / 12;
    grid-row: 5;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--desktop-action-width);
    gap: 20px;
    align-items: stretch;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  #home-view .reward-progress {
    min-width: 0;
    min-height: 80px;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--desktop-action-width);
    grid-template-rows: auto auto auto;
    column-gap: 20px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  #home-view .progress-heading {
    grid-column: 1;
    grid-row: 1;
  }

  #home-view .progress-heading h2,
  #home-view .progress-heading output {
    font-size: 1rem;
  }

  #home-view .progress-track {
    grid-column: 1;
    grid-row: 2;
    margin-top: 8px;
  }

  #home-view #progress-hint {
    grid-column: 1;
    grid-row: 3;
    margin-top: 7px;
    font-size: 0.8125rem;
  }

  #home-view .reward-progress .action-button {
    grid-column: 2;
    grid-row: 1 / 4;
    align-self: center;
    min-height: 48px;
    margin: 0;
    border: 1px solid #176b59;
    border-radius: 8px;
  }

  #home-view .reward-progress .action-button:disabled {
    border-color: #b9d7cc;
    background: transparent;
    color: #5e7d74;
    opacity: 1;
  }

  #home-view .primary-actions {
    min-width: 0;
    min-height: 80px;
    display: flex;
    align-items: center;
    margin: 0;
  }

  #home-view .finish-button {
    width: 100%;
    min-height: 48px;
    height: 48px;
    margin: 0;
    border: 0;
    border-radius: 8px;
    background: #176b59;
    color: #fff;
  }

  /* City lights continue to use a large map and a dedicated ranking rail. */
  #city-view.is-active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(320px, 28vw, 400px);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 20px 24px;
    align-items: stretch;
  }

  #city-view > .section-header {
    grid-column: 1 / -1;
  }

  .province-map-section,
  .ranking-section {
    min-width: 0;
    margin-top: 0;
    border-radius: 8px;
  }

  .province-map-heading {
    padding: 18px 20px 14px;
  }

  .province-map-heading h3,
  .ranking-heading h3 {
    font-size: 1.05rem;
  }

  .province-map-heading p,
  .province-map-note,
  .ranking-heading p {
    font-size: 0.8rem;
  }

  .province-map-frame {
    height: clamp(320px, calc(100dvh - 430px), 650px);
  }

  .province-summary {
    min-height: 76px;
    padding: 14px 20px;
  }

  .province-summary-name span,
  .province-summary dt {
    font-size: 0.75rem;
  }

  .province-summary-name strong {
    font-size: 1.2rem;
  }

  .province-summary dd {
    font-size: 0.9rem;
  }

  .province-map-legend {
    padding: 11px 20px 5px;
    font-size: 0.72rem;
  }

  .province-map-note {
    padding: 0 20px 14px;
  }

  .ranking-section {
    max-height: calc(100dvh - 128px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .ranking-list {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #b9d9cc transparent;
  }

  .ranking-row {
    min-height: 55px;
    font-size: 0.875rem;
    cursor: pointer;
  }

  .ranking-row:hover {
    background: #f0f8f4;
  }

  .current-city-rank {
    flex: 0 0 auto;
  }

  /* Community and profile share the same top navigation and reading width. */
  #community-view.is-active {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-content: start;
    column-gap: 20px;
  }

  #community-view > .section-header,
  #community-view > .section-intro,
  #community-view > .filter-row,
  #community-view > .composer-trigger,
  #community-view > .community-feed {
    grid-column: 1 / -1;
  }

  #community-view .section-intro {
    font-size: 1rem;
  }

  #community-view .filter-row {
    width: min(900px, 100%);
    justify-self: center;
    margin-top: 18px;
  }

  #community-view .filter-button {
    min-height: 40px;
    padding-inline: 18px;
    font-size: 0.875rem;
  }

  #community-view .composer-trigger {
    width: min(900px, 100%);
    justify-self: center;
    min-height: 54px;
    margin-top: 14px;
    font-size: 0.95rem;
  }

  .community-feed {
    width: min(900px, 100%);
    justify-self: center;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin-top: 20px;
  }

  .feed-item {
    height: auto;
    margin: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .feed-content {
    font-size: 0.95rem;
    line-height: 1.7;
  }

  .reaction-button {
    font-size: 0.875rem;
  }

  #profile-view.is-active {
    display: grid;
    grid-template-columns: minmax(300px, 0.72fr) minmax(480px, 1.28fr);
    column-gap: 28px;
    align-content: start;
  }

  #profile-view > .section-header {
    grid-column: 1 / -1;
  }

  #profile-view .profile-header,
  #profile-view .wechat-login-button,
  #profile-view .profile-stats {
    grid-column: 1;
  }

  #profile-view .profile-menu,
  #profile-view .finish-preview {
    grid-column: 2;
  }

  #profile-view .profile-menu {
    grid-row: 2 / span 3;
    margin-top: 18px;
    border-radius: 8px;
  }

  #profile-view .profile-header,
  #profile-view .profile-stats,
  #profile-view .finish-preview {
    border-radius: 8px;
  }

  #profile-view .profile-menu button {
    min-height: 66px;
    font-size: 0.95rem;
  }

  #profile-view .finish-preview {
    margin-top: 18px;
    padding: 24px;
  }

  .sheet-dialog {
    width: min(480px, calc(100% - 48px));
    margin: auto;
    border-radius: 8px;
  }

  .sheet-content {
    padding: 28px;
  }

  .sheet-handle {
    display: none;
  }

  .toast {
    bottom: 24px;
  }
}

@media (min-width: 900px) and (max-width: 1199px) {
  :root {
    --desktop-page-padding: 24px;
  }

  .bottom-nav {
    padding-inline: 18px;
    gap: 2px;
  }

  .bottom-nav::after,
  .desktop-nav-brand {
    flex-basis: 190px;
  }

  .desktop-nav-brand strong {
    font-size: 0.9rem;
  }

  .nav-button {
    min-width: 82px;
    padding-inline: 8px;
    gap: 5px;
    font-size: 0.8125rem;
  }

  #home-view.is-active {
    gap-inline: 14px;
  }

  #home-view .home-actions {
    --desktop-action-width: 180px;
    grid-column: 1 / -1;
    gap: 14px;
  }

  #home-view .woodfish-button {
    transform: scale(1.12);
  }

  #home-view .woodfish-stage::before {
    width: 350px;
    height: 230px;
  }

  #city-view.is-active {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
  }

  #profile-view.is-active {
    grid-template-columns: minmax(270px, 0.8fr) minmax(400px, 1.2fr);
    column-gap: 20px;
  }
}

@media (min-width: 1600px) {
  #home-view .woodfish-button {
    transform: scale(1.46);
  }
}

@media (min-width: 900px) and (max-height: 760px) {
  .view.is-active {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  #home-view.is-active {
    grid-template-rows: auto auto minmax(180px, 1fr) auto auto;
    padding-top: calc(var(--desktop-topbar-height) + 18px);
    gap-block: 8px;
  }

  #home-view .home-greeting h2 {
    font-size: 1.65rem;
  }

  #home-view .home-greeting p {
    font-size: 0.875rem;
  }

  #home-view .woodfish-stage {
    min-height: 180px;
  }

  #home-view .woodfish-button {
    transform: scale(1.05);
  }

  #home-view .woodfish-stage::before {
    width: 330px;
    height: 215px;
  }

  #home-view .woodfish-stage > p {
    margin-top: 8px;
  }

  #home-view .home-actions {
    padding-top: 8px;
  }

  #home-view .reward-progress,
  #home-view .primary-actions {
    min-height: 68px;
  }

  #home-view .reward-progress {
    padding-block: 0;
  }

  #home-view .city-summary,
  #home-view .metric-row > div {
    min-height: 58px;
  }

  #home-view .metric-row b {
    font-size: 1.55rem;
  }
}

@media (min-width: 900px) and (max-height: 900px) {
  #home-view .woodfish-body {
    left: 50%;
    margin-left: -85px;
  }

  #home-view .gummy-ripple {
    left: 50%;
    margin-left: -92px;
  }
}


/* Desktop theme adapter. */
@media (min-width: 900px) {
  html[data-theme] .bottom-nav {
    border-bottom-color: var(--line);
    background: var(--nav-bg);
  }

  html[data-theme] .desktop-nav-brand span {
    border-radius: var(--control-radius);
    background: var(--primary-soft);
    color: var(--primary);
  }

  html[data-theme] .nav-button {
    border-radius: var(--control-radius);
    color: var(--muted);
  }

  html[data-theme] .nav-button:hover,
  html[data-theme] .nav-button.is-active {
    border-radius: var(--control-radius);
    background: var(--primary-soft);
    color: var(--primary);
  }

  html[data-theme] .nav-button.is-active::after {
    background: var(--primary);
  }

  .desktop-theme-button {
    position: fixed;
    z-index: 31;
    top: 14px;
    right: clamp(20px, 3vw, 40px);
    display: grid;
    cursor: pointer;
  }

  #home-view #sound-toggle {
    right: clamp(74px, 7vw, 94px);
  }

  #home-view .home-presence {
    right: clamp(130px, 11vw, 154px);
  }

  html[data-theme] #home-view .reward-progress .action-button {
    border-color: var(--primary);
  }

  html[data-theme] #home-view .reward-progress .action-button:disabled {
    border-color: var(--line);
    background: transparent;
    color: var(--muted);
  }

  html[data-theme] #home-view .finish-button {
    background: var(--primary);
    color: var(--on-primary);
  }

  html[data-theme] .province-map-section,
  html[data-theme] .ranking-section,
  html[data-theme] .feed-item,
  html[data-theme] #profile-view .profile-header,
  html[data-theme] #profile-view .profile-stats,
  html[data-theme] #profile-view .profile-menu,
  html[data-theme] #profile-view .finish-preview {
    border-radius: var(--card-radius);
  }

  html[data-theme] .ranking-list {
    scrollbar-color: var(--line) transparent;
  }

  html[data-theme] .ranking-row:hover {
    background: var(--surface-3);
  }

  html[data-theme] .sheet-dialog {
    border-radius: var(--card-radius);
  }

  .theme-dialog {
    width: min(560px, calc(100% - 48px));
  }

  .theme-option {
    min-height: 106px;
    cursor: pointer;
  }

  .theme-dialog-actions {
    grid-template-columns: 1fr 1fr;
  }
}

html[data-theme="paper"] .home-greeting h2,
html[data-theme="vermilion"] .home-greeting h2,
html[data-theme="paper"] .section-header h2,
html[data-theme="vermilion"] .section-header h2 {
  font-weight: 600;
}

html[data-theme="focus"] .nav-button,
html[data-theme="focus"] .filter-button,
html[data-theme="focus"] .action-button {
  font-weight: 650;
}

@media (min-width: 900px) {
  .service-banner {
    top: 84px;
    right: 24px;
    bottom: auto;
    left: auto;
    width: clamp(280px, 32vw, 430px);
    transform: none;
  }
}
