/* KEES calculator: a savings passbook. Sage paper, forest-green ink, ruled ledger lines, monospaced amounts. */
:root {
  --bg: #eef3ec;
  --paper: #fbfdf8;
  --ink: #17251d;
  --muted: #4a5c50;
  --rule: #cbd9cd;
  --rule-strong: #8fa897;
  --accent: #1d6a45;
  --accent-ink: #ffffff;
  --accent-soft: #dcebdf;
  --zero: #6d7d73;
  --warn: #8a4600;
  --err: #a32121;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --r: 6px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1712;
    --paper: #16211a;
    --ink: #e4ede6;
    --muted: #a8bbae;
    --rule: #2b3c31;
    --rule-strong: #4f6a58;
    --accent: #7fd3a2;
    --accent-ink: #0b1a11;
    --accent-soft: #1f3327;
    --zero: #8a9e91;
    --warn: #f0b56a;
    --err: #ff8f8f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.top, main { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 22px; padding-bottom: 6px; }
h1 { font-size: 1.75rem; line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.01em; max-width: 24ch; }
.lede { margin: 0 0 14px; max-width: 62ch; color: var(--muted); }
h2 { font-size: 1.3rem; line-height: 1.25; margin: 34px 0 8px; }
h3 { font-size: 1.05rem; margin: 20px 0 4px; }
.sub, .dim { color: var(--muted); }
.sub { font-size: 0.9rem; }

/* tabs */
.tabs { display: inline-flex; border: 1.5px solid var(--rule-strong); border-radius: var(--r); overflow: hidden; margin: 0 0 12px; }
.tabs button { font: 600 0.98rem var(--font); min-height: 44px; padding: 0 18px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.store-note, .link-note { margin: 0 0 12px; padding: 8px 12px; border-left: 4px solid var(--warn); background: var(--paper); max-width: 62ch; }
.link-box { width: 100%; margin-top: 6px; font: 15px var(--mono); padding: 8px; border: 1px solid var(--rule-strong); border-radius: var(--r); background: var(--bg); color: var(--ink); }

/* the ledger (the one card on the page) */
.ledger-wrap { display: grid; gap: 18px; }
.ledger {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-left: 6px double var(--accent);
  border-radius: var(--r);
  padding: 4px 14px 12px;
}
.led-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 0 10px; border-bottom: 2px solid var(--ink); }
.led-head label { font-weight: 650; }
select, input, textarea { font: 16px var(--font); color: var(--ink); background: var(--bg); border: 1.5px solid var(--rule-strong); border-radius: var(--r); }
select { min-height: 44px; padding: 0 10px; }
input { min-height: 44px; padding: 0 10px; width: 100%; }
textarea { width: 100%; padding: 10px; font-family: var(--mono); font-size: 15px; line-height: 1.5; resize: vertical; tab-size: 12; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--err); }
.led-cols { display: grid; grid-template-columns: 1fr 5.6rem 5.4rem; gap: 10px; font-size: 0.8rem; color: var(--muted); padding: 8px 0 2px; }
.led-cols span:nth-child(3) { text-align: right; }
.led-row {
  display: grid;
  grid-template-columns: 1fr 5.6rem 5.4rem;
  grid-template-areas: "what in amt" "err err err";
  gap: 0 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
}
.led-what { grid-area: what; display: flex; flex-direction: column; min-width: 0; }
.what { font-weight: 650; }
.led-row .gpa { grid-area: in; font-family: var(--mono); text-align: center; }
.amt { grid-area: amt; text-align: right; font: 600 1.05rem var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.zero { color: var(--zero); font-weight: 400; }
.amt.maybe { color: var(--muted); font-style: italic; font-weight: 400; }
.maybe-line { margin: 2px 0 0; text-align: right; font-weight: 600; color: var(--warn); }
.led-row.off .gpa { opacity: 0.55; }
.led-row.off .amt { font: 0.85rem var(--font); color: var(--zero); }
.err { grid-area: err; margin: 4px 0 0; color: var(--err); font-size: 0.9rem; }
.test-row { grid-template-areas: "what what amt" "ins ins ins" "err err err"; }
.test-ins { grid-area: ins; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.test-row .err + .err { margin-top: 0; }
.mini { display: flex; align-items: center; gap: 8px; }
.mini span { font-size: 0.9rem; color: var(--muted); min-width: 2.2em; }
.mini input { font-family: var(--mono); text-align: center; }
.exam-row { grid-template-areas: "what what amt" "grid grid grid"; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; min-height: 44px; padding-top: 10px; }
.led-what .check { padding-top: 0; min-height: 0; align-items: center; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.check span { font-weight: 600; }
.led-what .check + .sub { padding-left: 32px; }
.exam-grid { grid-area: grid; margin-top: 6px; }
.exam-line { border: 0; margin: 0; padding: 6px 0 0; display: grid; grid-template-columns: 6.2rem repeat(3, 1fr); gap: 8px; align-items: center; }
.exam-line legend { float: left; font-size: 0.9rem; font-weight: 600; padding: 0; margin: 0; }
.exam-line .mini { gap: 4px; flex-direction: column; align-items: stretch; }
.exam-line .mini span { font-size: 0.78rem; min-width: 0; text-align: center; }
.led-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 0 2px; border-top: 2px solid var(--ink); margin-top: -1px; }
.led-total span { font-weight: 700; font-size: 1.05rem; }
.big { font: 700 2.1rem/1.1 var(--mono); font-variant-numeric: tabular-nums; color: var(--accent); }
.per-more { margin: 4px 0 6px; color: var(--muted); }
.per-more b { color: var(--ink); font-family: var(--mono); }
.more { margin-top: 8px; border-top: 1px solid var(--rule); padding-top: 4px; }
.more summary, .pt summary, .kept summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--accent); }
.nocount { border: 0; padding: 0; margin: 0 0 4px; }
.nocount legend { font-weight: 600; padding: 0; }
.nocount .sub { margin: 2px 0 2px; }
.nocount-boxes { display: flex; flex-wrap: wrap; gap: 0 20px; }

