:root {
  --bg: #f5f6f2;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(26, 45, 35, 0.12);
  --line-strong: rgba(26, 45, 35, 0.18);
  --text: #163128;
  --muted: #5f7469;
  --primary: #24563f;
  --accent: #d68630;
  --danger: #b64b3f;
  --info: #285b8f;
  --success: #2b6a50;
  --accent-soft: #f7e6d2;
  --danger-soft: #f8ddda;
  --info-soft: #dcebf8;
  --success-soft: #dceddf;
  --shadow: 0 18px 45px rgba(25, 48, 38, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --max-width: 1700px;
  --sidebar-width: 272px;
  --toc-width: 292px;
  --mark: #fff3a0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(222, 236, 227, 0.95), transparent 28%),
    radial-gradient(circle at top right, rgba(247, 230, 210, 0.85), transparent 26%),
    var(--bg);
}

body.nav-open {
  overflow: hidden;
}

a {
  color: var(--primary);
}

button,
input {
  font: inherit;
}

.app-shell {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
  gap: 22px;
  padding: 22px;
}

.sidebar,
.toc-card,
.topbar,
.summary-card,
.detail-card,
.quick-card,
.alert-card,
.metric-card,
.timeline-card,
.accordion,
.day-card,
.meal-card,
.search-result,
.empty-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.sidebar {
  position: sticky;
  top: 22px;
  align-self: start;
  min-height: calc(100vh - 44px);
  padding: 24px 18px;
  border-radius: var(--radius-xl);
}

.brand {
  padding: 4px 8px 22px;
  border-bottom: 1px solid var(--line);
}

.brand-kicker,
.eyebrow,
.toc-kicker,
.section-kicker,
.module-eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand h1,
.module-hero h3,
.section-head h4,
.summary-card h4,
.detail-card h4,
.quick-card h4,
.alert-card h4,
.metric-card h4,
.timeline-card h4,
.day-card h4,
.meal-card h5,
.empty-card h4 {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.2;
}

.brand-copy {
  margin: 10px 0 0;
  line-height: 1.6;
  color: var(--muted);
}

.primary-nav {
  display: grid;
  gap: 8px;
  padding-top: 20px;
}

.nav-button {
  width: 100%;
  border: 0;
  padding: 15px 16px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-button:hover,
.nav-button.is-active {
  background: linear-gradient(135deg, rgba(36, 86, 63, 0.12), rgba(36, 86, 63, 0.04));
}

.nav-button strong {
  display: block;
  font-size: 15px;
}

.nav-button span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.topbar {
  position: sticky;
  top: 22px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 440px);
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius-xl);
  transition:
    top 0.22s ease,
    padding 0.22s ease,
    gap 0.22s ease,
    border-radius 0.22s ease,
    box-shadow 0.22s ease,
    background-color 0.22s ease;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  transition: gap 0.22s ease;
}

.topbar-main h2 {
  margin: 0;
  font-size: 28px;
  transition: font-size 0.22s ease;
}

.search-area {
  position: relative;
  transition: transform 0.22s ease;
}

.search-box {
  display: grid;
  gap: 8px;
}

.search-box span {
  font-size: 13px;
  color: var(--muted);
  transition:
    opacity 0.18s ease,
    max-height 0.18s ease,
    margin 0.18s ease;
}

.search-box input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  padding: 13px 18px;
  background: rgba(255, 255, 255, 0.9);
  outline: none;
  transition:
    padding 0.22s ease,
    font-size 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease;
}

.search-box input:focus {
  border-color: rgba(36, 86, 63, 0.38);
  box-shadow: 0 0 0 4px rgba(36, 86, 63, 0.12);
}

.search-results {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  right: 0;
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.search-results[hidden] {
  display: none !important;
}

.topbar.is-condensed {
  top: 10px;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 34px rgba(25, 48, 38, 0.1);
}

.topbar.is-condensed .topbar-main {
  gap: 10px;
}

.topbar.is-condensed .topbar-main h2 {
  font-size: 22px;
}

.topbar.is-condensed .eyebrow {
  display: none;
}

.topbar.is-condensed .search-box {
  gap: 0;
}

.topbar.is-condensed .search-box span {
  opacity: 0;
  max-height: 0;
  margin: 0;
  overflow: hidden;
}

.topbar.is-condensed .search-box input {
  padding: 10px 16px;
  font-size: 15px;
}

.search-result {
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
}

.search-result:hover {
  border-color: rgba(36, 86, 63, 0.22);
  background: rgba(222, 236, 227, 0.55);
}

.search-result-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 6px;
}

.pill,
.tag,
.module-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
}

.pill,
.module-tag {
  background: rgba(36, 86, 63, 0.1);
  color: var(--primary);
}

.module-tag.warning,
.alert-card.warning {
  background: var(--accent-soft);
  color: #7e4a10;
}

.module-tag.danger,
.alert-card.danger {
  background: var(--danger-soft);
  color: #8e2c24;
}

.module-tag.info,
.alert-card.info {
  background: var(--info-soft);
  color: #1d4c79;
}

.module-tag.success,
.alert-card.success {
  background: var(--success-soft);
  color: #22523e;
}

