:root {
  --bg: #F4F1E8;
  --bg-2: #ECE7DA;
  --card: #FFFDF7;
  --card-2: #F7F4EA;
  --line: rgba(46, 61, 36, .10);
  --text: #1F271B;
  --muted: #6E7766;
  --matcha-900: #22341C;
  --matcha-700: #3F5F2E;
  --matcha-600: #557A3C;
  --matcha-500: #78A04F;
  --matcha-300: #B8D08A;
  --matcha-100: #E3ECCC;
  --in: #4E7F33;
  --in-soft: #E1EDCF;
  --out: #B5603A;
  --out-soft: #F6E2D6;
  --shadow: 0 1px 2px rgba(34, 52, 28, .05), 0 8px 24px -12px rgba(34, 52, 28, .18);
  --shadow-lg: 0 24px 60px -20px rgba(34, 52, 28, .35);
  --r: 22px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111510; --bg-2: #171C15; --card: #1A2017; --card-2: #20271C; --line: rgba(200, 225, 170, .09);
    --text: #E9EEDF; --muted: #93A086; --matcha-100: #26331F; --matcha-300: #6F8F4C;
    --in: #9CCB6E; --in-soft: rgba(156, 203, 110, .14); --out: #E59372; --out-soft: rgba(229, 147, 114, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111510; --bg-2: #171C15; --card: #1A2017; --card-2: #20271C; --line: rgba(200, 225, 170, .09);
  --text: #E9EEDF; --muted: #93A086; --matcha-100: #26331F; --matcha-300: #6F8F4C;
  --in: #9CCB6E; --in-soft: rgba(156, 203, 110, .14); --out: #E59372; --out-soft: rgba(229, 147, 114, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; min-height: 100dvh; overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h2 { font-size: 26px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pos { color: var(--in); }
.neg { color: var(--out); }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.eyebrow.light { color: rgba(255, 255, 255, .72); }
[hidden] { display: none !important; }

/* ---------- Bố cục ---------- */
.app { min-height: 100dvh; }
.views { overflow-x: clip; max-width: 1080px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.active { display: block; animation: viewIn .5s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 2px 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-2 > .card { margin-bottom: 0; min-width: 0; }
.grid-2 { margin-bottom: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 4px 10px; flex-wrap: wrap; }
.section-head.tight { margin: 0 0 14px; }
.link { color: var(--matcha-600); font-weight: 600; font-size: 14px; }
:root[data-theme="dark"] .link { color: var(--matcha-300); }

/* Tab bar: dưới trên mobile, cột trái trên desktop */
.tabbar {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 4px; padding: 6px;
  background: color-mix(in srgb, var(--card) 82%, transparent); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-lg);
}
.tabbar .brand { display: none; }
/* Bàn phím đang mở trên điện thoại: giấu thanh tab để không đè lên ô nhập */
@media (max-width: 899px) {
  .tabbar { transition: transform .3s var(--ease), opacity .2s; }
  body.kb .tabbar { transform: translate(-50%, 160%); opacity: 0; pointer-events: none; }
  body.kb .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
}
.tabbar button {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 76px; padding: 8px 0 6px; border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 600;
  transition: color .3s var(--ease), transform .2s var(--ease);
}
.tabbar button:active { transform: scale(.94); }
.tabbar button.active { color: #fff; }
.tab-indicator { position: absolute; z-index: 0; top: 6px; left: 0; height: calc(100% - 12px); border-radius: 999px; background: linear-gradient(135deg, var(--matcha-600), var(--matcha-700)); box-shadow: 0 6px 18px -6px var(--matcha-700); transition: transform .45s var(--spring), width .45s var(--spring); }

@media (min-width: 900px) {
  .views { padding: 32px 32px 48px 268px; max-width: 1300px; }
  .tabbar { left: 16px; top: 16px; bottom: 16px; transform: none; flex-direction: column; width: 220px; border-radius: 28px; padding: 14px; gap: 6px; }
  .tabbar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 6px 18px; }
  .tabbar .brand img { border-radius: 10px; }
  .brand-txt { display: grid; line-height: 1.25; min-width: 0; }
  .brand-txt b { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
  .brand-txt small { font-size: 11px; color: var(--muted); font-weight: 500; }
  .tabbar button { flex-direction: row; width: 100%; gap: 12px; padding: 12px 14px; font-size: 15px; justify-content: flex-start; }
  .tab-indicator { left: 14px; top: 0; width: calc(100% - 28px) !important; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  h2 { font-size: 30px; }
}

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; color: #fff; border: 0; padding: 22px 22px 18px; background: var(--matcha-700); }
.hero-bg { position: absolute; inset: 0; background:
  radial-gradient(120% 90% at 100% 0%, rgba(184, 208, 138, .55), transparent 55%),
  radial-gradient(90% 80% at 0% 100%, rgba(34, 52, 28, .9), transparent 60%),
  linear-gradient(135deg, #5E8A41, #2C4521); }
.hero-bg::after { content: ''; position: absolute; inset: 0; opacity: .18; background-image: radial-gradient(rgba(255, 255, 255, .5) 1px, transparent 1px); background-size: 18px 18px; mask: linear-gradient(120deg, transparent 30%, #000); }
.hero > *:not(.hero-bg) { position: relative; }
.hero-num { margin: 2px 0 14px; font-size: clamp(34px, 9vw, 48px); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.hero-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: rgba(255, 255, 255, .85); }
.hero-row b { color: #fff; margin-left: 4px; }
.hero-count { margin-left: auto; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.in { background: var(--matcha-300); }
.dot.out { background: #F1A27E; }
.legend .dot.in { background: var(--in); }
.legend .dot.out { background: var(--out); }

.sync { width: 10px; height: 10px; border-radius: 50%; background: var(--matcha-500); margin-bottom: 10px; box-shadow: 0 0 0 4px var(--matcha-100); transition: background .3s; }
.sync.pending { background: #D9A441; animation: pulse 1.2s infinite; }
.sync.off { background: #B5603A; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px transparent; } }

/* ---------- Ô nhập ---------- */
/* Viền LED RGB chạy vòng quanh khung nhập */
@property --led-a { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.composer {
  --led: conic-gradient(from var(--led-a), #ff2d55, #ff9500, #ffe600, #34e07a, #00c7ff, #5e5ce6, #ff2dd4, #ff2d55);
  position: relative; padding: 10px; border: 2px solid transparent;
  background: linear-gradient(var(--card), var(--card)) padding-box, var(--led) border-box;
  animation: led-spin 4s linear infinite;
  transition: transform .3s var(--ease);
}
.composer::before {
  content: ''; position: absolute; inset: -3px; z-index: -1; border-radius: inherit;
  background: var(--led); filter: blur(18px); opacity: .6;
  animation: led-spin 4s linear infinite; transition: opacity .4s var(--ease), filter .4s var(--ease);
}
.composer.focus, .composer.focus::before { animation-duration: 1.6s; }
.composer.focus::before { opacity: .95; filter: blur(24px); }
@keyframes led-spin { to { --led-a: 360deg; } }
:root:not([data-theme="dark"]) .composer::before { opacity: .4; }
:root:not([data-theme="dark"]) .composer.focus::before { opacity: .7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .composer::before { opacity: .6; } :root:not([data-theme="light"]) .composer.focus::before { opacity: .95; } }
.composer-field { display: flex; align-items: flex-end; gap: 8px; background: var(--card-2); border-radius: 16px; padding: 6px 6px 6px 14px; }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; font-size: 17px; font-weight: 500; padding: 9px 0; line-height: 1.45; max-height: 40vh; }
.composer textarea::placeholder { color: var(--muted); opacity: .75; font-weight: 400; }
.send { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--matcha-500), var(--matcha-700)); transition: transform .25s var(--spring), opacity .2s, filter .2s; }
.send:disabled { opacity: .35; filter: grayscale(.6); cursor: default; }
.send:not(:disabled):active { transform: scale(.88); }
.send.fly svg { animation: fly .5s var(--ease); }
@keyframes fly { 50% { transform: translateX(14px); opacity: 0; } 51% { transform: translateX(-14px); } }

.preview { display: grid; gap: 6px; }
.preview:not(:empty) { padding: 10px 4px 2px; }
.pv { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--card-2); animation: pop .35s var(--spring) both; }
.pv .ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: var(--card); flex: none; }
.pv .pv-tx { flex: 1; min-width: 0; }
.pv .pv-tx b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv .pv-tx small { color: var(--muted); }
.pv .amt { font-weight: 700; }
.pv.hint { background: transparent; border: 1px dashed color-mix(in srgb, var(--matcha-500) 55%, transparent); }
.pv .amt.muted { font-weight: 600; font-size: 13px; }
.pv .warn { color: var(--out); font-weight: 600; }
.pv.err { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.pv-total { display: flex; justify-content: space-between; padding: 4px 10px 2px; font-size: 13px; color: var(--muted); }
.pv-total b { color: var(--text); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 2px; scrollbar-width: none; mask: linear-gradient(90deg, #000 90%, transparent); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px 7px 9px; border-radius: 999px; background: var(--matcha-100); color: var(--text); font-size: 13.5px; font-weight: 500; transition: transform .2s var(--spring), background .2s; white-space: nowrap; }
.chip:active { transform: scale(.93); }
.chip small { color: var(--muted); font-weight: 600; }
.chip.in small { color: var(--in); }
.chip:hover { background: color-mix(in srgb, var(--matcha-300) 45%, var(--matcha-100)); }

/* ---------- Mini thống kê ---------- */
.mini-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14.5px; }
.mini-row span { color: var(--muted); }
.meter { height: 8px; background: var(--out-soft); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--matcha-300), var(--in)); border-radius: inherit; transition: width 1s var(--ease); }
.cat-mini { display: grid; gap: 9px; }
.cat-mini .row { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; font-size: 14px; }
.cat-mini .bar { grid-column: 2 / 4; height: 5px; border-radius: 9px; background: var(--card-2); overflow: hidden; margin-top: -4px; }
.cat-mini .bar i { display: block; height: 100%; background: var(--out); border-radius: inherit; transform-origin: left; animation: grow .8s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.empty { text-align: center; color: var(--muted); padding: 22px 10px; font-size: 14px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 6px; }

/* ---------- Danh sách giao dịch ---------- */
.tx-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tx { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; transition: transform .3s var(--ease), opacity .3s, box-shadow .2s; animation: pop .45s var(--ease) both; cursor: pointer; }
.tx:hover { box-shadow: var(--shadow); }
.tx:active { transform: scale(.985); }
.tx .ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; background: var(--out-soft); flex: none; }
.tx.in .ic { background: var(--in-soft); }
.tx .tx-main { flex: 1; min-width: 0; }
.tx .tx-main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .tx-main small { color: var(--muted); font-size: 12.5px; }
.tx .amt { font-weight: 700; color: var(--out); white-space: nowrap; }
.tx.in .amt { color: var(--in); }
.tx.leaving { opacity: 0; transform: translateX(30px) scale(.96); }
.tx.new { animation: flash 1.2s var(--ease); }
@keyframes flash { 0% { opacity: 0; transform: translateY(-10px) scale(.97); box-shadow: 0 0 0 3px var(--matcha-300); } 60% { box-shadow: 0 0 0 3px var(--matcha-100); } }

.day-group { margin-bottom: 16px; animation: pop .45s var(--ease) both; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.day-head b { color: var(--text); font-size: 14px; }

/* ---------- Báo cáo ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.seg { position: relative; display: inline-flex; background: var(--bg-2); border-radius: 14px; padding: 4px; }
.seg button { position: relative; z-index: 1; padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); transition: color .3s; }
.seg button.active { color: var(--text); }
.seg > i { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; border-radius: 10px; background: var(--card); box-shadow: var(--shadow); transition: transform .4s var(--spring), width .4s var(--spring); }
.seg.small button { padding: 5px 10px; font-size: 13px; }
.stepper { display: flex; gap: 6px; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 22px; line-height: 1; transition: transform .2s var(--spring); }
.stepper button:active { transform: scale(.9); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stats .stat:last-child { grid-column: 1 / -1; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stats .stat:last-child { grid-column: auto; } }
.stat { margin: 0; padding: 14px; min-width: 0; }
.stat b { display: block; font-size: clamp(15px, 4.4vw, 22px); font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; min-height: 1em; }

.bar-chart { height: 200px; display: flex; align-items: flex-end; gap: 3px; position: relative; padding-top: 10px; }
.bar-chart .col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; position: relative; cursor: default; }
.bar-chart .bars { width: 100%; max-width: 30px; flex: 1; display: flex; align-items: flex-end; gap: 2px; }
.bar-chart .b { flex: 1; border-radius: 6px 6px 3px 3px; transform-origin: bottom; animation: rise .7s var(--ease) both; min-height: 0; }
.bar-chart .b.in { background: var(--in); }
.bar-chart .b.cap { background: linear-gradient(to bottom, color-mix(in srgb, var(--in) 25%, transparent), var(--in) 30%); }
.bar-chart .b.out { background: var(--out); opacity: .85; }
.bar-chart .lbl { font-size: 10.5px; color: var(--muted); height: 14px; white-space: nowrap; }
.bar-chart .col:hover .b { filter: brightness(1.1); }
.bar-chart .tip { position: absolute; bottom: calc(100% - 20px); left: 50%; transform: translate(-50%, 6px); background: var(--text); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 10px; white-space: nowrap; pointer-events: none; opacity: 0; transition: .2s var(--ease); z-index: 3; }
.bar-chart .col:hover .tip, .bar-chart .col.show .tip { opacity: 1; transform: translate(-50%, 0); }
@keyframes rise { from { transform: scaleY(0); } }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }

.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
#donut { width: 150px; height: 150px; flex: none; margin: 0 auto; position: relative; }
#donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#donut circle { transition: stroke-dasharray .9s var(--ease), stroke-dashoffset .9s var(--ease); }
#donut .mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
#donut .mid b { font-size: 13px; letter-spacing: -.02em; }
#donut .mid small { color: var(--muted); font-size: 11px; }
.cat-list { list-style: none; padding: 0; margin: 0; flex: 1; min-width: min(200px, 100%); display: grid; gap: 8px; }
.cat-list li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; font-size: 14px; animation: pop .4s var(--ease) both; }
.cat-list li i { width: 10px; height: 10px; border-radius: 4px; }
.cat-list li small { color: var(--muted); margin-left: 4px; }
.recur { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.recur li { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; animation: pop .4s var(--ease) both; }
.recur .ic { width: 38px; height: 38px; border-radius: 12px; background: var(--matcha-100); display: grid; place-items: center; font-size: 18px; }
.recur small { color: var(--muted); display: block; font-size: 12.5px; }
.recur .days { display: flex; gap: 2px; margin-top: 4px; }
.recur .days i { width: 6px; height: 6px; border-radius: 2px; background: var(--card-2); }
.recur .days i.on { background: var(--matcha-500); }

.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; min-width: 0; flex: 1; max-width: 340px; transition: box-shadow .2s; }
.search:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--matcha-500) 25%, transparent); }
.search.wide { max-width: none; margin-bottom: 14px; }
.search svg { width: 18px; height: 18px; color: var(--muted); }
.search input { border: 0; outline: 0; background: none; padding: 11px 0; flex: 1; min-width: 0; }

/* ---------- Ghi chú ---------- */
.notes-grid { columns: 2 170px; column-gap: 12px; }
.note { break-inside: avoid; margin-bottom: 12px; padding: 16px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); cursor: pointer; transition: transform .3s var(--ease), box-shadow .3s; animation: pop .45s var(--ease) both; position: relative; }
.note:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.note h4 { margin: 0 0 6px; font-size: 15.5px; font-weight: 700; padding-right: 18px; }
.note p { margin: 0; white-space: pre-wrap; color: var(--muted); font-size: 14px; max-height: 220px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; }
.note small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 10px; opacity: .8; }
.note .pin { position: absolute; top: 12px; right: 12px; font-size: 13px; }
.note[data-c="matcha"] { background: #E3ECCC; } .note[data-c="latte"] { background: #F1E6D2; } .note[data-c="sakura"] { background: #F7E1E1; } .note[data-c="sky"] { background: #DFEAF2; } .note[data-c="lemon"] { background: #F5EFC8; }
:root[data-theme="dark"] .note[data-c] { background: var(--card); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note[data-c]:not([data-c=""]) { background: var(--card); } }
.note[data-c]:not([data-c=""]) { border-color: transparent; }

/* ---------- Cài đặt ---------- */
.cheat { display: grid; gap: 2px; margin-top: 10px; }
.cheat > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.cheat > div:last-child { border: 0; }
.cheat span { color: var(--muted); margin-left: auto; text-align: right; }
code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; background: var(--matcha-100); padding: 3px 8px; border-radius: 8px; }
.cat-editor { display: grid; gap: 8px; margin-top: 12px; }
.ce { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: start; padding: 10px; background: var(--card-2); border-radius: 16px; animation: pop .35s var(--ease) both; }
.ce input, .ce textarea { width: 100%; border: 1px solid transparent; background: var(--card); border-radius: 10px; padding: 8px 10px; outline: 0; transition: border-color .2s; }
.ce input:focus, .ce textarea:focus { border-color: var(--matcha-500); }
.ce .emo { text-align: center; font-size: 18px; padding: 6px 0; }
.ce .fields { display: grid; gap: 6px; }
.ce .nm { display: flex; gap: 6px; }
.ce textarea { resize: vertical; min-height: 38px; font-size: 13.5px; color: var(--muted); }
.ce .type { padding: 0 10px; border-radius: 10px; font-size: 12.5px; font-weight: 700; background: var(--out-soft); color: var(--out); white-space: nowrap; }
.ce .type.in { background: var(--in-soft); color: var(--in); }
.ce .del { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.ce .del:hover { background: var(--out-soft); color: var(--out); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 14px; font-weight: 600; text-decoration: none; transition: transform .2s var(--spring), filter .2s, background .2s; white-space: nowrap; }
.btn:active { transform: scale(.95); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--matcha-500), var(--matcha-700)); box-shadow: 0 8px 20px -10px var(--matcha-700); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--matcha-100); color: var(--text); }
.btn.small { padding: 7px 12px; font-size: 13.5px; border-radius: 11px; }
.btn.round { border-radius: 999px; }
.btn.danger-ghost { color: var(--out); margin-top: 14px; padding-left: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#themeSeg { margin-top: 12px; }
.pw-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pw-form input, .field { flex: 1; min-width: 160px; border: 1px solid var(--line); background: var(--card-2); border-radius: 14px; padding: 11px 14px; outline: 0; transition: border-color .2s, box-shadow .2s; }
.pw-form input:focus, .field:focus { border-color: var(--matcha-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--matcha-500) 20%, transparent); }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 28, 16, .38); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .35s var(--ease); }
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--card); border-radius: 28px 28px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); transform: translateY(105%); transition: transform .5s var(--ease); }
.sheet.show { transform: none; }
@media (min-width: 700px) { .sheet { bottom: auto; top: 50%; border-radius: 28px; transform: translateY(-40%) scale(.96); opacity: 0; pointer-events: none; transition: transform .45s var(--ease), opacity .3s; } .sheet.show { transform: translateY(-50%); opacity: 1; pointer-events: auto; } }
.grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin-bottom: 14px; font-size: 19px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form .field { min-width: 0; width: 100%; }
.form textarea.field { min-height: 180px; resize: vertical; line-height: 1.55; }
.form .title-field { font-size: 19px; font-weight: 700; border: 0; background: none; padding: 4px 0; }
.form .body-field { border: 0; background: none; padding: 0; min-height: 40dvh; font-size: 15.5px; box-shadow: none !important; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.sheet-actions .spacer { flex: 1; }
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--card-2); padding: 4px; border-radius: 14px; }
.type-toggle button { padding: 9px; border-radius: 10px; font-weight: 700; color: var(--muted); transition: .25s var(--ease); }
.type-toggle button.on.out { background: var(--out); color: #fff; }
.type-toggle button.on.in { background: var(--in); color: #fff; }
.colors { display: flex; gap: 8px; }
.colors button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); transition: transform .2s var(--spring); }
.colors button.on { transform: scale(1.18); border-color: var(--matcha-600); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card-2); transition: transform .2s var(--spring); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.on { background: var(--matcha-100); color: var(--matcha-700); }
.icon-btn.danger { color: var(--out); }

/* ---------- Toast ---------- */
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 11px 12px 11px 16px; border-radius: 16px; font-size: 14px; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .4s var(--ease); max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--matcha-300); font-weight: 700; padding: 4px 8px; }
@media (min-width: 900px) { .toast { bottom: 28px; left: calc(50% + 126px); } }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(60% 50% at 80% 10%, color-mix(in srgb, var(--matcha-300) 45%, transparent), transparent 70%),
  radial-gradient(50% 50% at 10% 90%, color-mix(in srgb, var(--matcha-500) 25%, transparent), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 380px; text-align: center; animation: viewIn .7s var(--ease) both; }
.logo-blob { width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 32px; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow-lg); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-3deg); } }
.login h1 { font-size: 32px; font-weight: 800; }
.login h1 span { color: var(--matcha-600); }
.login p { margin: 8px 0 22px; }
.login .slogan { margin: 6px 0 22px; font-size: 16px; font-weight: 600; color: var(--matcha-600); letter-spacing: .01em; }
.login .slogan::before, .login .slogan::after { content: ''; display: inline-block; width: 22px; height: 2px; border-radius: 2px; background: var(--matcha-300); vertical-align: middle; margin: 0 10px 3px; }
.login p.small { margin: 0 0 10px; }
.login form { display: grid; gap: 10px; }
.login input { border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 14px 16px; font-size: 16px; outline: 0; text-align: center; transition: box-shadow .2s; }
.login input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--matcha-500) 30%, transparent); }
.login .btn { padding: 14px; font-size: 16px; }
.err { color: var(--out); min-height: 1.4em; margin: 4px 0 0 !important; font-size: 14px; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

@media (max-width: 380px) { .tabbar button { width: 66px; } .stats { gap: 6px; } .stat { padding: 12px 10px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } .composer, .composer::before { animation: none !important; } }
