/* ============================================================
   TravelExpense — mobile web. Calm "nagomi" identity:
   warm paper, muted teal accent, soft cards. Light + dark.
   ============================================================ */

:root {
  --bg: #F4F1EA;
  --surface: #FFFFFF;
  --surface-2: #FBFAF6;
  --surface-sunk: #EEEAE0;
  --ink: #22302D;
  --ink-soft: #5C6B67;
  --muted: #8A958F;
  --line: #E4DFD3;
  --line-strong: #D6CFBF;
  --accent: #2E7D6B;
  --accent-ink: #1C5346;
  --accent-soft: #DCEAE5;
  --accent-contrast: #FFFFFF;
  --warn: #B4702A;
  --warn-soft: #F3E6D3;
  --danger: #C0483B;
  --danger-soft: #F5E0DC;
  --shadow: 0 1px 2px rgba(34, 48, 45, .06), 0 8px 24px -14px rgba(34, 48, 45, .30);
  --shadow-sheet: 0 -4px 24px -8px rgba(34, 48, 45, .28);
  --rad: 16px;
  --rad-sm: 10px;
  --rad-pill: 999px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 480px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181A;
    --surface: #1C2225;
    --surface-2: #20272A;
    --surface-sunk: #262E31;
    --ink: #E8ECEA;
    --ink-soft: #A7B2AE;
    --muted: #7E8A86;
    --line: #2C3438;
    --line-strong: #3A4448;
    --accent: #5FB3A0;
    --accent-ink: #8FD3C3;
    --accent-soft: #1F332E;
    --accent-contrast: #10201C;
    --warn: #D69A5A;
    --warn-soft: #322A1E;
    --danger: #E0796C;
    --danger-soft: #33211E;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -14px rgba(0, 0, 0, .6);
    --shadow-sheet: 0 -4px 24px -8px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100dvh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.app { max-width: var(--maxw); margin: 0 auto; min-height: 100dvh; position: relative; }
.tabnums { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.soft { color: var(--ink-soft); }

/* ============ App bar ============ */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar .back {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: var(--rad-pill); font-size: 1.1rem; color: var(--accent);
}
.appbar .title { flex: 1; min-width: 0; }
.appbar .title h1 {
  font-size: 1.18rem; font-weight: 800; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar .title .sub { font-size: .72rem; color: var(--muted); margin-top: 1px; }
.appbar .actions { display: flex; gap: 6px; flex: none; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: var(--rad-pill); color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--line); font-size: 1.05rem;
}
.icon-btn:active { transform: scale(.94); }

.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 1.05rem;
}
.brand h1 { font-size: 1.28rem; font-weight: 800; letter-spacing: -.02em; }
.brand .sub { font-size: .68rem; color: var(--muted); letter-spacing: .02em; }

/* ============ Scroll body ============ */
.page { padding: 16px 16px calc(120px + env(safe-area-inset-bottom)); }
.page.tight { padding-top: 12px; }

/* ============ Section + labels ============ */
.section-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 18px 2px 8px;
}
.section-label:first-child { margin-top: 4px; }

/* ============ Cards ============ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--rad); box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

/* Trip card */
.trip-card { padding: 16px; display: block; width: 100%; text-align: left; color: inherit; }
.trip-card:active { transform: scale(.99); }
.trip-card .tc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.trip-card h3 { font-size: 1.08rem; font-weight: 800; letter-spacing: -.01em; }
.trip-card .tc-total { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trip-card .tc-dates { font-size: .8rem; color: var(--ink-soft); margin-top: 3px; }
.trip-card .tc-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.cur-chip {
  font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  padding: 3px 8px; border-radius: var(--rad-pill);
  background: var(--surface-sunk); color: var(--ink-soft);
}
.cur-chip.accent { background: var(--accent-soft); color: var(--accent-ink); }
.tc-people { font-size: .74rem; color: var(--muted); }

/* ============ Empty state ============ */
.empty { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty .emoji { font-size: 2.6rem; }
.empty h2 { font-size: 1.1rem; font-weight: 700; color: var(--ink); margin: 14px 0 6px; }
.empty p { font-size: .88rem; max-width: 260px; margin: 0 auto; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 16px; border-radius: var(--rad);
  font-weight: 700; font-size: 1rem; letter-spacing: .01em;
  transition: transform .06s ease, opacity .15s ease;
  border: 1px solid transparent;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-row { display: flex; gap: 10px; }
.btn-sm { width: auto; padding: 9px 14px; font-size: .86rem; border-radius: var(--rad-sm); }
.btn-block + .btn-block { margin-top: 10px; }

/* Floating action area (trip list) */
.fab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 34%);
  pointer-events: none;
}
.fab-bar .inner { max-width: var(--maxw); margin: 0 auto; display: flex; gap: 10px; pointer-events: auto; }
.fab-bar .btn { flex: 1; box-shadow: var(--shadow); }
.fab-bar .btn-ghost { flex: none; width: 52px; padding: 0; }

/* ============ Forms ============ */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: .8rem; font-weight: 600; color: var(--ink-soft); margin: 0 2px 6px; }
.input, .select, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: var(--rad-sm);
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: 1rem;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); outline: none; }
.select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A958F' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.row-2 { display: flex; gap: 10px; }
/* min-width:0 is load-bearing: iOS Safari gives date inputs a large intrinsic
   width, and flex items refuse to shrink below it, pushing the End field off
   the right edge of the screen. */
