:root {
  --ground: #F4F3EF;
  --surface: #FFFFFF;
  --ink: #15171C;
  --ink-2: #3A3F4C;
  --muted: #5B6070;
  --line: #DEDCD5;
  --line-2: #EEECE6;
  --control: #C9C6BD;
  --fill-muted: #E9E7E1;
  --focus: #3B6FE0;

  --ded: #1D3F9E;
  --ded-bg: #E3EBFC;
  --ded-bar: #3B6FE0;
  --ind: #8A4A05;
  --ind-bg: #FBEBD7;
  --ind-bar: #E08A2A;
  --abd: #4A1D8C;
  --abd-bg: #ECE3F8;
  --abd-bar: #4A1D8C;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }

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

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

.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;
}

/* ---------- Screen shell ---------- */
.screen {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen-body { padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 16px; flex: 1; }

.top {
  padding: 16px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top-row { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }

.meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.icon-btn {
  width: 44px; height: 44px; margin-left: -12px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer;
}

.link-btn {
  border: 0; background: transparent; cursor: pointer;
  min-height: 44px; padding: 0 4px; font-size: 14px; font-weight: 600;
}

.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 44px; padding: 0 14px; margin-right: -6px;
  border-radius: 999px; border: 1px solid var(--control); background: var(--surface);
  font-size: 13px; font-weight: 600; cursor: pointer;
}

.steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.steps span { height: 4px; border-radius: 2px; background: var(--line); }
.steps span.on { background: var(--ink); }

h1.title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
h1.title.lg { font-size: 30px; }

.lede { margin: 0; color: var(--muted); font-size: 15px; }

.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}

/* ---------- Footer ---------- */
.footer {
  position: sticky;
  bottom: 0;
  background: var(--ground);
  border-top: 1px solid var(--line);
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.footer.stack { flex-direction: column; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 18px;
  border-radius: var(--r-md); border: 1px solid transparent;
  font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--ink); color: #FFFFFF; flex: 1; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--control); }
.btn-ghost { background: transparent; border: 0; min-height: 44px; font-size: 14px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { min-height: 44px; font-size: 14px; border-radius: var(--r-sm); }

/* ---------- Role ---------- */
.choices { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; }
.choices legend { padding: 0 0 10px; font-size: 13px; font-weight: 600; }

.choice {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer;
}
.choice:has(input:checked) { border: 2px solid var(--ink); padding: 7px 15px; }
.choice.alt { background: transparent; border-style: dashed; border-color: var(--control); }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex: none; }
.choice-text { display: flex; flex-direction: column; }
.choice-label { font-size: 16px; font-weight: 600; }
.choice-sub { font-size: 13px; color: var(--muted); }

/* ---------- Tasks ---------- */
.add-row { display: flex; gap: 8px; }
.text-input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px;
  border: 1px solid var(--control); border-radius: 12px; background: var(--surface);
  font-size: 16px;
}
.text-input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(59, 111, 224, 0.25); }
.square-btn {
  width: 48px; height: 48px; flex: none; border: 0; border-radius: 12px;
  background: var(--ink); color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.dashed-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 44px; border-radius: 12px; border: 1px dashed var(--control); background: transparent;
  font-size: 14px; font-weight: 600; cursor: pointer;
}

.list {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.list-row {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 4px 0 14px;
  border-bottom: 1px solid var(--line-2); font-size: 14px;
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 10px 0; }
.remove-btn {
  width: 44px; height: 44px; flex: none; border: 0; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: var(--r-sm);
}
.empty { padding: 18px 14px; font-size: 14px; color: var(--muted); text-align: center; }

/* ---------- Paste ---------- */
.paste-area {
  width: 100%; min-height: 180px; padding: 12px 14px; resize: vertical;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--surface);
  font-family: var(--font-mono); font-size: 14px; line-height: 1.5;
}
.notes { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-2); }

/* ---------- Tags ---------- */
.tag {
  display: inline-flex; align-items: center; align-self: flex-start;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px;
}
.tag.DEDUCTIVE { background: var(--ded-bg); color: var(--ded); }
.tag.INDUCTIVE { background: var(--ind-bg); color: var(--ind); }
.tag.ABDUCTIVE { background: var(--abd-bg); color: var(--abd); }
.tag.close { background: transparent; color: var(--ink); border: 1px solid var(--ink); padding: 3px 7px; }

.c-DEDUCTIVE { color: var(--ded); }
.c-INDUCTIVE { color: var(--ind); }
.c-ABDUCTIVE { color: var(--abd); }

/* ---------- Mix ---------- */
.bar { display: flex; height: 28px; border-radius: 8px; overflow: hidden; gap: 2px; background: var(--fill-muted); }
.bar span { display: block; height: 100%; }
.bar .DEDUCTIVE { background: var(--ded-bar); }
.bar .INDUCTIVE { background: var(--ind-bar); }
.bar .ABDUCTIVE { background: var(--abd-bar); }

.counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.count-num { display: block; font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.1; }
.count-label { display: block; font-size: 12px; font-weight: 600; }
.count-sub { display: block; font-size: 11px; color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.card.dashed { background: transparent; border-style: dashed; border-color: var(--control); }
.card.tint { background: var(--ded-bg); border-color: transparent; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-note { font-size: 13px; color: var(--muted); }
.card-items { display: flex; flex-direction: column; gap: 6px; font-size: 14px; margin: 0; padding: 0; list-style: none; }
.close-call {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--ground); border-radius: var(--r-sm); font-size: 13px;
}
.close-call .tag { flex: none; }

.alert {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm); background: #FCE8E6; color: #7A1F16; font-size: 13px;
}

