:root {
  color-scheme: light;
  --page: #f2f0ec;
  --surface: #fdfcfa;
  --surface-2: #f6f4f0;
  --ink: #1f1d1a;
  --ink-2: #57534b;
  --muted: #8c877d;
  --line: #e2ded5;
  --accent: #6b4fbb;
  --accent-soft: #ece6fa;
  --accent-ink: #ffffff;
  --good: #2f7d55;
  --good-soft: #e3f2ea;
  --bad: #b5452f;
  --bad-soft: #f9e7e2;
  --warn: #9a6a12;
  --warn-soft: #fbf1dc;
  --bar: #c9bdf0;
  --shadow: 0 1px 2px rgb(30 25 20 / 6%), 0 2px 8px rgb(30 25 20 / 4%);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #141317;
    --surface: #1d1c22;
    --surface-2: #24232b;
    --ink: #eeebe5;
    --ink-2: #bdb8ae;
    --muted: #8a857c;
    --line: #33323b;
    --accent: #a68cf0;
    --accent-soft: #2e2843;
    --accent-ink: #141317;
    --good: #6cc495;
    --good-soft: #1e3329;
    --bad: #ec8c76;
    --bad-soft: #3a2420;
    --warn: #e5b562;
    --warn-soft: #362c1a;
    --bar: #4d3f7d;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 "Petrov Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------------------------------------------------------------- shell */

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px max(24px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  grid-template-areas: "top top" "tabs view" "foot foot";
  column-gap: 28px;
}
.top {
  grid-area: top;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: max(16px, env(safe-area-inset-top)) 0 16px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 24px; letter-spacing: -0.03em; }
.logo { width: 28px; height: 28px; }
.logo-body { fill: var(--accent); }
.logo-shine { fill: var(--bar); }
.logo-base { fill: var(--ink); }
.save-info { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip { font-size: 13px; padding: 2px 9px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.chip.muted { color: var(--muted); }

.tabs {
  grid-area: tabs;
  position: sticky; top: 12px; align-self: start;
  display: flex; flex-direction: column; gap: 2px;
}
.tab {
  display: block; padding: 7px 12px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.on { background: var(--accent); color: var(--accent-ink); }

main { grid-area: view; min-width: 0; outline: none; }
.foot { grid-area: foot; color: var(--muted); font-size: 13px; margin-top: 32px; border-top: 1px solid var(--line); padding-top: 12px; }
.foot a { color: inherit; }

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "tabs" "view" "foot"; }
  .top { padding-bottom: 10px; }
  .save-info { order: 3; margin-left: 0; width: 100%; }
  .top .btn { margin-left: auto; }
  .tabs {
    position: sticky; top: 0; z-index: 5;
    flex-direction: row; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px 12px; padding: 8px 16px;
    background: var(--page); border-bottom: 1px solid var(--line);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 6px 12px; }
}

/* ---------------------------------------------------------------- bits */

.btn {
  border: 0; border-radius: 9px; padding: 8px 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { font-size: 17px; padding: 11px 22px; }
.btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.view-head h1 { margin: 0 0 2px; font-size: 26px; letter-spacing: -0.02em; }
.blurb { margin: 0 0 14px; color: var(--ink-2); max-width: 70ch; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -0.01em; }
.card h3 { margin: 14px 0 6px; font-size: 15px; }
.card > :last-child { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + * { margin-top: 14px; }

.answer {
  font-size: 17px; line-height: 1.45; margin: 0 0 12px;
  padding: 10px 14px; border-radius: 10px; background: var(--accent-soft);
}
.answer b, .answer strong { color: var(--accent); }
@media (prefers-color-scheme: dark) { .answer b, .answer strong { color: var(--ink); } }
.note { font-size: 14px; padding: 8px 12px; border-radius: 8px; margin: 8px 0; }
.note.info { background: var(--surface-2); color: var(--ink-2); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.good { background: var(--good-soft); color: var(--good); }
.credit { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.credit a { color: inherit; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0 0 12px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; display: flex; flex-direction: column; min-width: 0; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-note { font-size: 12px; color: var(--ink-2); }
.tile.good .tile-value { color: var(--good); }
.tile.bad .tile-value { color: var(--bad); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.hi td { background: var(--accent-soft); }
tr.dim td { color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }

.bar { display: inline-block; height: 8px; border-radius: 4px; background: var(--bar); vertical-align: middle; min-width: 2px; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- inputs */

details.inputs, details.more {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px;
}
details.more { background: transparent; border-style: dashed; margin: 10px 0 0; }
details.inputs > summary, details.more > summary {
  cursor: pointer; padding: 10px 16px; font-weight: 600; color: var(--ink-2); list-style: none;
}
details.inputs > summary::-webkit-details-marker, details.more > summary::-webkit-details-marker { display: none; }
details.inputs > summary::before, details.more > summary::before { content: "▸"; display: inline-block; width: 1.1em; transition: transform .15s; }
details[open].inputs > summary::before, details[open].more > summary::before { transform: rotate(90deg); }
details.inputs > .fields, details.more > :not(summary) { padding: 0 16px 14px; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 16px; }
.fields-heading { grid-column: 1 / -1; margin: 6px 0 -4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.field-label { color: var(--ink-2); }
.field-input { display: flex; align-items: center; gap: 6px; }
.field small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.field input[type=number], .field input[type=text], .field select, .inline-select {
  width: 100%; min-width: 0; padding: 6px 9px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.field input:focus, .field select:focus, .inline-select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field .unit { color: var(--muted); font-size: 13px; }
.field.check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; cursor: pointer; }
.field.check small { width: 100%; padding-left: 26px; }
.field.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.inline-select { width: auto; max-width: 100%; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.controls label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.controls input[type=number] { width: 9em; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }

/* ---------------------------------------------------------------- import */

dialog.sheet {
  border: 0; padding: 0; border-radius: 14px; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 10px 40px rgb(0 0 0 / 30%);
}
dialog.sheet::backdrop { background: rgb(10 8 15 / 50%); }
.sheet-inner { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.sheet-inner h2 { margin: 0; }
.steps { margin: 0; padding-left: 1.3em; color: var(--ink-2); }
textarea {
  width: 100%; resize: vertical; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); font: 13px/1.4 var(--mono);
}
.import-error { color: var(--bad); margin: 0; min-height: 1.2em; font-size: 14px; }
.sheet-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.welcome { max-width: 60ch; padding: 24px 0; }
.welcome h1 { font-size: 30px; letter-spacing: -0.03em; line-height: 1.15; margin: 0 0 10px; }
.welcome .steps { margin: 14px 0 20px; font-size: 16px; }

/* ---------------------------------------------------------------- checklist */

.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.check-list li:last-child { border-bottom: 0; }
.check-list .mark { flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 13px; font-weight: 700; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--muted); }
.check-list .mark.done { background: var(--good); border-color: var(--good); color: var(--surface); }
.check-list .mark.todo { border-color: var(--bad); color: var(--bad); }
.check-list button.mark { padding: 0; cursor: pointer; }
.check-list .what { flex: 1; min-width: 0; }
.check-list .what small { display: block; color: var(--muted); font-size: 12px; }
.check-list .val { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 4px 0 12px; }
.progress > span { display: block; height: 100%; background: var(--good); }

.spark { width: 100%; height: 60px; display: block; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark circle { fill: var(--accent); }

.running { color: var(--muted); font-style: italic; }

/* ---------------------------------------------------------------- overview */

.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card.ov { display: flex; flex-direction: column; gap: 4px; margin: 0; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.card.ov:hover { border-color: var(--accent); transform: translateY(-1px); }
.ov-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ov-body { font-size: 16px; line-height: 1.4; }
.ov-body b { color: var(--accent); }
@media (prefers-color-scheme: dark) { .ov-body b { color: var(--ink); } }

@media (max-width: 560px) {
  .hide-sm { display: none !important; }
  th, td { padding: 6px 5px; }
  .card { padding: 14px 12px; }
}
.controls label { max-width: 100%; min-width: 0; }
.controls .inline-select { min-width: 0; flex: 1 1 auto; }
.controls input[type=text] { min-width: 0; width: 12em; max-width: 100%; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--page); padding: 9px 16px; border-radius: 99px; font-weight: 600;
  box-shadow: 0 6px 24px rgb(0 0 0 / 25%); z-index: 20; animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
a.chip { text-decoration: none; }
a.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.bad { color: var(--bad); border-color: var(--bad); }

/* ---------------------------------------------------------------- compact phone layout */

@media (max-width: 560px) {
  body { font-size: 14px; }
  .shell { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .top { padding: max(8px, env(safe-area-inset-top)) 0 6px; gap: 6px; }
  .brand { font-size: 20px; gap: 6px; }
  .logo { width: 22px; height: 22px; }
  .top .btn { padding: 6px 12px; font-size: 14px; }
  .chip { font-size: 12px; padding: 1px 7px; }
  .tabs { padding: 6px 16px; margin-bottom: 8px; gap: 2px; }
  .tab { padding: 4px 10px; font-size: 14px; }

  .view-head h1 { font-size: 21px; margin-bottom: 0; }
  .blurb { font-size: 13px; line-height: 1.4; margin-bottom: 8px; }

  .card { padding: 10px 12px; margin-bottom: 8px; border-radius: 10px; }
  .card h2 { font-size: 16px; margin-bottom: 6px; }
  .card h3 { font-size: 14px; margin: 10px 0 4px; }
  .grid2 { gap: 8px; }
  .grid2 + * { margin-top: 8px; }
  .answer { font-size: 15px; padding: 7px 10px; margin-bottom: 8px; border-radius: 8px; }
  .note { font-size: 13px; padding: 6px 10px; margin: 6px 0; }
  .credit { margin-top: 6px; }
  .card p { margin: 6px 0; }
  .small { font-size: 12px; }

  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
  .tile { padding: 6px 9px; border-radius: 8px; }
  .tile-label, .tile-note { font-size: 11px; }
  .tile-value { font-size: 17px; }

  table { font-size: 13px; }
  th, td { padding: 4px 5px; }
  th { font-size: 11px; }

  details.inputs, details.more { margin-bottom: 8px; border-radius: 10px; }
  details.more { margin-top: 6px; }
  details.inputs > summary, details.more > summary { padding: 8px 12px; font-size: 14px; }
  details.inputs > .fields, details.more > :not(summary) { padding: 0 12px 10px; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
  .fields-heading { font-size: 11px; margin: 4px 0 -2px; }
  .field { font-size: 13px; gap: 2px; }
  .field-label { line-height: 1.25; }
  .field small { font-size: 11px; }
  .field input[type=number], .field input[type=text], .field select { padding: 5px 7px; }
  .field.check small { padding-left: 0; }
  .controls { gap: 6px 10px; margin-bottom: 8px; }
  .controls label { font-size: 13px; }

  .ov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
  .card.ov { padding: 9px 10px; gap: 2px; }
  .ov-label { font-size: 10px; }
  .ov-body { font-size: 14px; line-height: 1.35; }

  .check-list li { padding: 4px 0; gap: 8px; }
  .check-list .mark { width: 20px; height: 20px; font-size: 12px; }
  .progress { margin: 2px 0 8px; }
  .foot { margin-top: 16px; font-size: 12px; }
  .welcome { padding: 12px 0; }
  .welcome h1 { font-size: 24px; }
}
@media (max-width: 560px) {
  .blurb { display: none; }
  .view-head h1 { margin-bottom: 6px; }
  .card ol, .card ul:not(.check-list) { padding-left: 1.3em; margin: 4px 0; }
}
