:root {
  color-scheme: light;
  --peanut-bg: #fff7e6;
  --peanut-paper: #fffdfa;
  --peanut-ink: #382518;
  --peanut-muted: #715b49;
  --peanut-line: #eadbc2;
  --peanut-gold: #f7c453;
  --peanut-gold-soft: #ffedbb;
  --peanut-leaf: #3d632b;
  --peanut-leaf-soft: #e9f1d9;
  --peanut-coral: #a04032;
  --peanut-shadow: 0 10px 32px #6e43100c;
}

body {
  background: radial-gradient(ellipse at top left, #ffe9ad 0%, transparent 55%) no-repeat var(--peanut-bg);
  color: var(--peanut-ink);
  line-height: 1.5;
}
body.mobile-ready {
  --mist: var(--peanut-bg);
  --line: var(--peanut-line);
  --ink: var(--peanut-ink);
  --muted: var(--peanut-muted);
  --blue: var(--peanut-leaf);
  --blue-soft: var(--peanut-leaf-soft);
}
.muted, small { color: var(--peanut-muted); }
.income, #status, #quick [role=status] { color: var(--peanut-leaf); }
.expense, #quick [role=alert], #formError { color: var(--peanut-coral); }

.desktop-header {
  min-height: 74px;
  justify-content: space-between;
  gap: 16px;
  border-bottom-color: var(--peanut-line);
  background: var(--peanut-paper);
}
.site-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.site-brand img { border-radius: 12px; flex: none; }
#brand { color: var(--peanut-ink); font-size: clamp(1.1rem, 2.4vw, 1.5rem); }
#nav button { font-weight: 650; text-underline-offset: .5em; }
#nav button.active { color: var(--peanut-leaf); text-decoration-thickness: 2px; }

main#app, #quick, .ledger-ready .cloud {
  width: min(1240px, calc(100% - 40px));
  margin-inline: auto;
  border: 1px solid var(--peanut-line);
  border-radius: 22px;
  background: var(--peanut-paper);
  box-shadow: var(--peanut-shadow);
}
#quick[hidden] { display: none; }
main#app[data-view="總覽"] { background: transparent; border: 0; box-shadow: none; }
.top, .bar, aside, th, td, .group { border-color: var(--peanut-line); }
.top { padding: 22px 24px; }
.bar, aside, th, .group { background: #fff4df; }
.account, .claim-card, .claim-empty, .claim-summary { border-color: var(--peanut-line); border-radius: 16px; }
.claim-summary { background: var(--peanut-leaf-soft); }
.claim-due { color: var(--peanut-leaf); }
button, input, select, textarea { border-color: #dfcfb7; border-radius: 9px; }
button:hover, .side.active { background: var(--peanut-gold-soft); }
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--peanut-leaf);
  outline-offset: 2px;
}
.primary, .mobile-ready .primary, .mobile-ready #quick footer .primary {
  background: var(--peanut-gold);
  border-color: #e5ac39;
  color: #352212;
}
.primary:hover, .mobile-ready .primary:hover, .mobile-ready #quick footer .primary:hover { background: #ffda79; }
#quick .entry-types { gap: 4px; }
#quick .entry-types button { border-radius: 999px; }
#quick .entry-types button[aria-pressed="true"] {
  background: var(--peanut-leaf-soft);
  color: var(--peanut-leaf);
  box-shadow: none;
  font-weight: 750;
}

