:root {
  color-scheme: dark;
  --bg: #150e15;
  --bg-elevated: #1d121c;
  --surface: #261724;
  --surface-2: #301d2c;
  --surface-3: #3a2435;
  --text: #f7f0f4;
  --text-soft: #d5c8d0;
  --muted: #a997a3;
  --border: rgba(242, 224, 234, 0.13);
  --border-strong: rgba(210, 177, 113, 0.42);
  --plum: #a66b91;
  --plum-bright: #d69abb;
  --gold: #d2b171;
  --gold-soft: #f0d9a6;
  --success: #76b897;
  --danger: #e48792;
  --warning: #e2b96d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --topbar-height: 76px;
  --nav-height: 76px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f0ed;
  --bg-elevated: #fbf8f5;
  --surface: #fffdfb;
  --surface-2: #f5ecef;
  --surface-3: #eadde4;
  --text: #30232c;
  --text-soft: #57464f;
  --muted: #806f78;
  --border: rgba(75, 41, 61, 0.14);
  --border-strong: rgba(132, 93, 36, 0.38);
  --plum: #7f4168;
  --plum-bright: #9e5f83;
  --gold: #805a1c;
  --gold-soft: #77551f;
  --success: #397758;
  --danger: #a13f4d;
  --warning: #8a6421;
  --shadow: 0 18px 45px rgba(67, 43, 56, 0.1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 85% -10%, rgba(166, 107, 145, 0.17), transparent 38rem),
    radial-gradient(circle at -10% 35%, rgba(210, 177, 113, 0.08), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font: inherit; color: inherit; }
button, input[type="checkbox"], select { touch-action: manipulation; }
button { cursor: pointer; }
a { color: inherit; }
p, h1, h2, h3, h4 { overflow-wrap: anywhere; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--gold) 38%, transparent); outline-offset: 2px; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  transform: translateY(-160%);
  background: var(--gold);
  color: #21131d;
  font-weight: 800;
}
.skip-link:focus { transform: none; }

.app-shell {
  width: min(100%, 1220px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 max(16px, var(--safe-right)) calc(var(--nav-height) + var(--safe-bottom) + 24px) max(16px, var(--safe-left));
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  min-width: 0;
  min-height: calc(var(--topbar-height) + var(--safe-top));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 2px 10px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
}

.brand-mark {
  flex: 0 0 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(166, 107, 145, 0.2), rgba(210, 177, 113, 0.1));
  color: var(--gold-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 700;
}

.brand-copy { min-width: 0; flex: 1; }
.brand-copy h1 { margin: 1px 0 0; font-size: clamp(17px, 2.6vw, 21px); line-height: 1.2; letter-spacing: -0.02em; }
.eyebrow { margin: 0; color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }

.topbar-status { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.status-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--success); }
.status-dot.is-offline::before { background: var(--warning); }
.save-status.is-error { color: var(--danger); }

.inline-alert, .update-banner {
  min-width: 0;
  margin: 2px 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(226, 185, 109, 0.35);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
  color: var(--text-soft);
}

.update-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.update-banner[hidden], .inline-alert[hidden] { display: none; }

