:root {
  --ink: #302218;
  --muted: #685849;
  --line: #d4c1a2;
  --line-strong: #bca37a;
  --paper: #f5edd8;
  --surface: #fff9ed;
  --green-900: #415b32;
  --green-800: #597a46;
  --green-700: #597a46;
  --green-100: #edf0e7;
  --red: #a13c2f;
  --red-soft: #f4e6df;
  --gold: #b66c2d;
  --gold-soft: #f3e4c9;
  --blue: #6c7062;
  --blue-soft: #edf0e7;
  --prescription-paper: #fff9ed;
  --prescription-paper-deep: #e9dbbc;
  --prescription-line: #d4c1a2;
  --prescription-ink: #302218;
  --shadow: 0 4px 12px rgba(48, 34, 24, .08);
  --rail-width: 232px;
}

html,
body {
  background: var(--paper);
}

body {
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(161, 60, 47, .28);
  outline-offset: 2px;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

.app-shell {
  min-height: 100svh;
  background: var(--paper);
}

.side-rail {
  width: var(--rail-width);
  padding: 22px 14px 18px;
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.brand {
  min-height: 68px;
  gap: 10px;
  padding: 10px 8px 16px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.brand-art {
  display: none !important;
}

.brand::before {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  content: "凉";
  color: var(--surface);
  background: var(--red);
  border-radius: 50%;
  font: 700 19px/1 "STKaiti", "KaiTi", serif;
}

.brand-copy strong,
.mobile-brand::before {
  color: var(--ink);
  font-family: "Songti SC", "STSong", "STKaiti", "KaiTi", serif;
}

.brand-copy small {
  color: var(--muted);
}

.rail-nav {
  gap: 3px;
  margin-top: 16px;
}

.nav-item {
  min-height: 46px;
  color: var(--muted);
  border-radius: 8px;
}

.nav-item:hover,
.nav-item.active {
  color: var(--red);
  background: var(--gold-soft);
}

.nav-item.active::before {
  background: var(--red);
}

.rail-profile {
  gap: 10px;
  margin-top: auto;
  padding: 12px 8px;
  color: var(--ink);
  background: var(--prescription-paper-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.avatar,
.avatar-small {
  color: var(--surface);
  background: var(--red);
}

.main-content {
  min-height: 100svh;
  margin-left: var(--rail-width);
  padding: 0 28px 44px;
  background: var(--paper);
}

.topbar {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  max-width: 1260px;
  margin: 0 auto;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.topbar .mobile-brand {
  display: none;
}

.date-block strong,
.date-block .lunar-date {
  color: var(--muted);
}

.topbar-actions {
  gap: 10px;
}

.weather-summary,
.font-size-button,
.member-button {
  min-height: 42px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.weather-summary {
  padding-inline: 11px;
}

.weather-summary .weather-icon,
.weather-summary svg {
  color: var(--gold);
}

.font-size-button {
  padding: 5px 10px;
}

.font-size-button:hover,
.member-button:hover,
.weather-summary:hover {
  border-color: var(--line-strong);
  background: var(--gold-soft);
}

.font-size-menu {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.font-size-menu button:hover,
.font-size-menu button[aria-checked="true"] {
  color: var(--red);
  background: var(--gold-soft);
}

.member-button {
  padding: 5px 10px 5px 6px;
}

.app-view {
  max-width: 1260px;
  margin: 0 auto;
}

.season-band {
  min-height: 248px;
  margin: 26px 0 22px;
  padding: 24px;
  overflow: hidden;
  background: url("assets/lingnan-arcade-tea.png") center / cover no-repeat;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.season-band::after {
  display: none;
}

.season-band > div {
  max-width: min(510px, 68%);
  padding: 20px;
  color: var(--ink);
  background: rgba(255, 249, 237, .94);
  border: 1px solid rgba(212, 193, 162, .88);
  border-radius: 8px;
}

.eyebrow,
.section-kicker,
.formula-label {
  color: var(--red) !important;
  font-weight: 800;
  letter-spacing: 0;
}

.season-band h1,
.view-header h1,
.detail-content h1,
.dialog-header h2 {
  color: var(--ink);
  font-family: "Songti SC", "STSong", "STKaiti", "KaiTi", serif;
  letter-spacing: 0;
}

.season-band h1 {
  margin-top: 5px;
}

.season-band p {
  color: var(--muted);
}

.season-detail-button,
.primary-button {
  min-height: 46px;
  color: var(--surface);
  background: var(--red);
  border: 1px solid var(--red);
  border-radius: 8px;
  box-shadow: none;
}

.season-detail-button:hover,
.primary-button:hover {
  color: var(--surface);
  background: #873128;
  border-color: #873128;
}

.secondary-button,
.text-button,
.back-button,
.icon-button {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 8px;
}

.secondary-button:hover,
.text-button:hover,
.back-button:hover,
.icon-button:hover {
  color: var(--red);
  background: var(--gold-soft);
  border-color: var(--line-strong);
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.12fr) minmax(330px, .88fr);
  gap: 20px;
}

.body-log,
.formula-focus,
.library-section,
.source-band,
.recommendation-profile-gate,
.recommendation-profile-strip,
.recommendation-form,
.recommendation-result,
.catalog-panel,
.constitution-boundary,
.constitution-test-gender,
.constitution-test-progress,
.constitution-question-card,
.constitution-result-section,
.record-panel,
.notes-panel,
.profile-panel,
.admin-user-panel,
.admin-password-request-panel,
.detail-section,
.detail-content > section {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.body-log,
.formula-focus,
.library-section,
.source-band {
  padding: 22px;
}

.section-heading {
  border-color: var(--line);
}

.section-heading h2,
.panel-heading h2,
.body-log h2,
.formula-focus h2,
.library-section h2,
.profile-panel h2,
.record-panel h2,
.admin-user-panel h2 {
  color: var(--ink);
  font-family: "Songti SC", "STSong", "STKaiti", "KaiTi", serif;
  letter-spacing: 0;
}

.status-dot,
.tag,
.evidence-badge,
.formula-label {
  border-radius: 999px;
}

.status-dot,
.tag-green,
.evidence-badge {
  color: var(--green-800);
  background: var(--green-100);
  border-color: #c7d5bc;
}

.tag-red,
.caution,
.caution-note strong {
  color: var(--red);
}

.tag-gold {
  color: #8a4f19;
  background: var(--gold-soft);
  border-color: #ddc18d;
}

.choice-chip,
.mini-chip-group button,
.segmented-control button,
.form-chip-group label,
.recommendation-radio-row label,
.constitution-score-options label {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 8px;
}

.choice-chip:hover,
.mini-chip-group button:hover,
.segmented-control button:hover,
.recommendation-radio-row label:hover,
.constitution-score-options label:hover {
  border-color: var(--red);
  background: var(--gold-soft);
}

.choice-chip.selected,
.mini-chip-group button.selected,
.segmented-control button.active,
.form-chip-group label:has(input:checked),
.recommendation-radio-row label:has(input:checked),
.constitution-score-options label:has(input:checked) {
  color: var(--red);
  background: var(--gold-soft);
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
}

.field-group,
.log-footer,
.formula-actions,
.formula-list-item,
.source-band,
.recommendation-section,
.profile-panel dl > div,
.record-item,
.note-item,
.admin-user-item {
  border-color: var(--line);
}

.formula-focus {
  overflow: hidden;
  background: var(--prescription-paper-deep);
}

.formula-focus::before {
  width: 92px;
  height: 92px;
  position: absolute;
  top: 16px;
  right: 20px;
  display: grid;
  place-items: center;
  content: "方";
  color: rgba(161, 60, 47, .82);
  border: 2px double rgba(161, 60, 47, .68);
  border-radius: 50%;
  font: 700 40px/1 "STKaiti", "KaiTi", serif;
  transform: rotate(-7deg);
}

.formula-watermark {
  display: none;
}

.formula-topline,
.formula-focus > h2,
.formula-focus > p,
.ingredient-row,
.method-strip,
.caution-note,
.formula-actions {
  position: relative;
  z-index: 1;
}

.formula-focus h2 {
  color: var(--ink);
}

.formula-scenario,
.formula-focus p,
.formula-list-copy small,
.source-copy p,
.muted-data {
  color: var(--muted);
}

.ingredient-row > span,
.method-strip,
.caution-note {
  background: rgba(255, 249, 237, .8);
  border-color: var(--line);
}

.ingredient-row b {
  color: var(--surface);
  background: var(--gold);
}

.method-strip dt,
.method-strip svg {
  color: var(--gold);
}

.formula-list-item {
  color: var(--ink);
  background: transparent;
}

.formula-list-item:hover,
.formula-list-item.active {
  background: var(--gold-soft);
}

.formula-index {
  color: var(--red);
  font-family: "Songti SC", "STSong", serif;
}

.source-band {
  background: var(--prescription-paper-deep);
}

.source-symbol {
  color: var(--surface);
  background: var(--red);
  border-radius: 8px;
}

.source-tags span {
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 999px;
}

.h5-visual-strip--herbs,
.h5-visual-strip--formula,
.h5-visual-strip--solar,
.h5-visual-strip--herb {
  min-height: 138px;
  margin: 18px 0;
  background: url("assets/lingnan-herb-courtyard.png") center / cover no-repeat;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.view-header {
  margin-top: 26px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.view-header h1 {
  margin-top: 4px;
}

.recommendation-intro-line,
.recommendation-section-heading,
.recommendation-profile-heading,
.catalog-toolbar,
.constitution-toolbar,
.record-toolbar,
.notes-toolbar,
.profile-heading,
.panel-heading {
  border-color: var(--line);
}

.recommendation-intro-line > span,
.recommendation-section-heading > span,
.constitution-test-gender-icon,
.constitution-card-head b,
.constitution-primary-heading > span,
.profile-avatar,
.record-metrics > div > i {
  color: var(--surface);
  background: var(--red);
}

.recommendation-result-hero,
.constitution-result-hero,
.detail-hero,
.record-hero {
  color: var(--ink);
  background: var(--prescription-paper-deep);
  border-color: var(--line);
  border-radius: 8px;
}

.recommendation-result-hero h2,
.constitution-result-hero h2,
.detail-hero h1,
.record-hero h1 {
  color: var(--ink);
}

.recommendation-alert,
.form-boundary,
.profile-health-note,
.constitution-boundary,
.constitution-test-missing {
  color: var(--ink);
  background: var(--gold-soft);
  border-color: var(--line);
  border-left-color: var(--red);
}

.catalog-card,
.constitution-card,
.record-summary-card,
.note-card,
.detail-card,
.herb-identity,
.solar-term-card {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.catalog-card:hover,
.constitution-card:hover,
.solar-term-card:hover {
  background: var(--gold-soft);
  border-color: var(--line-strong);
  box-shadow: none;
  transform: none;
}

.catalog-card::before,
.constitution-card::before {
  background: var(--red);
}

.solar-term-card.current,
.constitution-test-steps button.active {
  color: var(--surface);
  background: var(--red);
  border-color: var(--red);
}

.solar-term-card.current small,
.constitution-test-steps button.active small {
  color: #f7e7dc;
}

.constitution-test-header,
.constitution-question-heading {
  color: var(--ink);
  background: var(--prescription-paper-deep);
}

.constitution-question-heading h2 {
  color: var(--ink);
}

.constitution-progress-track {
  background: var(--gold-soft);
}

.constitution-progress-track span {
  background: var(--red);
}

.constitution-test-actions {
  border-color: var(--line);
}

input,
select,
textarea,
.other-symptom-field input,
.record-form input,
.record-form select,
.record-form textarea,
.profile-form input,
.profile-form select,
.profile-form textarea,
.note-form input,
.note-form textarea,
.password-form input,
.admin-user-form input {
  color: var(--ink) !important;
  background: var(--paper) !important;
  border-color: var(--line) !important;
  border-radius: 8px !important;
}

input::placeholder,
textarea::placeholder {
  color: #8a7867;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(161, 60, 47, .12) !important;
}

.bottom-nav {
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 -4px 12px rgba(48, 34, 24, .06);
}

.bottom-nav button {
  color: var(--muted);
}

.bottom-nav button.active,
.bottom-nav button:hover {
  color: var(--red);
}

.bottom-nav button.active::before {
  background: var(--red);
}

.mobile-more-backdrop {
  background: rgba(48, 34, 24, .28);
}

.mobile-more-sheet {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 8px 8px 0 0;
}

.mobile-more-sheet header,
.mobile-more-sheet nav button {
  border-color: var(--line);
}

.mobile-more-sheet nav button:hover {
  background: var(--gold-soft);
}

dialog,
.formula-dialog,
.record-dialog,
.note-dialog,
.profile-dialog,
.password-dialog,
.delete-record-dialog,
.admin-user-dialog,
.admin-delete-user-dialog {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(48, 34, 24, .2);
}

.dialog-header,
.dialog-footer {
  border-color: var(--line);
}

.dialog-header h2,
.dialog-body h3 {
  color: var(--ink);
  font-family: "Songti SC", "STSong", "STKaiti", "KaiTi", serif;
}

body.auth-required {
  background: var(--paper);
}

.auth-screen {
  padding: 0;
  background: var(--paper);
}

.auth-panel {
  width: min(100%, 420px);
  min-height: 100svh;
  position: relative;
  padding: 0 20px 28px;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.auth-hero {
  min-height: 252px;
  margin: 0 -20px;
  padding: 0;
  overflow: visible;
  background: url("assets/lingnan-prescription-paper.png") center / cover no-repeat;
}

.auth-hero > p,
.auth-hero > small,
.auth-arcade,
.auth-tea-cup {
  display: none;
}

.auth-hero::after {
  width: 165px;
  height: 147px;
  position: absolute;
  z-index: 1;
  top: 78px;
  left: 55%;
  display: block;
  content: "";
  pointer-events: none;
  background: url("/generated/liangcha-hero-calligraphy.png?v=20260726-xiaozhuan-source-glyphs-1") center / contain no-repeat;
  transform: translateX(-50%) rotate(22deg);
  transform-origin: top center;
}

.auth-brand {
  width: 252px;
  height: 104px;
  position: absolute;
  z-index: 2;
  top: 270px;
  bottom: auto;
  left: calc(50% - 126px);
  display: block;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  transform: none;
}

.auth-brand img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.auth-welcome {
  display: none;
}

.auth-welcome h1 {
  color: var(--ink);
  font: 700 30px/1.25 "Songti SC", "STSong", "STKaiti", "KaiTi", serif;
}

.auth-welcome h1::before {
  display: block;
  margin-bottom: 4px;
  content: "凉茶簿";
  color: var(--ink);
  font-size: 32px;
}

.auth-welcome p {
  color: var(--muted);
}

.auth-form {
  gap: 10px;
  margin-top: 122px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-form label {
  gap: 4px;
  color: var(--ink);
  font-size: 13px;
}

.auth-form label::before,
.auth-form label::after {
  display: none;
}

.auth-form input {
  min-height: 44px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
  border-radius: 8px;
}

.auth-form input:focus {
  border-color: var(--red);
  outline-color: rgba(161, 60, 47, .18);
}

.auth-submit {
  min-height: 44px;
  margin-top: 3px;
  color: var(--surface);
  background: var(--red);
  border-color: var(--red);
  border-radius: 8px;
  box-shadow: none;
  font-size: 16px !important;
}

.auth-submit::before {
  display: none;
}

.auth-reset-request {
  min-height: 26px;
  margin: -2px auto 0;
  color: var(--red);
  font-size: 13px;
}

.auth-message {
  margin: 10px 0 0;
  color: var(--red);
}

.auth-message:empty,
.auth-privacy-note {
  display: none;
}

.auth-privacy-note span {
  color: var(--red);
}

.auth-boundary {
  margin: 8px 0 0;
  color: var(--muted);
}

@media (max-width: 720px) {
  body {
    min-width: 320px;
    background: var(--paper);
  }

  .app-shell {
    width: min(100%, 430px);
    min-height: 100svh;
    margin: 0 auto;
    background: var(--paper);
  }

  .side-rail {
    display: none !important;
  }

  .main-content {
    width: 100%;
    min-height: 100svh;
    margin: 0;
    padding: 0 16px 80px;
  }

  .topbar {
    min-height: 84px !important;
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto auto !important;
    grid-template-rows: 48px 25px !important;
    gap: 0 8px !important;
    width: calc(100% + 32px);
    margin: 0 -16px;
    padding: 5px 16px 6px;
    background: rgba(245, 237, 216, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
  }

  .topbar .mobile-brand {
    width: auto !important;
    height: 42px !important;
    display: block !important;
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    position: relative;
    background: transparent !important;
  }

  html[data-font-size] .topbar .mobile-brand .brand-art,
  html[data-font-size] .topbar .mobile-brand-copy {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: none !important;
  }

  html[data-font-size] .topbar .mobile-brand::before {
    display: block;
    content: "凉茶簿";
    color: var(--ink);
    background: transparent !important;
    font-size: 24px;
    font-weight: 700;
    line-height: 42px;
  }

  /* Keep the supplied brand asset. The text wordmark is intentionally removed
     so the mobile header has one clear product mark instead of two. */
  html[data-font-size] .topbar .mobile-brand .brand-art {
    width: 118px !important;
    height: 45px !important;
    display: block !important;
    background: url("/generated/liangcha-logo.png?v=20260726-original-logo") left center / contain no-repeat !important;
  }

  html[data-font-size] .topbar .mobile-brand::before {
    display: none !important;
    content: none;
  }

  .topbar .date-block {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    padding: 0 !important;
    transform: none !important;
  }

  .topbar .date-line {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px !important;
    line-height: 20px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .date-divider {
    margin-inline: 2px;
  }

  .topbar-actions {
    display: contents;
  }

  .topbar .font-size-control {
    position: static !important;
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  .topbar .font-size-button {
    min-width: 54px;
    min-height: 34px;
    display: grid !important;
    place-items: center;
    padding: 0 7px;
    color: var(--muted) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar .font-size-button > :not(.font-size-short-label) {
    display: none !important;
  }

  .topbar .font-size-short-label {
    display: block !important;
    font-size: 12px !important;
    font-weight: 700;
    white-space: nowrap;
  }

  .topbar .member-switcher {
    position: static !important;
    grid-column: 3;
    grid-row: 1;
    align-self: center;
    width: auto;
  }

  .topbar .member-button {
    width: auto !important;
    min-width: 48px !important;
    min-height: 34px;
    display: block !important;
    padding: 8px 0 0 !important;
    color: var(--muted) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0;
    text-align: right;
  }

  .topbar .member-button > .avatar,
  .topbar .member-button > i,
  .topbar .member-button small {
    display: none !important;
  }

  .topbar .member-button > span:nth-child(2),
  .topbar .member-button #currentMember {
    position: static !important;
    display: block !important;
    width: auto !important;
    transform: none !important;
    color: var(--muted) !important;
    font-size: 12px !important;
    font-weight: 700;
    line-height: 18px;
    text-align: right !important;
    white-space: nowrap;
  }

  .topbar .weather-summary {
    min-height: 20px;
    position: static !important;
    grid-column: 2 / 4;
    grid-row: 2;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 0 !important;
    color: var(--muted) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0;
  }

  .topbar .weather-icon,
  .topbar .weather-condition {
    display: none !important;
  }

  .topbar .weather-value {
    display: inline-flex !important;
    align-items: center;
    gap: 2px;
  }

  .topbar .weather-value > i {
    display: none;
  }

  .topbar #weatherTemperature::before {
    content: "温度 ";
  }

  .topbar #weatherHumidity::before {
    content: "湿度 ";
  }

  .topbar .weather-value strong,
  .topbar #weatherTemperature::before,
  .topbar #weatherHumidity::before {
    color: var(--muted) !important;
    font-size: 11px !important;
    font-weight: 600;
    line-height: 20px !important;
  }

  .app-view {
    width: 100%;
    margin: 0;
  }

  .season-band {
    min-height: 226px;
    margin: 16px 0 14px;
    padding: 14px;
    background-position: center;
  }

  .season-band > div {
    max-width: 74%;
    min-height: 0;
    padding: 14px;
  }

  .season-band h1 {
    margin: 4px 0 6px;
    font-size: calc(23px * var(--font-scale)) !important;
    line-height: 1.35;
  }

  .season-band p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .season-detail-button {
    min-height: 38px;
    padding: 0 12px;
    font-size: calc(13px * var(--font-scale)) !important;
  }

  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .body-log,
  .formula-focus,
  .library-section,
  .source-band {
    padding: 16px;
  }

  .formula-focus::before {
    width: 64px;
    height: 64px;
    top: 14px;
    right: 14px;
    font-size: 28px;
  }

  .formula-focus .formula-topline {
    max-width: calc(100% - 66px);
  }

  .formula-focus .ingredient-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .formula-focus .method-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .formula-focus .method-strip div {
    min-width: 0;
    padding-inline: 7px;
  }

  .formula-list-item {
    grid-template-columns: 30px minmax(0, 1fr) auto;
  }

  .formula-list-item .tag,
  .formula-list-item .list-meta {
    display: none;
  }

  .source-band {
    display: grid !important;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
  }

  .source-tags {
    grid-column: 1 / -1;
  }

  .view-header {
    margin-top: 16px;
  }

  .view-header h1 {
    font-size: calc(24px * var(--font-scale)) !important;
    line-height: 1.35;
  }

  .recommendation-profile-gate,
  .recommendation-profile-strip,
  .recommendation-form,
  .catalog-panel,
  .constitution-test-gender,
  .constitution-test-progress,
  .constitution-result-section,
  .record-panel,
  .notes-panel,
  .profile-panel,
  .admin-user-panel,
  .admin-password-request-panel,
  .detail-content > section {
    border-radius: 8px;
  }

  .constitution-test-layout,
  .constitution-result-layout,
  .record-layout,
  .profile-layout {
    grid-template-columns: 1fr;
  }

  .constitution-test-steps {
    position: static;
    max-height: none;
  }

  .constitution-score-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .constitution-test-actions {
    position: sticky;
    bottom: calc(72px + env(safe-area-inset-bottom));
    z-index: 6;
    margin-inline: -16px;
    padding: 12px 16px;
    background: rgba(245, 237, 216, .96);
  }

  .constitution-test-actions .primary-button,
  .constitution-test-actions .secondary-button {
    min-width: 0;
    flex: 1;
  }

  .bottom-nav {
    width: min(100vw, 430px);
    height: 64px !important;
    left: 0;
    right: auto;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 3px 4px !important;
    transform: none;
    border-top: 1px solid var(--line);
  }

  .bottom-nav button {
    min-width: 0;
    min-height: 58px !important;
    height: 58px !important;
    padding: 7px 2px 4px !important;
    font-size: 11px !important;
  }

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

  .mobile-more-sheet {
    width: min(100vw, 430px);
    left: 0;
    right: auto;
    transform: none;
  }

  dialog,
  .formula-dialog,
  .record-dialog,
  .note-dialog,
  .profile-dialog,
  .password-dialog,
  .delete-record-dialog,
  .admin-user-dialog,
  .admin-delete-user-dialog {
    width: min(calc(100% - 24px), 406px);
    max-height: min(86svh, 760px);
    border-radius: 8px;
  }
}

@media (max-width: 360px) {
  .main-content {
    padding-inline: 12px;
  }

  .topbar {
    width: calc(100% + 24px);
    margin-inline: -12px;
    padding-inline: 12px;
  }

  .season-band > div {
    max-width: 82%;
  }

  .auth-panel {
    padding-inline: 16px;
  }

  .auth-hero {
    margin-inline: -16px;
  }
}

html[data-font-size="xlarge"] .app-view {
  overflow: visible;
}

html[data-font-size="xlarge"] .season-band > div,
html[data-font-size="xlarge"] .formula-list-item,
html[data-font-size="xlarge"] .catalog-card,
html[data-font-size="xlarge"] .constitution-card,
html[data-font-size="xlarge"] .record-item,
html[data-font-size="xlarge"] .note-item {
  min-height: unset;
  height: auto;
}

html[data-font-size="xlarge"] .bottom-nav button {
  font-size: 12px !important;
}

/* Detail images are data-bound by app-main.js. Keep those distinct herb and
   solar-term images visible after the common paper-surface rules above. */
.detail-hero.herb-detail-hero--image {
  min-height: 0 !important;
  aspect-ratio: 16 / 9 !important;
  background-color: var(--prescription-paper-deep) !important;
  background-image: var(--herb-detail-image) !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}

.detail-hero.herb-detail-hero--image .herb-detail-image-copy {
  position: absolute;
  top: 14px;
  right: auto;
  bottom: auto;
  left: 14px;
  z-index: 1;
  width: min(268px, calc(100% - 28px));
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(75, 49, 24, .52);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  backdrop-filter: none;
}

.detail-hero.herb-detail-hero--image .herb-detail-image-copy .section-kicker {
  margin: 0;
  color: #f4cf7a;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.detail-hero.herb-detail-hero--image .herb-detail-image-copy h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font: 700 30px/1.15 "Songti SC", "STSong", "STKaiti", "KaiTi", serif;
  text-shadow: 0 1px 1px rgba(255, 249, 233, .72);
}

.detail-hero.herb-detail-hero--image .herb-detail-image-copy h1 + p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  text-shadow: 0 1px 1px rgba(255, 249, 233, .72);
}

.detail-hero.herb-detail-hero--image .herb-detail-image-copy .detail-badges {
  position: static;
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-hero.herb-detail-hero--image .herb-detail-image-copy .detail-badges span {
  padding: 6px 8px;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(75, 49, 24, .58);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(255, 249, 233, .72);
}

.detail-hero.solar-detail-hero--image {
  background-color: var(--prescription-paper-deep) !important;
  background-image: var(--solar-term-image) !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}

.solar-detail-hero--image .detail-hero-copy {
  background: rgba(255, 249, 237, .96) !important;
  border: 1px solid var(--line) !important;
  border-left: 4px solid var(--gold) !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(48, 34, 24, .12) !important;
  backdrop-filter: none !important;
}

.solar-detail-hero--image .detail-hero-copy .section-kicker {
  color: var(--red) !important;
  font-weight: 800;
}

.solar-detail-hero--image .detail-hero-copy h1 {
  color: var(--ink) !important;
}

.solar-detail-hero--image .detail-hero-copy > p:last-child {
  color: var(--muted) !important;
}

.h5-visual-strip--solar {
  background-image: url("/generated/lingnan-solar-terms-banner.webp") !important;
  background-position: center !important;
}

.h5-visual-strip--herb-library {
  background-image: url("/generated/lingnan-herb-banner-4k.webp") !important;
  background-position: center !important;
}

/* The desktop browser still presents the same centered H5 canvas. The old
   desktop rail is hidden, so its reserved margin must not shift the canvas. */
@media (min-width: 721px) {
  .main-content {
    width: 100%;
    margin-left: 0;
    padding: 0 0 calc(82px + env(safe-area-inset-bottom));
  }
}