.overview-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 29%);
  align-items: center;
  gap: clamp(12px, 3vw, 40px);
  padding: clamp(16px, 4vw, 44px);
  border: 1px solid var(--peanut-line);
  border-radius: 26px;
  background: linear-gradient(145deg, #fffdf8, #ffedb4);
}
.overview-content h1 { margin: 0 0 14px; font-size: clamp(1.45rem, 3vw, 2rem); }
.overview-art {
  width: 100%;
  height: auto;
  border-radius: 14%;
  mix-blend-mode: multiply;
}
.overview-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 0; }
.overview-metric { min-width: 0; padding: 9px 12px; background: #fffcf3; border-radius: 13px; }
.overview-metric:first-child { grid-column: 1/-1; background: var(--peanut-leaf-soft); }
.overview-metric dt { color: var(--peanut-muted); font-size: .85rem; font-weight: 650; }
.overview-metric dd { margin: 2px 0 0; font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.overview-metric:first-child dd { color: var(--peanut-leaf); font-size: clamp(1.6rem, 4vw, 2.8rem); }
.overview-metric dd.metric-note { font-size: .72rem; color: var(--peanut-muted); font-weight: 550; }
.overview-detail {
  margin-top: 16px;
  padding: 16px 20px;
  border: 1px solid var(--peanut-line);
  border-radius: 20px;
  background: var(--peanut-paper);
  box-shadow: var(--peanut-shadow);
}
.overview-detail h2 { margin: 0; font-size: 1.08rem; }
.overview-detail .asset-list { padding: 0; }
.overview-detail li { border-color: var(--peanut-line); }
.overview-detail li:last-child { border: 0; }
.overview-detail li strong { text-align: right; }

.login-shell {
  background: radial-gradient(ellipse at 10% 5%, #ffdf87, transparent 60%), var(--peanut-bg);
}
.login-shell .login-card {
  width: min(100%, 820px);
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-color: var(--peanut-line);
  background: var(--peanut-paper);
}
.login-art { display: grid; align-items: center; padding: 22px; background: #fff0c5; }
.login-art img { width: 100%; height: auto; border-radius: 18%; mix-blend-mode: multiply; }
.login-content { min-width: 0; padding: clamp(18px, 4vw, 42px); }
.login-content h1 { font-size: clamp(1.52rem, 4vw, 2.25rem); color: var(--peanut-ink); }
.login-content .brand-mark { border-radius: 14px; }

@media (max-width: 740px) {
  .desktop-header { min-height: 60px; padding: max(8px, env(safe-area-inset-top)) 14px 8px; }
  .site-brand img { width: 36px; height: 36px; }
  .mobile-ready main#app, .mobile-ready #quick { width: calc(100% - 24px); margin: 12px auto; }
  .mobile-ready main#app { background: var(--peanut-paper); }
  .mobile-ready #quick .quick-fields { background: #fff9eb; }
  .mobile-ready #quick footer { display: flex; }
  .mobile-ready #quick footer .primary { flex: 1; }
  #mobileNav:not([hidden]) { background: #fff9ecf5; border-top: 1px solid var(--peanut-line); padding-bottom: max(5px, env(safe-area-inset-bottom)); }
  #mobileNav button[aria-current] { color: var(--peanut-leaf); text-decoration-thickness: 2px; }
  .m-round, .m-segment { border-color: var(--peanut-line); background: #fff7e6; }
  .m-segment button[aria-pressed=true], .m-round[aria-pressed=true], .m-record i, .m-account i { color: var(--peanut-leaf); }
  .overview-hero { grid-template-columns: minmax(0, 1fr) 72px; align-items: start; position: relative; gap: 6px; }
  .overview-content { display: contents; }
  .overview-content h1 { grid-column: 1/-1; margin: 2px 78px 15px 0; }
  .overview-metrics { grid-column: 1/-1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-metric:first-child { grid-column: auto; }
  .overview-metric:first-child dd { font-size: 1.16rem; }
  .overview-art { position: absolute; width: 58px; top: 3px; right: 14px; pointer-events: none; }
  .overview-detail { padding: 12px 14px; }
  .login-shell { padding: 16px; }
  .login-shell .login-card { width: min(100%, 430px); grid-template-columns: 1fr; }
  .login-art { padding: 8px; justify-items: center; }
  .login-art img { width: min(42vw, 156px); }
  .login-content .brand-mark { display: none; }
}
.peanut-entry { display: none; }
#quickSheet:not([open]) { display: none; }
#quick .template-picker { grid-column: 1/-1; max-width: 280px; }
@media (max-width: 740px) {
  .desktop-header { padding-top: calc(14px + env(safe-area-inset-top)); }
  .peanut-entry { display: grid; justify-content: center; padding: 26px 0; }
  .peanut-entry button {
    display: grid; justify-items: center; gap: 6px; padding: 9px 26px 12px;
    border-color: #e5ac39; border-radius: 22px; background: var(--peanut-gold);
    font-weight: 750;
  }
  .peanut-shell { display: grid; font-size: 2rem; line-height: 1.15; }
  .peanut-shell span { grid-area: 1/1; }
  .peanut-shell span:first-child { clip-path: inset(0 50% 0 0); }
  .peanut-shell span:last-child { clip-path: inset(0 0 0 50%); }
  body:has(#quickSheet[open]) .peanut-shell span:first-child { transform: translateX(-4px) rotate(-12deg); }
  body:has(#quickSheet[open]) .peanut-shell span:last-child { transform: translateX(4px) rotate(12deg); }
  body:has(#quickSheet[open]) { overflow: hidden; }
  #quickSheet[open] {
    position: fixed; inset: auto 0 0; margin: 0 auto; width: min(100%, 540px);
    max-width: 100%; max-height: 88dvh; padding: 0 0 env(safe-area-inset-bottom);
    overflow: auto; overscroll-behavior: contain; background: var(--peanut-paper);
    border: 1px solid var(--peanut-line); border-radius: 24px 24px 0 0;
  }
  #quickSheet::backdrop { background: #38251866; }
  #quickSheet #quick { width: 100%; margin: 0; padding: 18px; border: 0; box-shadow: none; }
  #quickSheet #quick h2 { padding-right: 46px; }
  #quickSheet .sheet-close { position: absolute; top: 10px; right: 12px; min-width: 44px; font-size: 1.3rem; }
  #quick .template-picker { max-width: none; margin: 8px 0 12px; }
}
@media (max-width: 740px) and (prefers-reduced-motion: no-preference) {
  .peanut-shell span { transition: transform .18s ease; }
  #quickSheet[open] { animation: quick-slide .2s ease-out; }
  @keyframes quick-slide { from { transform: translateY(18px); opacity: .7; } }
}

#quick .template-controls {
  grid-column: 1/-1; display: flex; align-items: end; flex-wrap: wrap;
  gap: 6px 10px; margin: 0 0 12px;
}
#quick .template-controls .template-picker { flex: 1 1 130px; margin: 0; }
#quick .template-controls button { min-height: 38px; }
