:root{font:100%/1.55 "Inter","Noto Sans TC","Microsoft JhengHei",system-ui,sans-serif;color:var(--ink);background:#f4f6f1;--ink:#152823;--dim:#50635a;--line:#dce5dc;--green:#114b3b;--lime:#dcf482}
*{box-sizing:border-box}
body{margin:0}
[hidden]{display:none!important}
button,input,select{font:inherit}
button,select,summary{cursor:pointer}
button{min-height:44px;padding:.55rem .9rem;border:1px solid transparent;border-radius:10px;background:var(--green);color:white;font-weight:700}
button:disabled{opacity:.65;cursor:wait}
:focus-visible{outline:3px solid #4e932e;outline-offset:3px}
a{color:inherit}
.topbar{background:#fcfdf9;border-bottom:1px solid var(--line)}
.top-inner,main{max-width:1190px;margin:auto;padding-inline:clamp(1rem,4vw,2.2rem)}
.top-inner,.page-heading,.ledger header,footer,dialog header,.draft-heading{display:flex;align-items:center;justify-content:space-between;gap:1rem}
.top-inner{min-height:72px}
.brand{display:flex;align-items:center;gap:.7rem;font-size:1.15rem;letter-spacing:.05em;font-weight:800;text-decoration:none}
.brand img{border-radius:12px}
main{padding-top:clamp(1.3rem,4vw,3rem);padding-bottom:max(1.5rem,env(safe-area-inset-bottom))}
h1,h2,h3,p{margin:0}
h1{font-size:clamp(1.85rem,4vw,2.8rem);letter-spacing:-.045em;line-height:1.2}
h2{font-size:1.25rem}
h3{font-size:1rem}
#today{color:var(--dim);margin-top:.45rem}
.book-control{display:grid;gap:.24rem;font-size:.875rem;color:var(--dim);min-width:0}
.book-control select{min-width:9rem;max-width:13rem;font-weight:700}
input,select{border:1px solid #c8d6cb;border-radius:10px;padding:.6rem .75rem;min-height:44px;color:var(--ink);background:white;max-width:100%}
.summary{display:grid;grid-template-columns:1.28fr 1fr 1fr;gap:1rem;margin:1.4rem 0 1.15rem}
.summary>div{padding:clamp(.85rem,2.2vw,1.45rem);border:1px solid var(--line);border-radius:19px;background:#fcfdf9;min-width:0}
.summary .balance{background:#e7f1dd;border-color:#d4e3ce}
.summary span{font-size:.9rem;font-weight:700;display:flex;align-items:center;gap:.5rem}
.summary strong{display:block;font-size:clamp(1.45rem,4.2vw,2.6rem);line-height:1.15;margin:.55rem 0 .1rem;overflow-wrap:anywhere;font-variant-numeric:tabular-nums;letter-spacing:-.045em}
.summary small{color:var(--dim)}
.stat-icon{font-style:normal;display:inline-grid;place-items:center;width:1.6rem;height:1.6rem;border-radius:50%;background:#e4efdc;color:#215641}
.negative{background:#f6ece5;color:#854727}
.workspace{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.16fr);gap:1.15rem;align-items:start}
.capture,.ledger{border-radius:22px;padding:clamp(1rem,2.5vw,1.65rem)}
.capture{background:radial-gradient(ellipse at 50% 5%,#316952 0%,transparent 65%),#103b30;color:#f7fff5;text-align:center;min-height:380px}
.signal{width:128px;height:128px;border:1px solid #85b49a55;border-radius:50%;margin:.1rem auto .65rem;display:grid;place-items:center;background:radial-gradient(circle,#d6fa8420,transparent 75%);box-shadow:inset 0 0 0 12px #bde1ae0d,0 0 0 9px #bde1ae0a}
.wave{display:flex;align-items:center;gap:4px}
.wave i{display:block;width:3px;height:14px;border-radius:8px;background:#dff795;box-shadow:0 0 10px #dff79555}
.wave i:nth-child(2n){height:25px}
.wave i:nth-child(3n){height:35px}
.wave i:nth-child(5){height:47px}
.capture:has(.voice:disabled) .wave i{animation:pulse .7s ease-in-out infinite alternate}
.capture:has(.voice:disabled) .wave i:nth-child(even){animation-delay:.2s}
@keyframes pulse{to{transform:scaleY(.42)}}
.capture h2{font-size:1.6rem}
.capture-description{color:#d6e8dc;margin:.25rem 0 .8rem}
.voice,.confirm{background:var(--lime);color:#183627;min-width:9.6rem;border-radius:99px}
#quick,#draft{text-align:left;margin:1rem 0 0}
#quick label{font-size:.875rem;color:#e4eee7}
.row{display:flex;gap:.55rem;margin-top:.25rem}
.row input{flex:1;min-width:0}
.row button{flex:none}
#quick button{background:#e2f1e3;color:#174637}
#status:empty,#backup-status:empty{display:none}
#status,#backup-status{margin-top:.6rem;font-size:.925rem}
.ledger{min-height:380px;background:#fcfdf9;border:1px solid var(--line)}
.outline{background:#fcfdf9;color:var(--green);border-color:#cddbd0}
.empty{min-height:267px;display:grid;align-content:center;justify-items:center;text-align:center;padding:.75rem;gap:.25rem}
.empty p{color:var(--dim);font-size:.94rem}
.empty-icon{width:56px;height:56px;margin-bottom:.35rem;border:1px solid #dce7d6;background:#edf4e8;border-radius:16px;display:grid;place-content:center;gap:4px}
.empty-icon i{width:20px;border-top:2px solid #437760}
.empty-icon i:last-child{width:12px}
.text-button{background:transparent;color:var(--green);padding:.3rem .4rem}
.capture .text-button{color:#e1f4df}
#entries{padding:0;list-style:none;margin:.9rem 0 0}
#entries:empty{margin:0}
#entries li{display:flex;justify-content:space-between;align-items:center;gap:.6rem;padding:.7rem 0;border-bottom:1px solid var(--line)}
#entries li span{min-width:0;overflow-wrap:anywhere}
#entries li>span:last-child{font-weight:750;text-align:right;font-variant-numeric:tabular-nums}
#entries small{display:block;color:var(--dim)}
fieldset{display:grid;gap:.5rem;border:1px solid #7ba28b;padding:.75rem;margin:.55rem 0;border-radius:10px}
fieldset label{display:grid;grid-template-columns:3.3rem minmax(0,1fr);align-items:center;gap:.5rem}
footer{font-size:.875rem;color:var(--dim);margin-top:.85rem}
dialog{width:min(30rem,calc(100% - 2rem));max-height:calc(100% - 2rem);border:1px solid var(--line);border-radius:18px;background:#fcfdf9;color:var(--ink);padding:1.2rem}
dialog::backdrop{background:#0b211ab3}
dialog header{margin-bottom:1rem}
.backup-actions{margin:1rem 0;display:flex;gap:.55rem;flex-wrap:wrap}
.import{display:block}
@media(max-width:670px){
.workspace{grid-template-columns:1fr}
.summary{grid-template-columns:1fr 1fr;gap:.65rem}
.summary .balance{grid-column:1/-1}
.summary strong{font-size:1.6rem}
.summary .balance strong{font-size:2rem}
.top-inner{min-height:62px}
.book-control select{min-width:0;width:100%;max-width:9rem}
.ledger,.capture{min-height:0}
.empty{min-height:205px}
}
@media(prefers-reduced-motion:reduce){.wave i{animation:none!important}}
:root{
  --page:#edf2eb;--surface:#fbfdf8;--raised:#fff;--soft:#e5f0df;--outline:#cbd9d0;
  --glow:#bfd9c3;--hero:#103b30;--hero-light:#3e795d;--action-ink:#193426;
  --inc:#367652;--out:#a65a40;--shadow:#243f3020;--head:#f9fcf6df;
}
:root[data-theme=dusk]{
  --page:#f1edf6;--surface:#fcf9ff;--raised:#fff;--soft:#ece1f5;--outline:#dacee5;
  --glow:#d9c2eb;--hero:#372453;--hero-light:#79578c;--action-ink:#40224c;
  --ink:#2c2039;--dim:#685574;--line:#e4dcea;--green:#633d76;--lime:#f4c9ef;
  --inc:#713ca0;--out:#a54f63;--shadow:#3d23521e;--head:#fcf9ffdf;
}
:root[data-theme=midnight]{
  color-scheme:dark;
  --page:#111827;--surface:#1b2536;--raised:#182234;--soft:#273851;--outline:#445677;
  --glow:#283958;--hero:#162a4b;--hero-light:#345989;--action-ink:#162c50;
  --ink:#f2f6ff;--dim:#b3c0d8;--line:#32415c;--green:#96bdfb;--lime:#b6d6ff;
  --inc:#86bbfa;--out:#ffa891;--shadow:#02061764;--head:#172234eb;
}
:root{background:var(--page)}
body{background:radial-gradient(ellipse at 50% 2%,var(--glow),transparent 38rem),var(--page);min-height:100vh}
.topbar{position:sticky;top:0;z-index:2;background:var(--head);backdrop-filter:blur(20px) saturate(145%)}
.top-actions{display:flex;align-items:center;gap:.4rem}
.top-actions a{display:grid;align-items:center;min-height:44px;padding:.4rem .55rem;text-decoration:none;font-weight:750;color:var(--green)}
.summary>div,.ledger,.analytics,dialog{background:var(--surface);box-shadow:0 12px 28px -22px var(--shadow),inset 0 1px 0 color-mix(in srgb,var(--raised),transparent 40%)}
.summary .balance{background:linear-gradient(135deg,var(--soft),var(--surface));border-color:var(--outline)}
.stat-icon,.empty-icon{background:var(--soft);color:var(--inc);border-color:var(--outline)}
.negative{color:var(--out)}
.empty-icon i{border-color:var(--inc)}
input,select{background:var(--raised);border-color:var(--outline)}
button{background:var(--green);color:var(--surface)}
.outline{background:var(--raised);border-color:var(--outline);color:var(--green)}
.capture{background:radial-gradient(ellipse at 50% 4%,var(--hero-light),transparent 70%),var(--hero);box-shadow:0 15px 30px -20px var(--shadow)}
.wave i{background:var(--lime)}
.voice,.confirm,#quick button{background:var(--lime);color:var(--action-ink)}
.analytics{margin-top:1.15rem;padding:clamp(1rem,2.5vw,1.65rem);border:1px solid var(--line);border-radius:22px;scroll-margin-top:5.5rem}
.analytics-heading{display:flex;align-items:center;justify-content:space-between;gap:.75rem}
.analytics-heading p,.chart-detail{font-size:.875rem;color:var(--dim);margin-top:.2rem}
.period-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.5rem;margin:.9rem 0}
.period-metrics div{min-width:0;border-radius:13px;padding:.6rem .7rem;background:var(--soft);font-size:.875rem}
.period-metrics strong{display:block;font-size:clamp(1.1rem,3vw,1.55rem);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.analytics-empty{min-height:3.75rem;color:var(--dim)}
.analysis-grid{display:grid;grid-template-columns:minmax(0,1.28fr) minmax(0,1fr);gap:.75rem}
.analysis-card{border:1px solid var(--line);border-radius:15px;padding:.8rem;min-width:0}
.chart-legend{display:flex;gap:.8rem;font-size:.875rem;margin:.25rem 0;color:var(--dim)}
.chart-legend span::before{content:"";display:inline-block;width:.55rem;height:.55rem;border-radius:50%;background:var(--inc);margin-right:.35rem}
.chart-legend span+span::before{background:var(--out)}
.trend{display:grid;grid-template-columns:repeat(var(--buckets),minmax(0,1fr));gap:.15rem}
.trend-column{min-width:0;padding:.3rem .1rem;background:transparent;color:var(--dim);font-size:.75rem;overflow-wrap:anywhere}
.trend-column[aria-pressed=true]{background:var(--soft);color:var(--ink)}
.bar-pair{height:6rem;display:flex;justify-content:center;align-items:end;gap:2px;border-bottom:1px solid var(--line);margin-bottom:.2rem}
.bar-pair i{width:34%;max-width:18px;background:var(--inc);border-radius:4px 4px 0 0}
.bar-pair i+i{background:var(--out)}
.categories{list-style:none;padding:0;margin:.6rem 0 0;display:grid;gap:.65rem}
.categories li>div:first-child{display:flex;justify-content:space-between;gap:.5rem;font-size:.875rem;overflow-wrap:anywhere}
.category-track{height:.35rem;border-radius:1rem;overflow:hidden;background:var(--soft);margin-top:.25rem}
.category-track i{display:block;height:100%;background:var(--out);border-radius:inherit}
.theme-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.55rem}
.theme-grid button{display:grid;gap:.4rem;text-align:left;border-color:var(--outline);color:var(--ink);background:var(--surface)}
.theme-grid button[aria-pressed=true]{border-color:var(--green);box-shadow:inset 0 0 0 1px var(--green)}
.theme-grid i{height:36px;border-radius:6px;background:linear-gradient(125deg,#e5f0df 50%,#215644 50%)}
.theme-grid [data-choice=dusk] i{background:linear-gradient(125deg,#eddbf5 50%,#694783 50%)}
.theme-grid [data-choice=midnight] i{background:linear-gradient(125deg,#19273e 50%,#8cbbff 50%)}
.theme-grid [data-choice=system] i{background:linear-gradient(125deg,#f4f5f7 50%,#353a47 50%)}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.drive-backup{margin-top:1rem;padding-top:1rem;border-top:1px solid var(--line)}
.drive-backup p,.drive-backup small{color:var(--dim)}
.drive-backup label{display:block;margin:.5rem 0}
.drive-backup select{width:auto;max-width:100%}
#drive-status:empty{display:none}
@media(max-width:670px){
  .analysis-grid{grid-template-columns:1fr}
  .period-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
  .top-inner{gap:.25rem}
  .top-actions{gap:.15rem}
  .top-actions button,.top-actions a{padding-inline:.42rem;font-size:.875rem}
  .brand{font-size:1rem;gap:.35rem;letter-spacing:0;white-space:nowrap}
  .brand img{width:34px;height:34px}
}
main{padding-bottom:calc(7rem + env(safe-area-inset-bottom))}
.app-view{margin-top:1rem}
#record-view .capture{max-width:44rem;margin-inline:auto}
#manual{display:block;margin:.5rem auto 0}
.settings-view{padding:clamp(1rem,2.5vw,1.65rem);border:1px solid var(--line);border-radius:22px;background:var(--surface)}
.settings-actions{display:flex;flex-wrap:wrap;gap:.5rem;margin-bottom:1.2rem}
.storage-note{color:var(--dim);margin:.35rem 0 .75rem}
.bottom-nav{
 position:fixed;z-index:3;left:50%;bottom:max(.75rem,env(safe-area-inset-bottom));transform:translateX(-50%);
 display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.3rem;width:min(29rem,calc(100% - 1.25rem));
 padding:.35rem;border:1px solid var(--outline);border-radius:20px;background:var(--head);
 backdrop-filter:blur(24px) saturate(155%);box-shadow:0 8px 26px var(--shadow)
}
.bottom-nav a{
 display:grid;place-items:center;align-content:center;gap:.23rem;min-height:52px;
 border-radius:14px;color:var(--dim);text-decoration:none;font-size:.875rem;font-weight:750
}
.bottom-nav a[aria-current=page]{background:var(--soft);color:var(--green)}
.nav-icon{display:block;position:relative;width:17px;height:16px}
.nav-record{width:9px;height:13px;border:2px solid currentColor;border-radius:9px;margin-bottom:3px}
.nav-record::after{content:"";position:absolute;inset:3px -5px -5px;border:2px solid currentColor;border-top:0;border-radius:0 0 9px 9px}
.nav-ledger{border:2px solid currentColor;border-radius:4px}
.nav-ledger::after{content:"";position:absolute;inset:4px 2px;border-block:1px solid currentColor}
.nav-insights{background:linear-gradient(currentColor,currentColor) left bottom / 3px 40%,linear-gradient(currentColor,currentColor) center bottom / 3px 70%,linear-gradient(currentColor,currentColor) right bottom / 3px 100%;background-repeat:no-repeat}
.nav-settings{width:15px;height:15px;border:2px dotted currentColor;border-radius:50%}
.nav-settings::after{content:"";position:absolute;inset:3px;border:1px solid currentColor;border-radius:50%}
.settings-view{box-shadow:0 12px 28px -22px var(--shadow)}
input::placeholder{color:var(--dim);opacity:1}
html{scroll-padding-bottom:calc(6rem + env(safe-area-inset-bottom))}
@media(min-width:671px){
  main{padding-top:clamp(1rem,3vh,2.2rem)}
  .summary{margin:1rem 0}
  .summary>div{padding:1rem 1.2rem}
  #record-view .capture{min-height:0;padding:1.15rem 1.35rem}
  .signal{width:104px;height:104px}
}
@media(max-width:670px){
  .top-inner{min-height:54px}
  .summary{margin:.7rem 0}
  .summary>div{padding:.6rem .75rem}
  .summary .balance{display:flex;align-items:center;justify-content:space-between;gap:.5rem}
  .summary .balance small{display:none}
  .summary .balance strong{margin:0;font-size:1.65rem}
  .signal{width:86px;height:86px}
}