.view-root { min-width: 0; padding: 10px 0 16px; }
.loading-card { min-height: 52vh; display: grid; place-content: center; justify-items: center; gap: 18px; color: var(--muted); }
.loading-orbit { width: 48px; height: 48px; border: 2px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.primary-nav {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: calc(var(--nav-height) + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 7px max(8px, var(--safe-right)) calc(7px + var(--safe-bottom)) max(8px, var(--safe-left));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  box-shadow: 0 -14px 35px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  transition: transform 160ms ease;
}

.nav-item {
  min-width: 0;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.nav-icon { min-height: 25px; display: grid; place-items: center; font-size: 20px; font-weight: 800; }
.nav-item.is-active { background: color-mix(in srgb, var(--plum) 18%, transparent); color: var(--gold-soft); }

.page-head { min-width: 0; margin: 0 0 18px; }
.page-head h2 { margin: 6px 0 6px; font-size: clamp(28px, 6vw, 44px); line-height: 1.08; letter-spacing: -0.045em; }
.page-head p:last-child { max-width: 720px; margin: 0; color: var(--text-soft); }
.section-heading { display: flex; min-width: 0; align-items: end; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-heading h2, .section-heading h3 { margin: 0; font-size: clamp(20px, 4vw, 27px); letter-spacing: -0.025em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 96%, var(--plum) 4%), var(--surface));
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: clamp(20px, 4vw, 34px);
  background:
    linear-gradient(120deg, rgba(166, 107, 145, 0.2), transparent 52%),
    linear-gradient(145deg, var(--surface-2), var(--surface));
}
.hero-card::after { content: "ψ"; position: absolute; right: -12px; bottom: -68px; color: color-mix(in srgb, var(--gold) 8%, transparent); font-family: Georgia, serif; font-size: 250px; line-height: 1; pointer-events: none; }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 22px; }
.hero-copy { min-width: 0; }
.hero-copy h2 { max-width: 690px; margin: 6px 0 12px; font-size: clamp(28px, 6vw, 48px); line-height: 1.06; letter-spacing: -0.045em; }
.hero-copy .lead { margin: 0 0 20px; color: var(--text-soft); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.progress-ring {
  --progress: 0deg;
  width: clamp(118px, 20vw, 160px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--gold) var(--progress), color-mix(in srgb, var(--surface-3) 72%, transparent) 0);
  box-shadow: inset 0 0 0 1px var(--border-strong), 0 18px 40px rgba(0, 0, 0, 0.24);
}
.progress-ring::before { content: ""; grid-area: 1 / 1; width: 78%; aspect-ratio: 1; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.progress-ring-copy { z-index: 1; grid-area: 1 / 1; text-align: center; }
.progress-ring strong { display: block; color: var(--gold-soft); font-size: clamp(28px, 5vw, 40px); line-height: 1; }
.progress-ring span { color: var(--muted); font-size: 12px; }

.button {
  min-height: 46px;
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--gold);
  color: #21131d;
  font-weight: 850;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(210, 177, 113, 0.14);
}
.button.secondary { border-color: var(--border); background: var(--surface-3); color: var(--text); box-shadow: none; }
.button.ghost { border-color: var(--border); background: transparent; color: var(--text-soft); box-shadow: none; }
.button.danger { background: var(--danger); color: #211116; box-shadow: none; }
.button.small { min-height: 44px; padding: 8px 13px; font-size: 14px; }
.button:disabled { cursor: not-allowed; opacity: 0.45; }

.metric-grid { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.metric-card { min-width: 0; padding: 17px; }
.metric-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-value { display: block; color: var(--text); font-size: clamp(18px, 4vw, 26px); font-weight: 850; line-height: 1.2; }
.metric-detail { display: block; margin-top: 6px; color: var(--text-soft); font-size: 13px; }

.dashboard-grid { min-width: 0; display: grid; gap: 14px; }
.content-card { min-width: 0; padding: clamp(17px, 3.5vw, 24px); }
.content-card h3 { margin: 0 0 12px; font-size: 19px; }
.content-card p { color: var(--text-soft); }
.card-head { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head > div { min-width: 0; }
.card-head h3 { margin: 0; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.task-list, .plain-list, .block-list { min-width: 0; margin: 0; padding: 0; list-style: none; }
.plain-list { display: grid; gap: 10px; color: var(--text-soft); }
.task-list { display: grid; gap: 8px; }
.task-list li { min-width: 0; display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-list li:last-child { border-bottom: 0; }
.task-index { flex: 0 0 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 50%; color: var(--gold); font-size: 12px; font-weight: 800; }
.block-list { display: grid; gap: 8px; }
.block-link { width: 100%; min-height: 48px; display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid rgba(228, 135, 146, 0.26); border-radius: 13px; background: color-mix(in srgb, var(--danger) 7%, var(--surface)); text-align: left; }
.block-link strong, .block-link small { display: block; }
.block-link small { color: var(--muted); }
.empty-state { padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius-md); color: var(--muted); text-align: center; }

.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--plum-bright), var(--gold)); transition: width 180ms ease; }
.progress-caption { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--muted); font-size: 12px; }

.stage-workspace { min-width: 0; display: grid; gap: 14px; }
.stage-rail { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stage-tab { min-height: 64px; min-width: 0; padding: 9px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text-soft); text-align: left; }
.stage-tab strong, .stage-tab span { display: block; min-width: 0; }
.stage-tab strong { color: var(--gold); font-size: 12px; }
.stage-tab span { margin-top: 2px; font-size: 13px; font-weight: 750; line-height: 1.25; }
.stage-tab.is-selected { border-color: var(--border-strong); background: color-mix(in srgb, var(--plum) 18%, var(--surface)); color: var(--text); }
.stage-tab.is-current::after { content: "当前"; display: inline-block; margin-top: 6px; color: var(--success); font-size: 11px; font-weight: 800; }

.stage-detail { min-width: 0; }
.stage-hero { padding: clamp(19px, 4vw, 28px); }
.stage-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.badge { min-height: 28px; display: inline-flex; align-items: center; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 750; }
.badge.gold { border-color: var(--border-strong); color: var(--gold-soft); }
.badge.success { color: var(--success); }
.stage-hero h2 { margin: 10px 0 7px; font-size: clamp(27px, 5vw, 39px); line-height: 1.08; letter-spacing: -0.04em; }
.stage-hero .raw-core { margin: 0 0 18px; color: var(--text-soft); }
.stage-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }

