:root {
  --ink: #1f2926;
  --muted: #68736f;
  --quiet: #8c9692;
  --paper: #f4f1e9;
  --surface: #fbfaf6;
  --line: #d9d5ca;
  --line-strong: #b9b7ad;
  --brand: #0b6e63;
  --brand-dark: #07574f;
  --brand-pale: #dcebe6;
  --danger: #a64032;
  --danger-pale: #f5e5df;
  --warning: #94651f;
  --warning-pale: #f4ead6;
  --sans: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", SimSun, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 41, 38, .035) 1px, transparent 1px) 0 0 / 80px 80px,
    var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 64px;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(244, 241, 233, .92);
  backdrop-filter: blur(12px);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.wordmark-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -.04em;
}

.topbar-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-email { color: var(--muted); font-size: 12px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.environment-chip { border: 1px solid var(--line); border-radius: 99px; padding: 5px 9px; color: var(--muted); font-size: 11px; background: var(--surface); }
.environment-chip.ready { color: var(--brand-dark); border-color: #b8d4cc; background: var(--brand-pale); }

.gate {
  width: min(680px, calc(100% - 40px));
  margin: min(18vh, 160px) auto 0;
  padding: 48px 0;
  border-top: 2px solid var(--ink);
}

.gate-index, .eyebrow {
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  font-weight: 700;
}

.gate h1 { margin: 18px 0 12px; font-family: var(--serif); font-size: clamp(30px, 4.5vw, 48px); font-weight: 600; line-height: 1.2; letter-spacing: -.035em; }
.gate > p { max-width: 560px; margin: 0 0 28px; color: var(--muted); font-size: 15px; line-height: 1.75; }

.login-form { max-width: 420px; display: grid; gap: 14px; margin: 26px 0 18px; }
.login-form label, .paste-editor label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 110, 99, .1); }
textarea { resize: vertical; line-height: 1.65; }

.workspace { min-height: calc(100vh - 64px); display: grid; grid-template-columns: minmax(300px, 37%) minmax(0, 1fr); }
.process-rail { padding: clamp(44px, 6vw, 88px) clamp(28px, 5vw, 76px); border-right: 1px solid var(--line); background: rgba(251, 250, 246, .55); }
.rail-intro { max-width: 460px; }
.rail-intro h1 { margin: 14px 0 18px; font-family: var(--serif); font-size: clamp(29px, 3.2vw, 44px); font-weight: 600; line-height: 1.24; letter-spacing: -.035em; }
.rail-intro > p:last-child { max-width: 390px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.75; }

.steps { list-style: none; margin: 58px 0 0; padding: 0; max-width: 390px; border-top: 1px solid var(--line); }
.steps li { min-height: 72px; display: grid; grid-template-columns: 38px 1fr; align-items: center; border-bottom: 1px solid var(--line); color: var(--quiet); transition: color 180ms ease, padding 180ms ease; }
.steps li > span { font-size: 11px; font-variant-numeric: tabular-nums; }
.steps li div { display: grid; gap: 3px; }
.steps strong { font-size: 14px; font-weight: 650; }
.steps small { font-size: 12px; line-height: 1.45; }
.steps li.active { color: var(--ink); padding-left: 8px; }
.steps li.active > span { color: var(--brand); }
.steps li.complete { color: var(--muted); }
.steps li.complete > span { color: var(--brand); }
.privacy-note { max-width: 390px; margin: 26px 0 0; color: var(--quiet); font-size: 11px; line-height: 1.6; }

.work-area { min-width: 0; padding: clamp(44px, 7vw, 96px) clamp(28px, 7vw, 104px); background: var(--surface); }
.view { width: min(740px, 100%); margin: 0 auto; animation: view-enter 220ms ease both; }
.view-heading { margin-bottom: 34px; }
.view-heading h2 { margin: 12px 0 10px; font-family: var(--serif); font-size: clamp(28px, 3vw, 40px); font-weight: 600; line-height: 1.26; letter-spacing: -.035em; }
.view-heading > p:last-child, .split-heading > div > p:last-child { margin: 0; color: var(--muted); line-height: 1.75; font-size: 15px; }
.split-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; }
.limit-note { flex: 0 0 auto; padding-bottom: 4px; color: var(--quiet); font-size: 11px; }

