/* Notebook look borrowed from travel-admin's ledger (ink/paper/land/ocean palette, Kalam display). */
:root {
  --ink: #264b4b; --ink-soft: #506c65; --paper: #fffef9; --land: #eff1df; --ocean: #dceef4;
  --butter: #fff1bf; --red: #a3382f; --green: #2f6b3a;
  --display: "Kalam", "Noto Sans TC", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0 auto; max-width: 1080px; min-height: 100svh;
  padding: 24px clamp(14px, 4vw, 48px) 64px;
  font: 16px/1.6 "Noto Sans TC", system-ui, sans-serif; color: var(--ink); background: var(--paper);
  background-image: repeating-linear-gradient(transparent 0 31px, #e8eee6 31px 32px);
}
h1, h2, h3 { line-height: 1.4; margin: 0.6em 0 0.4em; }
h1 { font-size: clamp(26px, 4vw, 38px); margin: 0; }
h2 small, .caption, .meta small, .empty { color: var(--ink-soft); font-size: 13px; font-weight: 400; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .button {
  cursor: pointer; background: var(--land); border: 1.5px solid var(--ink); border-radius: 2px;
  padding: 7px 13px; line-height: 1.5; touch-action: manipulation; display: inline-block;
}
button:hover, .button:hover { background: var(--ocean); }
button:disabled { cursor: not-allowed; opacity: 0.5; }
button.primary { background: var(--butter); font-weight: 700; }
button.danger { border-color: var(--red); color: var(--red); background: #fff; }
:focus-visible { outline: 3px solid #5b9bd5; outline-offset: 2px; }
input, select, textarea { width: 100%; padding: 7px 9px; border: 1.5px solid var(--ink-soft); border-radius: 2px; background: #fff; min-width: 0; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 700; }

.head { border-bottom: 3px solid var(--ink); padding-bottom: 14px; }
.kicker { font: 700 15px var(--display); letter-spacing: 0.05em; margin: 0 0 4px; }
.session { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.session button, #reconnect { min-height: 44px; }
.identity { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.identity img { border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.identity small { display: block; color: var(--ink-soft); }
#sync-status { margin: 6px 0 0; }
#reconnect { margin-top: 6px; }
footer { margin-top: 32px; font-size: 14px; }
a { color: var(--ink); }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin: 22px 0 8px; }
.tabs { display: flex; gap: 8px; }
.tabs button { border-radius: 14px 14px 9px 9px; padding-inline: 16px; box-shadow: 0 3px 0 #d6deec; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#status { min-height: 1.6em; margin: 0; color: var(--ink-soft); font-size: 14px; }

.filters, .grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grow { grid-column: 1 / -1; }
.day { display: flex; justify-content: space-between; font: 700 16px var(--display); border-bottom: 1.5px dashed var(--ink-soft); margin-top: 22px; }
.day span { font: 400 13px "Noto Sans TC", sans-serif; color: var(--ink-soft); }
.entries, .bars, .plain { list-style: none; padding: 0; margin: 0; }
.entry {
  width: 100%; display: grid; grid-template-columns: 7.5em 1fr auto; gap: 10px; align-items: center;
  text-align: left; background: #fff; border-width: 0 0 1px; border-color: #dde3dc; padding: 10px 6px;
}
.cat { font-weight: 700; }
.meta { display: grid; overflow-wrap: anywhere; min-width: 0; }
.money { display: grid; text-align: right; font-variant-numeric: tabular-nums; }
.money small { color: var(--ink-soft); font-size: 12px; }
.amt.income { color: var(--green); }
.amt.transfer { color: var(--ink-soft); }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stats div { background: #fff; border: 1.5px solid var(--ink); padding: 12px; display: grid; }
.stats span { font-size: 13px; color: var(--ink-soft); }
.stats strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.bars li { display: grid; grid-template-columns: 8em 1fr auto; gap: 10px; align-items: center; padding: 4px 0; }
.bars meter { width: 100%; height: 14px; }
.bars strong { font-variant-numeric: tabular-nums; }

dialog { border: 2px solid var(--ink); border-radius: 4px; padding: 18px; width: min(640px, calc(100vw - 20px)); max-height: calc(100svh - 20px); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgb(20 30 30 / 45%); }
.kinds { display: flex; gap: 16px; border: 0; padding: 0; margin: 0 0 12px; }
.kinds label { display: flex; gap: 4px; font-weight: 400; }
.kinds input { width: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 14px; }
#settings .actions { justify-content: flex-start; }
.error { color: var(--red); min-height: 1em; margin: 8px 0 0; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb { font-weight: 400; }
.photo-preview { display: block; padding: 0; cursor: zoom-in; }
.thumb img { display: block; width: 88px; height: 88px; object-fit: cover; }
.thumb span { display: flex; gap: 4px; align-items: center; font-size: 13px; }
.thumb input { width: auto; }
#viewer form { display: grid; gap: 10px; }
#viewer img { max-width: 100%; max-height: 75svh; object-fit: contain; }

@media (max-width: 520px) {
  .entry { grid-template-columns: 1fr auto; }
  .entry .meta { grid-column: 1 / -1; grid-row: 2; }
  .bars li { grid-template-columns: 1fr auto; }
  .bars meter { grid-column: 1 / -1; grid-row: 2; }
}