.status-segment { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 5px; border: 1px solid var(--border); border-radius: 15px; background: var(--bg-elevated); }
.status-choice { min-height: 44px; min-width: 0; padding: 7px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 800; }
.status-choice.is-active { background: var(--surface-3); color: var(--gold-soft); }

.stage-sections { min-width: 0; display: grid; gap: 14px; margin-top: 14px; }
.section-card { min-width: 0; padding: clamp(17px, 3.5vw, 24px); }
.section-card h3 { margin: 0 0 4px; font-size: 20px; }
.section-card > p:first-of-type { margin-top: 4px; color: var(--muted); }

.checklist { min-width: 0; display: grid; gap: 8px; margin-top: 15px; }
.check-item-wrap { min-width: 0; }
.check-row { min-height: 54px; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 4px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 14px; background: color-mix(in srgb, var(--surface-2) 62%, transparent); }
.check-row.no-note { grid-template-columns: 44px minmax(0, 1fr); }
.check-row label { min-width: 0; padding: 8px 2px; line-height: 1.35; }
.check-row.is-done label { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.check-control { width: 44px; height: 44px; display: grid; place-items: center; }
.check-control input { width: 23px; height: 23px; margin: 0; accent-color: var(--gold); }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: var(--gold); font-weight: 850; }
.icon-button:active, .icon-button.is-active { background: var(--surface-3); }
.item-note { margin: 7px 0 2px 48px; }
.item-note[hidden] { display: none; }

.field-grid { min-width: 0; display: grid; gap: 13px; }
.field { min-width: 0; display: grid; gap: 7px; color: var(--text-soft); font-size: 14px; font-weight: 750; }
.field-hint { color: var(--muted); font-size: 12px; font-weight: 500; }
input[type="text"], input[type="search"], input[type="date"], input[type="number"], textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 16px;
}
textarea { min-height: 88px; max-height: 42vh; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 17%, transparent); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }

.toggle-row { min-height: 54px; display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-copy { min-width: 0; }
.toggle-copy strong, .toggle-copy span { display: block; }
.toggle-copy span { color: var(--muted); font-size: 13px; }
.switch { position: relative; flex: 0 0 54px; width: 54px; height: 44px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 6px 0; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-3); transition: background 150ms ease; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 150ms ease, background 150ms ease; }
.switch input:checked + span { background: color-mix(in srgb, var(--plum) 52%, var(--surface-3)); }
.switch input:checked + span::after { transform: translateX(22px); background: var(--gold-soft); }
.switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--gold) 25%, transparent); }

