@layer base, layout, components, responsive;

@layer base {
  :root {
    font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    --bg: #f7f8fa;
    --surface: #fff;
    --surface-subtle: #f4f6f7;
    --text: #192b36;
    --muted: #64737c;
    --border: #e0e6e9;
    --accent: #17634c;
    --accent-hover: #104c39;
    --accent-soft: #eaf3ef;
    --negative: #a94637;
    --negative-bg: #fff1ed;
    --focus: #32816b;
    --shadow: 0 16px 48px #132a3510;
    color-scheme: light;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #11191f;
      --surface: #18232b;
      --surface-subtle: #1d2b34;
      --text: #e3ecef;
      --muted: #a2b2bc;
      --border: #30404a;
      --accent: #80c4a8;
      --accent-hover: #a2d9c0;
      --accent-soft: #203c33;
      --negative: #f0a08e;
      --negative-bg: #402a27;
      --focus: #90d4b8;
      --shadow: 0 16px 48px #00000020;
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --bg: #11191f;
    --surface: #18232b;
    --surface-subtle: #1d2b34;
    --text: #e3ecef;
    --muted: #a2b2bc;
    --border: #30404a;
    --accent: #80c4a8;
    --accent-hover: #a2d9c0;
    --accent-soft: #203c33;
    --negative: #f0a08e;
    --negative-bg: #402a27;
    --focus: #90d4b8;
    --shadow: 0 16px 48px #00000020;
    color-scheme: dark;
  }
  * { box-sizing: border-box; }
  body { margin: 0; min-width: 280px; }
  button, input, select, textarea { font: inherit; }
  button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
  button { color: inherit; cursor: pointer; }
  button:disabled { cursor: not-allowed; opacity: .4; }
  a { color: inherit; text-decoration: none; }
  h1, h2, h3, p { margin: 0; }
  ul { list-style: none; margin: 0; padding: 0; }
  h1, h2, h3 { font-weight: 600; }
  button, a, input, select, textarea { outline-offset: 4px; }
  :focus-visible { outline: 2px solid var(--focus); }
  ::selection { background: var(--accent-soft); color: var(--text); }
  [hidden] { display: none !important; }
  .icon { width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }
  .muted { color: var(--muted); }
  .positive { color: var(--accent); }
  .negative, .danger-text { color: var(--negative); }
  .text-small { font-size: 13px; }
  .skip-link { position: fixed; top: -100px; left: 16px; padding: 12px; z-index: 20; background: var(--surface); border: 1px solid var(--accent); }
  .skip-link:focus { top: 10px; }
}

