:root {
  color-scheme: light;
  --bg: #f5efe5;
  --bg-elevated: rgba(255, 251, 245, 0.84);
  --surface: rgba(255, 250, 243, 0.88);
  --surface-strong: #fffaf2;
  --surface-soft: rgba(241, 232, 219, 0.72);
  --ink: #171411;
  --ink-soft: #5b5248;
  --ink-muted: #807466;
  --line: rgba(35, 27, 18, 0.11);
  --line-strong: rgba(35, 27, 18, 0.18);
  --accent: #245c52;
  --accent-strong: #1c4b42;
  --accent-soft: rgba(36, 92, 82, 0.12);
  --warn: #7f5b21;
  --warn-soft: rgba(127, 91, 33, 0.14);
  --danger: #9c4d3f;
  --danger-soft: rgba(156, 77, 63, 0.14);
  --success: #2e6156;
  --success-soft: rgba(46, 97, 86, 0.12);
  --radius-xs: 10px;
  --radius-sm: 16px;
  --radius-md: 22px;
  --radius-lg: 28px;
  --shadow-soft: 0 18px 48px rgba(34, 24, 16, 0.08);
  --shadow-card: 0 14px 34px rgba(36, 26, 18, 0.06);
  --font-ui: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-display: "Noto Serif SC", "Songti SC", serif;
  --page-pad: clamp(18px, 4vw, 34px);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #171411;
    --bg-elevated: rgba(23, 20, 17, 0.88);
    --surface: rgba(33, 28, 24, 0.9);
    --surface-strong: #26211c;
    --surface-soft: rgba(46, 39, 33, 0.74);
    --ink: #f8f1e7;
    --ink-soft: #d1c5b8;
    --ink-muted: #a89888;
    --line: rgba(248, 241, 231, 0.12);
    --line-strong: rgba(248, 241, 231, 0.2);
    --accent: #7fc0b3;
    --accent-strong: #95d4c8;
    --accent-soft: rgba(127, 192, 179, 0.13);
    --warn: #d8b26e;
    --warn-soft: rgba(216, 178, 110, 0.14);
    --danger: #df8d79;
    --danger-soft: rgba(223, 141, 121, 0.16);
    --success: #88d2c4;
    --success-soft: rgba(136, 210, 196, 0.15);
    --shadow-soft: none;
    --shadow-card: none;
  }
}

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

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(36, 92, 82, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 24%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
}

body {
  display: flex;
  justify-content: center;
}

a,
button,
input {
  font: inherit;
}

button,
.button-link {
  border: 0;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 40%, white 60%);
  outline-offset: 3px;
}

.app-shell {
  width: min(1180px, 100%);
  padding: 22px var(--page-pad) 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 16px;
  margin-bottom: 18px;
  backdrop-filter: blur(18px);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--surface-strong);
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
}

.brand-copy strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.brand-copy p,
.footer-note {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-chip,
.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 13px;
  color: var(--ink-soft);
}

.ghost-button,
.secondary-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  text-decoration: none;
}

.evidence-link {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}

.evidence-link:hover {
  color: var(--accent-strong);
}

.primary-button,
.cta-button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface-strong);
  text-decoration: none;
  box-shadow: 0 12px 24px rgba(36, 92, 82, 0.18);
}

.primary-button:hover,
.cta-button:hover,
.button-link:hover {
  background: var(--accent-strong);
}

.ghost-button:hover,
.secondary-button:hover,
.secondary-link:hover {
  background: var(--surface-soft);
}

main {
  display: grid;
  gap: 22px;
}

.hero-grid,
.results-layout {
  display: grid;
  gap: 22px;
  align-items: start;
}

.hero-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
}

.results-layout {
  grid-template-columns: minmax(0, 1.16fr) minmax(280px, 0.84fr);
}

.hero-panel,
.side-panel,
.results-panel,
.method-panel,
.secondary-card,
.support-card,
.state-card,
.failure-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.hero-panel,
.results-panel,
.failure-panel {
  padding: clamp(24px, 3.8vw, 40px);
}

.side-panel,
.method-panel,
.secondary-card,
.support-card,
.state-card {
  padding: 22px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 18px;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.display-title,
.results-title,
.primary-card h2,
.secondary-card h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.display-title {
  font-size: clamp(34px, 6vw, 64px);
  max-width: 11ch;
}

.results-title {
  font-size: clamp(28px, 4vw, 44px);
}

.hero-copy,
.lede,
.copy,
.failure-copy,
.support-card p,
.state-card p,
.method-panel li {
  color: var(--ink-soft);
  line-height: 1.72;
}

.hero-copy {
  margin: 18px 0 0;
  max-width: 52ch;
  font-size: clamp(16px, 2.3vw, 19px);
}

.hero-metrics,
.support-grid,
.state-grid,
.explain-grid {
  display: grid;
  gap: 12px;
}

.hero-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 28px;
}