.quantum-card { border-color: color-mix(in srgb, var(--plum-bright) 35%, var(--border)); background: linear-gradient(145deg, color-mix(in srgb, var(--plum) 12%, var(--surface)), var(--surface)); }
.quantum-quote { padding: 12px 14px; border-left: 3px solid var(--plum-bright); border-radius: 0 12px 12px 0; background: color-mix(in srgb, var(--plum) 9%, transparent); color: var(--text-soft); }
.quantum-source { margin: 12px 0; padding: 12px 14px; border-left: 3px solid var(--plum-bright); border-radius: 0 12px 12px 0; background: color-mix(in srgb, var(--plum) 9%, transparent); }
.editorial-note { margin: 0 0 9px; color: var(--muted); font-size: 13px; }
.source-label { margin: 0 0 7px; color: var(--gold-soft); font-size: 12px; font-weight: 850; letter-spacing: 0.04em; }
.quantum-source-list { margin: 0; padding-left: 20px; color: var(--text-soft); }
.quantum-source-list li + li { margin-top: 5px; }
.inline-message { margin: 10px 0 0; color: var(--warning); font-size: 13px; }

.days-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-button { min-height: 44px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-weight: 800; }
.filter-button.is-active { border-color: var(--border-strong); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); color: var(--gold-soft); }
.days-grid { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.day-card { min-width: 0; overflow: clip; }
.day-summary { min-height: 138px; display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 100%; padding: 15px; border: 0; background: transparent; text-align: left; }
.day-summary-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day-number { color: var(--gold); font-size: 13px; font-weight: 850; }
.day-date { color: var(--muted); font-size: 12px; }
.day-preview { min-width: 0; flex: 1; margin: 0; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.day-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.day-card.is-today { border-color: var(--border-strong); }
.day-card.is-today .day-number::after { content: " · 今天"; color: var(--success); }
.day-editor { grid-column: 1 / -1; min-width: 0; padding: 17px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.day-editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.day-editor h3 { margin: 0; }
.readout-field output { min-height: 48px; display: flex; align-items: center; padding: 11px 13px; border: 1px solid var(--border); border-radius: 13px; background: var(--bg-elevated); color: var(--gold-soft); font-size: 18px; font-weight: 850; }
.day-entries-panel, .completed-items-panel { min-width: 0; margin: 16px 0; padding: 15px; border: 1px solid var(--border); border-radius: 16px; background: color-mix(in srgb, var(--surface-2) 52%, transparent); }
.day-entries-panel h4, .completed-items-panel h4 { margin: 0; font-size: 17px; }
.day-entries-panel .card-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.study-entry-list { min-width: 0; display: grid; gap: 10px; margin-top: 12px; }
.study-entry { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.study-entry-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.completed-chip-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.completed-chip { max-width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-soft); font-size: 13px; overflow-wrap: anywhere; }
.empty-state.compact { margin: 0; padding: 12px; }
.inline-alert > p { margin: 0; }
.inline-alert > p + p { margin-top: 6px; }

.search-bar { position: sticky; z-index: 8; top: calc(var(--topbar-height) + var(--safe-top)); padding: 9px 0 12px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); }
.search-input-wrap { position: relative; }
.search-input-wrap input { min-height: 54px; padding-left: 44px; border-color: var(--border-strong); background: var(--surface); }
.search-input-wrap::before { content: "⌕"; position: absolute; z-index: 1; top: 13px; left: 15px; color: var(--gold); font-size: 22px; }
.search-results { min-width: 0; display: grid; gap: 9px; margin-top: 10px; }
.search-result { min-height: 68px; display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); text-align: left; }
.search-result > span:first-child { min-width: 0; }
.search-result strong, .search-result small { display: block; }
.search-result small { margin-top: 3px; color: var(--muted); }
.result-type { flex: 0 0 auto; color: var(--gold); font-size: 12px; font-weight: 800; }

.settings-grid { min-width: 0; display: grid; gap: 14px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.summary-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; margin: 16px 0; }
.summary-list dt { color: var(--muted); }
.summary-list dd { min-width: 0; margin: 0; font-weight: 750; overflow-wrap: anywhere; }
.roadmap-details { overflow: clip; }
.roadmap-details summary { min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; cursor: pointer; font-weight: 850; }
.roadmap-details summary::after { content: "+"; color: var(--gold); font-size: 24px; }
.roadmap-details[open] summary::after { content: "−"; }
.roadmap-content { min-width: 0; padding: 0 18px 20px; color: var(--text-soft); }
.roadmap-content h3 { margin: 22px 0 8px; color: var(--text); }
.roadmap-content ul, .roadmap-content ol { padding-left: 22px; }
.route-overview-list { display: grid; gap: 9px; }
.route-overview-item { min-width: 0; padding: 13px 14px; border: 1px solid var(--border); border-radius: 13px; background: var(--bg-elevated); }
.route-overview-item strong { color: var(--gold-soft); }
.route-overview-item p { margin: 5px 0 0; }
.route-acceptance { padding: 8px 0 10px; border-bottom: 1px solid var(--border); }
.route-acceptance:last-of-type { border-bottom: 0; }
.source-check-list { display: grid; gap: 7px; list-style: none; padding-left: 0 !important; }
.source-check-list li { display: flex; align-items: flex-start; gap: 9px; }
.source-check { flex: 0 0 24px; color: var(--muted); font-weight: 850; }
.source-check.is-checked { color: var(--success); }
.route-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
.route-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
.route-table th, .route-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.route-table th { color: var(--gold-soft); background: var(--surface-2); }

.toast-region { position: fixed; z-index: 100; right: max(16px, var(--safe-right)); bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px); left: max(16px, var(--safe-left)); display: grid; justify-items: center; pointer-events: none; }
.toast { max-width: 560px; padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: 13px; background: color-mix(in srgb, var(--surface-3) 94%, transparent); color: var(--text); box-shadow: var(--shadow); animation: toast-in 160ms ease; }
.toast.is-error { border-color: rgba(228, 135, 146, 0.5); }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

