:root {
  --bg: #0a0a0a;
  --fg: #e6e6e6;
  --dim: #8a8a8a;
  --faint: #3a3a3a;
  --line: #262626;
  --accent: #ffffff;
  --pos: #7ee787;
  --neg: #ff7b72;
  --warn: #e3b341;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; color: var(--fg); font: 14px/1.5 var(--mono); -webkit-text-size-adjust: 100%; }
html { background: var(--bg); }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
.top { background: var(--bg); display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: 0.02em; }
.tag { color: var(--dim); font-size: 12px; }
main { background: var(--bg); max-width: 760px; margin: 0 auto; padding: 24px 16px 80px; }
h1 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 12px; font-weight: 400; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; margin: 28px 0 8px; }
p { margin: 0 0 12px; color: var(--dim); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .dim { color: var(--dim); }
input, select, textarea, button { font: inherit; color: inherit; background: transparent; border: 1px solid var(--faint); border-radius: 2px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--fg); }
textarea { width: 100%; min-height: 64px; resize: vertical; }
input[type="file"] { border: 1px dashed var(--faint); width: 100%; padding: 18px 10px; }
label { display: block; color: var(--dim); font-size: 12px; margin: 14px 0 4px; }
button { cursor: pointer; border-color: var(--fg); }
button:hover { background: var(--fg); color: var(--bg); }
button:disabled { opacity: 0.4; cursor: default; }
button.ghost { border-color: var(--faint); color: var(--dim); }
button.ghost:hover { background: var(--faint); color: var(--fg); }
button.danger { border-color: var(--neg); color: var(--neg); }
button.danger:hover { background: var(--neg); color: var(--bg); }
.actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 400; color: var(--dim); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th.num, td.num { text-align: right; }
tr.link { cursor: pointer; } tr.link:hover td { background: #111; }
.list > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.err { color: var(--neg); border: 1px solid var(--neg); padding: 8px 10px; margin: 12px 0; }
.warn { color: var(--warn); border: 1px solid var(--warn); padding: 8px 10px; margin: 12px 0; }
.banner { color: var(--warn); border-bottom: 1px solid var(--warn); padding: 6px 16px; margin: -24px -16px 20px; font-size: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--faint); padding: 2px 8px; border-radius: 2px; cursor: text; }
.chip input { border: none; padding: 0; width: 8ch; }
.code { color: var(--dim); font-size: 12px; }
/* split grid */
.gridwrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.grid td.cell, .grid th.cell { padding: 4px; }
.grid input.cell { width: 100%; min-width: 9ch; border-color: transparent; padding: 6px 4px; }
.grid input.cell:hover, .grid input.cell:focus { border-color: var(--faint); }
.grid input.cell.num { min-width: 7ch; text-align: right; }
.grid th.tog, .grid td.tog { text-align: center; width: 44px; }
.grid td.tog { padding: 0; }
.grid th:first-child, .grid td:first-child { position: sticky; left: 0; background: var(--bg); z-index: 1; }
.grid th.tog { writing-mode: horizontal-tb; transform: none; height: auto; font-size: 11px; padding: 6px 2px; max-width: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.w { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; width: 44px; height: 44px; padding: 0; border: none; background: none; display: grid; place-items: center; }
button.w .dot { width: 30px; height: 30px; border-radius: 50%; border: 1px solid #666; display: grid; place-items: center; color: var(--fg); }
button.w.on .dot { border-color: var(--fg); }
button.w.auto .dot { border-style: dashed; color: var(--dim); }
button.w:hover { background: none; color: var(--fg); } button.w:hover .dot { background: var(--faint); }
button.x { border: none; color: var(--dim); padding: 4px 8px; min-width: 44px; height: 44px; } button.x:hover { color: var(--neg); background: none; }
.totals { margin-top: 12px; }
.receipt img { max-width: 100%; border: 1px solid var(--line); margin-top: 8px; }
.busy { color: var(--dim); } .busy::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { to { content: '...'; } }
@media (max-width: 480px) { main { padding: 16px 12px 80px; } .banner { margin: -16px -12px 16px; } .gridwrap { margin: 0 -12px; padding: 0 12px; } }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* enter and stagger only play on navigation (#app.enter), never on in-place re-renders */
#app.enter > :not(.banner) { animation: rise 220ms cubic-bezier(.2,.7,.2,1) both; }
#app.enter .stagger > * { animation: rise 260ms cubic-bezier(.2,.7,.2,1) backwards; animation-delay: calc(var(--i, 0) * 30ms); }
button.w .dot { transition: border-color 150ms, color 150ms; }
button.w.pop .dot { animation: pop 180ms cubic-bezier(.2,.8,.3,1.3); }
.num[data-total], #subtotal, #total, .num[data-key] { transition: color 150ms; }
#copy { transition: opacity 150ms; } #copy.swap { opacity: 0; }
.arrow { display: inline-block; width: 2.5ch; height: 1px; background: var(--dim); vertical-align: middle; margin: 0 6px; transform-origin: left; }
#app.enter .arrow { animation: draw 300ms cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 30ms + 120ms); }
.scanwrap { width: fit-content; max-width: 100%; position: relative; overflow: hidden; border: 1px solid var(--line); margin-top: 12px; }
.scanwrap img { display: block; max-width: 100%; opacity: 0.55; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- grid v2 ---------- */
.seg button { border-color: var(--faint); color: var(--dim); } .seg button.on { border-color: var(--fg); color: var(--fg); }
button.small { padding: 2px 8px; font-size: 12px; }
@media (max-width: 767px) { input, select, textarea { font-size: 16px; } }

/* ---------- fx v3 ---------- */
.fx-dots { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.fx-stars { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.starfield { position: relative; } .starfield > :not(.fx-stars) { position: relative; z-index: 1; }
.orbital { position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; transform: translate(-50%, -50%); }
.orbital .ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--dim); }
.orbital .ring.outer { border-color: transparent; border-top-color: var(--fg); animation: spin 1.4s linear infinite; }
.orbital .ring.inner { inset: 12px; opacity: 0.6; }
.orbital .p { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: var(--fg); transform-origin: 0 0; }
.orbital .p1 { animation: orbit 1.1s linear infinite; } .orbital .p2 { animation: orbit 1.7s linear infinite reverse; } .orbital .p3 { animation: orbit 2.3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes orbit { from { transform: rotate(0) translateX(24px); } to { transform: rotate(360deg) translateX(24px); } }
.odo { display: inline-flex; font-variant-numeric: tabular-nums; } .odo-col { display: inline-block; height: 1.5em; overflow: hidden; vertical-align: bottom; }
.odo-strip { display: inline-block; white-space: pre; line-height: 1.5em; transition: transform 500ms cubic-bezier(.2,.7,.2,1); }
tr.reveal { transform: perspective(600px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)); transition: transform 120ms; transform-style: preserve-3d; position: relative; }
tr.reveal td:first-child::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at var(--gx, 50%) 50%, rgba(255,255,255,0.06), transparent 60%); opacity: 0; transition: opacity 150ms; }
tr.reveal:hover td:first-child::after { opacity: 1; }
tr.reveal .shares { display: block; color: var(--dim); font-size: 12px; max-height: 0; overflow: hidden; opacity: 0; transition: max-height 200ms, opacity 200ms; }
tr.reveal:hover .shares, tr.reveal:focus-within .shares, tr.reveal.open .shares { max-height: 3em; opacity: 1; }
@media (prefers-reduced-motion: reduce) { .orbital .ring.outer, .orbital .p { animation: none; } tr.reveal { transform: none; } }

/* ---------- trip home v3 ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 8px; }
.tile { background: var(--bg); padding: 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .lbl { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; } .tile .val { font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .tile .sub { color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr 1fr; } .tile .val { font-size: 17px; } }
.badge { font-size: 12px; } #members .name { cursor: text; flex: 1; } .preset { min-height: 32px; }
.list .addrow input { flex: 1; min-width: 0; } .list input.rename { padding: 0 4px; }
.seg.small button { padding: 2px 8px; font-size: 12px; }
#members > div { align-items: baseline; }

/* ---------- landing v3 ---------- */
.card { background: var(--bg); border: 1px solid var(--line); padding: 20px; }
.card form > label:first-child { margin-top: 0; }
#mlist > div { align-items: center; padding: 0 0 0 0; }
#mlist .name { padding: 8px 0; overflow-wrap: anywhere; }
#mlist .addrow { border-bottom: none; padding-top: 8px; }

/* ---------- split controls v3 ---------- */
.splitrow { align-items: center; } .splitrow .row { gap: 6px; flex-wrap: nowrap; justify-content: flex-end; }
#remaining { min-height: 1.5em; margin-top: 6px; } #remaining.warn-text { color: var(--warn); }
.spread > .seg.small { flex-shrink: 0; }
#payer { min-width: 0; max-width: 100%; }
