/* 生活小記 — 現代簡約、淺色／深色 */
:root {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #f0f2f7; --surface-3: #e7eaf2;
  --text: #171a21; --text-2: #5d6474; --text-3: #9298a6; --line: #e3e6ee;
  --accent: #4f6bff; --accent-2: #eef1ff; --accent-text: #ffffff;
  --income: #13a36b; --expense: #e5484d; --warn: #f59e0b;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 6px 20px rgba(20, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(20, 24, 40, .18);
  --r: 16px; --r-sm: 10px; --tab-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1015; --surface: #171a21; --surface-2: #1e222b; --surface-3: #272c37;
    --text: #eceef3; --text-2: #a4abba; --text-3: #6d7486; --line: #2a2f3a;
    --accent: #7b8fff; --accent-2: #232a4d; --accent-text: #0e1015;
    --income: #34d399; --expense: #ff6b6f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1015; --surface: #171a21; --surface-2: #1e222b; --surface-3: #272c37;
  --text: #eceef3; --text-2: #a4abba; --text-3: #6d7486; --line: #2a2f3a;
  --accent: #7b8fff; --accent-2: #232a4d; --accent-text: #0e1015;
  --income: #34d399; --expense: #ff6b6f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, select, textarea { background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); padding: 10px 12px; outline: none; width: 100%; min-height: 44px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); }
input[type="color"] { padding: 4px; width: 52px; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); } .small { font-size: 13px; } .tiny { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }
.income { color: var(--income); } .expense { color: var(--expense); }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 版面 ---------- */
#app { min-height: 100%; }
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidenav { display: none; }
.main { flex: 1; min-width: 0; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; display: flex; align-items: center; gap: 8px; min-height: 56px; }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.page { padding: 4px 16px 16px; max-width: 1100px; margin: 0 auto; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.tab { height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-3); font-size: 11px; font-weight: 600; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }
@media (min-width: 900px) {
  .tabbar { display: none; }
  .main { padding-bottom: 24px; }
  .sidenav { display: flex; flex-direction: column; gap: 4px; width: 220px; padding: 22px 14px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: var(--surface); }
  .sidenav .brand { font-weight: 800; font-size: 19px; padding: 4px 12px 18px; display: flex; align-items: center; gap: 8px; }
  .sidenav .tab { flex-direction: row; justify-content: flex-start; gap: 12px; height: 44px; padding: 0 12px; border-radius: 12px; font-size: 15px; }
  .sidenav .tab.on { background: var(--accent-2); }
  .topbar { padding-top: 18px; }
  .page { padding: 4px 28px 28px; }
}

