@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/instrument-sans.woff2") format("woff2-variations");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: oklch(1 0 0);
  --group: oklch(0.968 0.004 200);
  --group-press: oklch(0.94 0.006 200);
  --line: oklch(0.91 0.006 200);
  --ink: oklch(0.21 0.015 200);
  --muted: oklch(0.47 0.015 200);
  --faint: oklch(0.82 0.008 200);
  --brand: oklch(0.45 0.09 203);
  --on-brand: oklch(1 0 0);
  --brand-soft: oklch(0.945 0.03 203);
  --warn: oklch(0.72 0.15 70);
  --warn-ink: oklch(0.42 0.1 65);
  --warn-soft: oklch(0.96 0.045 85);
  --danger: oklch(0.5 0.17 28);
  --in: oklch(0.47 0.13 155);
  --out: oklch(0.52 0.18 27);
  --in-soft: oklch(0.72 0.14 155);
  --out-soft: oklch(0.7 0.15 27);
  --z-pop: 30;
  --tile-l: 0.94;
  --tile-c: 0.035;
  --tile-ink-l: 0.41;
  --tile-ink-c: 0.1;
  --scrim: oklch(0.2 0.02 200 / 0.42);
  --sans: "Instrument Sans", "Noto Sans Arabic", "Segoe UI", system-ui, sans-serif;
  --z-bar: 10;
  --z-dock: 20;
  --z-toast: 40;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.18 0.01 203);
    --group: oklch(0.225 0.012 203);
    --group-press: oklch(0.27 0.014 203);
    --line: oklch(0.3 0.012 203);
    --ink: oklch(0.95 0.004 200);
    --muted: oklch(0.72 0.012 200);
    --faint: oklch(0.38 0.012 203);
    --brand: oklch(0.76 0.11 200);
    --on-brand: oklch(0.18 0.02 203);
    --brand-soft: oklch(0.29 0.04 203);
    --warn: oklch(0.78 0.14 75);
    --warn-ink: oklch(0.86 0.11 80);
    --warn-soft: oklch(0.29 0.05 75);
    --danger: oklch(0.72 0.15 28);
    --in: oklch(0.8 0.15 155);
    --out: oklch(0.76 0.14 27);
    --in-soft: oklch(0.66 0.14 155);
    --out-soft: oklch(0.64 0.16 27);
    --tile-l: 0.3;
    --tile-c: 0.045;
    --tile-ink-l: 0.86;
    --tile-ink-c: 0.08;
    --scrim: oklch(0 0 0 / 0.55);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior-x: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 0.9375rem/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