.ghost-button,
.solid-button,
.toc-button,
.tab-button,
.accordion-trigger,
.menu-button,
.back-to-top {
  border: 0;
  cursor: pointer;
}

.ghost-button,
.solid-button,
.menu-button {
  border-radius: 999px;
  padding: 10px 14px;
}

.ghost-button {
  background: rgba(36, 86, 63, 0.08);
  color: var(--primary);
}

.solid-button {
  background: var(--primary);
  color: #fff;
}

.menu-button {
  display: none;
  background: rgba(36, 86, 63, 0.1);
  color: var(--primary);
}

.module-content {
  padding: 20px 0 80px;
}

.module-page {
  display: grid;
  gap: 18px;
}

.module-hero {
  padding: 26px 28px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(222, 236, 227, 0.82), rgba(255, 255, 255, 0.92)),
    var(--panel);
  border: 1px solid rgba(36, 86, 63, 0.12);
  box-shadow: var(--shadow);
}

.module-hero h3 {
  font-size: 30px;
  line-height: 1.2;
}

.module-hero p {
  margin: 12px 0 0;
  line-height: 1.7;
  color: #335447;
  max-width: 900px;
}

.section-block {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.section-head p,
.summary-card p,
.detail-card p,
.quick-card p,
.alert-card p,
.metric-card p,
.timeline-card p,
.day-card p,
.meal-card p,
.empty-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.dashboard-grid,
.detail-grid,
.meal-grid,
.check-grid,
.storage-grid,
.risk-grid {
  display: grid;
  gap: 14px;
}

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.summary-card,
.detail-card,
.quick-card,
.alert-card,
.metric-card,
.timeline-card,
.accordion,
.day-card,
.meal-card,
.empty-card {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.summary-card ul,
.detail-card ul,
.quick-card ul,
.alert-card ul,
.metric-card ul,
.day-card ul,
.meal-card ul,
.timeline-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  line-height: 1.7;
}

.summary-card li + li,
.detail-card li + li,
.quick-card li + li,
.alert-card li + li,
.metric-card li + li,
.day-card li + li,
.meal-card li + li,
.timeline-card li + li {
  margin-top: 6px;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.tag-row,
.tab-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-button {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(26, 45, 35, 0.1);
  color: var(--muted);
}

.tab-button.is-active {
  background: var(--primary);
  color: #fff;
}

.day-card {
  display: grid;
  gap: 14px;
}

.day-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: start;
}

.meal-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.accordion {
  overflow: hidden;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.accordion-trigger strong {
  display: block;
  font-size: 16px;
}

.accordion-trigger span:last-child {
  color: var(--muted);
  line-height: 1.6;
}

.accordion-trigger::after {
  content: "＋";
  font-size: 22px;
  color: var(--primary);
}

.accordion.is-open .accordion-trigger::after {
  content: "－";
}

.accordion-panel {
  display: none;
  padding-top: 16px;
}

.accordion.is-open .accordion-panel {
  display: block;
}

.detail-grid,
.check-grid,
.storage-grid,
.risk-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.timeline-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.timeline-list li {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(245, 246, 242, 0.95);
}

.timeline-list time {
  font-weight: 700;
  color: var(--primary);
}

.alert-card,
.metric-card {
  border-left: 5px solid transparent;
}

.alert-card.warning {
  border-left-color: var(--accent);
}

.alert-card.danger {
  border-left-color: var(--danger);
}

.alert-card.info {
  border-left-color: var(--info);
}

.alert-card.success {
  border-left-color: var(--success);
}

.toc-panel {
  position: sticky;
  top: 22px;
  align-self: start;
}

.toc-card {
  border-radius: var(--radius-xl);
  padding: 20px;
}

.toc-list {
  display: grid;
  gap: 8px;
}

.toc-button {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
}

.toc-button:hover {
  background: rgba(222, 236, 227, 0.8);
}

.empty-card {
  text-align: center;
  padding: 26px;
}

mark {
  background: var(--mark);
  padding: 0 2px;
  border-radius: 4px;
}

.pulse-target {
  outline: 3px solid rgba(214, 134, 48, 0.45);
  outline-offset: 4px;
}

.back-to-top {
  position: fixed;
  right: 26px;
  bottom: 26px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 33, 26, 0.34);
}

@media (max-width: 1160px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .toc-panel {
    display: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    min-height: 100vh;
    z-index: 40;
    border-radius: 0 28px 28px 0;
    transform: translateX(-105%);
    transition: transform 0.24s ease;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    top: 14px;
    grid-template-columns: 1fr;
  }

  .topbar.is-condensed {
    top: 8px;
    padding: 10px 12px;
  }

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

  .span-4,
  .span-5,
  .span-6,
  .span-7 {
    grid-column: span 1;
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 16px;
  }

  .topbar.is-condensed .topbar-main h2 {
    font-size: 20px;
  }

  .topbar-main h2,
  .module-hero h3 {
    font-size: 24px;
  }

  .dashboard-grid,
  .meal-grid,
  .detail-grid,
  .check-grid,
  .storage-grid,
  .risk-grid {
    grid-template-columns: 1fr;
  }

  .timeline-list li {
    grid-template-columns: 1fr;
  }

  .back-to-top {
    right: 16px;
    bottom: 16px;
  }
}