/* ---------- 元件 ---------- */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.card h3, .section-title { margin: 0 0 10px; font-size: 15px; font-weight: 700; }
.section-title { margin: 20px 4px 8px; color: var(--text-2); font-size: 13px; font-weight: 600; letter-spacing: .3px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--expense); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); }
.icon-btn:hover, .btn:hover { filter: brightness(.97); }
.icon-btn svg { width: 22px; height: 22px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.chip.on { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.on .dot { box-shadow: 0 0 0 2px var(--accent-text); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-3); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { height: 34px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.avatar { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }
.list { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.item:last-child { border-bottom: 0; }
.item .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 18px; flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.empty { text-align: center; color: var(--text-3); padding: 36px 16px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px); z-index: 25; width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center; }
.fab svg { width: 28px; height: 28px; }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--text-2); }

/* ---------- 底部面板 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(10, 12, 20, .42); animation: fade .18s; }
.sheet { position: relative; width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: up .22s cubic-bezier(.2,.8,.2,1); }
.sheet.full { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; max-width: none; }
@media (min-width: 900px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 22px; max-height: 88vh; }
  .sheet.full { height: 88vh; max-width: 860px; border-radius: 22px; }
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 8px; padding-top: max(14px, env(safe-area-inset-top)); }
.sheet.full .sheet-head { padding-top: calc(env(safe-area-inset-top) + 10px); }
.sheet-head h2 { font-size: 17px; margin: 0; flex: 1; text-align: center; }
.sheet-body { overflow-y: auto; padding: 4px 16px 16px; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 0; }
@keyframes up { from { transform: translateY(30px); opacity: 0 } }
@keyframes fade { from { opacity: 0 } }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); z-index: 90; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: up .2s; max-width: 90vw; }

/* ---------- 隱私遮蔽 ---------- */
#cover { position: fixed; inset: 0; z-index: 999; background: var(--bg); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: var(--text-3); }
#cover.on { display: flex; }
#cover .logo { width: 64px; height: 64px; border-radius: 20px; background: var(--accent); display: flex; align-items: center; justify-content: center; color: var(--accent-text); }

/* ---------- 登入 ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px 22px; }
.auth .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth .brand .logo { width: 46px; height: 46px; border-radius: 14px; background: var(--accent); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }

/* ---------- 月曆 ---------- */
.monthnav { display: flex; align-items: center; gap: 4px; }
.monthnav .title { font-size: 20px; font-weight: 800; padding: 0 4px; min-width: 120px; }
.cal { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 12px; font-weight: 600; color: var(--text-3); text-align: center; padding: 8px 0 6px; border-bottom: 1px solid var(--line); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cell { min-height: 88px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 3px 4px; display: flex; flex-direction: column; gap: 2px; text-align: left; overflow: hidden; position: relative; }
.cell:nth-child(7n) { border-right: 0; }
.cell.out { background: var(--surface-2); }
.cell.out .d { color: var(--text-3); }
.cell .d { font-size: 12.5px; font-weight: 700; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; margin-left: 1px; }
.cell.today .d { background: var(--accent); color: var(--accent-text); }
.cell.sun .d, .cell.sat .d { color: var(--text-2); }
.cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.sh { font-size: 10.5px; font-weight: 700; line-height: 16px; height: 16px; border-radius: 5px; padding: 0 4px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh.off { background: var(--surface-3) !important; color: var(--text-2); }
.sh.annual { background: #fde68a !important; color: #7c5a00; }
.nt { font-size: 10.5px; line-height: 15px; height: 15px; border-radius: 4px; padding: 0 4px; background: var(--accent-2); color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.lg { font-size: 10.5px; font-weight: 700; margin-top: auto; text-align: right; padding-right: 2px; }
.nt .tm { display: none; }
@media (min-width: 900px) { .nt .tm { display: inline; } }
.more { font-size: 10px; color: var(--text-3); padding-left: 3px; }
@media (min-width: 900px) { .cell { min-height: 116px; padding: 6px; gap: 3px; } .sh, .nt { font-size: 12px; height: 19px; line-height: 19px; } .lg { font-size: 12px; } }
@media (max-width: 380px) { .cell { min-height: 76px; } }

/* ---------- 排班 ---------- */
.roster .rrow { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); min-height: 52px; }
.roster .rrow:last-child { border-bottom: 0; }
.roster .rdate { width: 52px; flex: none; text-align: center; line-height: 1.15; }
.roster .rdate b { display: block; font-size: 18px; }
.roster .rdate span { font-size: 11.5px; color: var(--text-3); }
.roster .rrow.today .rdate b { color: var(--accent); }
.roster .rrow.weekend { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.roster .rcells { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.rchip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 10px; background: var(--surface-2); font-size: 13px; font-weight: 600; min-height: 34px; }
.rchip .bar { width: 4px; align-self: stretch; border-radius: 4px; }
.rchip .t { color: var(--text-2); font-weight: 500; font-size: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--text-2); }
.wiz-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wiz-cal .wh { text-align: center; font-size: 12px; color: var(--text-3); font-weight: 600; }
.wday { aspect-ratio: 1 / 1.05; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-weight: 700; font-size: 15px; position: relative; overflow: hidden; }
.wday small { font-size: 10px; font-weight: 700; line-height: 1.1; max-width: 100%; padding: 0 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wday.blank { visibility: hidden; }
.wday.off { background: var(--surface-3); box-shadow: none; color: var(--text-2); }
.wday.annual { background: #fde68a; color: #7c5a00; box-shadow: none; }
.wday.work { color: #fff; box-shadow: none; }
.wday.locked { opacity: .45; }
.counter { display: flex; gap: 8px; flex-wrap: wrap; }
.counter .badge { height: 26px; font-size: 13px; }
.counter .badge.ok { background: color-mix(in srgb, var(--income) 18%, transparent); color: var(--income); }
.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 12px; }
.stepper button { width: 44px; height: 44px; font-size: 20px; font-weight: 600; color: var(--accent); }
.stepper input { text-align: center; background: transparent; border: 0; width: 56px; min-height: 44px; padding: 0; font-weight: 700; font-size: 17px; }
.tpl-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; height: 40px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; font-size: 13.5px; }
.tpl-chip .sw { width: 12px; height: 12px; border-radius: 4px; }
.tpl-chip.on { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-2); }
.timepair { display: flex; align-items: center; gap: 8px; }
.timepair input { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .5px; }
.timepair span { color: var(--text-3); font-weight: 600; flex: none; }

/* ---------- 記事 ---------- */
.date-head { position: sticky; top: 56px; z-index: 5; background: var(--bg); padding: 12px 4px 6px; font-weight: 700; font-size: 13.5px; color: var(--text-2); display: flex; gap: 8px; align-items: baseline; }
.date-head.today { color: var(--accent); }
.note-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; display: block; width: 100%; text-align: left; margin-bottom: 8px; border-left: 4px solid var(--accent); }
.note-card .ttl { font-weight: 700; font-size: 15px; }
.note-card .ex { color: var(--text-2); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.ed-toolbar { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 6px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 3; }
.ed-toolbar::-webkit-scrollbar { display: none; }
.ed-toolbar button { flex: none; min-width: 38px; height: 36px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--text-2); padding: 0 8px; }
.ed-toolbar button.on { background: var(--accent-2); color: var(--accent); }
.ed-area { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 4px 16px; min-height: 260px; margin-top: 10px; }
.title-input { font-size: 22px; font-weight: 800; background: transparent; padding: 6px 2px; border: 0; }
.title-input:focus { background: transparent; border: 0; }
.md { font-size: 15.5px; line-height: 1.7; word-break: break-word; }
.md .ProseMirror, .ProseMirror { outline: none; min-height: 240px; padding: 8px 0; }
.md h1 { font-size: 1.5em; margin: .6em 0 .3em; } .md h2 { font-size: 1.28em; margin: .6em 0 .3em; } .md h3 { font-size: 1.1em; margin: .5em 0 .2em; }
.md p { margin: .35em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: .35em 0; }
.md blockquote { margin: .5em 0; padding: 2px 12px; border-left: 3px solid var(--accent); color: var(--text-2); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.md pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md ul[data-type="taskList"] { list-style: none; padding-left: .2em; }
.md ul[data-type="taskList"] li { display: flex; gap: 8px; align-items: flex-start; }
.md ul[data-type="taskList"] li > label { margin-top: 4px; }
.md ul[data-type="taskList"] li > div { flex: 1; }
.md ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--text-3); text-decoration: line-through; }
.ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--text-3); float: left; height: 0; pointer-events: none; }
.mention-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mention-row:last-child { border-bottom: 0; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 30px; height: 30px; border-radius: 50%; }
.colors button.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }

