:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --label: #000000;
  --secondary: #6B6B70;
  --sep: #E5E5EA;
  --blue: #0066CC;
  --red: #D70015;
  --green: #1F7A35;
  --seg: #E3E3E8;
  --seg-on: #FFFFFF;
  --bar: #F9F9F9;
  --bar-line: #D1D1D6;
  --on-blue: #FFFFFF;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --label: #FFFFFF;
    --secondary: #A1A1A6;
    --sep: #38383A;
    --blue: #4DA3FF;
    --red: #FF6961;
    --green: #30D158;
    --seg: #1C1C1E;
    --seg-on: #636366;
    --bar: #161618;
    --bar-line: #38383A;
    --on-blue: #000000;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--label); font-family: var(--font); font-size: 17px; line-height: 1.3; }
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; }
.content { flex: 1; padding: 0 16px 24px; }

.large { padding: 24px 4px 4px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1.t { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: 0.37px; line-height: 1.2; overflow-wrap: anywhere; }
.sub { margin: 2px 0 0; font-size: 15px; color: var(--secondary); }
.small { margin: 2px 0 0; font-size: 13px; color: var(--secondary); }
.section-label { padding: 22px 16px 6px; font-size: 13px; color: var(--secondary); }
.foot { padding: 6px 16px 0; font-size: 13px; color: var(--secondary); line-height: 1.4; }
.error { padding: 10px 16px 0; font-size: 15px; color: var(--red); }

.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.card { background: var(--card); border-radius: 12px; padding: 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 8px 16px; border-bottom: 1px solid var(--sep); }
.row:last-child { border-bottom: 0; }
.row-btn { width: 100%; border: 0; background: transparent; color: var(--label); font-size: 17px; text-align: left; cursor: pointer; }
.row-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.row-title { font-size: 17px; overflow-wrap: anywhere; }
.row-title.strong { font-weight: 600; }
.row-sub { font-size: 13px; color: var(--secondary); }
.row-line { font-size: 15px; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.amt { font-size: 17px; font-weight: 600; }
.amt-label { font-size: 12px; color: var(--secondary); }
.owe { color: var(--red); }
.get { color: var(--green); }
.muted { color: var(--secondary); }

.field input, .field select { width: 100%; min-height: 44px; border: 0; background: transparent; color: var(--label); font-size: 17px; padding: 0 16px; outline-offset: -2px; }
.field input::placeholder { color: var(--secondary); }
.add-row { padding: 0 0 0 16px; }
.add-row input { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; color: var(--label); font-size: 17px; padding: 0; }
.add-row input::placeholder { color: var(--secondary); }
.amount-input { height: 64px !important; font-size: 40px !important; font-weight: 700; letter-spacing: -0.5px; }

.link { color: var(--blue); }
.strong { font-weight: 600; }
.danger { color: var(--red); }
.btn-reset { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: inherit; }
.text-btn { min-height: 44px; padding: 0 16px; border: 0; background: transparent; color: var(--blue); font-size: 17px; cursor: pointer; display: inline-flex; align-items: center; }

.primary { width: 100%; height: 50px; border: 0; border-radius: 14px; background: var(--blue); color: var(--on-blue); font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.primary[disabled] { opacity: 0.5; cursor: default; }
.quiet { width: 100%; min-height: 44px; border: 0; background: transparent; color: var(--blue); font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

.icon-btn { width: 44px; height: 44px; margin-right: -12px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--blue); cursor: pointer; }

.summary { margin-top: 16px; }
.summary .label { font-size: 15px; color: var(--secondary); }
.summary .big { font-size: 48px; font-weight: 700; letter-spacing: -1px; line-height: 1.15; }
.summary .foot-row { margin-top: 10px; border-top: 1px solid var(--sep); min-height: 48px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.summary .foot-row .t { font-size: 15px; color: var(--secondary); }
.summary a { min-height: 44px; display: inline-flex; align-items: center; gap: 2px; color: var(--blue); }

.segmented { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--seg); }
.segmented button { flex: 1; height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--label); font-size: 15px; font-weight: 500; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--seg-on); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }

.navbar { height: 56px; padding: 8px 4px 0; display: flex; align-items: center; justify-content: space-between; }
.navbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.navbar .text-btn:last-child { font-weight: 600; justify-content: flex-end; }

.dock { position: sticky; bottom: 0; background: var(--bg); }
.cta { padding: 8px 16px 12px; }
.tabbar { height: 64px; display: flex; background: var(--bar); border-top: 1px solid var(--bar-line); box-sizing: content-box; padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--secondary); }
.tabbar a[aria-current="page"] { color: var(--blue); }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 480px; background: var(--bg); border-radius: 14px 14px 0 0; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 92vh; overflow: auto; }
.grabber { align-self: center; width: 36px; height: 5px; border-radius: 3px; background: #C7C7CC; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 700; text-align: center; }
.sheet p { margin: 0; font-size: 15px; color: var(--secondary); text-align: center; line-height: 1.35; }
.bubble { background: var(--card); border-radius: 12px; padding: 12px 16px; font-size: 15px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }

.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; color: var(--secondary); }
.center h1 { margin: 0; font-size: 22px; color: var(--label); }
.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: rgba(40, 40, 42, 0.95); color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 15px; z-index: 20; }
.linkbox { font-size: 15px; color: var(--blue); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: rise 0.22s ease-out; }
  @keyframes rise { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
}

.pick-tools { display: flex; justify-content: flex-end; margin: 4px 0 2px; }
.pick-tools .text-btn { padding: 0 8px; font-size: 15px; }
.pick-tools .text-btn:last-child { padding-right: 4px; }
.pick-tools .text-btn[disabled] { opacity: 0.35; cursor: default; }
.group + .pick-tools { margin-top: 10px; }
.howto { padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.howto-step { display: flex; gap: 12px; align-items: flex-start; }
.howto-n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: var(--on-blue); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.row-btn[aria-expanded="true"] { border-bottom: 1px solid var(--sep); }