svg.i { width: 1.25em; height: 1.25em; display: block; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Whatever the person typed: right order for any language, aligned with the layout. */
.free { unicode-bidi: plaintext; text-align: left; overflow-wrap: anywhere; }
.muted { color: var(--muted); }

/* Money: decimals step back so the dinars read first. */
.m { white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.m i { font-style: normal; opacity: 0.8; }
.up { color: var(--in); }
.down { color: var(--out); }
.grow { flex: 1; min-width: 0; }
.sep { color: var(--muted); margin-inline: 0.3em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  font-weight: 600; background: var(--group);
  transition: background-color 150ms;
}
.btn:hover { background: var(--group-press); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: color-mix(in oklch, var(--brand) 88%, var(--ink)); }
.btn.danger { background: none; color: var(--danger); padding-inline: 0; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 0.875rem; border-radius: 10px; }
a.btn { color: inherit; text-decoration: none; }
.today-btn { min-height: 44px; padding: 0 10px; color: var(--brand); font-weight: 600; font-size: 0.875rem; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  transition: background-color 150ms;
}
.icon-btn:hover { background: var(--group); }
.icon-btn:disabled { opacity: 0.3; cursor: default; background: none; }

input, select {
  width: 100%; min-height: 44px; padding: 0 12px;
  background: var(--group); border: 1px solid transparent; border-radius: 10px;
}
input::placeholder { color: var(--muted); opacity: 1; }
input:focus { outline: none; border-color: var(--brand); }

/* Top bar */
.top { position: sticky; top: 0; z-index: var(--z-bar); padding-top: env(safe-area-inset-top); background: var(--bg); }
.bar {
  display: flex; align-items: center; gap: 2px; min-height: 56px;
  padding: 0 8px 0 16px;
}
.bar h1 { flex: 1; font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.bar .back { margin-inline-start: -10px; }

main {
  touch-action: pan-y;
  max-width: 560px; margin: 0 auto;
  padding: 0 16px calc(84px + var(--dock-h, 64px) + env(safe-area-inset-bottom));
}
main.no-dock { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

.compare { margin: -4px 0 8px; color: var(--muted); font-size: 0.875rem; }
.compare .m { color: var(--ink); }

/* To-check strip */
.check-strip {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; margin-top: 16px;
  padding: 8px 8px 8px 12px; border-radius: 12px;
  background: var(--warn-soft); color: var(--warn-ink); font-weight: 600; text-align: left;
}
.check-strip .grow { flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 10px 0 14px;
  border-radius: 10px; background: var(--brand-soft); font-size: 0.875rem; font-weight: 600;
}
.search { margin-top: 4px; display: grid; gap: 8px; }
.search-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.search-filters label { display: grid; gap: 2px; font-size: 0.75rem; color: var(--muted); min-width: 0; }
.search-filters select { color: var(--ink); font-size: 0.875rem; }
.search-count { margin-top: 12px; min-height: 1.4em; font-size: 0.875rem; }
.search-count .m { color: var(--ink); }
.net { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 2px 8px 2px 16px; background: var(--warn-soft); color: var(--warn-ink); font-size: 0.8125rem; font-weight: 500; }
.net button { flex: none; min-height: 44px; padding: 0 8px; font-weight: 700; text-decoration: underline; }
.note-text { width: 100%; padding: 12px; margin-bottom: 8px; border: 1px solid transparent; border-radius: 12px; background: var(--group); color: var(--ink); font: inherit; resize: vertical; unicode-bidi: plaintext; }
.note-text:focus { outline: none; border-color: var(--brand); }
.sheet-hint { margin-bottom: 12px; color: var(--muted); font-size: 0.875rem; }

/* Activity list */
.day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-top: 24px; padding-bottom: 6px;
  font-size: 0.8125rem; color: var(--muted); font-weight: 500;
}
.row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: 12px; align-items: center;
  width: 100%; min-height: 60px; padding: 8px 0; text-align: left;
  border-radius: 10px; transition: background-color 120ms;
}
.row:hover { background: var(--group); box-shadow: 8px 0 0 var(--group), -8px 0 0 var(--group); }
.row:active { background: var(--group-press); box-shadow: 8px 0 0 var(--group-press), -8px 0 0 var(--group-press); }
.tile {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: oklch(var(--tile-l) var(--tile-c) var(--h, 200));
  color: oklch(var(--tile-ink-l) var(--tile-ink-c) var(--h, 200));
  font-weight: 650; font-size: 1rem;
}
.tile.plain { background: var(--group); color: var(--muted); }
.row-main { min-width: 0; }
.row-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 0.8125rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.row.flash { animation: flash 1400ms ease-out; }
@keyframes flash { from { background: var(--brand-soft); box-shadow: 8px 0 0 var(--brand-soft), -8px 0 0 var(--brand-soft); } }
.row-sub.warn { color: var(--warn-ink); }
.row-amount { font-weight: 600; font-size: 1rem; text-align: right; padding-left: 4px; }
.dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--warn); vertical-align: 1px; }

.empty { padding: 32px 0; color: var(--muted); max-width: 34ch; }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }

/* Skeleton */
.skeleton { display: grid; gap: 12px; padding-top: 8px; }
.skeleton div { height: 22px; border-radius: 6px; background: var(--group); }
.skeleton div:first-child { height: 64px; }