@layer layout {
  #app { min-height: 100svh; display: flex; flex-direction: column; }
  .site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
  .header-inner { max-width: 1224px; margin: auto; height: 86px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; }
  .brand { display: inline-flex; align-items: center; gap: 10px; font-size: 25px; font-weight: 700; letter-spacing: -1px; }
  .brand-dot { color: var(--accent); }
  .header-actions { display: flex; align-items: center; gap: 30px; }
  .header-caption { font-size: 12px; color: var(--muted); }
  .home-main, .group-main { width: 100%; max-width: 1224px; margin: auto; padding: 0 32px; flex: 1; }
  .hero { display: grid; grid-template-columns: 1.15fr 1fr; align-items: center; gap: 76px; padding: 85px 0 80px; }
  .hero-copy { padding: 14px 0; }
  .eyebrow { font-size: 10px; font-weight: 650; letter-spacing: 1.7px; color: var(--muted); display: flex; align-items: center; gap: 10px; line-height: 1.7; }
  .small-line { width: 24px; height: 2px; background: var(--accent); }
  .hero h1 { font-size: clamp(42px, 4.2vw, 61px); line-height: 1.13; letter-spacing: -2.6px; margin: 24px 0; font-weight: 550; }
  .hero-description { max-width: 420px; color: var(--muted); font-size: 16px; line-height: 1.85; margin-bottom: 30px; }
  .hero-note { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); margin-top: 17px; }
  .hero-note .icon { width: 14px; height: 14px; }
  .preview-wrap { position: relative; padding: 10px 0 24px; }
  .preview-decoration { position: absolute; z-index: -1; right: -18px; bottom: 5px; width: 70%; height: 65%; border: 1px solid var(--border); border-radius: 12px; background: var(--accent-soft); }
  .preview-card { border: 1px solid var(--border); border-radius: 12px; padding: 26px; background: var(--surface); box-shadow: var(--shadow); }
  .preview-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 25px; }
  .preview-top .eyebrow { font-size: 9px; }
  .preview-dots { color: var(--muted); font-size: 13px; letter-spacing: 2px; }
  .preview-card h2 { font-size: 21px; letter-spacing: -.5px; margin-bottom: 7px; }
  .preview-total { display: flex; justify-content: space-between; align-items: center; padding: 20px 0; margin-top: 14px; border-bottom: 1px solid var(--border); }
  .preview-total span { font-size: 12px; color: var(--muted); }
  .preview-total strong { font-size: 27px; font-weight: 600; letter-spacing: -.7px; font-variant-numeric: tabular-nums; }
  .preview-expense { display: flex; gap: 12px; align-items: center; padding: 17px 0; border-bottom: 1px solid var(--border); }
  .preview-icon { width: 33px; height: 37px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-subtle); color: var(--muted); }
  .preview-icon .icon { width: 17px; height: 17px; }
  .preview-expense > div { flex: 1; }
  .preview-expense strong { display: block; font-size: 11px; font-weight: 550; }
  .preview-expense div span { display: block; font-size: 10px; color: var(--muted); margin-top: 5px; }
  .preview-expense b { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .preview-settle { display: flex; align-items: center; gap: 9px; background: var(--accent-soft); color: var(--accent); padding: 13px 10px; border-radius: 6px; margin-top: 20px; font-size: 11px; }
  .preview-check { display: grid; place-items: center; }
  .preview-check .icon { width: 16px; height: 16px; }
  .preview-settle b { margin-left: auto; font-size: 12px; font-weight: 600; }
  .preview-small-settle { display: flex; justify-content: space-between; padding: 12px 10px 0 35px; color: var(--muted); font-size: 10px; }
  .preview-small-settle b { font-weight: 500; }
  .preview-bottom { text-align: center; font-size: 10px; color: var(--muted); margin-top: 20px; }
  .how-section { border-top: 1px solid var(--border); padding: 40px 0 32px; }
  .how-section > h2 { font-size: 23px; letter-spacing: -.5px; margin-bottom: 32px; }
  .steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 54px; }
  .step-number { color: var(--accent); font-size: 11px; font-weight: 650; letter-spacing: 1px; display: inline-block; margin-bottom: 13px; }
  .step h3 { font-size: 15px; margin-bottom: 10px; }
  .step p { color: var(--muted); font-size: 13px; line-height: 1.8; max-width: 290px; }
  .privacy-note { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 12px 0 35px; line-height: 1.7; }
  .privacy-note .icon { width: 14px; height: 14px; }
  .site-footer { width: 100%; max-width: 1224px; margin: 0 auto; padding: 25px 32px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
  .site-footer > span { font-weight: 600; }
  .footer-caption { font-weight: 400; margin-left: 12px; font-size: 11px; }
  .site-footer .text-button { font-size: 11px; color: var(--muted); }
  .site-footer .icon { width: 14px; height: 14px; }
  .group-main { padding-top: 28px; padding-bottom: 10px; }
  .back-link { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; margin-bottom: 25px; }
  .back-link:hover { color: var(--text); }
  .back-link .icon { width: 15px; height: 15px; }
  .group-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
  .group-heading > div { min-width: 0; }
  .group-heading h1 { font-size: 34px; letter-spacing: -1.1px; margin: 8px 0 12px; overflow-wrap: anywhere; }
  .group-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }
  .group-meta .icon { width: 15px; height: 15px; }
  .stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); border-radius: 9px; background: var(--surface); margin-bottom: 29px; }
  .stat { min-width: 0; padding: 23px 26px; }
  .stat + .stat { border-left: 1px solid var(--border); }
  .stat > span { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .stat > span .icon { width: 17px; height: 17px; opacity: .8; }
  .stat > strong { display: block; font-size: clamp(23px, 2.5vw, 31px); font-weight: 550; letter-spacing: -.7px; margin: 15px 0 9px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .stat > small { color: var(--muted); font-size: 11px; line-height: 1.5; }
  .tabs { display: flex; gap: 30px; border-bottom: 1px solid var(--border); margin-bottom: 26px; }
  .tabs a { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 0 2px 15px; color: var(--muted); position: relative; font-weight: 500; }
  .tabs a .icon { width: 17px; height: 17px; }
  .tabs a.active { color: var(--accent); }
  .tabs a.active::after { content: ""; height: 2px; background: var(--accent); position: absolute; bottom: -1px; left: 0; right: 0; }
  .content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; align-items: start; }
  .group-privacy { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 10px; color: var(--muted); padding: 28px 0; line-height: 1.7; }
  .group-privacy .icon { width: 14px; height: 14px; }
}

