:root {
  color-scheme: light;
  --canvas: #f2f0ea;
  --surface: #faf9f5;
  --well: #e9e7e0;
  --ink: #14150f;
  --ink-soft: #3d3f36;
  --muted: #63665b;
  --line: #dad7cd;
  --line-dark: #9c998d;
  --signal: #bf2e1b;
  --signal-dark: #922012;
  --success: #405b4c;
  --danger: #8f1f15;
  --ease-in: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-out: cubic-bezier(0.3, 0, 0.8, 0.15);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, Georgia, serif;
  background: var(--canvas);
  color: var(--ink-soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.72;
}

button,
input,
select,
textarea { font: inherit; }

button,
select { cursor: pointer; }

button:disabled { cursor: not-allowed; opacity: .5; }

a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 10;
  left: 16px;
  top: -64px;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--surface);
  text-decoration: none;
  transition: top 120ms var(--ease-in);
}

.skip-link:focus { top: 16px; }

.app-shell { min-height: 100dvh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: max(12px, env(safe-area-inset-top)) 20px 12px;
  background: color-mix(in srgb, var(--canvas) 94%, transparent);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
  transition: transform 120ms var(--ease-in), opacity 120ms var(--ease-in);
}

.brand-mark { display: block; flex: 0 0 auto; width: 32px; height: 32px; }

.brand strong { display: block; letter-spacing: -.04em; font-size: 20px; line-height: 1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font: 12px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }

.top-action,
.text-action,
.quiet-button,
.utility-button,
.nav-item,
.mode-button,
.tab-button {
  appearance: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  min-height: 44px;
  padding: 0 12px;
  transition: transform 120ms var(--ease-in), background-color 120ms var(--ease-in), color 120ms var(--ease-in), opacity 120ms var(--ease-in);
}

.top-action { color: var(--signal); font-size: 13px; font-weight: 750; }

.top-action:hover,
.text-action:hover,
.quiet-button:hover,
.utility-button:hover,
.mode-button:hover,
.tab-button:hover { background: var(--well); }

.top-action:active,
.text-action:active,
.quiet-button:active,
.utility-button:active,
.nav-item:active,
.mode-button:active,
.tab-button:active,
.primary-action:active { transform: translateY(2px); }

:focus-visible { outline: 3px solid var(--signal); outline-offset: 3px; }

.page {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 20px calc(96px + env(safe-area-inset-bottom));
}

.boot { width: min(100% - 40px, 720px); margin: 0 auto; padding: 72px 0; }

.eyebrow,
.section-label,
.micro-label,
.index-label {
  margin: 0;
  color: var(--signal);
  font: 750 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.page h1,
.page h2,
.page h3 { margin: 0; color: var(--ink); font-weight: 700; }

.page h1 { max-width: 13ch; margin-top: 10px; font-size: 36px; letter-spacing: -.055em; line-height: 1.05; }
.page h2 { font-size: 20px; letter-spacing: -.03em; line-height: 1.22; }
.page h3 { font-size: 17px; letter-spacing: -.02em; line-height: 1.3; }

.lede { max-width: 34ch; margin: 20px 0 0; color: var(--ink-soft); font-size: 17px; line-height: 1.7; }
.muted { color: var(--muted); }
.copy { max-width: 40ch; margin: 0; }
.copy-spaced { margin-top: 16px; }
.copy-spaced-tight { margin-top: 10px; }

.hero-actions { display: grid; gap: 8px; margin-top: 32px; }

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  width: 100%;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  background: var(--signal);
  color: #fffaf5;
  font-weight: 760;
  text-align: left;
  transition: transform 120ms var(--ease-in), background-color 120ms var(--ease-in), opacity 120ms var(--ease-in);
}

.primary-action:hover { background: var(--signal-dark); }
.primary-action .arrow { font: 22px/1 sans-serif; }

.quiet-button { justify-self: start; color: var(--ink-soft); font-size: 14px; font-weight: 700; }

.home-section,
.report-section,
.archive-section,
.about-section,
.form-section { margin-top: 48px; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { max-width: 15ch; }

.method-note,
.empty-state,
.report-intro { padding: 20px; background: var(--well); }
.method-note p,
.empty-state p,
.report-intro p { margin: 8px 0 0; }

.method-note strong { color: var(--ink); }

.archive-list { display: grid; gap: 2px; }
.archive-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 16px 0;
  color: var(--ink);
  text-align: left;
}

