:root {
  color-scheme: light;
  --paper: #faf8f3;
  --ink: #322c2c;
  --muted: #706763;
  --line: #ddd7cf;
  --wine: #73283e;
  --masthead-height: 76px;
  --serif: "Baskerville", "Iowan Old Style", "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink); background: var(--paper); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box }
[hidden] { display:none !important }
body { position:relative; isolation:isolate; margin:0; min-width:300px; min-height:100svh }
button, input, textarea { font:inherit; color:inherit }
button { cursor:pointer; border:0; background:transparent; touch-action:manipulation }
button:disabled { cursor:default; opacity:.44 }
:root { -webkit-tap-highlight-color:transparent }
:where(input,textarea,button,[role="tabpanel"]):focus { outline:none }
button:focus-visible { text-decoration:underline; text-underline-offset:.2em }
@media (forced-colors:active) {
  :where(input,textarea,button):focus-visible { outline:2px solid Highlight }
}
.wrap { width:min(100% - 112px, 1024px); margin-inline:auto }
.masthead { border-bottom:1px solid #8e746722 }
.masthead-inner { height:var(--masthead-height); display:flex; align-items:center; justify-content:space-between; position:relative }
.brand { display:flex; align-items:center; gap:13px }
.brand b { font:600 25px/1 var(--serif); letter-spacing:.075em }
.brand-rule { width:1px; height:15px; background:var(--line); margin:0 2px }
.brand-sub,.member-button { font-size:12px; color:var(--muted); letter-spacing:.045em }
.member-button,.member-menu button,.sort-label,.locked-note,.primary,.secondary { display:inline-flex; align-items:center; justify-content:center; gap:8px }
.member-button { min-height:42px; padding:0 4px }
.member-menu { position:absolute; right:0; top:61px; z-index:5; padding:5px; border:1px solid var(--line); border-radius:12px; background:#fffdf9; box-shadow:0 8px 24px #3a252414 }
.member-menu button { border-radius:8px; padding:9px 14px }
i[data-icon] { display:inline-flex; flex:none; width:17px; height:17px; align-items:center; justify-content:center }
i[data-icon] svg { width:100%; height:100% }
i[data-icon=chevron] { width:12px }
.hero { position:relative; display:flex; align-items:center; isolation:isolate; min-height:clamp(326px,29vw,414px); padding:44px 0 34px; }
.hero-copy { position:relative; z-index:1; width:42%; pointer-events:none }
.hero-copy button,.login-form { pointer-events:auto }
.dateline { font-size:12px; letter-spacing:.09em; color:var(--muted); margin:0 0 19px; font-variant-numeric:tabular-nums }
h1 { margin:0; font:500 29px/1.28 var(--serif); letter-spacing:.07em }
.balance { display:flex; gap:13px; align-items:baseline; margin:0 0 13px; white-space:nowrap }
.balance strong { font:normal clamp(78px,8.6vw,116px)/1.04 var(--serif); letter-spacing:-.045em; font-variant-numeric:lining-nums tabular-nums }
.balance strong.long { font-size:clamp(32px,6.1vw,78px) }
.balance span { font-size:16px; color:var(--muted) }
.primary { border:1px solid var(--wine); background:var(--wine); color:#fff9f4; min-height:43px; padding:0 21px; border-radius:99px; font-size:14px; font-weight:550; transition:background .16s, transform .16s }
.primary:active { transform:scale(.97) }
.intro { margin:15px 0 25px; line-height:1.8; font-size:14px; color:var(--muted) }
.ledger { margin:4px 0 70px }
.ledger-head { display:flex; justify-content:space-between; align-items:center; border-bottom:1px solid var(--line); min-height:52px }
.tabs { display:flex; gap:26px }
.tabs button { position:relative; padding:12px 1px 15px; color:var(--muted); font-size:15px }
.tabs button[aria-selected=true] { color:var(--wine); font-weight:600 }
.tabs button[aria-selected=true]::after { content:""; position:absolute; height:2px; background:var(--wine); inset:auto 0 -1px }
.tabs span { margin-left:2px; font-size:12px; font-weight:500 }
.sort-label { font-size:12px; color:var(--muted) }.sort-label i { width:14px }
.empty { text-align:center; padding:46px 12px 52px; border-bottom:1px solid var(--line) }
.empty i { color:#9a7e7f; width:23px; height:23px }
.empty h3 { font-size:15px; font-weight:500; margin:9px 0 3px }.empty p { font-size:12px; color:var(--muted); margin:0 }
.entry,.event { display:grid; align-items:center; gap:18px; padding:22px 0; border-bottom:1px solid var(--line) }
.entry { grid-template-columns:minmax(0,1fr) auto auto }.event { grid-template-columns:minmax(0,1fr) auto }
.entry h3,.event h3 { margin:0; font-size:16px; font-weight:550; overflow-wrap:anywhere; white-space:pre-wrap; line-height:1.55 }
.meta { color:var(--muted); font-size:12px; margin:5px 0 0; line-height:1.65; overflow-wrap:anywhere }
.number { font:26px/1.1 var(--serif); white-space:nowrap; font-variant-numeric:lining-nums tabular-nums }.number small { font:12px/1.5 system-ui; margin-left:4px; color:var(--muted) }
.entry-action { min-height:37px; border:1px solid #d8c9c8; border-radius:99px; padding:0 15px; color:var(--wine); font-size:13px }
.add-number { color:var(--wine) }
.locked-note { display:flex; justify-content:flex-start; border-top:1px solid var(--line); padding-top:18px; gap:7px; color:var(--muted); font-size:12px }
.connection,.error { color:#8b2438; font-size:13px }.connection { padding:10px 0 }
dialog { width:min(420px,calc(100vw - 32px)); padding:27px; border:1px solid var(--line); border-radius:18px; color:var(--ink); background:#fcfaf6; box-shadow:0 18px 80px #24151929; max-height:90dvh; overflow:auto }
#sheet { bottom:var(--keyboard-inset,0px); max-height:min(90dvh,var(--visible-height,100dvh)); overscroll-behavior:contain }
dialog[open] { animation:sheet-in .17s ease-out }dialog::backdrop { background:#2820264d; backdrop-filter:blur(3px) }
@keyframes sheet-in { from { transform:translateY(8px); opacity:.4 } to { transform:none; opacity:1 } }
.sheet-heading { display:flex; align-items:center; justify-content:space-between; gap:14px; margin-bottom:20px }
h2 { margin:0; font:600 24px/1.35 var(--serif); letter-spacing:.04em }
.icon-button { display:grid; place-items:center; border-radius:50%; width:36px; height:36px; color:var(--muted) }
.sheet-context { font-size:14px; margin:-5px 0 19px; color:var(--muted); overflow-wrap:anywhere; white-space:pre-wrap }
.field { margin-top:19px }.field label { display:block; margin-bottom:7px; font-size:13px; font-weight:550 }
textarea,#password,.stepper { width:100%; background:#fffdf9; border:1px solid #cfc6bd; border-radius:10px }
textarea,#password { padding:11px 13px; font-size:16px }textarea { resize:vertical; min-height:80px; max-height:25dvh; display:block }
.stepper { display:flex; align-items:center; justify-content:space-between; padding:2px; height:46px }
.stepper button { display:grid; place-items:center; width:44px; height:40px; border-radius:8px }
.stepper input { background:transparent; border:0; width:5ch; text-align:center; font-size:19px; font-variant-numeric:tabular-nums }
.stepper input, textarea, #password { -webkit-appearance:none; appearance:none; box-shadow:none }
.stepper span { font-size:12px; color:var(--muted) }
.sheet-actions { display:flex; gap:9px; justify-content:flex-end; margin-top:24px }.secondary { border:1px solid var(--line); border-radius:99px; min-height:43px; padding:0 20px; font-size:14px }
.toast { position:fixed; left:50%; bottom:max(22px,env(safe-area-inset-bottom)); transform:translateX(-50%); padding:10px 19px; color:#fffaf4; background:#443838; border-radius:24px; box-shadow:0 4px 20px #24151921; white-space:nowrap; font-size:13px; z-index:9 }
@media (hover:hover) and (pointer:fine) {
  .member-menu button:hover,.icon-button:hover,.secondary:hover { background:#eee8e0 }
  .primary:hover { background:#5c1d31 }
  .entry-action:hover { background:#efe4e3 }
  .stepper button:hover { background:var(--paper) }
}
@media (min-width:1300px) { .hero { min-height:410px } }
@media (max-width:700px) {
  :root { --masthead-height:65px }
  .wrap { width:calc(100% - 40px) }.brand { gap:9px }.brand img { width:30px;height:30px }.brand b { font-size:23px }
  .hero { min-height:296px; padding:28px 0 32px }.hero-copy { width:48% }
  .dateline { font-size:11px; margin-bottom:18px; letter-spacing:.015em } h1 { font-size:24px }.balance { gap:8px; margin:3px 0 14px }.balance strong { font-size:76px }.balance strong.long { font-size:37px }.balance span { font-size:14px }
  .intro { font-size:13px; margin:12px 0 16px }.entry,.event { gap:12px; padding:18px 0 }
  .entry-action { min-height:44px; padding:0 12px }.number { font-size:23px }.empty { padding:38px 10px }
  .member-menu { top:54px }.tabs { gap:22px }
  dialog { margin:auto 0 0; width:100%; max-width:100%; max-height:92dvh; border-radius:19px 19px 0 0; padding:24px 22px max(24px,env(safe-area-inset-bottom)) }
  #sheet { max-height:min(92dvh,var(--visible-height,100dvh)) }
  #reason { resize:none }
  .stepper { height:48px }.stepper button,.icon-button { min-height:44px; min-width:44px }
  .sheet-actions button { flex:1; height:45px }.toast { max-width:95vw }
}
@media (max-width:360px) { .wrap { width:calc(100% - 28px) }.brand-sub { font-size:11px }.hero-copy { width:50% }.dateline { font-size:10px }.sort-label { font-size:11px } }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none !important; transition:none !important } }


/* The scene belongs to the page. Its window light carries through the header,
   and the lower fade clears the working rows. */
.page-atmosphere {
  --scene-height:clamp(535px,49vw,735px);
  position:absolute; z-index:-1; inset:0 0 auto; height:var(--scene-height); pointer-events:none;
  overflow:hidden;
}
.page-atmosphere::before {
  content:""; position:absolute; inset:0;
  background-image:url("/rain-window.webp");
  background-repeat:no-repeat;
  background-size:auto 112%; background-position:right 0 top -28px;
  opacity:.76; filter:saturate(.63) sepia(.15); mix-blend-mode:multiply;
  mask-image:linear-gradient(90deg,transparent max(3%,calc(100% - var(--scene-height)*1.59)),#000 max(57%,calc(100% - var(--scene-height)*.79)),#000),
    linear-gradient(180deg,#000 10%,#000 43%,rgba(0,0,0,.74) 61%,rgba(0,0,0,.19) 79%,transparent 98%);
  mask-composite:intersect;
}
.masthead { position:relative }
.member-button { background:#faf8f3ed; min-height:34px; padding:0 10px; border-radius:99px; color:#504549 }
.ledger { position:relative; isolation:isolate }
.ledger::before {
  content:""; pointer-events:none; position:absolute; z-index:-1; top:9px; right:0;
  width:clamp(190px,27vw,340px); height:clamp(135px,18vw,210px);
  background:url("/ribbon.webp") center / contain no-repeat; opacity:.14;
  mix-blend-mode:multiply; filter:saturate(.7) brightness(1.06);
  mask-image:radial-gradient(ellipse 56% 47% at 54% 48%,#000 30%,#000a 69%,transparent 100%);
}
.ledger-head,.entry,.event,.empty { border-color:#bcaea585 }
.sort-label { color:#635657 }
dialog { isolation:isolate }
dialog[data-mode="add"]::before {
  content:""; position:absolute; z-index:-1; inset:0 8px auto auto; width:190px; height:146px;
  background:url("/paddle.webp") center / contain no-repeat;
  opacity:.20; filter:saturate(.65) brightness(1.06); mix-blend-mode:multiply;
  mask-image:radial-gradient(ellipse 57% 48% at 50% 43%,#000 49%,transparent 100%);
}
@media (min-width:1600px) { .page-atmosphere::before { background-position:right max(0px,calc((100vw - 1600px)*.22)) top -28px } }
@media (max-width:700px) {
  .page-atmosphere { --scene-height:390px }
  .page-atmosphere::before {
    inset:40px 0 auto; height:clamp(240px,73vw,326px);
    background-size:auto 100%; background-position:right -72px top; opacity:.75;
    mask-image:linear-gradient(90deg,transparent 2%,#0001 17%,#0009 47%,#000 76%),
      linear-gradient(180deg,transparent,#000 17%,#000 68%,#0008 86%,transparent);
  }
  .hero-copy { width:61% }
  .member-button { background:#faf8f3e6; min-height:32px }
  .ledger::before { width:186px;height:122px;right:-5px }
}
@media (max-width:380px) {
  .page-atmosphere::before { background-position:right -68px top }
}

.login-form { max-width:320px; margin-top:25px }
.login-form label { display:block; font-size:13px; font-weight:550; margin-bottom:7px }
.login-line { display:flex; gap:8px }
.login-line input { min-width:0; flex:1 }
.login-line button { flex:none; padding-inline:16px }
.login-form .error { margin:8px 0 0 }
#tease p { color:var(--muted); line-height:1.8; margin:12px 0 0 }
@media (max-width:820px) {
  body:has(#login-form:not([hidden])) {
    --login-art-width:min(78vw,calc(100vw - 104px),530px);
    --login-art-height:calc(var(--login-art-width) * 854 / 1280);
    --login-art-top:clamp(32px,6vw,48px);
    --login-art-bottom:calc(var(--login-art-top) + var(--login-art-height));
  }
  body:has(#login-form:not([hidden])) .page-atmosphere { height:var(--login-art-bottom) }
  body:has(#login-form:not([hidden])) .page-atmosphere::before {
    inset:var(--login-art-top) 0 auto auto;
    width:var(--login-art-width); height:var(--login-art-height);
    background-size:cover; background-position:center;
    mask-image:linear-gradient(90deg,transparent,#0003 14%,#000d 43%,#000 68%),
      linear-gradient(180deg,transparent,#000 17%,#000 72%,transparent);
  }
  .hero:has(#login-form:not([hidden])) { display:block; min-height:0; padding:0 0 26px }
  .hero-copy:has(#login-form:not([hidden])) { width:100% }
  .hero-copy:has(#login-form:not([hidden])) .hero-heading {
    min-height:calc(var(--login-art-bottom) - var(--masthead-height));
    padding-top:clamp(28px,7vw,54px);
  }
  .login-form { width:100%; max-width:400px; margin-top:10px }
  .login-line { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px }
  .login-line input,.login-line button { min-height:44px }
  #password { padding-block:8px }
}