.row-2 > * { flex: 1; min-width: 0; }
/* iOS renders date inputs as centered buttons with intrinsic sizing; normalize
   them to behave like our text inputs. */
input[type='date'].input, input[type='datetime-local'].input {
  -webkit-appearance: none; appearance: none;
  display: block; min-width: 0; min-height: 47px; text-align: left;
}
.input-error, .input-error:focus { border-color: var(--danger); }
.field-error { font-size: .76rem; color: var(--danger); margin: 6px 2px 0; }
.hint { font-size: .76rem; color: var(--muted); margin: 6px 2px 0; }
.hint.warn { color: var(--warn); }

.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad); padding: 14px; box-shadow: var(--shadow); }
.form-card + .form-card { margin-top: 14px; }

/* amount + currency combined */
.amount-row { display: flex; gap: 10px; }
.amount-row .input { flex: 1; font-variant-numeric: tabular-nums; }
.amount-row .select { width: 108px; flex: none; }

/* FX rate rows */
.fx-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.fx-row .fx-code { font-weight: 700; font-size: .9rem; white-space: nowrap; }
.fx-row .input { flex: 1; text-align: right; font-variant-numeric: tabular-nums; }
.fx-row .fx-main { color: var(--muted); font-size: .85rem; }
.remove-btn { color: var(--danger); font-size: 1.2rem; display: grid; place-items: center; width: 30px; height: 30px; }

/* member rows */
.member-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: none; }
.member-row .m-icon { color: var(--accent); }
.member-row .m-name { flex: 1; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row .input { flex: 1; }

/* ============ Chips ============ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .84rem; font-weight: 600;
  padding: 8px 14px; border-radius: var(--rad-pill);
  background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--ink-soft);
  transition: transform .06s ease;
}
.chip:active { transform: scale(.95); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.chip.chip-all { border-style: dashed; }
.chip.chip-all.on { border-style: solid; }
.chip .x { color: inherit; opacity: .6; font-size: .95rem; margin-left: 2px; }
.chip.removable { padding-right: 8px; }

/* ============ Tabs (segmented) ============ */
.segmented {
  display: flex; gap: 2px; padding: 3px; margin: 12px 16px 0;
  background: var(--surface-sunk); border-radius: var(--rad-sm);
}
.segmented button {
  flex: 1; padding: 8px; border-radius: 8px; font-size: .88rem; font-weight: 600; color: var(--ink-soft);
}
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 700; }

/* ============ Ledger ============ */
.ledger-tools { padding: 10px 16px 0; }
.search {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: var(--surface-sunk); border-radius: var(--rad-sm); border: 1px solid transparent;
}
.search input { flex: 1; background: none; border: none; outline: none; font-size: .95rem; }
.search .s-ic { color: var(--muted); }
.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; flex: none;
  font-size: .82rem; font-weight: 600; padding: 7px 12px; border-radius: var(--rad-pill);
  background: var(--surface-sunk); color: var(--ink-soft); border: 1px solid transparent;
}
.filter-chip.active { background: var(--accent-soft); color: var(--accent-ink); }
.filter-chip .count {
  font-size: .68rem; font-weight: 800; background: var(--accent); color: var(--accent-contrast);
  border-radius: var(--rad-pill); padding: 0 6px; min-width: 16px; text-align: center;
}
.filter-chip.clear { color: var(--danger); }

.sort-bar { display: flex; align-items: center; gap: 8px; padding: 4px 16px 8px; font-size: .78rem; color: var(--muted); }
.sort-bar .select { width: auto; padding: 6px 30px 6px 10px; font-size: .8rem; border-radius: var(--rad-pill); background-color: var(--surface-sunk); border-color: transparent; }
.sort-dir { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--rad-pill); background: var(--surface-sunk); color: var(--ink-soft); }