@layer components {
  .button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 6px; min-height: 40px; padding: 10px 16px; font-size: 12px; font-weight: 550; line-height: 1.4; white-space: nowrap; background: none; }
  .button .icon { width: 16px; height: 16px; }
  .primary { color: var(--surface); background: var(--accent); }
  .primary:hover { background: var(--accent-hover); }
  .secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
  .secondary:hover { background: var(--surface-subtle); }
  .danger { color: var(--surface); background: var(--negative); }
  .danger:hover { filter: brightness(.9); }
  .danger-secondary { color: var(--negative); border-color: var(--border); }
  .danger-secondary:hover { background: var(--negative-bg); }
  .button-large { min-height: 49px; padding: 13px 22px; font-size: 13px; gap: 12px; }
  .button-large .icon { width: 18px; height: 18px; }
  .icon-button { display: inline-grid; place-items: center; background: none; border: 1px solid transparent; border-radius: 5px; width: 34px; height: 34px; flex: 0 0 auto; color: var(--muted); }
  .icon-button:hover:not(:disabled) { background: var(--surface-subtle); color: var(--text); }
  .icon-button .icon { width: 16px; height: 16px; }
  .icon-button.danger-text { color: var(--negative); }
  .text-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; background: none; padding: 5px 0; color: var(--accent); font-size: 12px; font-weight: 500; }
  .text-button:hover { text-decoration: underline; text-underline-offset: 4px; }
  .settings-button { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 11px; display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); min-height: 37px; }
  .settings-button:hover { background: var(--surface-subtle); }
  .settings-button .icon { width: 16px; height: 16px; }
  .count { display: inline-grid; place-items: center; min-width: 19px; height: 19px; border-radius: 4px; background: var(--surface-subtle); color: var(--muted); font-size: 10px; padding: 0 5px; font-weight: 600; }
  .tabs a.active .count { background: var(--accent-soft); color: var(--accent); }
  .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; min-width: 0; }
  .panel-heading { padding: 23px; }
  .panel-heading h2 { font-size: 16px; letter-spacing: -.2px; line-height: 1.5; }
  .panel-heading p { color: var(--muted); font-size: 11px; margin-top: 5px; line-height: 1.7; }
  .heading-with-action { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
  .heading-with-action .button { font-size: 11px; min-height: 35px; padding: 8px 11px; }
  .heading-with-action .button .icon { width: 14px; height: 14px; }
  .expense-list li { border-top: 1px solid var(--border); }
  .expense-row { display: flex; align-items: center; gap: 13px; width: 100%; padding: 20px 23px; background: none; border: 0; text-align: left; }
  .expense-row:hover { background: var(--surface-subtle); }
  .expense-row:focus-visible { outline-offset: -3px; }
  .expense-icon { display: grid; place-items: center; width: 37px; height: 41px; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 6px; color: var(--muted); flex-shrink: 0; }
  .expense-icon .icon { width: 18px; height: 18px; }
  .expense-main { flex: 1; min-width: 0; }
  .expense-main strong { display: block; font-size: 13px; font-weight: 550; overflow-wrap: anywhere; line-height: 1.5; }
  .expense-main small { display: block; color: var(--muted); font-size: 10px; line-height: 1.7; margin-top: 4px; overflow-wrap: anywhere; }
  .expense-amount { text-align: right; white-space: nowrap; }
  .expense-amount strong { font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; }
  .expense-amount small { display: block; font-size: 10px; color: var(--muted); margin-top: 5px; }
  .expense-row > .icon { width: 13px; height: 13px; color: var(--muted); margin-left: 3px; }
  .avatar { display: inline-grid; place-items: center; width: 33px; height: 33px; border-radius: 50%; font-size: 11px; font-weight: 600; flex: 0 0 auto; border: 1px solid transparent; }
  .color-0 { color: #377461; background: #e8f1ed; }
  .color-1 { color: #626590; background: #eeedf5; }
  .color-2 { color: #93703b; background: #f5efdf; }
  .color-3 { color: #53738e; background: #e8eff5; }
  .color-4 { color: #956265; background: #f6eaea; }
  .avatar-large { width: 43px; height: 43px; font-size: 13px; }
  .balance-list { padding: 0 22px 10px; }
  .balance-list li { display: flex; align-items: center; gap: 10px; padding: 15px 0; border-top: 1px solid var(--border); }
  .balance-person { flex: 1; font-size: 12px; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
  .balance-person small { display: block; font-size: 10px; font-weight: 400; color: var(--muted); margin-top: 5px; }
  .balance-value { font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
  .panel-footnote { background: var(--surface-subtle); border-top: 1px solid var(--border); padding: 15px 21px; font-size: 10px; color: var(--muted); display: flex; gap: 8px; line-height: 1.8; }
  .panel-footnote .icon { width: 14px; height: 14px; margin-top: 2px; }
  .panel-empty { font-size: 12px; color: var(--muted); padding: 0 23px 24px; }
  .subheading { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; padding: 13px 23px; border-top: 1px solid var(--border); background: var(--surface-subtle); }
  .subheading .count { border: 1px solid var(--border); background: var(--surface); }
  .transfer-row { display: flex; align-items: center; gap: 12px; padding: 23px; border-bottom: 1px solid var(--border); }
  .transfer-row:last-child { border-bottom: 0; }
  .transfer-checkbox { width: 23px; height: 23px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); flex: 0 0 auto; padding: 0; display: grid; place-items: center; }
  .transfer-checkbox:hover { border-color: var(--accent); background: var(--accent-soft); }
  .transfer-checkbox.checked { border-color: var(--accent); background: var(--accent); color: var(--surface); }
  .transfer-checkbox .icon { width: 15px; height: 15px; }
  .transfer-person { flex: 1; min-width: 0; }
  .transfer-person strong { font-size: 12px; font-weight: 550; line-height: 1.8; overflow-wrap: anywhere; }
  .transfer-person strong span { color: var(--muted); font-weight: 400; margin: 0 6px; }
  .transfer-person small { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
  .transfer-amount { font-size: 14px; font-weight: 550; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .transfer-notice, .people-notice { display: flex; align-items: start; gap: 7px; font-size: 10px; color: var(--muted); line-height: 1.8; padding: 0 23px 19px; }
  .transfer-notice .icon, .people-notice .icon { width: 14px; height: 14px; margin-top: 2px; }
  .status-badge { background: var(--accent-soft); color: var(--accent); padding: 5px 7px; border-radius: 4px; font-size: 9px; white-space: nowrap; }
  .completed-row .transfer-amount { font-size: 12px; color: var(--muted); }
  .quiet-empty { text-align: center; color: var(--muted); padding: 32px 20px; }
  .quiet-empty p { font-size: 12px; margin-bottom: 7px; }
  .quiet-empty small { font-size: 10px; }
  .empty-state { padding: 40px 24px 48px; display: flex; align-items: center; flex-direction: column; text-align: center; }
  .empty-icon { width: 50px; height: 50px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 17px; }
  .empty-icon .icon { width: 22px; height: 22px; }
  .empty-state h3 { font-size: 17px; line-height: 1.5; margin-bottom: 9px; }
  .empty-state p { font-size: 12px; line-height: 1.8; color: var(--muted); max-width: 300px; }
  .empty-state .button { margin-top: 23px; }
  .people-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 0 23px 23px; }
  .person-card { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 7px; }
  .person-card > strong { flex: 1; min-width: 50px; overflow-wrap: anywhere; font-size: 13px; font-weight: 550; }
  .person-card > div { display: flex; gap: 0; margin-left: auto; }
  .recent-section { margin-bottom: 35px; }
  .section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
  .section-heading h2 { font-size: 20px; letter-spacing: -.5px; }
  .section-heading p { font-size: 11px; color: var(--muted); }
  .recent-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .recent-card { display: flex; align-items: center; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
  .recent-card:hover { border-color: var(--accent); }
  .recent-icon { color: var(--accent); }
  .recent-card > span:nth-child(2) { flex: 1; min-width: 0; }
  .recent-card strong { display: block; font-size: 12px; font-weight: 550; overflow-wrap: anywhere; line-height: 1.7; }
  .recent-card small { display: block; color: var(--muted); font-size: 10px; margin-top: 5px; }
  .recent-card > .icon { width: 16px; height: 16px; color: var(--muted); }
  .loading-state, .error-state { min-height: 450px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 20px; text-align: center; }
  .loading-state p { color: var(--muted); font-size: 13px; }
  .loading-dot { width: 25px; height: 25px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .loading-dot { animation: none; } }
  .error-state { padding: 35px; }
  .error-state h1 { font-size: 26px; letter-spacing: -.5px; }
  .error-state p { font-size: 13px; line-height: 1.8; }
  .error-state > .icon { width: 36px; height: 36px; color: var(--muted); }
  .alert { padding: 13px 15px; border: 1px solid var(--negative); border-radius: 6px; background: var(--negative-bg); color: var(--negative); font-size: 12px; line-height: 1.8; margin: 16px 0; }
  .toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 14px 22px; border-radius: 7px; max-width: min(520px, calc(100vw - 32px)); width: max-content; box-shadow: var(--shadow); z-index: 30; font-size: 12px; line-height: 1.7; }
  .toast-error { background: var(--negative-bg); color: var(--negative); border: 1px solid var(--negative); }
  dialog { width: min(500px, calc(100vw - 32px)); max-height: calc(100svh - 48px); padding: 0; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overscroll-behavior: contain; }
  dialog::backdrop { background: #0c202a80; }
  .dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 28px 28px 0; }
  .dialog-header h2 { font-size: 23px; letter-spacing: -.6px; line-height: 1.4; }
  .dialog-header p { color: var(--muted); font-size: 12px; line-height: 1.8; margin-top: 10px; }
  .dialog-header .icon-button { margin: -5px -10px 0 0; }
  dialog form, .dialog-body { padding: 25px 28px 28px; }
  .field { display: flex; flex-direction: column; gap: 9px; font-size: 12px; font-weight: 550; margin-bottom: 20px; line-height: 1.6; min-width: 0; }
  input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea { width: 100%; min-width: 0; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; min-height: 43px; padding: 10px 12px; font-size: 13px; line-height: 1.5; }
  input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
  textarea { resize: vertical; }
  input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; flex: 0 0 auto; margin: 0; cursor: pointer; }
  .field-hint { font-size: 10px; color: var(--muted); font-weight: 400; line-height: 1.8; }
  .optional { color: var(--muted); font-size: 10px; font-weight: 400; margin-top: -6px; }
  .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .dialog-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: 10px; padding-top: 23px; margin-top: 24px; border-top: 1px solid var(--border); }
  .dialog-actions .button { white-space: normal; }
  .dialog-note { display: flex; align-items: start; gap: 8px; font-size: 11px; line-height: 1.8; color: var(--muted); }
  .dialog-note .icon { width: 15px; height: 15px; margin-top: 2px; }
  .theme-fieldset, .split-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
  legend { padding: 0; font-size: 12px; font-weight: 550; margin-bottom: 13px; }
  .theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
  .theme-option { position: relative; display: flex; flex-direction: column; align-items: center; gap: 11px; padding: 18px 10px; font-size: 11px; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; color: var(--muted); }
  .theme-option:has(input:checked) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
  .theme-option input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
  .theme-option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
  .split-tools { display: flex; gap: 16px; margin: -4px 0 10px; }
  .split-tools .text-button { font-size: 10px; }
  dialog[data-kind="expense"] { width: min(620px, calc(100vw - 32px)); }
  .split-options { display: grid; gap: 8px; margin-bottom: 10px; padding: 3px; }
  .split-columns, .split-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 84px; gap: 12px; align-items: center; }
  .split-columns { font-size: 10px; color: var(--muted); padding: 0 14px 8px; }
  .split-columns > :nth-child(2) { text-align: center; }
  .split-columns > :last-child { text-align: right; }
  .split-row { border: 1px solid var(--border); padding: 10px; border-radius: 5px; }
  .split-row:has([name="participants"]:checked) { background: var(--accent-soft); border-color: var(--accent); }
  .split-person { display: flex; align-items: center; gap: 9px; font-size: 12px; cursor: pointer; overflow-wrap: anywhere; min-width: 0; }
  .weight-controls { display: flex; align-items: center; gap: 3px; min-width: 0; }
  .weight-controls .icon-button { width: 30px; height: 34px; border-color: var(--border); background: var(--surface); }
  .weight-controls input[name="weight"] { min-height: 34px; padding: 6px 3px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
  .weight-controls input:disabled { opacity: .4; }
  .split-row output { font-size: 12px; font-weight: 550; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .payment-impact { display: inline-block; font-size: inherit; font-weight: 550; margin-left: 5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .split-error { font-size: 11px; color: var(--negative); line-height: 1.7; margin: 8px 0; }
  .edit-note { margin-top: 16px; }
  .detail-amount { font-size: 38px; letter-spacing: -1px; margin-bottom: 12px; font-weight: 550; overflow-wrap: anywhere; }
  .detail-description { font-size: 17px; font-weight: 500; line-height: 1.6; overflow-wrap: anywhere; }
  .detail-list { margin: 25px 0 0; }
  .detail-list div { display: flex; justify-content: space-between; align-items: start; gap: 20px; border-top: 1px solid var(--border); padding: 14px 0; font-size: 12px; line-height: 1.7; }
  .detail-list dt { color: var(--muted); flex: 0 0 35%; }
  .detail-list dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
  .share-input { font-size: 11px !important; }
  .confirm-description { font-size: 13px; line-height: 1.9; color: var(--muted); }
}

@layer responsive {
  @media (max-width: 1050px) {
    .hero { gap: 40px; padding: 65px 0; }
    .content-grid { grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; }
    .panel-heading, .expense-row, .transfer-row { padding: 20px; }
    .heading-with-action { align-items: start; flex-direction: column; gap: 13px; }
    .expense-date { display: block; }
    .desktop-dot { display: none; }
    .people-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .completed-row { flex-wrap: wrap; }
    .completed-row .status-badge { display: none; }
  }
  @media (max-width: 760px) {
    .header-inner { height: 70px; padding: 0 22px; }
    .brand { font-size: 23px; }
    .brand img { width: 30px; height: 30px; }
    .header-caption { display: none; }
    .home-main, .group-main { padding-left: 22px; padding-right: 22px; }
    .hero { grid-template-columns: 1fr; gap: 40px; padding: 42px 0 45px; }
    .hero-copy { padding: 0; }
    .hero h1 { font-size: 50px; letter-spacing: -2px; margin-top: 20px; }
    .hero-description { max-width: 480px; font-size: 15px; }
    .preview-wrap { max-width: 430px; width: calc(100% - 15px); margin: 0 auto; }
    .steps { gap: 24px; }
    .step h3 { font-size: 14px; line-height: 1.6; }
    .step p { font-size: 12px; }
    .how-section > h2 { font-size: 21px; }
    .privacy-note { align-items: start; }
    .site-footer { padding: 22px; }
    .footer-caption { display: none; }
    .group-main { padding-top: 22px; }
    .group-heading { align-items: start; gap: 15px; }
    .group-heading h1 { font-size: 28px; }
    .group-heading > .button { padding: 9px 11px; font-size: 11px; margin-top: 22px; }
    .group-meta { gap: 7px; font-size: 10px; }
    .stats { margin-bottom: 24px; }
    .stat { padding: 18px 15px; }
    .stat > span { font-size: 10px; }
    .stat > span .icon { display: none; }
    .stat > strong { font-size: 23px; margin: 12px 0 7px; }
    .stat > small { font-size: 9px; }
    .tabs { gap: 25px; }
    .content-grid { grid-template-columns: 1fr; }
    .balance-panel { margin-top: 3px; }
    .heading-with-action { flex-direction: row; align-items: center; }
    .expense-date { display: inline; }
    .desktop-dot { display: inline; }
    .recent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .group-privacy { justify-content: start; align-items: start; }
    .group-privacy .icon { margin-top: 2px; }
    .completed-row .status-badge { display: inline; }
  }
  @media (max-width: 460px) {
    .header-inner, .home-main, .group-main { padding-left: 18px; padding-right: 18px; }
    .hero h1 { font-size: 43px; letter-spacing: -1.8px; }
    .hero .eyebrow { font-size: 8px; letter-spacing: 1.25px; }
    .hero-description { font-size: 14px; }
    .preview-card { padding: 22px; }
    .preview-decoration { right: -12px; }
    .steps { grid-template-columns: 1fr; gap: 25px; }
    .step { display: grid; grid-template-columns: 30px 1fr; column-gap: 13px; }
    .step-number { grid-row: span 2; padding-top: 3px; }
    .step h3 { font-size: 15px; margin-bottom: 6px; }
    .step p { max-width: none; }
    .how-section { padding-top: 30px; }
    .how-section > h2 { font-size: 19px; margin-bottom: 25px; }
    .section-heading { align-items: start; flex-direction: column; gap: 6px; }
    .recent-grid { grid-template-columns: 1fr; }
    .group-heading { flex-wrap: wrap; gap: 15px; }
    .group-heading > div { flex: 1 1 100%; }
    .group-heading > .button { margin: 0; }
    .group-heading h1 { font-size: 29px; }
    .group-meta { font-size: 11px; }
    .stats { grid-template-columns: 1fr 1fr; }
    .stat { padding: 17px 15px; }
    .stat:last-child { display: none; }
    .stat > strong { font-size: 25px; }
    .tabs { justify-content: space-between; gap: 8px; margin-bottom: 20px; }
    .tabs a { font-size: 12px; gap: 6px; }
    .tabs a .icon { width: 15px; height: 15px; }
    .tabs .count { font-size: 9px; min-width: 16px; height: 17px; padding: 0 4px; }
    .heading-with-action { flex-direction: column; align-items: start; }
    .panel-heading { padding: 20px 18px; }
    .panel-heading h2 { font-size: 16px; }
    .expense-row { padding: 18px 15px; gap: 10px; }
    .expense-main strong { font-size: 12px; }
    .expense-main small { font-size: 9px; }
    .expense-date { display: block; }
    .desktop-dot { display: none; }
    .expense-amount strong { font-size: 12px; }
    .expense-amount small { font-size: 9px; }
    .expense-row > .icon { display: none; }
    .expense-icon { width: 32px; height: 36px; }
    .balance-list { padding-left: 18px; padding-right: 18px; }
    .people-grid { grid-template-columns: 1fr; padding: 0 18px 18px; }
    .people-notice { padding: 0 18px 18px; }
    .transfer-row { padding: 20px 16px; gap: 9px; }
    .transfer-row > .avatar { display: none; }
    .transfer-person strong { font-size: 11px; }
    .transfer-person strong span { margin: 0 4px; }
    .transfer-amount { font-size: 13px; }
    .status-badge { display: none !important; }
    .completed-row .transfer-amount { font-size: 12px; }
    .transfer-notice { padding: 0 16px 18px; }
    .dialog-header { padding: 23px 21px 0; }
    .dialog-header h2 { font-size: 22px; }
    dialog form, .dialog-body { padding: 22px 21px; }
    .field-row { gap: 10px; }
    input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea { font-size: 16px; padding: 10px; }
    .field-hint { font-size: 10px; }
    .dialog-actions .button { padding-left: 12px; padding-right: 12px; font-size: 11px; }
    .split-columns { display: none; }
    .split-row { grid-template-columns: minmax(0, 1fr) 82px; gap: 9px; }
    .split-person { grid-column: 1; grid-row: 1; }
    .split-row output { grid-column: 2; grid-row: 1; }
    .weight-controls { grid-column: 1 / -1; grid-row: 2; width: 150px; }
    .weight-controls input[name="weight"] { font-size: 16px; }
    .toast { bottom: 16px; }
  }
  @media (max-width: 380px) {
    .tabs a { font-size: 11px; gap: 5px; }
    .tabs a .icon { display: none; }
  }
}
