/* Splittems styles. Shared by every page. */
@font-face { font-family: 'Space Grotesk'; font-weight: 400; font-display: swap; src: url(/fonts/space-grotesk-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-display: swap; src: url(/fonts/space-grotesk-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 600; font-display: swap; src: url(/fonts/space-grotesk-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 700; font-display: swap; src: url(/fonts/space-grotesk-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(/fonts/jetbrains-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-display: swap; src: url(/fonts/jetbrains-mono-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 600; font-display: swap; src: url(/fonts/jetbrains-mono-latin-600-normal.woff2) format('woff2'); }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
[hidden] { display: none !important; }
img { max-width: 100%; }
/* Layout: one-screen app. Header, then a full-height stage holding the active view (graph or table)
   and the Settle-up panel (bottom drawer on phones, right-hand column on desktop). */
:root {
  --paper: #F2EEE6;    /* page */
  --raised: #FAF8F3;   /* windows, drawer */
  --greige: #D8D1C4;   /* quiet fills */
  --ink: #2E2B28;      /* text */
  --muted: #6E675E;    /* secondary text */
  --hair: #CFC7B9;     /* hairlines */
  --terra: #B4472C;    /* accent, transfers, owes */
  --olive: #5A6B4E;    /* is owed */
  --terra-wash: rgba(180, 71, 44, .09);
  --olive-wash: rgba(90, 107, 78, .10);
  --shadow: 0 10px 30px rgba(46, 43, 40, .12);
  --sans: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --peek: 64px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
html { height: 100%; box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }
body {
  height: 100%; margin: 0; overflow: hidden;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .18 0 0 0 0 .16 0 0 0 0 .14 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--terra); outline-offset: 2px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.label { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------- App frame ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.top { padding: 10px var(--gutter-r) 0 var(--gutter-l); display: grid; gap: 8px; position: relative; }
.row1, .row2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row1 { justify-content: space-between; align-items: flex-start; }
.row1-actions { display: flex; align-items: center; gap: 2px; flex: none; margin-top: -4px; }
.share-btn { height: 36px; padding: 0 12px; }
.share-btn svg { margin-top: -2px; }
.share-url { width: 100%; height: 48px; border: 1px solid var(--hair); border-radius: 10px; background: var(--paper); padding: 0 12px; font-size: 13px; color: var(--ink); }
.link-line { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; min-width: 0; }
.link-line .url { font-family: var(--mono); font-size: 12px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; user-select: all; }
.title-wrap { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 10px; row-gap: 2px; min-width: 0; }
.title-wrap h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0; line-height: 1.15; text-wrap: balance; }
.title-btn { font: inherit; letter-spacing: inherit; border: 0; background: transparent; padding: 0; text-align: left; text-decoration: underline dashed var(--hair); text-underline-offset: 6px; text-decoration-thickness: 1px; }
.title-btn:hover { text-decoration-color: var(--terra); }
.title-btn:disabled { text-decoration: none; cursor: default; color: inherit; }
.title-form { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0; }
.title-form input { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--ink); border-radius: 10px; background: var(--raised); padding: 0 10px; font-size: 18px; font-weight: 600; }
.pill { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--terra); color: var(--terra); white-space: nowrap; }
.pill.final { background: var(--terra); color: var(--raised); }
.pill.ghost { border-color: var(--hair); color: var(--muted); }
.row2 { justify-content: space-between; }
.adds { display: flex; gap: 6px; }
.btn { height: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--ink); background: transparent; font-size: 14px; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--terra-wash); }
.btn.primary { background: var(--terra); border-color: var(--terra); color: var(--raised); }
.btn.primary:hover { background: #9e3c24; }
.btn.primary:disabled { background: var(--greige); border-color: var(--greige); color: var(--muted); cursor: not-allowed; }
.btn.ghost { border-color: var(--hair); }
.btn.danger { border-color: var(--terra); color: var(--terra); }
.btn.sm { height: 36px; font-size: 13px; padding: 0 12px; }
.btn.wide { width: 100%; }
.btn.splittems { height: 52px; font-size: 18px; font-weight: 600; letter-spacing: .01em; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; font-size: 22px; line-height: 1; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--terra-wash); }
.seg { display: inline-flex; border: 1px solid var(--hair); border-radius: 999px; padding: 3px; gap: 2px; flex: none; }
.seg button { height: 36px; border: 0; border-radius: 999px; background: transparent; padding: 0 11px; font-family: var(--mono); font-size: 12px; letter-spacing: .02em; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--raised); }
.seg.small button { height: 30px; padding: 0 10px; font-size: 11px; }
.mock-tag { position: absolute; left: var(--gutter-l); bottom: 1px; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: var(--paper); padding-right: 8px; }
.top-loop { display: block; width: 100%; height: 22px; margin-top: 2px; pointer-events: none; }
.top-loop path { fill: none; stroke: var(--terra); stroke-width: 1.2; }

.stage { flex: 1; min-height: 0; position: relative; display: flex; }
.view { position: absolute; inset: 0 0 var(--peek) 0; display: flex; flex-direction: column; }
.view[hidden] { display: none !important; }

/* ---------- Graph view ---------- */
.graph-controls { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px var(--gutter-r) 0 var(--gutter-l); flex-wrap: wrap; }
.graph-box { flex: 1; min-height: 0; position: relative; }
#graph { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
#graph .edge { cursor: pointer; outline: none; }
#graph .edge .hit { stroke: transparent; stroke-width: 22; fill: none; pointer-events: stroke; }
#graph .edge .ln { fill: none; stroke: var(--terra); stroke-linecap: round; }
#graph .edge .ah { fill: none; stroke: var(--terra); stroke-linecap: round; stroke-linejoin: round; }
#graph .edge .dot { fill: var(--terra); }
#graph .thin .ln { stroke-width: 1.3; opacity: .6; }
#graph .thin .ah { stroke-width: 1.3; opacity: .6; }
#graph .thin .dot { opacity: .6; }
#graph .bold .ln { stroke-width: 3.2; }
#graph .bold .ah { stroke-width: 3; }
#graph .amt rect { fill: var(--paper); }
#graph .amt text { font-family: var(--mono); font-size: 12px; fill: var(--terra); font-weight: 500; text-anchor: middle; dominant-baseline: central; }
#graph .amt { pointer-events: none; }
#graph .amt.thin { opacity: 0; transition: opacity .15s; }
#graph .amt.thin.hov, #graph .amt.thin.on { opacity: 1; }
#graph.dim .amt:not(.on) { opacity: 0; }
#graph .thin:hover .ln, #graph .thin.on .ln, #graph .thin:hover .ah, #graph .thin.on .ah { opacity: 1; stroke-width: 1.8; }
#graph .edge:focus-visible .ln { stroke: var(--ink); }
#graph .node { cursor: pointer; outline: none; }
#graph .node text { paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; text-anchor: middle; }
#graph .node .nm { font-family: var(--sans); font-size: 16px; font-weight: 600; fill: var(--ink); }
#graph .node .nv { font-family: var(--mono); font-size: 11.5px; fill: var(--muted); }
#graph .node .nv.neg { fill: var(--terra); }
#graph .node .nv.pos { fill: var(--olive); }
#graph .node .hitbox { fill: transparent; }
#graph .node:focus-visible .nm { text-decoration: underline; }
#graph .node.me .nm { text-decoration: underline; text-decoration-color: var(--terra); text-underline-offset: 4px; }
#graph.dim .edge:not(.on) { opacity: .12; }
#graph.dim .node:not(.on) { opacity: .35; }
#graph .empty-note { font-family: var(--sans); font-size: 14px; fill: var(--muted); text-anchor: middle; }
.tip { position: fixed; z-index: 40; pointer-events: none; background: var(--ink); color: var(--raised); padding: 6px 10px; border-radius: 8px; font-size: 13px; max-width: 260px; }
.tip .mono { color: #F2B8A6; }

/* ---------- Table view ---------- */
.table-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px var(--gutter-r) 6px var(--gutter-l); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-height: 44px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--terra); }
.table-wrap { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--hair); overscroll-behavior: contain; }
table.mx { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 14px; }
.mx th, .mx td { padding: 10px 10px; border-bottom: 1px solid var(--hair); white-space: nowrap; text-align: left; vertical-align: middle; background: var(--paper); }
.mx thead th { position: sticky; top: 0; z-index: 2; font-weight: 500; font-size: 12px; color: var(--muted); background: var(--paper); border-bottom: 1px solid var(--ink); }
.mx .sticky-l { position: sticky; left: 0; z-index: 1; border-right: 1px solid var(--hair); }
.mx thead .sticky-l { z-index: 3; }
.mx tfoot th, .mx tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--raised); border-bottom: 0; }
.mx tfoot tr:first-child th, .mx tfoot tr:first-child td { border-top: 1px solid var(--ink); }
.mx tfoot .sticky-l { z-index: 3; }
.mx tfoot tr:nth-last-child(2) th, .mx tfoot tr:nth-last-child(2) td { bottom: 41px; }
.mx tfoot tr:nth-last-child(3) th, .mx tfoot tr:nth-last-child(3) td { bottom: 82px; }
.mx .c-exp { min-width: 150px; max-width: 200px; white-space: normal; padding-left: var(--gutter-l); }
.mx tbody .c-exp { font-weight: 500; }
.mx .ecell { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.mx .c-exp .ed { min-width: 0; }
.mx .num { text-align: right; }
.mx .cur { color: var(--muted); font-size: 12px; }
.mx .c-m { min-width: 74px; text-align: right; }
.mx .sh { color: var(--ink); }
.mx .sh.payer { color: var(--terra); }
.mx .nil { color: var(--hair); }
.mx .c-add { min-width: 132px; padding-right: var(--gutter-r); }
.mx .pos { color: var(--olive); }
.mx .neg { color: var(--terra); }
.mx .zero { color: var(--muted); }
.mx tfoot th { font-size: 12px; font-weight: 500; color: var(--muted); }
.mh { border: 0; background: transparent; padding: 6px 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); min-height: 32px; border-bottom: 1px dashed var(--hair); }
.add-col { border-color: var(--terra); color: var(--terra); }
.add-col:hover { background: var(--terra-wash); }
.rm { flex: none; margin: -6px -4px -6px 0; width: 32px; height: 32px; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; vertical-align: middle; }
.rm:hover { border-color: var(--terra); color: var(--terra); }
.mx tr.removed th, .mx tr.removed td { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--terra); }
.mx tr.removed .removed-note { display: block; text-decoration: none; font-size: 11px; font-family: var(--mono); color: var(--terra); font-weight: 400; }
.mx .addrow-btn th, .mx .addrow-btn td { border-bottom: 0; padding-block: 12px 18px; }
.mx tr.adding th, .mx tr.adding td { background: var(--raised); vertical-align: top; }
.mx tr.adding input[type=text], .mx tr.adding input[inputmode], .mx tr.adding select { height: 40px; border: 1px solid var(--hair); border-radius: 8px; background: var(--paper); padding: 0 8px; font-size: 16px; width: 100%; }
.mx tr.adding #ar-amt { width: 104px; }
.mx tr.adding #ar-cur { width: 92px; }
.mx tr.adding #ar-paid { width: 112px; }
.mx tr.adding .tick { text-align: right; }
.mx tr.adding .tick input { width: 22px; height: 22px; accent-color: var(--terra); margin: 9px 0; }
.ar-actions { display: flex; gap: 6px; margin-top: 8px; }
.ar-err { margin: 6px 0 0; color: var(--terra); font-size: 12px; white-space: normal; }