/* Capture dock */
.dock {
  position: fixed; z-index: var(--z-dock); inset-inline: 0;
  bottom: calc(60px + env(safe-area-inset-bottom));
  padding: 0 12px 8px; pointer-events: none;
}
.dock > * { pointer-events: auto; max-width: 536px; margin-inline: auto; }
.composer {
  display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 16px;
  background: var(--group); border: 1px solid var(--line); border-radius: 26px;
  box-shadow: 0 6px 20px oklch(0.2 0.02 200 / 0.1);
}
.composer:focus-within { border-color: var(--brand); }
.composer input { flex: 1; min-width: 0; padding: 0; background: none; border: 0; }
.composer button {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand);
  transition: opacity 150ms;
}
.composer button:disabled { opacity: 0.35; cursor: default; }
.composer.busy { opacity: 0.6; }
@keyframes pulse { to { opacity: 0.45; } }

.model-picker { display: grid; gap: 6px; color: var(--muted); }
.model-picker select { width: 100%; min-height: 48px; padding: 0 12px; border: 0; border-radius: 14px; background: var(--group); color: var(--ink); font: inherit; }
.model-picker select:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.model-note { margin: 8px 0 0; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* Tabs */
.tabs {
  position: fixed; z-index: var(--z-dock); inset-inline: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg); border-top: 1px solid var(--line);
}
.tabs button {
  position: relative; display: grid; justify-items: center; gap: 2px; height: 60px; padding-top: 9px;
  color: var(--muted); font-size: 0.71875rem; font-weight: 500;
}
.tabs button .ico { font-size: 1.125rem; }
.tabs button.on { color: var(--ink); font-weight: 600; }
.tabs button.on .ico { color: var(--brand); }
.badge {
  position: absolute; top: 5px; left: calc(50% + 7px); min-width: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--danger); color: var(--bg);
  font-size: 0.6875rem; font-weight: 700; line-height: 16px; text-align: center;
}

/* Sections */
.section { margin-top: 28px; }
.section:first-child { margin-top: 4px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-head h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }

/* Inset grouped list */
.group { background: var(--group); border-radius: 14px; overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 14px;
  text-align: left; transition: background-color 120ms;
}
button.item:hover { background: var(--group-press); }
.item + .item { border-top: 1px solid var(--line); }
.item .grow { flex: 1; min-width: 0; }
.item .value { font-weight: 600; }
.tag { font-size: 0.8125rem; color: var(--muted); font-weight: 400; }

/* Category spending */
.cat { display: grid; grid-template-columns: 40px minmax(0, 1fr) 6.25rem; column-gap: 12px; align-items: center; width: 100%; min-height: 60px; padding: 6px 0; text-align: left; }
.cat-note { display: block; margin-top: 4px; font-size: 0.75rem; color: var(--muted); }
.cat-note.over { color: var(--danger); font-weight: 600; }
.cat-fill.over { background: var(--danger); }
.cat-track { height: 4px; margin-top: 6px; border-radius: 2px; background: var(--line); }
.cat-fill { height: 100%; border-radius: 2px; background: var(--out-soft); }
.cat-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-amount { text-align: right; font-weight: 600; }
.cat-amount small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--muted); }

