@import url("fonts/noto-sans-sc/index.css");

:root {
  color-scheme: light;
  --ink: #172033;
  --ink-soft: #4f5d73;
  --navy: #112d52;
  --navy-hover: #0b2342;
  --navy-pale: #e9eff7;
  --paper: #ffffff;
  --canvas: #f3f5f8;
  --canvas-warm: #f7f5f1;
  --line: #d8dee8;
  --line-strong: #bbc5d3;
  --teal: #156b67;
  --teal-pale: #e5f2f0;
  --amber: #8a5a16;
  --amber-pale: #fff3d8;
  --danger: #a33a35;
  --danger-pale: #faeceb;
  --shadow-sm: 0 1px 2px rgba(17, 45, 82, 0.08);
  --shadow-lg: 0 18px 48px rgba(17, 45, 82, 0.14);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --content: 1440px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "Noto Sans SC Variable", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
button, input, select, textarea { font: inherit; }
button, summary, .drop-zone { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed; left: 12px; top: -64px; z-index: 1000;
  background: var(--navy); color: white; padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid #2b76c5; outline-offset: 3px; }

.topbar {
  min-height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-seal {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--navy); color: white; border-radius: 8px;
  font-family: STKaiti, KaiTi, serif; font-size: 22px;
}
.brand strong, .brand small { display: block; line-height: 1.25; }
.brand strong { letter-spacing: 0.08em; }
.brand small { margin-top: 2px; color: var(--ink-soft); font-size: 11px; letter-spacing: 0.08em; }
.topbar-meta { display: flex; align-items: center; gap: 16px; color: var(--ink-soft); font-size: 13px; }
.mode-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }

main { min-height: calc(100dvh - 72px); }
.intake-shell {
  max-width: var(--content); margin: 0 auto; padding: clamp(40px, 6vw, 88px) clamp(20px, 5vw, 72px) 96px;
  display: grid; grid-template-columns: minmax(300px, 0.82fr) minmax(520px, 1.18fr); gap: clamp(40px, 7vw, 104px); align-items: start;
}
.hero-copy { position: sticky; top: 128px; }
.eyebrow, .step-label {
  margin: 0 0 10px; color: var(--teal); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
}
.hero-copy h1, .results-header h1, .progress-card h1 {
  margin: 0; font-family: "Noto Sans SC Variable", "Microsoft YaHei", sans-serif; color: var(--navy); font-weight: 760; line-height: 1.22;
}
.hero-copy h1 { font-size: clamp(38px, 5vw, 66px); letter-spacing: -0.04em; }
.hero-lede { max-width: 570px; margin: 28px 0 36px; color: var(--ink-soft); font-size: 18px; line-height: 1.85; }
.result-preview { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line-strong); }
.result-preview li { display: flex; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.result-preview li > span { color: var(--teal); font: 700 12px/1 ui-monospace, monospace; }
.result-preview strong, .result-preview small { display: block; }
.result-preview small { margin-top: 2px; color: var(--ink-soft); font-size: 13px; }

.intake-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(24px, 3vw, 40px); box-shadow: var(--shadow-lg); }
.card-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 28px; }
.card-heading h2 { margin: 0; font: 700 26px/1.35 "Noto Sans SC Variable", "Microsoft YaHei", sans-serif; color: var(--navy); }
.required-note { color: var(--ink-soft); font-size: 12px; }
.field { margin-bottom: 22px; }
.field-row { display: flex; gap: 16px; }
.field-grow { flex: 1; }
.field-type { width: 160px; }
.field label { display: block; margin-bottom: 7px; font-weight: 700; font-size: 14px; }
.field label b { color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 11px 13px;
  color: var(--ink); background: white; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.field textarea { resize: vertical; min-height: 112px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #2b76c5; box-shadow: 0 0 0 3px rgba(43,118,197,0.14); outline: none; }
.field small { display: block; margin-top: 6px; color: var(--ink-soft); font-size: 12px; }
#evidence-files { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.drop-zone {
  min-height: 112px; padding: 20px; display: flex; align-items: center; justify-content: center; gap: 16px;
  border: 1px dashed #8392a8; background: #fafbfc; border-radius: var(--radius-md); cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--navy); background: var(--navy-pale); }
.drop-zone svg { width: 30px; height: 30px; flex: 0 0 auto; fill: none; stroke: var(--navy); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drop-zone strong, .drop-zone small { display: block; }
.drop-zone small { max-width: 430px; margin-top: 3px; }
.file-list { margin: 10px 0 0; padding: 0; list-style: none; }
.file-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; background: var(--navy-pale); border-radius: var(--radius-sm); font-size: 13px; }
.file-list li + li { margin-top: 6px; }
.file-list span { color: var(--ink-soft); }
.advanced-fields { margin: 6px 0 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced-fields summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
.advanced-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; padding-top: 8px; }
.privacy-note { display: flex; gap: 9px; padding: 12px 14px; margin-bottom: 18px; border-left: 3px solid var(--amber); background: var(--amber-pale); color: #69440f; font-size: 12px; }
.privacy-note strong { white-space: nowrap; }
.primary-button, .secondary-button, .text-button, .icon-button {
  min-height: 46px; border-radius: var(--radius-sm); font-weight: 750; transition: background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}
.primary-button { width: 100%; padding: 12px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: var(--navy); border: 1px solid var(--navy); color: white; }
.primary-button:hover { background: var(--navy-hover); }
.primary-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.primary-button.is-loading svg { animation: spin 800ms linear infinite; border: 2px solid currentColor; border-left-color: transparent; border-radius: 50%; }
.secondary-button { padding: 10px 16px; background: white; border: 1px solid var(--line-strong); color: var(--navy); }
.secondary-button:hover { border-color: var(--navy); background: var(--navy-pale); }
.text-button { padding: 0 2px; background: transparent; border: 0; color: var(--teal); }
.icon-button { width: 46px; padding: 0; background: white; border: 1px solid var(--line); color: var(--navy); font-size: 25px; }
.alert { padding: 12px 14px; margin-bottom: 20px; border-radius: var(--radius-sm); }
.alert-error { background: var(--danger-pale); border: 1px solid #e8b7b3; color: #7c2925; }

.progress-view { min-height: calc(100dvh - 72px); display: grid; place-items: center; padding: 40px 20px; }
.progress-card { width: min(720px, 100%); padding: clamp(30px, 5vw, 56px); background: white; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.progress-card h1 { font-size: clamp(32px, 5vw, 48px); }
.progress-card > p:not(.eyebrow) { color: var(--ink-soft); }
.progress-steps { margin: 34px 0 20px; padding: 0; list-style: none; }
.progress-steps li { position: relative; min-height: 48px; padding: 10px 12px 10px 44px; color: var(--ink-soft); border-left: 2px solid var(--line); }
.progress-steps li::before { content: ""; position: absolute; left: -7px; top: 17px; width: 12px; height: 12px; background: var(--paper); border: 2px solid var(--line-strong); border-radius: 50%; }
.progress-steps li.is-complete { color: var(--teal); border-color: var(--teal); }
.progress-steps li.is-complete::before { background: var(--teal); border-color: var(--teal); }
.progress-steps li.is-active { color: var(--navy); font-weight: 800; }
.progress-steps li.is-active::before { background: white; border-color: var(--navy); box-shadow: 0 0 0 4px var(--navy-pale); }
.progress-notice { padding: 12px; background: var(--canvas); color: var(--ink-soft); font-size: 13px; border-radius: var(--radius-sm); }

.results-shell { max-width: 1600px; margin: 0 auto; padding: 34px clamp(18px, 3vw, 48px) 96px; }
.results-header { display: flex; justify-content: space-between; gap: 32px; align-items: end; margin-bottom: 26px; }
.results-header h1 { font-size: clamp(32px, 4vw, 50px); }
.results-header .text-button { margin-bottom: 16px; }
.results-summary { max-width: 820px; margin: 10px 0 0; color: var(--ink-soft); }
.result-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; font-size: 12px; color: var(--ink-soft); }
.result-meta > * { padding: 6px 9px; background: white; border: 1px solid var(--line); border-radius: 999px; }
.status-badge { color: #69440f; background: var(--amber-pale) !important; border-color: #e6c77c !important; font-weight: 800; }
.executive-strip { display: grid; grid-template-columns: 0.8fr 1.2fr 1.2fr 1.2fr; background: var(--navy); color: white; border-radius: var(--radius-md); overflow: hidden; }
.executive-strip > div { min-height: 132px; padding: 20px; border-right: 1px solid rgba(255,255,255,0.16); }
.executive-strip > div:last-child { border: 0; }
.executive-strip small { display: block; margin-bottom: 9px; color: #bac9dd; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; }
.executive-strip strong, .executive-strip p { margin: 0; font-size: 14px; line-height: 1.65; }
.executive-strip .risk { background: #4a2e2c; }
.result-tabs { margin-top: 24px; display: grid; grid-template-columns: repeat(4, 1fr); background: white; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.result-tab { min-height: 64px; padding: 10px 12px; background: white; color: var(--ink-soft); border: 0; border-right: 1px solid var(--line); font-weight: 750; }
.result-tab:last-child { border-right: 0; }
.result-tab span { margin-right: 8px; color: #8491a4; font: 700 11px/1 ui-monospace, monospace; }
.result-tab:hover { background: var(--canvas); }
.result-tab.is-active { background: var(--navy); color: white; }
.result-tab.is-active span { color: #a9c7e8; }
.results-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr) 300px; gap: 20px; align-items: start; margin-top: 20px; }
.section-nav, .analysis-aside { position: sticky; top: 92px; }
.section-nav { padding: 12px; background: white; border: 1px solid var(--line); border-radius: var(--radius-md); }
.section-nav a { display: block; padding: 8px 9px; color: var(--ink-soft); text-decoration: none; border-left: 2px solid transparent; font-size: 13px; }
.section-nav a:hover { color: var(--navy); background: var(--canvas); border-left-color: var(--teal); }
.result-document { min-width: 0; }
.document-head { padding: 40px clamp(20px, 5vw, 64px) 28px; background: var(--canvas-warm); border: 1px solid #ded9cf; border-bottom: 0; text-align: center; }
.document-head h2 { margin: 0; font: 700 clamp(26px, 3vw, 36px)/1.35 "Noto Sans SC Variable", "Microsoft YaHei", sans-serif; color: #282c35; }
.document-head p { margin: 10px 0 0; color: var(--ink-soft); font-size: 13px; }
.document-section { padding: 28px clamp(20px, 5vw, 64px); background: white; border: 1px solid var(--line); border-top: 0; }
.document-section:first-child { border-top: 1px solid var(--line); }
.document-section h3 { margin: 0 0 16px; color: var(--navy); font: 750 20px/1.45 "Noto Sans SC Variable", "Microsoft YaHei", sans-serif; }
.supported-point { padding: 16px 0; border-top: 1px solid var(--line); }
.supported-point:first-of-type { border-top: 0; padding-top: 0; }
.point-top { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.point-top h4 { margin: 0; font-size: 16px; color: var(--ink); }
.point-status { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; background: var(--teal-pale); color: #0e5955; font-size: 11px; font-weight: 800; }
.point-status.partial, .point-status.provisional, .point-status.conflicted { background: var(--amber-pale); color: #69440f; }
.supported-point > p { margin: 9px 0; white-space: pre-line; }
.risk-note { color: var(--danger); font-size: 13px; }
.ref-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ref-button { min-height: 34px; padding: 5px 9px; background: var(--navy-pale); color: var(--navy); border: 1px solid #c7d5e6; border-radius: 999px; font: 750 11px/1 ui-monospace, monospace; }
.ref-button:hover { background: #d8e5f3; border-color: #829dbc; }
.simple-list { margin: 0; padding-left: 21px; }
.simple-list li + li { margin-top: 7px; }
.strategy-card, .defense-card, .claim-treatment, .question-card { margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fbfcfd; }
.strategy-card h4, .defense-card h4, .claim-treatment h4, .question-card h4 { margin: 0 0 8px; color: var(--navy); }
.strategy-card p, .defense-card p, .claim-treatment p, .question-card p { margin: 6px 0; }
.label { margin-right: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 800; }
.strength { display: inline-block; padding: 3px 7px; border-radius: 4px; background: var(--amber-pale); color: #69440f; font-size: 11px; font-weight: 800; }
.judge-disclaimer { padding: 12px 14px; margin-bottom: 16px; background: var(--amber-pale); border-left: 3px solid var(--amber); color: #69440f; font-weight: 750; }
.analysis-aside section { margin-bottom: 14px; padding: 16px; background: white; border: 1px solid var(--line); border-radius: var(--radius-md); }
.analysis-aside h2 { margin: 0 0 10px; font-size: 15px; color: var(--navy); }
.gap-item, .conflict-item, .check-item { padding: 10px 0; border-top: 1px solid var(--line); font-size: 12px; }
.gap-item:first-child, .conflict-item:first-child, .check-item:first-child { border-top: 0; padding-top: 0; }
.gap-item strong, .conflict-item strong { display: block; margin-bottom: 3px; }
.gap-item p, .conflict-item p, .check-item p { margin: 0; color: var(--ink-soft); }
.check-item { display: flex; gap: 8px; }
.check-mark { color: var(--teal); font-weight: 900; }
.post-workspace { margin-top: 28px; padding: 28px; display: flex; align-items: center; justify-content: space-between; gap: 28px; background: white; border: 1px solid var(--line); border-radius: var(--radius-md); }
.post-workspace h2 { margin: 0; color: var(--navy); }
.post-workspace p:not(.eyebrow) { max-width: 760px; margin: 8px 0 0; color: var(--ink-soft); }
.post-actions { min-width: 360px; display: flex; gap: 10px; }
.post-actions button { flex: 1; }
.primary-button.compact { width: auto; white-space: nowrap; }
.post-message { flex-basis: 100%; padding: 12px; background: var(--amber-pale); color: #69440f; border-radius: var(--radius-sm); }

.drawer-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(10,21,37,0.5); }
.reference-drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(440px, 94vw); z-index: 80; background: white; box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform 220ms ease; }
.reference-drawer.is-open { transform: translateX(0); }
.reference-drawer header { min-height: 88px; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.reference-drawer h2 { margin: 0; color: var(--navy); }
.reference-content { height: calc(100dvh - 88px); padding: 22px; overflow-y: auto; }
.reference-content dl { margin: 0; }
.reference-content div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.reference-content dt { color: var(--ink-soft); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; }
.reference-content dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.source-excerpt { margin-top: 18px; padding: 16px; background: var(--canvas-warm); border-left: 3px solid var(--teal); white-space: pre-wrap; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); padding: 12px 16px; background: var(--navy); color: white; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }

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

@media (max-width: 1180px) {
  .intake-shell { grid-template-columns: 1fr; max-width: 900px; }
  .hero-copy { position: static; }
  .result-preview { display: grid; grid-template-columns: 1fr 1fr; }
  .result-preview li:nth-child(odd) { padding-right: 18px; }
  .results-layout { grid-template-columns: minmax(0, 1fr) 280px; }
  .section-nav { display: none; }
  .executive-strip { grid-template-columns: 1fr 1fr; }
  .executive-strip > div:nth-child(2) { border-right: 0; }
  .executive-strip > div:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,0.16); }
}

@media (max-width: 820px) {
  .topbar { min-height: 64px; padding: 0 16px; }
  .topbar-meta #current-user { display: none; }
  main { min-height: calc(100dvh - 64px); }
  .intake-shell { padding: 32px 16px 72px; gap: 32px; }
  .hero-copy h1 { font-size: 40px; }
  .hero-lede { margin: 20px 0 28px; font-size: 16px; }
  .result-preview { display: block; }
  .intake-card { padding: 22px 18px; border-radius: var(--radius-md); }
  .field-row { display: block; }
  .field-type { width: auto; }
  .advanced-grid { grid-template-columns: 1fr; }
  .privacy-note { display: block; }
  .privacy-note strong { display: block; margin-bottom: 3px; }
  .results-shell { padding: 24px 12px 72px; }
  .results-header { display: block; }
  .result-meta { justify-content: flex-start; margin-top: 16px; }
  .executive-strip { grid-template-columns: 1fr; }
  .executive-strip > div { min-height: 0; border-right: 0; border-bottom: 1px solid rgba(255,255,255,0.16); }
  .result-tabs { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .result-tab { min-width: 190px; scroll-snap-align: start; }
  .results-layout { display: block; }
  .analysis-aside { position: static; display: grid; grid-template-columns: 1fr; margin-top: 16px; }
  .document-head { padding: 28px 18px 22px; }
  .document-section { padding: 24px 18px; }
  .post-workspace { display: block; padding: 22px 18px; }
  .post-actions { min-width: 0; margin-top: 20px; flex-direction: column; }
  .primary-button.compact { width: 100%; }
}

@media (max-width: 430px) {
  .brand small, .mode-badge { display: none; }
  .hero-copy h1 { font-size: 35px; }
  .card-heading { display: block; }
  .required-note { display: block; margin-top: 8px; }
  .drop-zone { align-items: flex-start; justify-content: flex-start; }
  .point-top { display: block; }
  .point-status { display: inline-block; margin-top: 7px; }
}
