
    :root {
      --bg: #f6f7f8;
      --card: #fff;
      --ink: #1f2328;
      --muted: #6b7280;
      --line: #e5e7eb;
      --primary: #F2644A;
      --owe: #dc2626;
      --owed: #16a34a;
      --chip: #f6f7f8;
      --shadow: 0 1px 3px rgba(20, 32, 30, 0.08);
      --radius: 12px;
      --tap: 44px;
      --safe-bottom: env(safe-area-inset-bottom, 0px);
    }
    * { box-sizing: border-box; }
    html { -webkit-text-size-adjust: 100%; }
    body {
      margin: 0;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      color: var(--ink);
      background: var(--bg);
      line-height: 1.4;
      padding-bottom: calc(1.25rem + var(--safe-bottom));
    }
    .app { max-width: 28rem; margin: 0 auto; padding: 0 0.75rem 1rem; }
    .topbar {
      position: sticky; top: 0; z-index: 20;
      background: rgba(246, 247, 248, 0.96);
      backdrop-filter: blur(8px);
      border-bottom: 1px solid var(--line);
      margin: 0 -0.75rem;
      padding: calc(0.65rem + env(safe-area-inset-top, 0px)) 0.75rem 0.75rem;
    }
    .brand { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.45rem; }
    .trip-switch { display: flex; gap: 0.4rem; align-items: stretch; }
    section.card {
      background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
      box-shadow: var(--shadow); padding: 0.85rem 0.9rem; margin: 0.75rem 0;
    }
    section.card h2 { margin: 0 0 0.55rem; font-size: 1rem; }
    section.card p.lead { margin: -0.25rem 0 0.65rem; font-size: 0.82rem; color: var(--muted); }
    label.field { display: block; margin: 0.45rem 0 0.15rem; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
    input, select, textarea, button { font: inherit; }
    input[type="text"], input[type="number"], select, textarea {
      width: 100%; min-height: var(--tap); padding: 0.55rem 0.65rem;
      border: 1px solid var(--line); border-radius: 10px; background: #fff;
    }
    .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    @media (max-width: 360px) { .row { grid-template-columns: 1fr; } }
    .checks { display: flex; flex-wrap: wrap; gap: 0.35rem; }
    .checks label {
      display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.25rem;
      padding: 0.25rem 0.6rem; background: var(--chip); border: 1px solid var(--line); border-radius: 10px; font-size: 0.9rem;
    }
    .checks input { width: 1rem; height: 1rem; }
    button {
      min-height: var(--tap); padding: 0.55rem 0.9rem; border-radius: 10px;
      border: 1px solid transparent; cursor: pointer; font-weight: 600;
    }
    button.primary { background: var(--primary); color: #fff; width: 100%; margin-top: 0.65rem; }
    button.primary:active { filter: brightness(.95); }
    button.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
    button.small { min-height: 2.25rem; padding: 0.35rem 0.65rem; font-size: 0.85rem; }
    button:disabled { opacity: 0.45; cursor: not-allowed; }
    .settle-empty { color: var(--muted); padding: 20px 0; text-align: center; }
    .pay-form { margin-top: 12px; }
    .toast {
      position: fixed; left: 50%; bottom: calc(1rem + var(--safe-bottom)); transform: translateX(-50%);
      background: var(--ink); color: #fff; padding: 0.55rem 0.9rem; border-radius: 999px;
      font-size: 0.85rem; max-width: calc(100% - 2rem); z-index: 50; opacity: 0;
      pointer-events: none; transition: opacity 0.2s;
    }
    .toast.show { opacity: 1; }
    pre.debug-out {
      background: #f6f7f8; padding: 0.5rem; overflow: auto; white-space: pre-wrap;
      font-size: 0.72rem; max-height: 18rem;
    }
    .trip-notice {
      margin: 0.5rem 0 0; padding: 0.5rem 0.65rem; border-radius: 10px;
      background: #fef2f2; border: 1px solid var(--line); color: #dc2626; font-size: 0.85rem;
    }
    .status { font-size: 0.8rem; color: var(--muted); min-height: 1.2em; margin: 0.35rem 0 0; }
    .status.err { color: var(--owe); }
    .history { margin-top: 1rem; color: var(--muted); font-size: 0.85rem; }
    .history summary { cursor: pointer; padding: 0.5rem 0; }
    .history-row { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
    .history-row small { display: block; font-size: 0.75rem; margin-top: 0.2rem; }

[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #6b7280; outline-offset: 3px; }
.app { max-width: 430px; padding: 0 22px 24px; }
.topbar { position: static; margin: 0 -22px; padding: calc(30px + env(safe-area-inset-top, 0px)) 22px 18px; border: 0; }
.brand { align-items: center; justify-content: flex-start; gap: 8px; margin-bottom: 28px; }
.brand img { width: 28px; height: 28px; }
.wordmark { font-size: 23px; letter-spacing: -1.2px; font-weight: 750; }
.wordmark span { color: #F2644A; }
.trip-heading { flex: 1; min-width: 0; }
.trip-switch { align-items: center; }
.trip-switch h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.8px; margin: 0 0 9px; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: 13px; }
.trip-heading p { margin: 0; }
.icon-button { flex-shrink: 0; width: 44px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); background: white; border-radius: 13px; }
.link-button { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--muted); text-decoration: underline; font-weight: 400; }
.picker { padding: 18px; background: white; border: 1px solid var(--line); border-radius: 18px; margin: 8px 0 20px; }
.eyebrow { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 14px; }
.people { display: flex; flex-wrap: wrap; gap: 18px; justify-content: space-around; }
.person { border: 0; background: none; padding: 2px; display: grid; justify-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 400; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; font-weight: 650; color: var(--ink); background: #e8e5f2; }
.person:nth-child(4n+2) .avatar { background: #e3ece5; }
.person:nth-child(4n+3) .avatar { background: #e5ebf2; }
.person:nth-child(4n+4) .avatar { background: #f0e9db; }
.your { margin: 0 0 18px; border-radius: 12px; padding: 14px; background: #ecfdf3; color: #16a34a; font-variant-numeric: tabular-nums; }
.your small { display: block; font-size: 11px; margin-bottom: 5px; }
.your strong { font-size: 20px; letter-spacing: -.4px; }
.your.negative { background: #fef2f2; color: #dc2626; }
.your.square { background: #f6f7f8; color: #6b7280; }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tabs button { width: 33.333%; border: 0; background: none; padding: 13px 0; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.tabs button[aria-selected=true] { color: var(--ink); font-weight: 650; border-bottom-color: var(--ink); }
section.card { border-radius: 15px; box-shadow: none; }
button.primary { border-radius: 14px; }

.money { font-variant-numeric: tabular-nums; }
.creditor { border-left: 3px solid #F2644A; }

body:has(#expenseFooter:not([hidden])) { padding-bottom: calc(100px + var(--safe-bottom)); }
.expense-heading { font-size: 15px; margin: 0 0 13px; }
#expenseList { color: var(--muted); font-size: 13px; }
.expense-card { display: flex; align-items: center; gap: 12px; padding: 17px 14px; background: white; border: 1px solid var(--line); border-radius: 15px; margin-bottom: 10px; color: var(--ink); }
.expense-card .avatar { width: 38px; height: 38px; flex-shrink: 0; }
.expense-details { flex: 1; min-width: 0; }
.expense-title { font-size: 14px; font-weight: 650; margin-bottom: 5px; overflow-wrap: anywhere; }
.expense-details .muted { font-size: 11px; }
.expense-money { font-size: 15px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.expense-footer { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 430px; padding: 12px 22px calc(16px + var(--safe-bottom)); background: var(--bg); z-index: 25; }
.expense-footer button.primary { margin: 0; }
.toast { bottom: calc(90px + var(--safe-bottom)); }
.expense-overlay { position: fixed; inset: 0; background: #1f232866; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.expense-sheet { width: 100%; max-width: 430px; background: white; border-radius: 25px 25px 0 0; padding: 12px 24px calc(24px + var(--safe-bottom)); max-height: 95dvh; overflow: auto; }
.sheet-handle { width: 36px; height: 4px; border-radius: 3px; background: var(--line); margin: 0 auto 20px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 20px; margin: 0; }
#sheetClose { border: 0; background: var(--bg); border-radius: 50%; font-size: 24px; width: 44px; padding: 0; }
.sheet-segments { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; margin-top: 18px; }
.sheet-segments button { flex: 1; background: transparent; font-size: 12px; padding: 8px; }
.sheet-segments button[aria-pressed=true] { background: white; box-shadow: var(--shadow); }
.sheet-amount { display: flex; align-items: center; gap: 8px; font-size: 42px; margin: 24px 0; }
.sheet-amount input[type=text] { font-size: 42px; border: 0; padding: 0; min-width: 0; font-variant-numeric: tabular-nums; }
#sheetWhen { width: 100%; min-height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.expense-sheet .field { display: block; font-size: 12px; font-weight: 600; margin: 18px 0 10px; }
.sheet-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.sheet-chip { flex: 1; border: 1px solid var(--line); background: white; font-size: 12px; padding: 10px; }
.sheet-chip[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: white; }
.sheet-check { display: flex; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--line); font-size: 14px; }
.sheet-check input { width: 18px; height: 18px; accent-color: var(--ink); }
body.sheet-open { overflow: hidden; }

.balance-heading, .history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.balance-heading h2, .history-heading h2, .settle-heading { font-size: 15px; color: var(--ink); margin: 0; }
.balance-card { display: flex; align-items: center; gap: 12px; padding: 17px 14px; background: white; border: 1px solid var(--line); border-radius: 15px; margin-bottom: 10px; }
.balance-card.creditor { border-left: 3px solid var(--primary); }
.balance-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 650; }
.balance-card .avatar { flex-shrink: 0; }
.balance-card .money { font-size: 15px; font-weight: 650; white-space: nowrap; }
.balance-card .positive { color: #16a34a; background: #ecfdf3; border-radius: 8px; padding: 5px 8px; }
.balance-card .negative { color: #dc2626; }
.settle-heading { margin: 26px 0 10px; }
.settle-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; border-bottom: 1px solid var(--line); padding: 14px 0; font-size: 13px; }
.settle-names { flex: 1; overflow-wrap: anywhere; }
.settle-actions { display: flex; gap: 8px; }
.settle-actions button.primary { margin: 0; width: auto; }
.settle-question, .settle-row .status { width: 100%; overflow-wrap: anywhere; }
#otherPayment { margin-top: 24px; font-size: 13px; color: var(--muted); }
#otherPayment summary { cursor: pointer; padding: 10px 0; }
#btnPay { width: 100%; margin-top: 12px; }
.export-placeholder { display: flex; align-items: center; gap: 7px; color: var(--muted); }
#btnExport { color: var(--muted); background: var(--bg); font-size: 12px; font-weight: 400; }

button.brand { background: transparent; border: 0; padding: 0; color: var(--ink); }
#tripPeople { padding: 0; min-height: 30px; text-decoration: none; }
.screen { min-height: 65vh; padding: 0 0 24px; }
.screen-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.screen-heading h2 { font-size: 25px; letter-spacing: -.7px; margin: 0; }
.screen-back { font-size: 25px; padding: 0; width: 44px; }
.trip-row { display: grid; gap: 7px; text-align: left; width: 100%; background: white; border: 1px solid var(--line); padding: 18px; margin-bottom: 10px; border-radius: 15px; overflow-wrap: anywhere; }
.people-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.new-person-row { display: flex; gap: 8px; margin: 10px 0; }
#btnAddPerson { margin-top: 12px; }
.share-note { margin: 6px 0 0; font-size: 12px; line-height: 1.4; }
.toast.toast-multi { border-radius: 14px; text-align: center; width: max-content; max-width: min(340px, calc(100% - 2rem)); }
.screen-subtitle { margin: 3px 0 0; font-size: 13px; }
.identity-confirm { color: inherit; padding-left: 0; }