/* ---------- 記帳 ---------- */
.daynav { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; }
.daynav .label { text-align: center; font-weight: 700; }
.daynav .label small { display: block; font-size: 12px; color: var(--text-2); font-weight: 500; }
.lrow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 58px; width: 100%; text-align: left; }
.lrow:last-child { border-bottom: 0; }
.lrow .ic { width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.lrow .amt { font-weight: 800; font-size: 17px; }
.lrow .amt.zero { color: var(--text-3); font-weight: 600; font-size: 15px; }
.lrow .add { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.ask .seg { width: 120px; flex: none; }
.ask { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface-2); }
.sum-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sum-bar .stat b { font-size: 18px; }
.numpad-display { text-align: right; padding: 8px 4px 2px; }
.numpad-display .amt { font-size: 44px; font-weight: 800; letter-spacing: .5px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.numpad button { height: 58px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); font-size: 24px; font-weight: 700; }
.numpad button.fn { background: var(--surface-2); box-shadow: none; font-size: 17px; }
.numpad button.ok { background: var(--accent); color: var(--accent-text); font-size: 18px; grid-column: span 3; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; }
.kpi span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.kpi b { display: block; font-size: 19px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .delta { font-size: 11.5px; font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut-wrap svg { flex: none; }
.rank .ritem { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank .ritem:last-child { border-bottom: 0; }
.rank .rbar { grid-column: 2 / 4; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.rank .rbar i { display: block; height: 100%; border-radius: 3px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-top: 8px; }
.bars .b { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; position: relative; }
.bars .b.off { background: var(--text-3); opacity: .55; }
.bars .b.today { opacity: 1; box-shadow: 0 0 0 1px var(--text); }
.bars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.cmp-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.cmp-row:last-child { border-bottom: 0; }
.updown.up { color: var(--expense); } .updown.down { color: var(--income); }
.dayblock { margin-bottom: 10px; }
.dayblock .dh { display: flex; justify-content: space-between; padding: 8px 4px 6px; font-size: 13px; font-weight: 700; color: var(--text-2); }

/* ---------- 設定 ---------- */
.set-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; min-height: 54px; }
.set-item:last-child { border-bottom: 0; }
.set-item .ic { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.set-item .ic svg { width: 18px; height: 18px; }
.set-item .chev { color: var(--text-3); }
.drag-list .ditem { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.drag-list .ditem:last-child { border-bottom: 0; }
.drag-list .ditem .mv { display: flex; flex-direction: column; }
.drag-list .ditem .mv button { width: 30px; height: 22px; color: var(--text-3); font-size: 12px; }
.code-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; word-break: break-all; user-select: all; }
.steps { padding-left: 1.3em; margin: 6px 0; } .steps li { margin: 4px 0; }
.drag-list .tpl-chip { min-width: 78px; justify-content: center; flex: none; }

/* ---------- 記帳專案 ---------- */
.transfer { color: var(--accent); }
.lg.pj { color: var(--accent); }
.pj-tag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 700; background: color-mix(in srgb, var(--pc) 16%, transparent); color: var(--pc); }
.proj-card { border-top: 4px solid var(--pc); }
.pbar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 4px; background: var(--pc, var(--accent)); }
.proj-row, .act-row { display: block; width: 100%; text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); }
.proj-row:last-child, .act-row:last-of-type { border-bottom: 0; }
.proj-row { border-left: 3px solid var(--pc); padding-left: 10px; margin-top: 8px; }

/* ---------- 深色配色（設定 → 深色配色；預設 graphite 即上面的深色） ---------- */
:root[data-theme="dark"][data-dark="navy"] {
    --bg: #0b1220; --surface: #121b2d; --surface-2: #18233a; --surface-3: #223050;
    --text: #e8edf7; --text-2: #a3b0c8; --text-3: #6b7a96; --line: #22304a;
    --accent: #7aa2ff; --accent-2: #1c2a4d; --accent-text: #0b1220; --income: #3ddc97; --expense: #ff6b81;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-dark="navy"] {
    --bg: #0b1220; --surface: #121b2d; --surface-2: #18233a; --surface-3: #223050;
    --text: #e8edf7; --text-2: #a3b0c8; --text-3: #6b7a96; --line: #22304a;
    --accent: #7aa2ff; --accent-2: #1c2a4d; --accent-text: #0b1220; --income: #3ddc97; --expense: #ff6b81;
} }
:root[data-theme="dark"][data-dark="oled"] {
    --bg: #000000; --surface: #0f0f10; --surface-2: #1a1a1c; --surface-3: #26262a;
    --text: #f2f2f4; --text-2: #a1a1aa; --text-3: #6b6b74; --line: #222226;
    --accent: #8b9bff; --accent-2: #1d2140; --accent-text: #000000; --income: #34d399; --expense: #ff6b6f;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-dark="oled"] {
    --bg: #000000; --surface: #0f0f10; --surface-2: #1a1a1c; --surface-3: #26262a;
    --text: #f2f2f4; --text-2: #a1a1aa; --text-3: #6b6b74; --line: #222226;
    --accent: #8b9bff; --accent-2: #1d2140; --accent-text: #000000; --income: #34d399; --expense: #ff6b6f;
} }
:root[data-theme="dark"][data-dark="warm"] {
    --bg: #141210; --surface: #1d1a17; --surface-2: #26221e; --surface-3: #322d28;
    --text: #f1ece6; --text-2: #b8ada0; --text-3: #7d7368; --line: #2e2924;
    --accent: #f0a35e; --accent-2: #3a2a1a; --accent-text: #141210; --income: #7bd88f; --expense: #ff7a6b;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-dark="warm"] {
    --bg: #141210; --surface: #1d1a17; --surface-2: #26221e; --surface-3: #322d28;
    --text: #f1ece6; --text-2: #b8ada0; --text-3: #7d7368; --line: #2e2924;
    --accent: #f0a35e; --accent-2: #3a2a1a; --accent-text: #141210; --income: #7bd88f; --expense: #ff7a6b;
} }
:root[data-theme="dark"][data-dark="forest"] {
    --bg: #0b1412; --surface: #121e1b; --surface-2: #182824; --surface-3: #21352f;
    --text: #e6f0ec; --text-2: #a2b8b0; --text-3: #6a827a; --line: #20302b;
    --accent: #4fd1a5; --accent-2: #16332a; --accent-text: #0b1412; --income: #5eead4; --expense: #ff7a85;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-dark="forest"] {
    --bg: #0b1412; --surface: #121e1b; --surface-2: #182824; --surface-3: #21352f;
    --text: #e6f0ec; --text-2: #a2b8b0; --text-3: #6a827a; --line: #20302b;
    --accent: #4fd1a5; --accent-2: #16332a; --accent-text: #0b1412; --income: #5eead4; --expense: #ff7a85;
} }
.dk-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.dk-opt { border-radius: 14px; padding: 8px; box-shadow: inset 0 0 0 1px var(--line); text-align: left; }
.dk-opt.on { box-shadow: inset 0 0 0 2px var(--accent); }
.dk-opt .pv { height: 46px; border-radius: 9px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.dk-opt .pv i { display: block; height: 8px; border-radius: 4px; }
.dk-opt span { display: block; font-size: 12.5px; font-weight: 700; margin-top: 6px; }
.lg { white-space: nowrap; overflow: hidden; text-overflow: clip; letter-spacing: -.2px; }

/* ---------- Apple 質感半透明材質（v1.4） ---------- */
:root { --glass: rgba(255,255,255,.66); --glass-strong: rgba(250,250,252,.80); --glass-line: rgba(0,0,0,.08); --glass-blur: saturate(180%) blur(22px); --dim: rgba(10,12,20,.28); }
:root[data-theme="dark"] { --glass: rgba(30,32,40,.62); --glass-strong: rgba(26,28,36,.78); --glass-line: rgba(255,255,255,.08); --dim: rgba(0,0,0,.45); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --glass: rgba(30,32,40,.62); --glass-strong: rgba(26,28,36,.78); --glass-line: rgba(255,255,255,.08); --dim: rgba(0,0,0,.45); } }
:root[data-theme="dark"][data-dark="oled"] { --glass: rgba(28,28,30,.62); --glass-strong: rgba(22,22,24,.80); --glass-line: rgba(255,255,255,.10); --dim: rgba(0,0,0,.55); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-dark="oled"] { --glass: rgba(28,28,30,.62); --glass-strong: rgba(22,22,24,.80); --glass-line: rgba(255,255,255,.10); --dim: rgba(0,0,0,.55); } }
.topbar { background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); box-shadow: 0 .5px 0 var(--glass-line); }
.tabbar { background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border-top: .5px solid var(--glass-line); }
.sheet-bg { background: var(--dim); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet { background: var(--glass-strong); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); box-shadow: 0 0 0 .5px var(--glass-line), var(--shadow-lg); }
.sheet-foot { background: var(--glass); border-top: .5px solid var(--glass-line); }
.sheet .list, .sheet .card, .sheet .numpad button:not(.fn):not(.ok) { background: color-mix(in srgb, var(--surface) 82%, transparent); }
.toast { background: var(--glass-strong); color: var(--text); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); box-shadow: 0 0 0 .5px var(--glass-line), var(--shadow-lg); }
.date-head { background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); margin: 0 -16px; padding-left: 20px; padding-right: 20px; }
.ed-toolbar { background: var(--glass-strong); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }
.fab { box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent), 0 0 0 .5px var(--glass-line); }
#cover { background: var(--glass-strong); backdrop-filter: saturate(160%) blur(40px); -webkit-backdrop-filter: saturate(160%) blur(40px); }
.seg { background: color-mix(in srgb, var(--surface-3) 80%, transparent); }
@media (min-width: 900px) { .sidenav { background: var(--glass); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border-right: .5px solid var(--glass-line); } }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .sheet, #cover { background: var(--bg); } }
:root[data-theme="dark"][data-accent="blue"] { --accent: #0A84FF; --accent-2: color-mix(in srgb, #0A84FF 22%, transparent); --accent-text: #ffffff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="blue"] { --accent: #0A84FF; --accent-2: color-mix(in srgb, #0A84FF 22%, transparent); --accent-text: #ffffff; } }
:root[data-theme="dark"][data-accent="indigo"] { --accent: #5E5CE6; --accent-2: color-mix(in srgb, #5E5CE6 22%, transparent); --accent-text: #ffffff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="indigo"] { --accent: #5E5CE6; --accent-2: color-mix(in srgb, #5E5CE6 22%, transparent); --accent-text: #ffffff; } }
:root[data-theme="dark"][data-accent="purple"] { --accent: #BF5AF2; --accent-2: color-mix(in srgb, #BF5AF2 22%, transparent); --accent-text: #ffffff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="purple"] { --accent: #BF5AF2; --accent-2: color-mix(in srgb, #BF5AF2 22%, transparent); --accent-text: #ffffff; } }
:root[data-theme="dark"][data-accent="pink"] { --accent: #FF375F; --accent-2: color-mix(in srgb, #FF375F 22%, transparent); --accent-text: #ffffff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="pink"] { --accent: #FF375F; --accent-2: color-mix(in srgb, #FF375F 22%, transparent); --accent-text: #ffffff; } }
:root[data-theme="dark"][data-accent="orange"] { --accent: #FF9F0A; --accent-2: color-mix(in srgb, #FF9F0A 22%, transparent); --accent-text: #000000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="orange"] { --accent: #FF9F0A; --accent-2: color-mix(in srgb, #FF9F0A 22%, transparent); --accent-text: #000000; } }
:root[data-theme="dark"][data-accent="yellow"] { --accent: #FFD60A; --accent-2: color-mix(in srgb, #FFD60A 22%, transparent); --accent-text: #000000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="yellow"] { --accent: #FFD60A; --accent-2: color-mix(in srgb, #FFD60A 22%, transparent); --accent-text: #000000; } }
:root[data-theme="dark"][data-accent="green"] { --accent: #30D158; --accent-2: color-mix(in srgb, #30D158 22%, transparent); --accent-text: #000000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="green"] { --accent: #30D158; --accent-2: color-mix(in srgb, #30D158 22%, transparent); --accent-text: #000000; } }
:root[data-theme="dark"][data-accent="mint"] { --accent: #63E6E2; --accent-2: color-mix(in srgb, #63E6E2 22%, transparent); --accent-text: #000000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="mint"] { --accent: #63E6E2; --accent-2: color-mix(in srgb, #63E6E2 22%, transparent); --accent-text: #000000; } }
:root[data-theme="dark"][data-accent="cyan"] { --accent: #64D2FF; --accent-2: color-mix(in srgb, #64D2FF 22%, transparent); --accent-text: #000000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="cyan"] { --accent: #64D2FF; --accent-2: color-mix(in srgb, #64D2FF 22%, transparent); --accent-text: #000000; } }
:root[data-theme="dark"][data-accent="gray"] { --accent: #AEAEB2; --accent-2: color-mix(in srgb, #AEAEB2 22%, transparent); --accent-text: #000000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-accent="gray"] { --accent: #AEAEB2; --accent-2: color-mix(in srgb, #AEAEB2 22%, transparent); --accent-text: #000000; } }
.acc-opts { display: flex; flex-wrap: wrap; gap: 10px; }
.acc-opts button { width: 38px; height: 38px; border-radius: 50%; position: relative; }
.acc-opts button.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.acc-opts button.def { background: conic-gradient(#0A84FF, #BF5AF2, #FF375F, #FF9F0A, #30D158, #0A84FF); }

/* ---------- 行事曆格子 v1.5：班表／記事／記帳分區 ---------- */
:root { --fill: rgba(120,120,128,.12); --fill-2: rgba(120,120,128,.07); }
:root[data-theme="dark"] { --fill: rgba(120,120,128,.26); --fill-2: rgba(120,120,128,.14); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fill: rgba(120,120,128,.26); --fill-2: rgba(120,120,128,.14); } }
.cal-grid .cell { gap: 3px; padding: 4px 3px 3px; }
.z-sh, .z-nt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.z-lg { margin-top: auto; display: flex; flex-direction: column; align-items: flex-end; font-size: 10px; font-weight: 700; line-height: 13px; letter-spacing: -.2px; white-space: nowrap; }
.z-lg .pj { color: var(--accent); }
/* 班別文字色：淺色加深、深色提亮，維持對比 */
.sh { --tc: color-mix(in srgb, var(--c) 78%, #000); color: var(--tc) !important; background: var(--fill) !important; height: auto; line-height: 1.25; padding: 2px 5px; border-radius: 6px; font-size: 10.5px; font-weight: 800; display: flex; align-items: center; gap: 4px; min-width: 0; }
:root[data-theme="dark"] .sh { --tc: color-mix(in srgb, var(--c) 72%, #fff); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sh { --tc: color-mix(in srgb, var(--c) 72%, #fff); } }
.sh .sn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh .stm { display: none; font-weight: 600; opacity: .75; font-size: .92em; }
.sh .ud { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.sh.k-off { --tc: var(--text-3) !important; font-weight: 600; }
.nt { background: none !important; color: var(--text-2); padding: 0 2px; height: auto; line-height: 1.3; font-weight: 600; font-size: 10.5px; display: flex; align-items: center; gap: 3px; white-space: nowrap; overflow: hidden; }
.nt::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--c); flex: none; }
@media (min-width: 900px) { .sh .stm { display: inline; } .sh, .nt { font-size: 12px; } .z-lg { font-size: 12px; line-height: 15px; flex-direction: row; justify-content: flex-end; gap: 6px; } }

/* 1. 玻璃膠囊：半透明玻璃底＋細框 */
.cs-pill .sh { border-radius: 999px; padding: 2px 6px; box-shadow: inset 0 0 0 .5px var(--glass-line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); justify-content: center; }
.cs-pill .z-lg { border-top: .5px solid var(--line); padding-top: 2px; width: 100%; }

/* 2. 左緣色條：玻璃底＋班別色條 */
.cs-bar .sh { border-radius: 4px 6px 6px 4px; box-shadow: inset 2.5px 0 0 var(--c); padding-left: 6px; }
.cs-bar .nt { padding-left: 3px; }

/* 3. 分區卡：班表一條、記事、記帳底欄各自一區 */
.cs-zone .cell { padding: 0; gap: 0; }
.cs-zone .cell .d { margin: 3px 0 2px 3px; }
.cs-zone .z-sh { padding: 0 3px 3px; }
.cs-zone .sh { border-radius: 5px; justify-content: center; padding: 3px 4px; }
.cs-zone .z-nt { padding: 3px 3px 2px; border-top: .5px dashed var(--line); }
.cs-zone .z-lg { background: var(--fill-2); width: 100%; padding: 2px 4px; border-top: .5px solid var(--line); }

/* 4. 極簡：只有彩色文字、記事圓點 */
.cs-minimal .sh { background: none !important; padding: 0 2px; font-size: 11px; }
.cs-minimal .sh.k-off { font-size: 10.5px; }
.ndots { display: flex; gap: 3px; padding: 2px 3px; }
.ndots i { width: 6px; height: 6px; border-radius: 50%; }
.cs-minimal .z-lg { opacity: .9; }

/* v1.5.1 合併檢視：左邊緣條＝使用者顏色，班別只用文字顏色 */
.sh .ud { display: none; }
.cal-grid .sh.mu { box-shadow: inset 3px 0 0 var(--uc), inset 0 0 0 .5px var(--glass-line); padding-left: 7px; }
.cs-pill .sh.mu { border-radius: 4px 999px 999px 4px; }

/* v1.6 膠囊左側細弧條、自訂顏色 */
.cal-grid .sh.mu { box-shadow: inset 2px 0 0 color-mix(in srgb, var(--uc) 85%, transparent), inset 0 0 0 .5px var(--glass-line); padding-left: 6px; }
.cs-pill .sh.mu { border-radius: 999px; }
.colors .cc { width: 30px; height: 30px; border-radius: 50%; position: relative; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--text-2);
  background: conic-gradient(#ff3b30, #ff9500, #ffcc00, #34c759, #00c7be, #007aff, #af52de, #ff2d55, #ff3b30); cursor: pointer; overflow: hidden; }
.colors .cc:not([style*="background"])::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface); }
.colors .cc { z-index: 0; } .colors .cc > * { position: relative; z-index: 1; }
.colors .cc input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; min-height: 0; padding: 0; z-index: 2; }
.colors .cc.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }
.sw-big { width: 28px; height: 28px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.15); }

/* v1.7 管理者：登入鎖定清單 */
.lock-card { gap: 10px; }
.lock-row { gap: 10px; padding-top: 10px; border-top: .5px solid var(--line); }
.lock-row .btn { flex: none; }