details { margin-top: 8px; font-size: 0.875rem; }
summary { color: var(--muted); cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; flex: none; width: 7px; height: 7px; margin-inline: 2px 3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 150ms; }
details[open] > summary::before { transform: rotate(45deg); }
.fold summary { color: var(--ink); font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.fold-action { width: 100%; margin-top: 8px; }
.loans-summary { margin-top: 8px; }
.data-actions { display: grid; gap: 8px; }
.loan-state { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.loan-state > div { display: grid; gap: 2px; padding: 10px 14px; border-radius: 12px; background: var(--group); font-weight: 600; }
.payments { margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 0; border-bottom: 1px solid var(--line); text-align: right; font-weight: 400; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); }

/* Loans */
.loan { display: block; width: 100%; min-height: 72px; padding: 12px 14px; text-align: left; transition: background-color 120ms; }
.loan:hover { background: var(--group-press); }
.loan + .loan { border-top: 1px solid var(--line); }
.loan-top { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.progress { height: 4px; margin: 8px 0 6px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress div { height: 100%; background: var(--in-soft); }
.loan .tag { display: block; }

.inbox { padding: 12px 14px; }
.inbox + .inbox { border-top: 1px solid var(--line); }
.inbox-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Sheet */
.sheet {
  width: 100%; max-width: 520px; max-height: 94dvh; margin: auto auto 0; padding: 0;
  background: var(--bg); color: var(--ink); border: 0; border-radius: 20px 20px 0 0;
}
.sheet[open] { animation: sheet-up 240ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes sheet-up { from { transform: translateY(32px); opacity: 0; } }
@media (min-width: 640px) { .sheet { margin: auto; border-radius: 20px; } }
.sheet::backdrop { background: var(--scrim); }
.sheet form { padding: 0 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-bar {
  position: sticky; top: 0; z-index: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 56px; margin: 0 -16px; padding: 0 8px; background: var(--bg);
}
.sheet-bar h2 { font-size: 1rem; font-weight: 600; }
.sheet-bar .text-btn { justify-self: start; min-height: 44px; padding: 0 8px; color: var(--muted); }
.sheet-bar .save { justify-self: end; min-height: 44px; padding: 0 8px; color: var(--brand); font-weight: 650; }
.sheet-bar .save:disabled { opacity: 0.5; }
.amount-field { display: flex; align-items: baseline; justify-content: center; gap: 8px; padding: 8px 0 16px; font-size: 2.25rem; font-weight: 600; letter-spacing: -0.02em; }
.amount-field span { color: var(--muted); font-size: 1.25rem; font-weight: 500; letter-spacing: 0; }
.amount-field input { width: min(11ch, 68vw); min-height: 52px; padding: 0 4px; background: none; border: 0; border-bottom: 2px solid var(--line); border-radius: 0; text-align: center; }
.amount-field input:focus { border-bottom-color: var(--brand); }
.amount-field[data-flow="up"] input { color: var(--in); }
.amount-field[data-flow="down"] input { color: var(--out); }

.said-quote { margin-bottom: 16px; color: var(--muted); font-size: 0.875rem; }
.notice { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 10px 10px 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn-ink); font-size: 0.875rem; font-weight: 500; }
.notice p { flex: 1; min-width: 0; }

.fields { background: var(--group); border-radius: 14px; margin-bottom: 16px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 4px 0 14px; color: var(--muted); }
.field + .field { border-top: 1px solid var(--line); }
.field > input, .field > select {
  flex: 1; min-width: 0; max-width: 70%; background: none; border: 0; border-radius: 8px;
  color: var(--ink); text-align: right; padding: 0 10px; text-align-last: right;
}
.field > input:focus, .field > select:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.field.stacked { display: grid; justify-content: stretch; gap: 4px; padding: 0; min-height: 0; }
.field.stacked > input { max-width: none; background: var(--group); text-align: left; }
.field.check { cursor: pointer; }
.field.check > input { flex: none; width: 22px; min-height: 22px; margin-right: 10px; accent-color: var(--brand); }

.items-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; font-weight: 600; }
.line-item { padding: 8px 14px 10px; }
.line-item + .line-item { border-top: 1px solid var(--line); }
.line-top { display: flex; align-items: center; gap: 4px; margin-right: -10px; }
.line-top input { flex: 1; background: none; padding: 0; font-weight: 550; }
.line-nums { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.line-nums label { display: grid; gap: 2px; font-size: 0.75rem; color: var(--muted); min-width: 0; }
.line-nums input { min-height: 44px; padding: 0 8px; background: var(--bg); text-align: right; font-size: 0.875rem; }
.items-sum { margin: -8px 0 16px; font-size: 0.8125rem; color: var(--muted); }
.items-sum.off { color: var(--warn-ink); font-weight: 600; }
.form-error { color: var(--danger); font-size: 0.875rem; margin-bottom: 8px; }
.form-error:empty { display: none; }
.sheet-actions { display: flex; gap: 8px; justify-content: space-between; }

/* Login */
.login { display: grid; gap: 16px; max-width: 320px; margin: 16vh auto 0; padding: 0 24px; }
.login img { border-radius: 14px; }
.login h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; margin-top: -4px; }
.login .field { color: var(--muted); font-size: 0.875rem; }

.toast {
  position: fixed; z-index: var(--z-toast); inset-inline: 16px; top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 480px; margin: auto; padding: 8px 8px 8px 14px; min-height: 44px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 0.875rem;
}
.toast button { flex: none; min-height: 44px; padding: 0 10px; color: inherit; font-weight: 700; text-decoration: underline; }

/* On a big screen the app stays one comfortable column, tabs included. */
@media (min-width: 760px) {
  .tabs { padding-inline: calc((100vw - 560px) / 2); }
  .bar { padding-inline: calc((100vw - 560px) / 2 + 16px) calc((100vw - 560px) / 2 + 8px); }
}

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

/* Fade the list out behind the composer. */
.dock::before {
  content: ""; position: absolute; inset: -20px 0 0; z-index: -1; pointer-events: none;
  background: linear-gradient(transparent, var(--bg) 20px);
}

/* Recording */
.recorder { padding-left: 4px; gap: 6px; }
.composer .rec-cancel { background: none; color: var(--muted); }
.composer .rec-cancel:hover { background: var(--group-press); }
.rec-wave { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 2px; height: 32px; }
.rec-wave span { flex: 1; max-width: 4px; min-height: 3px; border-radius: 2px; background: var(--brand); transition: height 90ms linear; }
.rec-time { display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; font-weight: 600; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 900ms ease-in-out infinite alternate; }

/* Touch screens keep :hover after a tap, which would leave rows looking selected. */
@media (hover: none) {
  .row:hover { background: none; box-shadow: none; }
  .row:active { background: var(--group-press); box-shadow: 8px 0 0 var(--group-press), -8px 0 0 var(--group-press); }
  button.item:hover, .loan:hover, .icon-btn:hover { background: none; }
}

/* Account picker, top left */
.acct { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; max-width: 62vw; margin-inline-start: -8px; padding: 0 8px; border-radius: 10px; font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.acct:hover { background: var(--group); }
.acct svg { flex: none; width: 1.05em; height: 1.05em; color: var(--muted); }
.acct-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: fixed; inset: auto; margin: 0; padding: 4px; width: min(300px, calc(100vw - 16px)); background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 36px oklch(0.2 0.02 200 / 0.2); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 46px; padding: 0 10px 0 6px; border-radius: 10px; text-align: left; }
.menu-item:hover { background: var(--group); }
.menu-item.on { font-weight: 600; }
.menu-item.manage { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; margin-top: 4px; color: var(--muted); font-size: 0.875rem; }
.menu-check { flex: none; width: 22px; display: grid; place-items: center; color: var(--brand); }
.menu-check svg { width: 1.05em; height: 1.05em; }
.menu-value { font-size: 0.875rem; font-weight: 500; color: var(--muted); }
.menu-value.down { color: var(--out); }

/* Tooltips */
.tip-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; margin: -6px -4px; vertical-align: middle; color: var(--muted); border-radius: 50%; }
.tip-btn svg { width: 16px; height: 16px; }
.tip-btn:hover { color: var(--ink); }
.tip { position: fixed; inset: auto; margin: 0; max-width: min(300px, calc(100vw - 24px)); padding: 10px 12px; background: var(--ink); color: var(--bg); border: 0; border-radius: 10px; font-size: 0.8125rem; line-height: 1.4; box-shadow: 0 8px 24px oklch(0.2 0.02 200 / 0.25); }
.label-row { display: flex; align-items: center; gap: 6px; min-height: 32px; margin-bottom: 8px; color: var(--muted); font-size: 0.875rem; }
.add-row { display: flex; align-items: center; gap: 12px; }

/* Overview */
.ov { margin-top: 2px; }
.ov-head { display: flex; align-items: center; gap: 2px; min-height: 40px; }
.ov-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.ov-toggle svg { width: 1em; height: 1em; transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1); }
.ov-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.ov-now { min-height: 40px; padding: 0 2px; color: var(--brand); font-size: 0.8125rem; font-weight: 600; }
.ov-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ov-tile { display: grid; gap: 2px; min-width: 0; padding: 8px 8px 7px; border: 1px solid transparent; border-radius: 12px; background: var(--group); text-align: left; transition: background-color 150ms, border-color 150ms; }
.ov-tile.on { border-color: var(--brand); background: var(--brand-soft); }
.ov-name { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-line { display: flex; justify-content: space-between; gap: 4px; font-size: min(0.75rem, 3.15vw); font-weight: 550; }
.ov-line > span:first-child { color: var(--muted); font-weight: 450; }
.ov-line .m i { opacity: 0.72; }
.ov-bars { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); height: 92px; margin-top: 12px; border-bottom: 1px solid var(--line); touch-action: pan-y; cursor: pointer; user-select: none; }
.ov-b { display: flex; align-items: flex-end; justify-content: center; gap: 1px; height: 100%; border-radius: 6px 6px 0 0; }
.ov-b.pick { background: var(--brand-soft); }
.ov-b i { display: block; flex: 1; max-width: 9px; min-height: 0; border-radius: 2px 2px 0 0; }
.ov-b .in { background: var(--in-soft); }
.ov-b .out { background: var(--out-soft); }
.ov-labels { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); margin-top: 3px; font-size: 0.6875rem; color: var(--muted); text-align: center; }
.ov-labels span { white-space: nowrap; overflow: visible; display: flex; justify-content: center; }
.ov-labels .pick { color: var(--ink); font-weight: 700; }
.ov-read { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 0.8125rem; color: var(--muted); }
.ov-read-name { color: var(--ink); font-weight: 600; }
.ov-net { font-weight: 600; }

