:root {
  --paper: #f2eee4;
  --paper-deep: #e5dfd1;
  --card: #fffdf7;
  --ink: #11232c;
  --ink-soft: #526068;
  --ink-muted: #7a8589;
  --blue: #175dff;
  --blue-dark: #0b378f;
  --orange: #ff5b2b;
  --mint: #a7e6cb;
  --mint-dark: #1b7456;
  --line: rgba(17, 35, 44, 0.16);
  --line-strong: rgba(17, 35, 44, 0.32);
  --shadow: 0 20px 60px rgba(31, 43, 48, 0.12);
  --display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, Georgia, serif;
  --body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(17, 35, 44, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 35, 44, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 76% 0%, rgba(23, 93, 255, 0.09), transparent 28rem),
    var(--paper);
  background-size: 32px 32px, 32px 32px, auto, auto;
  font-family: var(--body);
  line-height: 1.65;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(23, 93, 255, 0.32);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  color: white;
  background: var(--ink);
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 370px;
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px 18px;
  background: rgba(242, 238, 228, 0.94);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.rail-head {
  position: relative;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  flex: 0 0 42px;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  height: 42px;
  padding: 8px;
  background: var(--ink);
  border-radius: 50%;
}

.brand-mark i {
  display: block;
  width: 3px;
  margin: auto;
  background: var(--mint);
  border-radius: 3px;
}

.brand-mark i:nth-child(1) { height: 12px; }
.brand-mark i:nth-child(2) { height: 22px; background: var(--orange); }
.brand-mark i:nth-child(3) { height: 16px; }

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 2px;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.mobile-close {
  display: none;
}

.progress-card {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 28px 0 22px;
  padding: 14px;
  background: rgba(255, 253, 247, 0.64);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.progress-ring {
  --size: 48px;
  display: grid;
  flex: 0 0 var(--size);
  width: var(--size);
  height: var(--size);
  place-items: center;
  background: conic-gradient(var(--blue) calc(var(--progress) * 1%), rgba(23, 93, 255, 0.1) 0);
  border-radius: 50%;
}

.progress-ring::before {
  grid-area: 1 / 1;
  width: 36px;
  height: 36px;
  content: "";
  background: var(--card);
  border-radius: 50%;
}

.progress-ring span {
  z-index: 1;
  grid-area: 1 / 1;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.micro-label,
.eyebrow {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.progress-card strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.progress-card p {
  margin: 3px 0 0;
  color: var(--ink-muted);
  font-size: 10px;
  line-height: 1.45;
}

.module-nav {
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
}

.nav-stage {
  margin: 19px 0 7px;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) 13px;
  gap: 8px;
  align-items: center;
  width: 100%;
  margin: 3px 0;
  padding: 9px 8px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item:hover {
  background: rgba(255, 253, 247, 0.68);
}

.nav-item.active {
  color: white;
  background: var(--ink);
}

.nav-item .nav-no {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 9px;
}

.nav-item.active .nav-no {
  color: var(--mint);
}

.nav-item .nav-title {
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item .nav-state {
  width: 9px;
  height: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.nav-item.complete .nav-state {
  background: var(--mint);
  border-color: var(--mint-dark);
}

.nav-item.active .nav-state {
  border-color: rgba(255, 255, 255, 0.45);
}

.rail-foot {
  margin-top: auto;
  padding-top: 14px;
}

.rail-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 8px;
  color: var(--ink-soft);
  font-size: 11px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

kbd {
  padding: 1px 5px;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 9px;
  background: rgba(17, 35, 44, 0.06);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.privacy-note {
  margin: 9px 8px 0;
  color: var(--ink-muted);
  font-size: 9px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  padding: 0 42px 80px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(var(--paper) 70%, rgba(242, 238, 228, 0));
}

.crumbs {
  display: flex;
  min-width: 0;
  gap: 8px;
  align-items: center;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.crumbs strong {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--body);
  font-size: 11px;
  letter-spacing: 0;
  text-overflow: ellipsis;
}

.signal-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--orange);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 91, 43, 0.12);
}

.topbar-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.text-button,
.primary-small,
.primary-button,
.ghost-button,
.icon-button,
.mini-link,
.send-button {
  border: 0;
  cursor: pointer;
}

.text-button {
  padding: 7px 10px;
  color: var(--ink-soft);
  font-size: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.text-button:hover {
  border-color: var(--line);
}

.primary-small {
  padding: 8px 13px;
  color: white;
  font-size: 10px;
  font-weight: 700;
  background: var(--blue);
  border-radius: 8px;
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.menu-button {
  display: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(380px, 0.97fr);
  gap: 40px;
  align-items: center;
  min-height: 500px;
  padding: 46px 0 64px;
}

.hero h1 {
  max-width: 740px;
  margin: 14px 0 24px;
  font-family: var(--display);
  font-size: clamp(42px, 5vw, 74px);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.hero h1 em {
  color: var(--blue);
  font-style: normal;
}

.hero-lede {
  max-width: 650px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.9;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.primary-button,
.ghost-button {
  padding: 12px 18px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
}

.primary-button {
  color: white;
  background: var(--ink);
}

.primary-button span {
  margin-left: 8px;
  color: var(--mint);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line-strong);
}

.hero-map {
  position: relative;
  padding: 20px;
  overflow: hidden;
  background: var(--ink);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.hero-map::after {
  position: absolute;
  right: -60px;
  bottom: -90px;
  width: 280px;
  height: 280px;
  content: "";
  background: radial-gradient(circle, rgba(23, 93, 255, 0.35), transparent 68%);
  pointer-events: none;
}

.map-head,
.map-legend {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.48);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.pipeline {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1.1fr) 20px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  margin: 26px 0 22px;
}

.pipeline article {
  position: relative;
  min-height: 185px;
  padding: 15px 13px;
  color: white;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 15px;
}

.pipeline article.pipe-core {
  background: linear-gradient(160deg, rgba(23, 93, 255, 0.92), rgba(9, 52, 151, 0.85));
  border-color: rgba(167, 230, 203, 0.4);
}

.pipe-index {
  display: grid;
  width: 28px;
  height: 28px;
  margin-bottom: 22px;
  place-items: center;
  color: var(--mint);
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
}

.pipeline strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}

.pipeline p {
  margin: 9px 0 0;
  color: rgba(255, 255, 255, 0.58);
  font-size: 10px;
  line-height: 1.65;
}

.pipe-arrow {
  display: grid;
  place-items: center;
  color: var(--mint);
  font-family: var(--mono);
}

.pulse {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 8px;
  height: 8px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(167, 230, 203, 0.5);
  animation: signal 2.2s infinite;
}

@keyframes signal {
  0%, 100% { box-shadow: 0 0 0 0 rgba(167, 230, 203, 0.48); }
  50% { box-shadow: 0 0 0 9px rgba(167, 230, 203, 0); }
}

.map-legend {
  justify-content: flex-start;
  gap: 16px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0;
}

.map-legend span {
  display: flex;
  gap: 6px;
  align-items: center;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-dot.blue { background: #77a1ff; }
.legend-dot.orange { background: var(--orange); }
.legend-dot.mint { background: var(--mint); }

.route-strip {
  padding: 34px 0 54px;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 30px;
  line-height: 1.2;
}

.section-heading > p {
  max-width: 480px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.route-stage {
  position: relative;
  min-height: 158px;
  padding: 16px;
  background: rgba(255, 253, 247, 0.62);
  border: 1px solid var(--line);
  border-radius: 15px;
}

.route-stage::after {
  position: absolute;
  top: 27px;
  right: -11px;
  z-index: 1;
  width: 20px;
  color: var(--blue);
  content: "→";
  text-align: center;
}

.route-stage:last-child::after {
  content: "";
}

.route-stage .stage-no {
  color: var(--orange);
  font-family: var(--mono);
  font-size: 9px;
}

.route-stage h3 {
  margin: 16px 0 7px;
  font-family: var(--display);
  font-size: 18px;
}

.route-stage p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.65;
}

.lesson {
  min-height: 620px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}

.lesson-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 32px;
  align-items: end;
  margin-bottom: 30px;
}

.lesson-kicker {
  display: flex;
  gap: 10px;
  align-items: center;
}

.lesson-kicker span:first-child {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.lesson-kicker span:last-child {
  color: var(--ink-muted);
  font-size: 10px;
}

.lesson h2 {
  max-width: 850px;
  margin: 9px 0 15px;
  font-family: var(--display);
  font-size: clamp(34px, 4.2vw, 55px);
  letter-spacing: -0.04em;
  line-height: 1.16;
}

.lesson-summary {
  max-width: 780px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.85;
}

.lesson-controls {
  text-align: right;
}

.complete-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 10px 13px;
  color: var(--ink-soft);
  font-size: 11px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.complete-toggle.done {
  color: var(--mint-dark);
  background: rgba(167, 230, 203, 0.24);
  border-color: rgba(27, 116, 86, 0.25);
}

.complete-toggle i {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  font-size: 10px;
  font-style: normal;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.lesson-controls p {
  margin: 9px 0 0;
  color: var(--ink-muted);
  font-size: 9px;
}

.thesis-card {
  position: relative;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 26px;
  padding: 20px 22px;
  overflow: hidden;
  background: var(--ink);
  border-radius: var(--radius);
}

.thesis-card::after {
  position: absolute;
  top: -60px;
  right: -50px;
  width: 200px;
  height: 200px;
  content: "";
  border: 1px solid rgba(167, 230, 203, 0.22);
  border-radius: 50%;
}

.thesis-card span {
  padding-top: 3px;
  color: var(--mint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.thesis-card strong {
  max-width: 820px;
  color: white;
  font-family: var(--display);
  font-size: 22px;
  line-height: 1.5;
}

.lesson-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(260px, 0.72fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  padding: 20px;
  background: rgba(255, 253, 247, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}

.panel-title h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 20px;
}

.panel-title span {
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.diagram {
  min-height: 235px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: #d7f9e9;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.75;
  white-space: pre;
  background:
    radial-gradient(circle at 90% 10%, rgba(23, 93, 255, 0.32), transparent 35%),
    #0d1d25;
  border-radius: 12px;
}

.point-list,
.question-list,
.proof-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.point-list li,
.question-list li,
.proof-list li {
  position: relative;
  padding-left: 20px;
  color: var(--ink-soft);
  font-size: 12px;
}

.point-list li::before,
.question-list li::before,
.proof-list li::before {
  position: absolute;
  left: 0;
  color: var(--blue);
  content: "◆";
  font-size: 8px;
  top: 7px;
}

.point-list strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 12px;
}

.metric-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 16px 0;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.metric-band div {
  padding: 15px;
  background: rgba(255, 253, 247, 0.8);
}

.metric-band span {
  display: block;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.09em;
}

.metric-band strong {
  display: block;
  margin-top: 6px;
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.35;
}

.field-note {
  margin: 16px 0;
  padding: 20px;
  background:
    linear-gradient(120deg, rgba(255, 91, 43, 0.08), transparent 45%),
    rgba(255, 253, 247, 0.72);
  border: 1px solid rgba(255, 91, 43, 0.24);
  border-radius: var(--radius);
}

.field-note label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.field-note textarea {
  width: 100%;
  min-height: 94px;
  padding: 12px;
  color: var(--ink);
  line-height: 1.65;
  resize: vertical;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.field-note p {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 9px;
}

.sales-drill {
  padding: 20px;
  background: linear-gradient(145deg, rgba(23, 93, 255, 0.09), rgba(167, 230, 203, 0.18));
  border: 1px solid rgba(23, 93, 255, 0.14);
  border-radius: var(--radius);
}

.sales-drill blockquote {
  margin: 10px 0 0;
  padding-left: 15px;
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.6;
  border-left: 2px solid var(--blue);
}

.lesson-footer {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 28px;
}

.lesson-footer button {
  min-width: 140px;
}

.coach {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 18px 16px;
  background: #e9e5d9;
  border-left: 1px solid var(--line);
}

.coach-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.coach-head h2 {
  margin: 3px 0 0;
  font-family: var(--display);
  font-size: 25px;
}

.context-chip {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  color: var(--ink-soft);
  font-size: 10px;
  background: rgba(255, 253, 247, 0.65);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  margin: 12px -4px 10px;
  padding: 2px 4px;
  overflow-y: auto;
}

.message {
  max-width: 94%;
  padding: 12px 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.message.user {
  align-self: flex-end;
  color: white;
  background: var(--blue);
  border-color: var(--blue);
}

.message.error {
  background: #fff0eb;
  border-color: rgba(255, 91, 43, 0.3);
}

.message-label {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.message.user .message-label {
  color: rgba(255, 255, 255, 0.68);
}

.message p {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 9px;
}

.prompt-chip {
  max-width: 100%;
  padding: 6px 8px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 253, 247, 0.56);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.composer {
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
}

.composer textarea {
  width: 100%;
  min-height: 52px;
  padding: 5px;
  color: var(--ink);
  line-height: 1.5;
  resize: none;
  background: transparent;
  border: 0;
  outline: 0;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-link {
  padding: 5px;
  color: var(--ink-muted);
  font-size: 9px;
  background: transparent;
}

.send-button {
  padding: 7px 12px;
  color: white;
  font-size: 10px;
  font-weight: 700;
  background: var(--ink);
  border-radius: 8px;
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.52;
}

dialog {
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

dialog::backdrop {
  background: rgba(11, 24, 31, 0.54);
  backdrop-filter: blur(5px);
}

.settings-card,
.search-card {
  width: min(540px, calc(100vw - 32px));
  padding: 24px;
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dialog-head h2 {
  margin: 3px 0 0;
  font-family: var(--display);
  font-size: 30px;
}

.settings-copy {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 11px;
}

.settings-card > label {
  display: block;
  margin-top: 12px;
}

.settings-card label span {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
}

.settings-card input,
.search-input-wrap input {
  width: 100%;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.settings-status {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 10px;
}

.search-card {
  width: min(680px, calc(100vw - 32px));
  padding: 12px;
}

.search-input-wrap {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
}

.search-input-wrap input {
  padding: 13px;
  font-size: 15px;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-results {
  max-height: 55vh;
  margin-top: 8px;
  overflow: auto;
}

.search-result {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.search-result:hover {
  background: rgba(255, 253, 247, 0.65);
}

.search-result .result-no {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 9px;
}

.search-result strong,
.search-result small {
  display: block;
}

.search-result strong {
  font-size: 12px;
}

.search-result small {
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: 360px;
  padding: 11px 14px;
  color: white;
  font-size: 11px;
  background: var(--ink);
  border-radius: 9px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.rail-scrim {
  display: none;
}

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

  .coach {
    position: fixed;
    right: 16px;
    bottom: 16px;
    top: auto;
    z-index: 40;
    width: min(390px, calc(100vw - 32px));
    height: min(650px, calc(100vh - 32px));
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    transform: translateX(calc(100% + 32px));
    transition: transform 220ms ease;
  }

  .coach.open {
    transform: translateX(0);
  }

  .main {
    padding-right: 30px;
    padding-left: 30px;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 0.85fr);
  }
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .rail {
    position: fixed;
    left: 0;
    z-index: 60;
    width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform 220ms ease;
  }

  .rail.open {
    transform: translateX(0);
  }

  .mobile-close {
    position: absolute;
    top: -10px;
    right: 0;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 50%;
  }

  .rail-scrim {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    background: rgba(11, 24, 31, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .rail-scrim.show {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-button {
    display: grid;
  }

  .main {
    padding: 0 20px 60px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .hero-map {
    max-width: 720px;
  }

  .lesson-head {
    grid-template-columns: 1fr;
  }

  .lesson-controls {
    text-align: left;
  }
}

@media (max-width: 720px) {
  .topbar {
    gap: 8px;
  }

  .crumbs span:not(.signal-dot),
  .crumbs strong {
    display: none;
  }

  .topbar-actions .text-button {
    display: none;
  }

  .hero {
    min-height: auto;
    padding: 35px 0 42px;
  }

  .hero h1 {
    font-size: 42px;
  }

  .pipeline {
    grid-template-columns: 1fr;
  }

  .pipe-arrow {
    transform: rotate(90deg);
  }

  .pipeline article {
    min-height: auto;
  }

  .pipe-index {
    margin-bottom: 8px;
  }

  .route-grid {
    grid-template-columns: 1fr 1fr;
  }

  .route-stage::after {
    display: none;
  }

  .section-heading {
    display: block;
  }

  .section-heading > p {
    margin-top: 10px;
  }

  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .thesis-card {
    grid-template-columns: 1fr;
  }

  .metric-band {
    grid-template-columns: 1fr;
  }

  .lesson-footer {
    flex-direction: column;
  }

  .lesson-footer button {
    width: 100%;
  }
}

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