/* ---------- Progress ---------- */
.progress { display: flex; flex-direction: column; gap: 10px; padding-top: 40px; }
.progress-track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; background: var(--ink); transition: width 0.3s ease; }

/* ---------- Automate ---------- */
.markers-row { display: flex; align-items: center; gap: 10px; }
.markers { flex: 1; display: grid; gap: 6px; }
.marker {
  height: 32px; border-radius: 8px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; background: var(--fill-muted); color: var(--muted);
}
.marker.yes { background: var(--ink); color: #FFFFFF; font-weight: 700; }
.marker.no { background: var(--surface); border: 1px solid var(--ink); color: var(--ink); font-weight: 700; }
.marker.current { background: var(--surface); border: 2px solid var(--focus); color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; }
.field legend { padding: 0 0 8px; font-size: 14px; font-weight: 600; }
.seg { display: grid; gap: 6px; }
.seg-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seg-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seg button {
  min-height: 44px; border-radius: var(--r-sm); border: 1px solid var(--control);
  background: var(--surface); font-size: 14px; cursor: pointer; padding: 0 2px;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; border: 2px solid var(--ink); font-weight: 600; }

.budget {
  background: var(--ink); color: #FFFFFF; border-radius: 16px; padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.budget-label { font-size: 12px; color: #C9C6BD; }
.budget-value { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.budget-formula { font-family: var(--font-mono); font-size: 12px; color: #C9C6BD; }

.verdict {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px; border-radius: 12px; border: 1px solid;
  font-size: 17px; font-weight: 700; line-height: 1.3;
}
.verdict svg { flex: none; width: 22px; height: 22px; }
.verdict.good { background: #E3F4E8; border-color: #9FD3AE; color: #14632F; }
.verdict.bad { background: #FCE8E6; border-color: #F1B3AC; color: #8A1C12; }
.hint { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Queue ---------- */
.q-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 8px 14px;
  border: 0; border-bottom: 1px solid var(--line-2); background: var(--surface); text-align: left; cursor: pointer;
}
.q-row:last-child { border-bottom: 0; }
.q-row.current { background: #EEF3FD; }
.q-mark {
  flex: none; width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; background: var(--fill-muted); color: var(--muted);
}
.q-mark.yes { background: var(--ink); color: #FFFFFF; font-weight: 700; }
.q-mark.no { background: var(--surface); border: 1px solid var(--ink); color: var(--ink); font-weight: 700; }
.q-mark.current { background: var(--surface); border: 2px solid var(--focus); color: var(--ink); }
.q-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.q-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.q-sub { font-size: 12px; color: var(--muted); }

/* ---------- Plan ---------- */
.p-section { display: flex; flex-direction: column; gap: 8px; }
.p-heading { font-size: 15px; font-weight: 700; }
.p-row {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px;
  border-bottom: 1px solid var(--line-2);
}
.p-row:last-child { border-bottom: 0; }
.p-value { flex: none; font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: #14632F; }
.list.dashed { background: transparent; border-style: dashed; border-color: var(--control); }
.list.dashed .p-row { border-bottom-style: dashed; border-bottom-color: var(--line); }
.q-mark.abd { background: var(--abd-bg); color: var(--abd); font-family: var(--font-body); font-weight: 700; }
.q-mark.bad { background: transparent; border: 1px solid #8A1C12; color: #8A1C12; font-weight: 700; }
.mono { font-family: var(--font-mono); }

/* ---------- Saved ---------- */
.code-card {
  background: var(--ink); color: #FFFFFF; border-radius: var(--r-lg); padding: 22px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.code-value { font-family: var(--font-mono); font-size: 40px; font-weight: 500; letter-spacing: 0.12em; }
.code-actions { display: flex; gap: 8px; width: 100%; }
.code-actions button { flex: 1; min-height: 48px; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; }
.code-actions .on-dark { border: 1px solid #5B6070; background: transparent; color: #FFFFFF; }
.code-actions .light { border: 0; background: #FFFFFF; color: var(--ink); }
.code-input { font-family: var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }

.divider { border: 0; border-top: 1px solid var(--line); margin: 8px 0 0; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(21, 23, 28, 0.6);
  display: flex; align-items: flex-start; justify-content: center; padding: 18vh 20px 20px; z-index: 50;
}
.modal {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h2 { margin: 0; font-family: var(--font-display); font-size: 22px; line-height: 1.2; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; }
.modal-head .icon-btn { margin: -10px -12px 0 0; }
.modal p { margin: 0; font-size: 14px; color: var(--ink-2); }
.code-field {
  height: 56px; padding: 0 16px; border: 2px solid var(--ink); border-radius: 12px; background: var(--surface);
  font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.14em; text-align: center; text-transform: uppercase;
}
.form-error { margin: 0; font-size: 13px; color: #A3261A; min-height: 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { min-height: 52px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #FFFFFF; padding: 10px 16px; border-radius: 999px;
  font-size: 14px; z-index: 60; max-width: calc(100% - 40px);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