/* Note being worked on */
.pending { position: relative; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; padding: 12px 14px 14px; overflow: hidden; background: var(--group); border: 1px solid var(--line); box-shadow: 0 8px 28px oklch(0.2 0.02 200 / 0.14); border-radius: 16px; font-size: 0.875rem; animation: rise 200ms cubic-bezier(0.22, 1, 0.36, 1); }
.pending-main { flex: 1; min-width: 0; }
.pending-label { font-weight: 600; }
.pending-time { font-weight: 400; opacity: 0.75; }
.pending-text { margin-top: 2px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spinner { flex: none; width: 18px; height: 18px; margin-top: 1px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 800ms linear infinite; }
.pending-bar { position: absolute; inset: auto 0 0; height: 3px; overflow: hidden; }
.pending-bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; background: var(--brand); border-radius: 2px; animation: slide 1300ms cubic-bezier(0.45, 0, 0.55, 1) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.busybar { position: fixed; z-index: var(--z-toast); inset: 0 0 auto; height: 2px; overflow: hidden; }
.busybar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; background: var(--brand); animation: slide 1100ms cubic-bezier(0.45, 0, 0.55, 1) infinite; }
@media (prefers-reduced-motion: reduce) {
  .spinner { border-top-color: var(--line); }
  .pending-bar::before, .busybar::before { width: 100%; opacity: 0.5; }
}

