:root {
  color-scheme: light;
  --paper: #f7f8f5;
  --white: #fff;
  --ink: #202b28;
  --muted: #7b8580;
  --line: #e4e9e4;
  --green: #28785e;
  --green-dark: #1d614a;
  --green-soft: #e4f0e9;
  --coral: #d77761;
  --coral-soft: #f6e8e2;
  --yellow: #d5ae52;
  --shadow: 0 16px 48px rgba(32, 54, 42, .07);
  font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.app-shell { width: min(100%, 680px); min-height: 100vh; margin: 0 auto; padding: 0 28px 36px; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-size: 17px; font-weight: 800; }
.brand-mark { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; border-radius: 7px; background: var(--green); transform: rotate(-9deg); }
.brand-mark i { width: 2px; border-radius: 3px; background: #eff8ef; transform: rotate(9deg); }
.brand-mark i:nth-child(1) { height: 9px; }.brand-mark i:nth-child(2) { height: 15px; }.brand-mark i:nth-child(3) { height: 11px; }
.icon-button { width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; transition: background .18s, border-color .18s; }
.icon-button:hover { background: var(--white); border-color: #cdd7cf; }
.icon-button svg, .record-button svg, .share-code svg, .modal-symbol svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.main-content { padding-top: 34px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.couple-strip { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.couple-copy { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.couple-copy span { font-size: 13px; font-weight: 700; }
.couple-copy i { padding: 0 4px; color: var(--coral); font-style: normal; }
.couple-copy small { color: var(--muted); font-size: 10px; }
.couple-photos { display: flex; align-items: center; flex: 0 0 auto; padding-right: 4px; }
.couple-photos img { width: 44px; height: 44px; object-fit: cover; border: 2px solid var(--paper); border-radius: 50%; background: var(--white); }
.couple-photos .partner-photo { object-position: 42% 34%; }
.couple-photos .cat-photo { margin-left: -10px; object-position: 50% 35%; }
.eyebrow { margin: 0 0 7px; color: var(--muted); font: 500 11px/1.3 'DM Mono', 'Noto Sans SC', sans-serif; letter-spacing: 0; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 26px; line-height: 1.3; font-weight: 700; }
h2 { margin-bottom: 0; font-size: 17px; line-height: 1.35; font-weight: 700; }
.sync-state { display: inline-flex; align-items: center; gap: 7px; padding-bottom: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #5ca87d; box-shadow: 0 0 0 3px #e4f0e9; }
.sync-state.offline .sync-dot { background: var(--yellow); box-shadow: 0 0 0 3px #f5efd9; }
.people-switch { display: grid; grid-template-columns: 1fr 1fr; margin-top: 26px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #eff2ee; }
.person-tab { min-height: 42px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; transition: color .16s, background .16s, box-shadow .16s; }
.person-tab.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 40, 30, .08); }
.person-tab span { margin-left: 5px; color: var(--muted); font: 400 11px 'DM Mono', sans-serif; }
.balance-panel { position: relative; overflow: hidden; margin-top: 15px; padding: 24px 26px 21px; border-radius: 12px; background: var(--green); color: white; box-shadow: var(--shadow); }
.balance-panel::after { content: ''; position: absolute; width: 150px; height: 150px; right: -76px; top: 49px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 20px rgba(255,255,255,.035), 0 0 0 41px rgba(255,255,255,.025); pointer-events: none; }
.balance-topline { display: flex; align-items: center; justify-content: space-between; color: rgba(255,255,255,.78); font-size: 12px; }
.balance-unit { font-size: 11px; }
.balance-number { margin-top: 3px; font: 500 64px/.98 'DM Mono', monospace; letter-spacing: 0; }
.balance-meta { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 19px; color: rgba(255,255,255,.8); font-size: 11px; }
.balance-meta b { margin-left: 4px; color: #fff; font: 500 12px 'DM Mono', monospace; }
.meta-swatch { display: inline-block; width: 7px; height: 7px; margin-right: 4px; vertical-align: 1px; border-radius: 2px; background: #9cc6ae; }
.weekly-swatch { background: #edc966; }
.balance-note { min-height: 14px; margin-top: 13px; color: rgba(255,255,255,.62); font-size: 10px; }
.log-section, .week-section, .history-section, .settlements-section { margin-top: 34px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.today-count { display: flex; align-items: baseline; gap: 6px; color: var(--muted); }
.today-count span { color: var(--ink); font: 500 22px 'DM Mono', monospace; }
.today-count small { font-size: 10px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr minmax(110px, 1.25fr) 46px; gap: 8px; margin-top: 14px; }
.amount-button { height: 58px; display: flex; align-items: baseline; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); cursor: pointer; transition: transform .12s, border .15s, background .15s; }
.amount-button:hover { border-color: #aac7b5; background: #f7fbf8; }
.amount-button:active, .record-button:active { transform: scale(.97); }
.amount-button span { font: 500 21px 'DM Mono', monospace; }
.amount-button small { color: var(--muted); font-size: 10px; }
.custom-amount { height: 58px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.custom-amount span { color: var(--muted); font-size: 9px; }
.custom-amount input { width: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 500 16px 'DM Mono', monospace; }
.custom-amount input::placeholder { color: #b5bdb7; }
.record-button { display: grid; place-items: center; border: 0; border-radius: 8px; background: var(--coral); color: white; cursor: pointer; transition: transform .12s, background .15s; }
.record-button:hover { background: #c96a54; }
.record-button svg { width: 21px; height: 21px; stroke-width: 2; }
.log-feedback { min-height: 20px; margin-top: 8px; color: var(--green-dark); font-size: 11px; }
.log-feedback.error { color: #b84839; }
.confirm-hint { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.undo-button, .text-button { padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.undo-button { margin-top: 1px; text-decoration: underline; text-underline-offset: 3px; }
.undo-button:hover, .text-button:hover { color: var(--green); }
.week-section { padding-top: 22px; border-top: 1px solid var(--line); }
.compact-head .eyebrow { margin-bottom: 6px; }
.week-range { color: var(--muted); font: 400 10px 'DM Mono', monospace; }
.money-summary { display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; row-gap: 14px; margin-top: 18px; padding: 16px 18px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.55); }
.money-summary > div:not(.net-line) { display: flex; flex-direction: column; gap: 5px; }
.money-summary > div:nth-child(3) { padding-left: 18px; }
.money-label { color: var(--muted); font-size: 10px; }
.money-summary strong { font: 500 21px 'DM Mono', monospace; }
.money-divider { height: 34px; background: var(--line); }
.net-line { grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid var(--line); color: var(--green-dark); font-size: 11px; }
.week-stats { display: flex; gap: 24px; margin-top: 13px; color: var(--muted); font-size: 10px; }
.week-stats div { display: flex; gap: 7px; align-items: center; }
.week-stats b { color: var(--ink); font: 500 11px 'DM Mono', monospace; }
.history-section { padding-top: 21px; border-top: 1px solid var(--line); }
.history-list { margin-top: 8px; }
.history-item { min-height: 54px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.history-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); }
.history-icon.partner { background: var(--coral-soft); color: var(--coral); }
.history-icon svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.history-description { display: flex; flex-direction: column; gap: 3px; }
.history-description b { font-size: 11px; font-weight: 600; }
.history-description small { color: var(--muted); font-size: 9px; }
.history-value { text-align: right; }
.history-value b { display: block; font: 500 12px 'DM Mono', monospace; }
.history-value small { color: var(--muted); font-size: 9px; }
.empty-history { padding: 17px 0; color: var(--muted); font-size: 11px; }
.settlements-section { padding-top: 21px; border-top: 1px solid var(--line); }
.settlement-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin-top: 10px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.settlement-item > span { color: var(--muted); font-size: 10px; }
.settlement-item > b { font: 500 12px 'DM Mono', monospace; }
.settlement-item button { grid-column: 1 / -1; justify-self: start; margin-top: 2px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: transparent; font-size: 10px; cursor: pointer; }
.settlement-item button.paid { border-color: #c8ded0; background: var(--green-soft); color: var(--green-dark); }
.page-footer { margin: 34px 0 8px; color: #98a09b; text-align: center; font-size: 10px; }
.modal-backdrop { position: fixed; z-index: 5; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(24, 39, 32, .34); backdrop-filter: blur(3px); }
.room-modal { position: relative; width: min(100%, 390px); padding: 30px 28px 23px; border-radius: 12px; background: var(--paper); box-shadow: 0 20px 60px rgba(20, 35, 28, .2); }
.modal-close { position: absolute; top: 17px; right: 17px; width: 34px; height: 34px; }
.modal-close svg { width: 17px; height: 17px; }
.modal-symbol { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 11px; background: var(--green-soft); color: var(--green); }
.modal-symbol svg { width: 22px; height: 22px; }
.room-modal h2 { font-size: 22px; }
.modal-copy { margin: 8px 0 23px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.primary-button { min-height: 46px; padding: 0 16px; border: 0; border-radius: 7px; background: var(--green); color: white; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s; }
.primary-button:hover { background: var(--green-dark); }
.full-button { width: 100%; }
.code-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.code-input { width: 100%; height: 46px; margin-bottom: 10px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: white; font: 500 15px 'DM Mono', monospace; text-transform: uppercase; }
.code-input:focus { border-color: #74a38a; box-shadow: 0 0 0 3px rgba(40,120,94,.1); }
.share-code-wrap { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: 10px; }
.share-code { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 13px; border: 1px dashed #b9c9bd; border-radius: 7px; background: #fff; cursor: pointer; }
.share-code span { color: var(--ink); font: 500 19px 'DM Mono', monospace; }
.share-code svg { width: 17px; height: 17px; color: var(--muted); }
.modal-feedback { min-height: 16px; margin: 9px 0 0; color: #b84839; font-size: 10px; }
.modal-footnote { margin: 10px 0 0; color: #9aa39d; font-size: 9px; line-height: 1.6; }
.toast { position: fixed; z-index: 8; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; max-width: calc(100vw - 32px); padding: 10px 15px; border-radius: 7px; background: #26352f; color: white; font-size: 11px; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confirm-modal { width: min(100%, 370px); padding: 25px 23px 20px; border-radius: 12px; background: var(--paper); box-shadow: 0 20px 60px rgba(20, 35, 28, .2); }
.confirm-modal h2 { font-size: 18px; }
.confirm-amount { display: flex; align-items: baseline; gap: 6px; margin: 19px 0 8px; color: var(--muted); font-size: 12px; }
.confirm-amount strong { color: var(--ink); font: 500 38px/1 'DM Mono', monospace; }
.confirm-copy { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 9px; margin-top: 22px; }
.confirm-actions button { min-height: 46px; border-radius: 7px; font-size: 12px; font-weight: 600; cursor: pointer; }
.cancel-button { border: 1px solid var(--line); background: white; }
.confirm-button { border: 0; background: var(--coral); color: white; }
.confirm-button:hover { background: #c96a54; }
.confirm-button:disabled { opacity: .65; cursor: wait; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(40, 120, 94, .3); outline-offset: 2px; }
@media (max-width: 520px) {
  .app-shell { padding: 0 20px max(28px, env(safe-area-inset-bottom)); }
  .topbar { height: 64px; }
  .main-content { padding-top: 26px; }
  h1 { font-size: 23px; }
  .balance-panel { padding: 21px 21px 18px; }
  .balance-number { font-size: 59px; }
  .log-section, .week-section, .history-section, .settlements-section { margin-top: 29px; }
  .week-section, .history-section, .settlements-section { padding-top: 19px; }
}
@media (max-width: 370px) {
  .app-shell { padding-right: 15px; padding-left: 15px; }
  .quick-actions { grid-template-columns: .85fr .85fr minmax(92px, 1.2fr) 42px; gap: 6px; }
  .custom-amount { padding: 0 8px; }
  .money-summary { padding-right: 13px; padding-left: 13px; }
  .money-summary > div:nth-child(3) { padding-left: 13px; }
}