/* beside the ledger */
.after { min-width: 0; }
.raise { border-left: 4px solid var(--accent); padding: 2px 0 2px 14px; margin-bottom: 14px; }
.raise:empty { display: none; }
.raise-h { font-size: 1.1rem; margin: 0 0 4px; }
.raise p { margin: 0 0 6px; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; padding: 5px 0; border-bottom: 1px dashed var(--rule); font-variant-numeric: tabular-nums; }
.steps li > span { white-space: nowrap; }
.steps .sg { width: 3.2rem; }
.steps .dim { margin-left: auto; }
.steps .sg { font: 600 1rem var(--mono); }
.steps .dim { font-size: 0.9rem; }
.notes { margin: 0 0 12px; padding-left: 1.1em; }
.notes li { margin: 0 0 6px; }
.notes:empty { display: none; }
.pt { margin: 0 0 12px; }
.pt-t { border-collapse: collapse; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.pt-t th, .pt-t td { text-align: left; padding: 4px 16px 4px 0; border-bottom: 1px solid var(--rule); }
.pt-t td:last-child { font-family: var(--mono); text-align: right; padding-right: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.btn { font: 600 1rem var(--font); min-height: 44px; padding: 0 16px; border-radius: var(--r); border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { min-height: 36px; padding: 0 10px; font-size: 0.9rem; }
.fine { font-size: 0.92rem; color: var(--muted); max-width: 62ch; }

/* class list */
.class-setup { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; margin-bottom: 4px; }
.field > span { font-size: 0.95rem; }
.field.grow { flex: 1 1 220px; }
.c-sum { margin: 6px 0 8px; font-weight: 600; }
.c-sum .dim { font-weight: 400; }
.c-table { container-type: inline-size; }
.ct { width: 100%; border-collapse: collapse; background: var(--paper); font-variant-numeric: tabular-nums; }
.ct th, .ct td { text-align: left; vertical-align: top; padding: 7px 8px; border-bottom: 1px solid var(--rule); }
.ct thead th { border-bottom: 2px solid var(--ink); font-size: 0.85rem; }
.ct small { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 400; }
.ct small.warn { color: var(--warn); }
.ct td { font-family: var(--mono); }
.ct td small { font-family: var(--font); }
.ct .tot { font-weight: 700; }
.ct .zero { color: var(--zero); }
@container (max-width: 340px) {
  .ct tr { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@container (max-width: 760px) {
  .ct thead { display: none; }
  .ct, .ct tbody, .ct tr { display: block; }
  .ct tr { border: 1px solid var(--rule-strong); border-radius: var(--r); margin: 0 0 10px; padding: 6px 10px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 10px; }
  .ct th { grid-column: 1 / -1; border: 0; padding: 4px 0; font-size: 1.05rem; }
  .ct td { border: 0; padding: 4px 0; display: flex; flex-direction: column; }
  .ct td::before { content: attr(data-l); font: 600 0.78rem var(--font); color: var(--muted); }
}
.kept { margin-top: 18px; }
.kept ul { list-style: none; padding: 0; margin: 0; }
.kept li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.kept li > span { flex: 1 1 240px; }

/* below the tool */
.explain { max-width: 70ch; }
.explain p { margin: 0 0 12px; }
.floors, .chart { border-collapse: collapse; margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.floors th, .floors td, .chart th, .chart td { text-align: left; padding: 6px 14px 6px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.floors thead th, .chart thead th { border-bottom: 2px solid var(--ink); font-size: 0.9rem; }
.chart td.n { font-family: var(--mono); text-align: right; }
.chart tr.old td { color: var(--muted); }
.faq h3 { margin-top: 18px; }
.sources { font-size: 0.9rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 26px; }
.crumbs { font-size: 0.92rem; margin: 0 0 8px; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs li + li::before { content: "/"; color: var(--muted); margin-right: 6px; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: calc(100vw - 32px); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r); display: flex; align-items: center; gap: 12px; z-index: 20; box-shadow: 0 4px 18px rgba(0,0,0,.25); }
.toast .btn { background: var(--bg); color: var(--ink); border-color: var(--bg); }

/* footer */
.site-foot { max-width: 1080px; margin: 40px auto 0; padding: 18px 16px 30px; border-top: 1px solid var(--rule); font-size: 0.88rem; color: var(--muted); }
.sb-footer p { margin: 0 0 8px; }
.sb-more a { color: var(--muted); }
.sb-credit a { color: var(--accent); }

.print-root { display: none; }

@media (min-width: 900px) {
  h1 { font-size: 2.3rem; }
  .ledger-wrap { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); align-items: start; gap: 28px; }
  .after { position: sticky; top: 16px; }
  .led-cols, .led-row { grid-template-columns: 1fr 7rem 6.5rem; }
}
@media (max-width: 360px) {
  .led-cols, .led-row { grid-template-columns: 1fr 4.7rem 4.8rem; gap: 0 8px; }
  .ledger { padding: 4px 10px 12px; }
  .exam-line { grid-template-columns: 4.8rem repeat(3, 1fr); }
  .big { font-size: 1.8rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* ------------------------------------------------------------ print */
@media print {
  @page { size: auto; margin: 0.5in; }
  body { background: #fff; color: #000; font: 10pt/1.35 var(--font); }
  body.app > *:not(.print-root) { display: none !important; }
  body.app .print-root { display: block !important; }
  body:not(.app) .top .lede, body:not(.app) .site-foot, body:not(.app) .skip, body:not(.app) .crumbs, body:not(.app) .noprint { display: none !important; }
  body:not(.app) main, body:not(.app) .top { max-width: none; padding: 0; }
  body:not(.app) h1 { font-size: 17pt; }
  body:not(.app) h2 { font-size: 12.5pt; margin: 10pt 0 4pt; break-after: avoid; }
  body:not(.app) .chart, body:not(.app) .floors { break-inside: avoid; font-size: 9.5pt; }
  body:not(.app) .chart th, body:not(.app) .chart td, body:not(.app) .floors th, body:not(.app) .floors td { color: #000 !important; padding: 2pt 10pt 2pt 0; border-bottom: 0.75pt solid #999; }
  body:not(.app) .explain { max-width: none; }
  body:not(.app) .blk { break-inside: avoid; }
  body:not(.app) .explain { columns: 2; column-gap: 0.35in; }
  body:not(.app) .explain > h2:first-child, body:not(.app) .blk > h2 { margin-top: 0; }
  body:not(.app) .explain .sources { column-span: all; }
  body:not(.app) .explain p { break-inside: avoid; font-size: 9.5pt; margin: 0 0 6pt; }
  body:not(.app) .explain .chart th, body:not(.app) .explain .chart td, body:not(.app) .explain .floors th, body:not(.app) .explain .floors td { padding-top: 1.5pt; padding-bottom: 1.5pt; }
  body:not(.app) .chart tr.old td { font-style: italic; }
  a { color: #000; }

  .p-sheet { color: #000; }
  .p-title { font: 800 17pt/1.2 var(--font); margin: 0 0 3pt; }
  .p-meta { margin: 0 0 8pt; font-size: 10pt; color: #222; }
  .p-blank { display: inline-block; min-width: 1.1in; border-bottom: 0.75pt solid #000; height: 11pt; vertical-align: bottom; }
  .p-blank.wide { min-width: 2.6in; }
  .p-ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  .p-ledger th, .p-ledger td { text-align: left; padding: 4pt 6pt 4pt 0; border-bottom: 0.75pt solid #888; }
  .p-ledger thead th { border-bottom: 1.5pt solid #000; font-size: 9pt; }
  .p-ledger .n { text-align: right; font-family: var(--mono); padding-right: 0; }
  .p-ledger .p-sep td { border-top: 1.5pt solid #000; }
  .p-ledger tfoot th, .p-ledger tfoot td { border-top: 1.5pt solid #000; border-bottom: 0; font-size: 12pt; font-weight: 800; padding-top: 6pt; }
  .p-sum { margin: 6pt 0; font-weight: 600; }
  .p-box { border: 1pt solid #000; padding: 5pt 7pt; margin: 6pt 0; break-inside: avoid; }
  .p-notes { margin: 4pt 0 6pt; padding-left: 12pt; }
  .p-notes li { margin: 0 0 2pt; }
  .p-ref { break-inside: avoid; }
  .p-charts { display: flex; gap: 0.3in; align-items: flex-start; margin-top: 8pt; break-inside: avoid; }
  .p-mini { border-collapse: collapse; font-size: 8.5pt; font-variant-numeric: tabular-nums; }
  .p-mini caption { text-align: left; font-weight: 700; font-size: 9.5pt; padding-bottom: 2pt; white-space: nowrap; }
  .p-mini th, .p-mini td { text-align: left; padding: 1pt 10pt 1pt 0; border-bottom: 0.5pt solid #aaa; }
  .p-mini thead th { border-bottom: 1pt solid #000; }
  .p-mini tr.old td { color: #555; font-style: italic; }
  .p-ledger tfoot tr.p-maybe td { font-size: 10pt; font-weight: 600; border-top: 0; padding-top: 2pt; }
  .p-small { font-size: 8.5pt; color: #222; margin: 6pt 0 0; }
  .p-list { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; font-size: 8.5pt; }
  .p-list col.c-name { width: 19%; }
  .p-list col.c-yr { width: 8.5%; }
  .p-list col.c-test { width: 9%; }
  .p-list col.c-exam { width: 13%; }
  .p-list col.c-tot { width: 9.5%; }
  .p-list th, .p-list td { border: 0.75pt solid #777; padding: 2pt 3pt; text-align: left; vertical-align: top; overflow-wrap: break-word; height: 20pt; }
  .p-list thead { display: table-header-group; }
  .p-list thead th { border-bottom: 1.5pt solid #000; font-size: 8pt; height: auto; }
  .p-list tr { break-inside: avoid; }
  .p-list small { display: block; font-size: 7pt; color: #333; font-weight: 400; }
  .p-list .tot { font-weight: 700; }
  .p-list .zero, .p-list .dim { color: #555; }
}
#plan:focus { outline: none; }