/* The next page beside the one being swiped */
.swipe-ghost { position: fixed; bottom: 0; z-index: 1; padding: 0 16px; overflow: hidden; background: var(--bg); pointer-events: none; will-change: transform; max-width: none; margin: 0; }

/* Lines of a reply */
.reply-line { display: block; text-align: left; overflow-wrap: anywhere; }
.reply-gap { display: block; height: 0.6em; }

/* People under a name field */
.people { display: flex; gap: 6px; align-items: center; padding: 2px 12px 10px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.people::-webkit-scrollbar { display: none; }
.people.empty-row { display: none; }
.person-chip { flex: none; min-height: 36px; padding: 0 12px; border-radius: 18px; background: var(--bg); font-size: 0.875rem; font-weight: 500; white-space: nowrap; }
.person-chip.on { background: var(--brand); color: var(--on-brand); }
.people-new { flex: none; color: var(--muted); font-size: 0.8125rem; padding-inline-start: 2px; }

/* What came back from a note */
.result { display: flex; flex-direction: column; max-height: min(62dvh, 560px); margin-bottom: 8px; overflow: hidden; background: var(--group); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 28px oklch(0.2 0.02 200 / 0.14); font-size: 0.875rem; animation: rise 200ms cubic-bezier(0.22, 1, 0.36, 1); }
.r-head { flex: none; display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding-inline-start: 14px; }
.r-heading { font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.result-ok .r-heading { color: var(--in); }
.result-failed .r-heading, .result-error .r-heading, .result-ignored .r-heading { color: var(--warn-ink); }
.r-close { display: grid; place-items: center; width: 44px; height: 40px; color: var(--muted); }
.r-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.r-section { display: flex; align-items: flex-start; gap: 2px; padding: 10px 0 10px 14px; border-top: 1px solid var(--line); }
.r-main { flex: 1; min-width: 0; }
.r-gear { flex: none; display: grid; place-items: center; width: 44px; height: 40px; margin-block: -6px; color: var(--muted); }
.r-gear svg { width: 18px; height: 18px; }
.r-gear:active { color: var(--brand); }
.r-label { font-size: 0.75rem; color: var(--muted); }
.r-transcript { margin-top: 3px; font-size: 0.9375rem; line-height: 1.45; }
.r-entry-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.r-kind { font-size: 0.75rem; color: var(--muted); }
.r-amount { font-size: 1.0625rem; font-weight: 650; }
.r-title { margin-top: 1px; font-size: 0.9375rem; font-weight: 550; line-height: 1.35; }
.r-meta { margin-top: 2px; font-size: 0.8125rem; color: var(--muted); text-align: left; }
.r-items { margin: 8px 0 0; padding: 0; list-style: none; border-top: 1px dashed var(--line); }
.r-items li { display: flex; justify-content: space-between; gap: 12px; padding-top: 6px; font-size: 0.8125rem; }
.r-item-name { min-width: 0; overflow-wrap: anywhere; }
.r-qty { color: var(--muted); }
.r-loan { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--line); font-size: 0.8125rem; color: var(--muted); }
.r-loan .m { color: var(--ink); font-weight: 600; }
.r-warn { margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn-ink); font-size: 0.8125rem; font-weight: 500; }
.r-message { padding-inline-end: 14px; }
.r-foot { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); }
.r-reject, .r-accept { min-height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 600; }
.r-reject { color: var(--muted); }
.r-accept { background: var(--brand); color: var(--on-brand); }

/* What someone wrote, once its direction has been worked out */
.free[dir] { unicode-bidi: isolate; }
.r-transcript, .said-quote, .r-message, .reply-line[dir="rtl"], .inbox p[dir], .waiting-text { text-align: start; }

/* Waiting notes */
.waiting { display: grid; gap: 4px; padding: 12px 14px; }
.waiting + .waiting { border-top: 1px solid var(--line); }
.waiting audio { width: 100%; height: 40px; }
.waiting-error { color: var(--warn-ink); }
.plain-btn { background: none; }

/* Loan entries */
.payments .item svg { flex: none; width: 1em; height: 1em; color: var(--muted); }
.loan-locked { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--muted); font-weight: 600; }