.archive-row + .archive-row { border-top: 1px solid var(--line); }
.archive-row strong { display: block; font-size: 17px; }
.archive-row small { display: block; color: var(--muted); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.archive-row .row-arrow { align-self: center; color: var(--signal); font: 24px/1 sans-serif; }

.archive-summary { margin: 0 0 24px; color: var(--ink-soft); font-size: 15px; }
.archive-summary strong { color: var(--signal); font: 750 24px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.archive-search { margin: 0 0 18px; }
.archive-no-result { padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.archive-no-result strong { color: var(--ink); }
.archive-no-result p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.backup-section { margin-top: 44px; padding-top: 28px; border-top: 1px solid var(--line-dark); }
.backup-section h2 { margin-top: 8px; }
.backup-section > p:not(.section-label) { max-width: 40ch; margin: 12px 0 0; color: var(--ink-soft); }
.backup-actions { display: grid; margin-top: 20px; border-top: 1px solid var(--line); }
.backup-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--signal);
  padding: 0 2px;
  font-weight: 760;
  text-align: left;
  transition: transform 120ms var(--ease-in), background-color 120ms var(--ease-in), color 120ms var(--ease-in), opacity 120ms var(--ease-in);
}
.backup-action > span:last-child { font: 24px/1 sans-serif; }
.backup-action:hover { background: var(--well); }
.backup-action:active { transform: translateY(2px); }

.online-consult { margin-top: 24px; }
.online-consult > h3 { margin-top: 8px; }
.online-scope-fieldset { margin-top: 20px; }
.online-scope-fieldset legend { color: var(--ink); font-size: 13px; font-weight: 750; }
.online-scope-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; margin-top: 8px; background: var(--well); }
.online-scope-choice {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 0;
  color: var(--ink);
  padding: 0 10px;
  text-align: center;
  transition: transform 120ms var(--ease-in), background-color 120ms var(--ease-in), color 120ms var(--ease-in);
}
.online-scope-choice input { position: absolute; opacity: 0; pointer-events: none; }
.online-scope-choice strong { font-size: 15px; }
.online-scope-choice:has(input:checked) { background: var(--ink); color: var(--surface); }
.online-scope-choice:has(input:focus-visible) { outline: 3px solid var(--signal); outline-offset: -3px; }
.online-scope-fieldset:disabled { opacity: .72; }
.online-transcript { margin-top: 24px; padding: 20px; background: var(--well); }
.online-transcript h3 { display: block; margin-top: 8px; color: var(--ink); }
.online-message-list { display: grid; gap: 12px; margin-top: 18px; }
.online-message { border-left: 2px solid var(--line-dark); padding: 12px 0 12px 14px; }
.online-message.is-user { border-left-color: var(--signal); }
.online-message .micro-label { margin: 0; }
.online-message > p:not(.micro-label) { max-width: 42ch; margin: 7px 0 0; color: var(--ink-soft); }
.online-question { margin-top: 20px; }
.online-question textarea { min-height: 132px; }
.online-actions { margin-top: 20px; }
.online-status { margin: 20px 0 0; border-left: 2px solid var(--signal); color: var(--signal-dark); padding-left: 12px; font-size: 13px; font-weight: 700; }
.online-footnote { margin: 16px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.form-head { margin-bottom: 28px; }
.form-head h1 { max-width: 14ch; }

.mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 24px 0 32px; background: var(--well); }
.mode-button { min-height: 48px; padding: 0 8px; font-size: 13px; font-weight: 750; }
.mode-button[aria-selected="true"] { background: var(--ink); color: var(--surface); }

.form-grid { display: grid; gap: 20px; }
.field { display: grid; gap: 6px; }
.field > span,
.field legend { color: var(--ink); font-size: 13px; font-weight: 750; }
.field small { color: var(--muted); font-size: 12px; line-height: 1.55; }
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-bottom: 2px solid var(--line-dark);
  border-radius: 0;
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 11px 0;
  transition: border-color 120ms var(--ease-in), background-color 120ms var(--ease-in);
}

.field textarea { min-height: 120px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-bottom-color: var(--signal); background: #fffdf8; }
.fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }

.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.four-columns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; background: var(--well); }
.segmented label { position: relative; display: grid; place-items: center; min-height: 48px; color: var(--muted); font-size: 14px; font-weight: 700; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--ink); color: var(--surface); }

.inline-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; color: var(--ink-soft); font-size: 13px; }
.inline-check input { accent-color: var(--signal); width: 18px; height: 18px; margin: 2px 0 0; }

.form-actions { display: grid; gap: 12px; margin-top: 32px; }
.field-panel[hidden], .custom-location[hidden] { display: none; }

.report-header { margin-bottom: 28px; }
.report-header h1 { max-width: 12ch; font-size: clamp(30px, 7vw, 40px); }
.report-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.report-meta span { white-space: nowrap; }

.report-tabs { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.report-tabs::-webkit-scrollbar { display: none; }
.tab-button { flex: 0 0 auto; min-height: 42px; padding: 0 12px; color: var(--muted); font-size: 13px; font-weight: 750; }
.tab-button[aria-selected="true"] { background: var(--ink); color: var(--surface); }

.pillar-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 18px; background: var(--well); }
.pillar { min-width: 0; padding: 14px 8px 16px; text-align: center; }
.pillar + .pillar { border-left: 1px solid var(--line); }
.pillar .pillar-label { display: block; color: var(--muted); font-size: 12px; }
.pillar strong { display: block; margin-top: 8px; color: var(--ink); font-size: 28px; line-height: 1; letter-spacing: .02em; }
.pillar small { display: block; min-height: 34px; margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.4; }