/* ---------- Settle-up panel ---------- */
.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--raised); border-top: 1px solid var(--hair); border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 26px rgba(46, 43, 40, .08);
  max-height: min(80dvh, 680px); display: flex; flex-direction: column;
  transform: translateY(calc(100% - var(--peek) - env(safe-area-inset-bottom, 0px)));
  transition: transform .32s cubic-bezier(.3, .7, .2, 1);
}
.panel.open { transform: none; }
.panel.open.half { max-height: 46dvh; }
.panel-head { flex: none; height: var(--peek); width: 100%; border: 0; background: transparent; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 10px var(--gutter-r) 0 var(--gutter-l); text-align: left; position: relative; }
.panel-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--hair); }
.panel-head .sum { display: grid; gap: 1px; min-width: 0; }
.panel-head .sum b { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head .chev { width: 32px; height: 32px; display: grid; place-items: center; transition: transform .3s; color: var(--muted); }
.panel.open .chev { transform: rotate(180deg); }
.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 4px var(--gutter-r) calc(20px + env(safe-area-inset-bottom, 0px)) var(--gutter-l); display: grid; gap: 22px; align-content: start; overscroll-behavior: contain; }
.panel section { display: grid; gap: 10px; }
.panel h2 { margin: 0; }
.info { border: 1px solid var(--terra); border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; background: var(--paper); }
.info-head { display: flex; justify-content: space-between; align-items: center; }
.info-head .icon-btn { width: 36px; height: 36px; font-size: 18px; margin: -6px -8px -6px 0; }
.info-title { margin: 0; font-size: 18px; font-weight: 600; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.info-title .mono { color: var(--terra); font-size: 18px; font-weight: 500; }
.info p { margin: 0; font-size: 14px; color: var(--muted); }
.breakdown { list-style: none; margin: 0; padding: 0; display: grid; }
.breakdown li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--hair); font-size: 14px; align-items: baseline; }
.breakdown li small { display: block; color: var(--muted); font-size: 12.5px; }
.breakdown .mono { white-space: nowrap; }
.tlist { list-style: none; margin: 0; padding: 0; display: grid; }
.tlist li button { width: 100%; min-height: 48px; border: 0; border-top: 1px solid var(--hair); background: transparent; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; text-align: left; font-size: 15px; }
.tlist li:last-child button { border-bottom: 1px solid var(--hair); }
.tlist li button:hover { background: var(--terra-wash); }
.tlist .who { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.tlist .arrow { color: var(--terra); font-family: var(--mono); }
.tlist .amt { font-family: var(--mono); font-weight: 500; color: var(--terra); white-space: nowrap; }
.tlist .you { font-weight: 700; }
.cur-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.bal { width: 100%; border-collapse: collapse; font-size: 14px; }
.bal th, .bal td { padding: 7px 0; border-top: 1px solid var(--hair); text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.bal th:first-child, .bal td:first-child { text-align: left; font-family: var(--sans); }
.bal thead th { border-top: 0; font-size: 11px; letter-spacing: .1em; color: var(--muted); font-weight: 400; }
.bal .pos { color: var(--olive); } .bal .neg { color: var(--terra); } .bal .zero { color: var(--muted); }
.details-btn { width: 100%; min-height: 52px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; border: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--hair); background: transparent; padding: 0; font-size: 15px; font-weight: 600; text-align: left; }
.details-btn .label { font-weight: 400; }
.details-btn svg { transition: transform .25s; color: var(--muted); }
.details-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.details { display: grid; gap: 22px; }
.details[hidden] { display: none; }
.final-note { border: 1px solid var(--ink); border-radius: 14px; padding: 12px 14px; display: grid; gap: 4px; }
.final-note p { margin: 0; font-size: 14px; color: var(--muted); }
.history { list-style: none; margin: 0; padding: 0; display: grid; }
.history li { padding: 9px 0; border-top: 1px solid var(--hair); font-size: 14px; display: grid; gap: 2px; }
.history time { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.history .rm-ev { color: var(--terra); }
.muted { color: var(--muted); }

/* ---------- Windows (dialogs) ---------- */
dialog { border: 1px solid var(--hair); background: var(--raised); color: var(--ink); padding: 0; box-shadow: var(--shadow); width: 100%; max-width: 100%; margin: auto auto 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
dialog::backdrop { background: rgba(46, 43, 40, .32); }
dialog[open] { animation: up .28s cubic-bezier(.3, .7, .2, 1); }
@keyframes up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.dlg { display: grid; gap: 18px; padding: 20px var(--gutter-r) calc(20px + env(safe-area-inset-bottom, 0px)) var(--gutter-l); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dlg-head h2 { margin: 0; font-size: 21px; font-weight: 600; }
.field { display: grid; gap: 6px; }
.field > label, .field > .flabel { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.field input[type=text], .field input[inputmode], .field select { height: 48px; border: 1px solid var(--hair); border-radius: 10px; background: var(--paper); padding: 0 12px; font-size: 16px; width: 100%; min-width: 0; }
.field input:focus, .field select:focus { border-color: var(--ink); outline: none; }
.amount-row { display: grid; grid-template-columns: 1fr 110px; gap: 8px; }
.amount-row input { font-family: var(--mono); font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--hair); background: transparent; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { border-color: var(--terra); background: var(--terra); color: var(--raised); }
.chip-tools { display: flex; gap: 12px; }
.linkbtn { border: 0; background: transparent; color: var(--terra); font-size: 13px; padding: 6px 0; min-height: 32px; text-decoration: underline; text-underline-offset: 3px; }
.preview { font-family: var(--mono); font-size: 13px; color: var(--muted); padding: 10px 12px; border-radius: 10px; background: var(--paper); border: 1px dashed var(--hair); }
.preview b { color: var(--terra); font-weight: 500; }
.err { color: var(--terra); font-size: 14px; margin: 0; min-height: 0; }
.err:empty { display: none; }
.dlg-actions { display: flex; gap: 10px; }
.dlg-actions .btn { flex: 1; }
.newcur { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.note { font-size: 14px; color: var(--muted); margin: 0; }

/* Instructions window */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; position: relative; }
.steps li { display: grid; grid-template-columns: 44px 1fr; gap: 10px; position: relative; z-index: 1; }
.steps .n { font-family: var(--mono); font-size: 22px; font-weight: 500; color: var(--terra); line-height: 1.1; background: var(--raised); justify-self: start; padding-bottom: 4px; }
.steps p { margin: 0; font-size: 15px; }
.steps p b { font-weight: 600; }
.steps-loop { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.steps-loop path { fill: none; stroke: var(--terra); stroke-width: 1.2; vector-effect: non-scaling-stroke; opacity: .7; }
.small-print { font-size: 13px; color: var(--muted); margin: 0; border-top: 1px solid var(--hair); padding-top: 12px; }

/* Menu */
.menu { position: fixed; z-index: 30; top: calc(env(safe-area-inset-top, 0px) + 56px); right: var(--gutter-r); background: var(--raised); border: 1px solid var(--hair); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 220px; }
.menu button { min-height: 44px; border: 0; background: transparent; text-align: left; padding: 0 12px; border-radius: 10px; font-size: 15px; }
.menu button:hover { background: var(--terra-wash); }
.menu hr { border: 0; border-top: 1px solid var(--hair); margin: 4px 6px; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(var(--peek) + 16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--raised); padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }

/* ---------- Wider screens ---------- */
@media (min-width: 600px) {
  .title-wrap h1 { font-size: 26px; }
  dialog { max-width: 520px; margin: auto; border-radius: 20px; }
  .dlg { padding: 24px; }
}
@media (min-width: 960px) {
  .top { padding-top: 14px; }
  .row1 { order: 0; }
  .view { inset: 0; }
  .panel, .panel.open.half { position: relative; left: auto; right: auto; bottom: auto; transform: none; width: 380px; flex: none; max-height: none; border-radius: 0; border-top: 0; border-left: 1px solid var(--hair); box-shadow: none; transition: none; background: rgba(250, 248, 243, .7); }
  .panel-head { cursor: default; padding-top: 14px; }
  .panel-head::before, .panel-head .chev { display: none; }
  .stage-main { position: relative; flex: 1; min-width: 0; }
  .toast { bottom: 24px; }
  .mx .c-exp { min-width: 200px; max-width: 280px; }
  .mx .c-m { min-width: 86px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Message screen (loading, not found) ---------- */
.screen-msg { min-height: 100%; display: grid; place-items: center; padding: 24px var(--gutter-r) 24px var(--gutter-l); text-align: center; }
.screen-msg-inner { max-width: 420px; display: grid; gap: 10px; justify-items: center; }
.screen-msg h1 { margin: 0; font-size: 24px; font-weight: 600; }
.screen-msg p { margin: 0; color: var(--muted); }
.msg-loop { width: 220px; height: 60px; }
.msg-loop path { fill: none; stroke: var(--terra); stroke-width: 1.4; }
.msg-loop circle { fill: var(--terra); }
button[aria-busy="true"] { opacity: .7; cursor: progress; }

/* ---------- Scrolling pages: landing, create, admin ---------- */
body.page { overflow: auto; height: auto; min-height: 100%; }
.page-wrap { max-width: 560px; margin: 0 auto; padding: 28px var(--gutter-r) 48px var(--gutter-l); display: grid; gap: 22px; }
.page-wrap.wide { max-width: 1040px; }
.brand { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--terra); text-decoration: none; }
.page h1 { margin: 0; font-size: clamp(30px, 8vw, 44px); font-weight: 600; letter-spacing: -.02em; line-height: 1.05; text-wrap: balance; }
.page .lede { margin: 0; font-size: 18px; color: var(--muted); max-width: 46ch; }
.page-loop { width: 100%; height: 70px; display: block; }
.page-loop path { fill: none; stroke: var(--terra); stroke-width: 1.4; }
.page-loop circle { fill: var(--terra); }
.form { display: grid; gap: 18px; }
.people-list { display: grid; gap: 8px; }
.people-row { display: grid; grid-template-columns: 1fr 44px; gap: 8px; align-items: center; }
.people-row input { height: 48px; border: 1px solid var(--hair); border-radius: 10px; background: var(--raised); padding: 0 12px; font-size: 16px; min-width: 0; }
.people-row input:focus { border-color: var(--ink); outline: none; }
.people-row .icon-btn { font-size: 20px; color: var(--muted); }
.page .field input[type=text], .page .field input[type=password], .page .field select { height: 48px; border: 1px solid var(--hair); border-radius: 10px; background: var(--raised); padding: 0 12px; font-size: 16px; width: 100%; }
.page .field input:focus, .page .field select:focus { border-color: var(--ink); outline: none; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.cur-row { display: grid; grid-template-columns: 1fr 120px; gap: 8px; }
.steps-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.steps-mini li { display: grid; grid-template-columns: 40px 1fr; gap: 10px; }
.steps-mini .n { font-family: var(--mono); color: var(--terra); font-size: 18px; }
.steps-mini p { margin: 0; }
.foot { font-size: 13px; color: var(--muted); border-top: 1px solid var(--hair); padding-top: 14px; }

/* Admin */
.admin-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.tree { list-style: none; margin: 0; padding: 0; display: grid; }
.tree .tree { padding-left: 22px; border-left: 1px solid var(--hair); margin-left: 8px; }
.g-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 0; border-top: 1px solid var(--hair); align-items: center; }
.g-row .g-title { font-weight: 600; text-decoration: none; color: var(--ink); }
.g-row .g-title:hover { color: var(--terra); }
.g-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; grid-column: 1 / -1; }
.g-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.g-actions .toggle { font-size: 12px; min-height: 36px; }