.support-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 20px;
}

.state-grid,
.explain-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric,
.support-grid div,
.explain-grid article {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.metric strong {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 4px;
}

.metric span,
.microcopy,
.form-note,
.state-card small,
.support-grid dt {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-muted);
}

.input-card {
  margin-top: 24px;
  padding: 22px;
  background: var(--surface-strong);
  border-radius: 24px;
  border: 1px solid var(--line-strong);
}

.input-card h2,
.side-panel h3,
.method-panel h3,
.support-card h3,
.state-card h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.input-wrap {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.input-wrap label {
  font-size: 13px;
  color: var(--ink-muted);
}

.query-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  border-radius: 18px;
  padding: 16px 18px;
  min-height: 56px;
}

.action-row,
.results-summary,
.card-topline,
.cta-cluster,
.prompt-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.prompt-list {
  margin-top: 18px;
}

.prompt-pill {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  padding: 10px 14px;
  border-radius: 999px;
  min-height: 44px;
  text-decoration: none;
}

.prompt-pill:hover {
  background: var(--surface-soft);
}

.error-banner,
.status-banner {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.65;
}

.error-banner,
.status-banner.danger {
  background: var(--danger-soft);
  color: color-mix(in srgb, var(--danger) 84%, var(--ink) 16%);
}

.status-banner.warn {
  background: var(--warn-soft);
  color: color-mix(in srgb, var(--warn) 82%, var(--ink) 18%);
}

.status-banner.success {
  background: var(--success-soft);
  color: color-mix(in srgb, var(--success) 88%, var(--ink) 12%);
}

.trust-strip {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.trust-item {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: start;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.trust-item strong {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.trust-item span,
.support-grid dd {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-soft);
}

.support-grid dd {
  margin: 0;
}

.primary-card {
  padding: 24px;
  border-radius: 30px;
  background: linear-gradient(180deg, var(--surface-strong), rgba(255, 250, 243, 0.72));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-card);
}

.primary-card h2 {
  font-size: clamp(26px, 3.8vw, 38px);
  max-width: 13ch;
}

.secondary-card h3 {
  font-size: 22px;
}

.card-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  min-height: 36px;
}

.card-chip.medium {
  background: var(--warn-soft);
  color: var(--warn);
}

.card-chip.low {
  background: color-mix(in srgb, var(--danger-soft) 76%, transparent);
  color: var(--danger);
}

.lede {
  margin: 14px 0 18px;
  font-size: 16px;
}

.card-section-label {
  display: block;
  margin: 16px 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.evidence-list {
  margin: 0;
  padding-left: 20px;
}

.evidence-list li {
  margin-bottom: 10px;
  color: var(--ink-soft);
  line-height: 1.68;
}

.evidence-list strong {
  color: var(--ink);
}

.secondary-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.mini-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.state-card small {
  display: block;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.results-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.failure-panel {
  display: grid;
  gap: 18px;
}

.failure-panel h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.06;
}

.analysis-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(19, 16, 14, 0.3);
  backdrop-filter: blur(8px);
  z-index: 40;
}

.analysis-sheet {
  width: min(760px, 100%);
  padding: clamp(24px, 4vw, 40px);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.analysis-sheet h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.analysis-steps {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.step-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.step-item:first-child {
  border-top: 0;
}

.step-num {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-weight: 700;
}

.step-item.current .step-num {
  background: var(--accent);
  color: var(--surface-strong);
}

body.is-submitting .analysis-overlay {
  display: grid;
}

.footer-note {
  text-align: center;
  margin-top: 28px;
}

@media (max-width: 1024px) {
  .hero-grid,
  .results-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
  }
}

@media (max-width: 768px) {
  .app-shell {
    padding-top: 14px;
  }

  .hero-metrics,
  .support-grid,
  .state-grid,
  .explain-grid {
    grid-template-columns: 1fr;
  }

  .display-title {
    max-width: 10ch;
  }

  .results-header {
    margin-bottom: 16px;
  }
}

@media (max-width: 375px) {
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero-panel,
  .side-panel,
  .results-panel,
  .primary-card,
  .secondary-card,
  .method-panel,
  .state-card,
  .support-card,
  .failure-panel {
    border-radius: 24px;
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar {
    padding: 12px;
    border-radius: 18px;
  }
}