.element-list { display: grid; gap: 13px; margin-top: 20px; }
.element-row { display: grid; grid-template-columns: 22px 1fr 42px; align-items: center; gap: 10px; }
.element-row span { color: var(--ink); font-weight: 750; }
.element-bar { display: block; width: 100%; height: 7px; border: 0; border-radius: 0; appearance: none; -webkit-appearance: none; background: var(--well); color: var(--ink); overflow: hidden; }
.element-bar::-webkit-progress-bar { background: var(--well); }
.element-bar::-webkit-progress-value { background: var(--ink); }
.element-bar::-moz-progress-bar { background: var(--ink); }
.element-row:nth-child(2) .element-bar { color: var(--signal); }
.element-row:nth-child(2) .element-bar::-webkit-progress-value { background: var(--signal); }
.element-row:nth-child(2) .element-bar::-moz-progress-bar { background: var(--signal); }
.element-row small { color: var(--muted); font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tag { display: inline-flex; align-items: center; min-height: 30px; padding: 0 9px; background: var(--well); color: var(--ink-soft); font-size: 12px; font-weight: 700; }

.data-table-wrap { overflow-x: auto; margin-top: 16px; background: var(--surface); }
.data-table { width: 100%; min-width: 600px; border-collapse: collapse; }
.data-table th,
.data-table td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
.data-table thead th { color: var(--muted); font-weight: 700; }
.data-table tbody th { width: 72px; color: var(--ink); font-weight: 750; }
.data-table td { color: var(--ink-soft); }

.flow-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.flow-controls select { min-height: 48px; border: 0; border-bottom: 2px solid var(--line-dark); border-radius: 0; background: var(--surface); color: var(--ink); padding: 0 4px; }
.flow-spotlight { margin-top: 20px; padding: 22px 20px; background: var(--well); }
.flow-spotlight p { margin: 8px 0 0; }
.timeline { position: relative; display: grid; gap: 0; margin-top: 24px; }
.timeline::before { position: absolute; top: 8px; bottom: 8px; left: 8px; width: 2px; background: var(--line-dark); content: ""; }
.timeline-row { position: relative; display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; min-height: 58px; border: 0; border-radius: 0; background: transparent; color: var(--ink); padding: 0; text-align: left; }
.timeline-dot { z-index: 1; width: 18px; height: 18px; border: 3px solid var(--canvas); background: var(--well); }
.timeline-row[aria-current="true"] .timeline-dot { background: var(--signal); }
.timeline-row span { color: var(--muted); font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.timeline-row strong { font-size: 15px; }
.timeline-row small { color: var(--muted); font-size: 12px; }

.report-copy { display: grid; gap: 28px; margin-top: 22px; }
.report-copy article { max-width: 40ch; }
.report-copy article p { margin: 10px 0 0; }

.utility-row { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 18px; }
.utility-button { min-height: 44px; padding-inline: 12px; color: var(--ink-soft); font-size: 13px; font-weight: 750; }
.utility-button.is-danger { color: var(--danger); }

.bottom-nav {
  position: fixed;
  z-index: 4;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
}

.nav-item { display: grid; place-items: center; min-height: 56px; padding: 8px; color: var(--muted); font-size: 11px; font-weight: 750; }
.nav-item[aria-current="page"] { background: var(--ink); color: var(--surface); }

.toast {
  position: fixed;
  z-index: 8;
  right: 20px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  left: 20px;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px;
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  box-shadow: 0 8px 18px rgba(20, 21, 15, .18);
}

@media (min-width: 760px) {
  .page { padding-top: 48px; }
  .hero-actions { max-width: 380px; grid-template-columns: 1fr auto; align-items: center; }
  .hero-actions .primary-action { width: 250px; }
  .home-section, .report-section, .archive-section, .about-section, .form-section { margin-top: 64px; }
  .bottom-nav { right: 20px; bottom: 20px; left: auto; width: 440px; padding: 4px; background: var(--surface); box-shadow: 0 8px 18px rgba(20, 21, 15, .08); }
  .nav-item { min-height: 48px; }
}

@media (max-width: 420px) {
  .page { padding-right: 16px; padding-left: 16px; }
  .topbar { padding-right: 16px; padding-left: 16px; }
  .four-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; background: var(--well); }
  .four-columns .field { padding: 8px; background: var(--surface); }
  .pillar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; }
  .pillar + .pillar { border-left: 0; }
  .pillar { background: var(--surface); }
  .data-table { min-width: 0; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td { display: block; width: 100%; }
  .data-table tr { padding: 14px 0; border-bottom: 1px solid var(--line); }
  .data-table th,
  .data-table td { border: 0; padding: 3px 0; }
  .data-table td::before { display: block; color: var(--muted); content: attr(data-label); font-size: 11px; font-weight: 700; }
}

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