.exp-list { padding: 4px 16px; }
.exp-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.exp-row .cat-ic {
  width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-sunk); font-size: 1.15rem;
}
.exp-main { flex: 1; min-width: 0; }
.exp-main .e-desc { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-main .e-sub { font-size: .76rem; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }
.exp-amt { text-align: right; flex: none; }
.exp-amt .e-main { font-weight: 700; font-variant-numeric: tabular-nums; }
.exp-amt .e-orig { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.type-tag { font-size: .64rem; font-weight: 700; padding: 1px 6px; border-radius: var(--rad-pill); text-transform: uppercase; letter-spacing: .03em; }
.type-Shared { background: var(--accent-soft); color: var(--accent-ink); }
.type-Custom { background: var(--warn-soft); color: var(--warn); }
.type-Personal { background: var(--surface-sunk); color: var(--ink-soft); }

/* add-expense FAB inside trip detail */
.add-fab {
  position: fixed; right: max(16px, calc((100vw - var(--maxw)) / 2 + 16px));
  bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 20;
  width: 58px; height: 58px; border-radius: var(--rad-pill);
  background: var(--accent); color: var(--accent-contrast); font-size: 1.7rem;
  display: grid; place-items: center; box-shadow: 0 6px 20px -6px rgba(34,48,45,.5);
}
.add-fab:active { transform: scale(.94); }

/* ============ Summary ============ */
.sum-section { margin-bottom: 12px; }
.sum-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad);
  box-shadow: var(--shadow);
}
.sum-head .chev { color: var(--muted); font-size: .85rem; transition: transform .2s ease; }
.sum-head.open .chev { transform: rotate(90deg); }
.sum-head .st { font-size: 1.05rem; font-weight: 800; flex: 1; text-align: left; }
.sum-head .sv { font-weight: 800; font-variant-numeric: tabular-nums; }
.sum-body { padding: 4px 4px 8px; }
.sub-label { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 12px 6px; }
.sum-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; color: inherit;
}
.sum-row:last-child { border-bottom: none; }
.sum-row .sr-name { flex: 1; min-width: 0; }
.sum-row .sr-amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.sum-row .sr-drill { color: var(--muted); font-size: .8rem; }
.settle-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.settle-row:last-child { border-bottom: none; }
.settle-row .who { font-weight: 700; }
.settle-row .arr { color: var(--accent); }
.settle-row .amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.settle-row.balanced .amt { font-weight: 500; font-size: .8rem; color: var(--muted); }
.settle-toggle { width: 100%; }
.contrib { padding: 8px 12px 12px 40px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.contrib .cl { padding: 6px 0; border-bottom: 1px dotted var(--line); }
.contrib .cl:last-child { border-bottom: none; }
.contrib .cl-top { display: flex; justify-content: space-between; gap: 8px; font-size: .84rem; }
.contrib .cl-sub { display: flex; justify-content: space-between; gap: 8px; font-size: .74rem; color: var(--muted); margin-top: 2px; }
.contrib .cl-net { display: flex; justify-content: space-between; font-size: .78rem; font-weight: 700; padding-top: 8px; color: var(--ink-soft); }
.per-person { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-variant-numeric: tabular-nums; }
.per-person .pp-amt { font-weight: 700; }

.placeholder-tab { text-align: center; padding: 60px 24px; color: var(--muted); }
.placeholder-tab .emoji { font-size: 2.2rem; }
.placeholder-tab h3 { font-weight: 700; color: var(--ink); margin: 12px 0 6px; }

/* ============ Chat tab ============ */
.chat-feed {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px calc(96px + env(safe-area-inset-bottom));
}
.chat-empty { text-align: center; color: var(--muted); padding: 48px 20px 24px; }
.chat-empty .emoji { font-size: 2.2rem; }
.chat-empty h3 { font-weight: 700; color: var(--ink); margin: 10px 0 6px; }
.chat-empty p { font-size: .86rem; max-width: 280px; margin: 0 auto; }

.bubble-line { display: flex; }
.bubble-line.right { justify-content: flex-end; }

.bubble-user {
  max-width: 80%; padding: 9px 13px; border-radius: 16px 16px 4px 16px;
  background: var(--accent); color: var(--accent-contrast); font-size: .95rem;
  overflow-wrap: anywhere;
}
.bubble-photo {
  max-width: 62%; border-radius: 16px 16px 4px 16px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.bubble-photo img { display: block; width: 100%; height: auto; }

.bubble-reading {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 16px 16px 16px 4px;
  background: var(--surface-sunk); color: var(--ink-soft); font-size: .88rem;
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bubble-error {
  display: flex; align-items: center; gap: 8px; max-width: 88%;
  padding: 10px 12px; border-radius: 14px;
  background: var(--warn-soft); color: var(--warn); font-size: .88rem;
  border: 1px solid transparent; cursor: pointer; text-align: left;
}
.bubble-error:active { transform: scale(.99); }
.bubble-error .ic { flex: none; }
.bubble-error span:nth-child(2) { flex: 1; }
.bubble-error .dismiss { flex: none; opacity: .6; font-weight: 700; }

/* Confirmed expense bubble (ports ExpenseBubble.swift) */
.bubble-expense {
  display: flex; align-items: flex-start; gap: 10px; max-width: 92%;
  padding: 10px 12px; border-radius: 14px 14px 14px 4px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.bubble-expense .eb-ic {
  width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); font-size: 1.05rem;
}
.bubble-expense .eb-body { flex: 1; min-width: 0; }
.eb-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.eb-top .eb-desc { font-weight: 700; overflow-wrap: anywhere; }
.eb-top .eb-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.eb-sub { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.eb-sub .approx { font-variant-numeric: tabular-nums; }
.eb-when { font-size: .72rem; color: var(--muted); margin-top: 3px; }
.eb-note { font-size: .8rem; color: var(--ink-soft); margin-top: 3px; }

/* Draft bubble (ports DraftBubble.swift) */
.draft-card {
  width: 100%; max-width: 96%;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 16px;
  box-shadow: var(--shadow); padding: 14px;
}
.draft-card .field:last-of-type { margin-bottom: 0; }
.draft-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.draft-head .dh-ic { font-size: 1.1rem; }
.draft-head .dh-title { font-weight: 800; flex: 1; }
.draft-head .dh-x { color: var(--muted); font-size: 1rem; padding: 4px; }
.draft-card .dp-preview { min-height: 1em; }
.draft-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Input bar (fixed to bottom; FAB is hidden on the chat tab) */
.chat-input {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
}
.chat-input .ci-btn {
  flex: none; width: 42px; height: 42px; border-radius: var(--rad-pill);
  display: grid; place-items: center; font-size: 1.2rem;
  background: var(--surface-sunk); color: var(--ink-soft);
}
.chat-input .ci-btn:active { transform: scale(.94); }
.chat-input .ci-text {
  flex: 1; min-width: 0; padding: 11px 14px; border-radius: 20px;
  background: var(--surface-sunk); border: 1px solid transparent; font-size: .95rem; outline: none;
}
.chat-input .ci-text:focus { border-color: var(--accent); }
.chat-input .ci-send {
  flex: none; width: 42px; height: 42px; border-radius: var(--rad-pill);
  display: grid; place-items: center; font-size: 1.25rem; font-weight: 700;
  background: var(--accent); color: var(--accent-contrast);
}
.chat-input .ci-send:active { transform: scale(.94); }
.chat-input .ci-send[disabled] { opacity: .4; pointer-events: none; }

/* ============ Sheets / dialogs / toast ============ */
.scrim { position: fixed; inset: 0; background: rgba(20, 24, 26, .5); z-index: 40; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: var(--maxw); margin: 0 auto;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-sheet);
  max-height: 92dvh; display: flex; flex-direction: column; animation: slideup .22s ease;
}
.sheet .grabber { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 10px auto 4px; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 6px 16px 12px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h2 { flex: 1; font-size: 1.05rem; font-weight: 800; }
.sheet-head .link { color: var(--accent); font-weight: 700; font-size: .95rem; padding: 4px; }
.sheet-head .link.muted { color: var(--muted); }
.sheet-body { padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; }

.dialog {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 42;
  width: min(340px, calc(100vw - 48px)); background: var(--surface); border-radius: var(--rad);
  padding: 22px 20px 18px; box-shadow: var(--shadow); animation: pop .16s ease;
}
.dialog h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 6px; }
.dialog p { font-size: .9rem; color: var(--ink-soft); margin-bottom: 18px; }
.dialog .btn-row { margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: var(--rad-pill);
  font-size: .88rem; font-weight: 600; box-shadow: var(--shadow); animation: fade .18s ease; max-width: 84vw; text-align: center;
}

@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.96); } }

/* preview list (import) */
.preview-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.preview-row:last-child { border-bottom: none; }
.preview-row .pr-main { min-width: 0; }
.preview-row .pr-desc { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-row .pr-sub { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.preview-row .pr-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.detected { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.detected:last-child { border-bottom: none; }
.detected .d-val { font-weight: 600; }