.ownership-form { display: grid; border-top: 1px solid var(--line-strong); }
.choice-row { min-height: 126px; padding: 24px 2px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 26px 1fr; gap: 16px; cursor: pointer; }
.choice-row > input { position: absolute; opacity: 0; pointer-events: none; }
.choice-control { width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; }
.choice-row > input:checked + .choice-control { border: 5px solid var(--brand); }
.choice-copy { display: grid; gap: 7px; }
.choice-copy strong { font-size: 16px; line-height: 1.4; }
.choice-copy small { color: var(--muted); font-size: 13px; line-height: 1.65; }
.choice-copy select { max-width: 360px; margin-top: 7px; }
.choice-row:has(input:not(:checked)) select { opacity: .5; pointer-events: none; }

.primary-action, .secondary-action {
  min-height: 44px;
  border-radius: 8px;
  padding: 11px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.primary-action { color: white; background: var(--brand); }
.primary-action:hover:not(:disabled) { background: var(--brand-dark); transform: translateY(-1px); }
.primary-action:disabled { opacity: .45; cursor: not-allowed; }
.secondary-action { color: var(--ink); border-color: var(--line-strong); background: transparent; }
.secondary-action:hover { border-color: var(--ink); }
.align-right { justify-self: end; margin-top: 28px; }
.text-button, .quiet-link { color: var(--brand); border: 0; padding: 5px 4px; background: transparent; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; font-weight: 600; line-height: 1.4; }
.text-button:hover, .quiet-link:hover { color: var(--ink); }
#homePortraitLink, #homeImportButton, #homeWritingLink { color: var(--brand); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.home-view > section {
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.home-view > section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.home-view > section > p:not(.eyebrow) { max-width: 760px; margin: 12px 0; font-size: 15px; line-height: 1.75; }
.home-view > section > p > strong { font-size: 17px; font-weight: 650; }
.home-view .eyebrow { margin-bottom: 12px; }

.drop-zone { min-height: 200px; border: 1px dashed var(--line-strong); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; text-align: center; cursor: pointer; background: #f7f5ef; transition: border-color 160ms ease, background 160ms ease, transform 160ms ease; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone strong { font-size: 15px; }
.drop-zone small { color: var(--quiet); font-size: 11px; }
.drop-symbol { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; color: var(--brand); font-size: 23px; }
.drop-zone.dragging { border-color: var(--brand); background: var(--brand-pale); transform: scale(1.008); }
.drop-zone:focus-visible { outline: 3px solid rgba(11, 110, 99, .16); outline-offset: 3px; }

.source-ledger { margin-top: 26px; border-top: 1px solid var(--line-strong); }
.ledger-header { height: 46px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.ledger-header strong { color: var(--ink); font-size: 12px; }
.source-ledger ul, .failure-details ul { list-style: none; margin: 0; padding: 0; }
.source-item { min-height: 58px; padding: 11px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; border-bottom: 1px solid var(--line); }
.source-name { min-width: 0; display: grid; gap: 4px; }
.source-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.source-name small { color: var(--quiet); font-size: 10px; }
.source-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.remove-source { border: 0; background: transparent; color: var(--quiet); cursor: pointer; font-size: 16px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.status-dot.working { background: var(--brand); box-shadow: 0 0 0 4px rgba(11, 110, 99, .10); }
.status-dot.success { background: var(--brand); }
.status-dot.danger { background: var(--danger); }

.paste-panel { margin-top: 20px; border-bottom: 1px solid var(--line); }
.paste-panel summary { padding: 14px 0; color: var(--muted); font-size: 12px; cursor: pointer; }
.paste-editor { padding: 8px 0 22px; display: grid; gap: 15px; }
.paste-editor .secondary-action { justify-self: start; }
.view-actions { margin-top: 30px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.form-error { margin: 0; padding: 10px 12px; border-left: 3px solid var(--danger); color: var(--danger); background: var(--danger-pale); font-size: 12px; line-height: 1.6; }
.notice { width: min(740px, 100%); margin: 0 auto 22px; padding: 12px 14px; border-left: 3px solid var(--brand); background: var(--brand-pale); color: var(--brand-dark); font-size: 12px; line-height: 1.55; }
.notice.danger { color: var(--danger); border-color: var(--danger); background: var(--danger-pale); }

.progress-block { margin: 44px 0 36px; }
.progress-number { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.progress-number strong { font-size: 38px; font-weight: 500; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.progress-number span { color: var(--muted); font-size: 11px; }
.progress-track { height: 3px; background: var(--line); overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--brand); transition: width 260ms ease; }
.stage-line { list-style: none; margin: 15px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); color: var(--quiet); font-size: 10px; }
.stage-line li { position: relative; }
.stage-line li.active { color: var(--ink); font-weight: 650; }
.stage-line li.complete { color: var(--brand); }
.processing-ledger { margin-top: 0; }
.progress-retry { justify-content: flex-end; }

.result-mark { width: 58px; height: 58px; margin-bottom: 28px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--brand); font-size: 26px; }
.result-mark.danger { background: var(--danger); }
.result-heading { max-width: 650px; }
.result-facts { margin: 36px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.result-facts div { min-height: 100px; padding: 22px 18px 18px 0; border-right: 1px solid var(--line); }
.result-facts div:not(:first-child) { padding-left: 18px; }
.result-facts div:last-child { border-right: 0; }
.result-facts dt { color: var(--quiet); font-size: 10px; }
.result-facts dd { margin: 10px 0 0; font-size: 22px; font-weight: 500; }
.failure-details { margin-top: 22px; border-bottom: 1px solid var(--line); }
.failure-details summary { padding: 13px 0; color: var(--danger); font-size: 12px; cursor: pointer; }
.failure-details li { padding: 12px 0; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.55; }
.failure-details strong { display: block; margin-bottom: 3px; }
.failure-details span { color: var(--muted); }
.boundary-note { margin-top: 30px; padding: 18px 20px; background: #f0eee7; border-left: 3px solid var(--line-strong); }
.boundary-note strong { font-size: 12px; }
.boundary-note p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.boundary-note.closed { background: var(--brand-pale); border-left-color: var(--brand); }
.boundary-note.closed strong { color: var(--brand-dark); }
.closed-action { color: var(--muted) !important; border-color: var(--line) !important; background: #f0eee7 !important; cursor: default !important; pointer-events: none; }
.result-actions { justify-content: flex-end; }

@keyframes view-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 880px) {
  .topbar { padding: 0 18px; }
  .user-email { display: none; }
  .workspace { display: block; }
  .process-rail { padding: 30px 22px 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-intro h1 { font-size: 30px; }
  .rail-intro > p:last-child, .privacy-note { display: none; }
  .steps { margin-top: 28px; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 0; gap: 5px; }
  .steps li { min-height: auto; padding: 10px 4px 0; display: block; border-top: 2px solid var(--line); border-bottom: 0; }
  .steps li.active { padding-left: 4px; border-color: var(--brand); }
  .steps li div { margin-top: 5px; }
  .steps small { display: none; }
  .work-area { padding: 38px 22px 64px; }
  .split-heading { display: block; }
  .limit-note { display: block; margin-top: 10px; }
}

@media (max-width: 560px) {
  .environment-chip { display: none; }
  .process-rail { padding-top: 24px; }
  .rail-intro .eyebrow { display: none; }
  .rail-intro h1 { margin-top: 0; font-size: 25px; }
  .work-area { padding-left: 18px; padding-right: 18px; }
  .view-heading h2 { font-size: 30px; }
  .choice-row { min-height: 116px; }
  .drop-zone { min-height: 170px; padding: 20px; }
  .view-actions { align-items: stretch; flex-direction: column-reverse; }
  .view-actions > * { width: 100%; }
  .result-facts { grid-template-columns: 1fr; }
  .result-facts div, .result-facts div:not(:first-child) { min-height: 76px; padding: 16px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .result-facts div:last-child { border-bottom: 0; }
}

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