.modal { width: min(92vw, 520px); max-height: min(82dvh, 720px); overflow: auto; padding: 24px; border: 1px solid var(--border-strong); border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5); }
.modal::backdrop { background: rgba(12, 6, 10, 0.7); backdrop-filter: blur(5px); }
.modal h2 { margin: 5px 0 10px; }
.modal-warning { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--text-soft); }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.confirm-field { display: grid; gap: 7px; margin-top: 16px; color: var(--text-soft); font-weight: 750; }

.highlight-target { animation: target-pulse 1.7s ease; }
.keyboard-open .primary-nav { transform: translateY(120%); pointer-events: none; }
@keyframes target-pulse {
  0%, 100% { box-shadow: none; }
  20%, 65% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 34%, transparent); border-color: var(--gold); }
}

@media (min-width: 700px) {
  .app-shell { padding-right: max(24px, var(--safe-right)); padding-left: max(24px, var(--safe-left)); }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid .span-full { grid-column: 1 / -1; }
  .field-grid.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .days-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stage-rail { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (min-width: 980px) {
  .app-shell { padding-left: calc(104px + max(22px, var(--safe-left))); padding-bottom: 34px; }
  .primary-nav {
    top: calc(var(--topbar-height) + var(--safe-top) + 10px);
    right: auto;
    bottom: auto;
    left: max(18px, var(--safe-left));
    width: 74px;
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
  }
  .nav-item { min-height: 64px; }
  .stage-workspace { grid-template-columns: 230px minmax(0, 1fr); align-items: start; }
  .stage-rail { position: sticky; top: calc(var(--topbar-height) + var(--safe-top) + 14px); display: grid; grid-template-columns: 1fr; }
  .stage-tab { min-height: 68px; }
  .stage-sections { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .stage-sections .span-full { grid-column: 1 / -1; }
  .days-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .toast-region { bottom: 22px; }
}

@media (max-width: 520px) {
  .app-shell { padding-right: max(12px, var(--safe-right)); padding-left: max(12px, var(--safe-left)); }
  .brand-mark { flex-basis: 44px; height: 44px; border-radius: 14px; }
  .topbar-status .status-dot { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .progress-ring { width: 126px; justify-self: start; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .stage-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .days-grid { grid-template-columns: 1fr; }
  .day-editor { grid-column: 1; }
  .button { width: 100%; }
  .hero-actions .button, .stage-actions .button, .settings-actions .button { flex: 1 1 100%; }
  .dialog-actions .button { width: auto; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (display-mode: standalone) {
  .topbar { padding-top: calc(12px + var(--safe-top)); }
}
