/* Theme tokens. These defaults are the "classic" notebook; each [data-theme] block below overrides them. */
:root {
  --ink: #2d3a6e;
  --ink-soft: #5b6797;
  --on-ink: #fff;
  --line: #c8cde2;
  --paper: #fffefb;
  --desk: #eeece6;
  --desk-image: none;
  --chrome: #fffefb;
  --chrome-text: #2d3a6e;
  --nav-text: #2a2d3a;
  --text: #2a2d3a;
  --muted: #7a7f92;
  --hover: #eef0f8;
  --field: #fff;
  --reading: #dfe4f6;
  --done: #f3d27a;
  --done-ink: #8a6512;
  --alert: #c62828;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(30, 35, 60, .08);
  --radius: 14px;
  --serif: "Noto Serif TC", "Songti TC", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--desk);
  background-image: var(--desk-image);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 8px;
  border: 1.5px solid var(--ink); background: var(--ink); color: var(--on-ink);
  text-decoration: none; font-weight: 500;
}
.btn:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--hover); }
.btn-google { background: #fff; color: var(--text); border-color: #d5d8e3; padding: 10px 20px; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); text-align: center; padding: 48px 32px; }
.login-card h1 { font-family: var(--serif); color: var(--ink); margin: 8px 0; font-size: 32px; }
.login-card p { color: var(--muted); }
.login-mark { font-size: 40px; color: var(--ink); }
.fine { font-size: 13px; margin-top: 24px; }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: var(--chrome); color: var(--chrome-text);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--chrome-text); text-decoration: none; }
.topbar .btn-ghost, .nav-toggle { color: var(--chrome-text); border-color: var(--chrome-text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--line); }
.avatar:not([src]) { visibility: hidden; }
.save-status { font-size: 13px; color: var(--muted); min-width: 64px; text-align: right; }
.save-status.error { color: var(--alert); }
.nav-toggle { display: none; background: none; border: 0; font-size: 22px; color: var(--ink); }

.layout { display: flex; max-width: 1280px; margin: 0 auto; }
.sidebar {
  width: 200px; flex-shrink: 0; padding: 24px 12px;
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
}
.sidebar a {
  display: block; padding: 7px 12px; border-radius: 8px;
  text-decoration: none; color: var(--nav-text);
}
.sidebar a:hover { background: var(--hover); color: var(--text); }
.sidebar a.active { background: var(--ink); color: var(--on-ink); }
.nav-group { font-size: 12px; color: var(--nav-text); opacity: .65; margin: 16px 12px 4px; letter-spacing: .1em; }
.nav-sep { border-top: 1px solid var(--line); margin: 16px 12px; }
.view { flex: 1; min-width: 0; padding: 24px 24px 64px; }

/* ---------- Paper ---------- */
.paper {
  background: var(--paper);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.page { max-width: 880px; margin: 0 auto; padding: 40px 48px 48px; }
.page-head { margin-bottom: 24px; }
.page-head h1 {
  font-family: var(--serif); color: var(--ink); font-size: 22px; margin: 0;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.page-head h1 small { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); letter-spacing: .12em; }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }

.box {
  border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 18px;
}
.box-title { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: 15px; }
.box-hint { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.bullet { display: flex; gap: 8px; align-items: center; color: var(--ink); font-weight: 700; margin-top: 10px; }
.bullet::before { content: ""; width: 7px; height: 7px; background: var(--ink); }

/* Writing surfaces: ruled lines so it still reads like paper. */
textarea.lined, .lined {
  width: 100%; border: 0; resize: vertical; background-color: transparent;
  background-image: linear-gradient(transparent calc(2em - 1px), var(--line) calc(2em - 1px));
  background-size: 100% 2em; background-attachment: local;
  line-height: 2em; padding: 0 2px; min-height: 6em; outline: none;
}
input.inline {
  border: 0; border-bottom: 1px solid var(--line); background: transparent;
  padding: 2px 4px; outline: none; width: 100%;
}
input.inline:focus, textarea:focus { border-color: var(--ink); }
textarea.lined:focus { box-shadow: inset 0 0 0 1px var(--line); border-radius: 4px; }

/* ---------- Pickers (month / week) ---------- */
.picker { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; max-width: 880px; margin-inline: auto; }
.chip {
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper);
  text-decoration: none; font-size: 13px; color: var(--text);
}
.chip.filled { border-color: var(--ink-soft); }
.chip.filled::after { content: " •"; color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip.active::after { color: var(--on-ink); }

/* ---------- Home ---------- */
.home-hello { max-width: 960px; margin: 0 auto 20px; }
.home-hello h1 { font-family: var(--serif); color: var(--ink); margin: 0; }
.home-hello p { color: var(--muted); margin: 4px 0 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; max-width: 960px; margin: 0 auto; }
.card { padding: 20px; text-decoration: none; display: block; transition: transform .15s; }
.card:hover { transform: translateY(-2px); }
.card-icon { height: 56px; color: var(--ink); }
.card-icon svg { height: 56px; width: auto; }
.card-icon svg path, .card-icon svg rect { fill: none; stroke: currentColor; stroke-width: 2; }
.card h3 { font-family: var(--serif); color: var(--ink); margin: 8px 0 2px; font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- Wishes (jars) ---------- */
.jars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px 12px; }
.jar { position: relative; aspect-ratio: 100 / 130; }
.jar svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.jar svg path, .jar svg rect { fill: transparent; stroke: var(--ink-soft); stroke-width: 1.6; transition: fill .2s; }
.jar.done svg path { fill: var(--done); }
.jar textarea {
  position: absolute; left: 16%; right: 16%; top: 32%; bottom: 20%;
  border: 0; background: transparent; resize: none; text-align: center;
  font-size: 13px; line-height: 1.5; outline: none; overflow: hidden;
}
.jar label { position: absolute; left: 0; right: 0; bottom: 5%; text-align: center; font-size: 12px; color: var(--muted); }
.jar.done label { color: var(--done-ink); font-weight: 700; }

/* ---------- Books (shelves) ---------- */
.shelf { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 0 12px; border-bottom: 3px double var(--ink); margin-bottom: 26px; }
.spine {
  flex: 1; min-width: 0; border: 1.5px solid var(--ink-soft); border-bottom: 0;
  border-radius: 14px 14px 0 0; background: var(--paper);
  writing-mode: vertical-rl; text-orientation: upright;
  font-size: 12px; padding: 10px 0; overflow: hidden; color: var(--text);
  display: flex; align-items: center; justify-content: flex-start;
}
.spine:hover { background: var(--hover); }
.spine.reading { background: var(--reading); }
.spine.done { background: var(--done); border-color: var(--done-ink); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 20px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--ink-soft); border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .l-reading::before { background: var(--reading); }
.legend .l-done::before { background: var(--done); }

/* ---------- Rewards (bags) ---------- */
.bags { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.bag { position: relative; aspect-ratio: 1 / 1.05; }
.bag svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.bag svg path { fill: transparent; stroke: var(--ink-soft); stroke-width: 1.6; transition: fill .2s; }
.bag.done svg .bag-body { fill: var(--done); }
.bag-fields { position: absolute; left: 14%; right: 14%; top: 36%; bottom: 8%; display: flex; flex-direction: column; gap: 2px; }
.bag-fields input[type=text] { border: 0; border-bottom: 1px dashed var(--line); background: transparent; font-size: 13px; text-align: center; outline: none; padding: 2px 0; }
.bag-fields .goal { font-size: 12px; color: var(--muted); }
.bag-fields label { margin-top: auto; text-align: center; font-size: 12px; color: var(--muted); }
.bag.done .bag-fields label { color: var(--done-ink); font-weight: 700; }

/* ---------- Learning schedule ---------- */
.schedule { width: 100%; border-collapse: collapse; table-layout: fixed; }
.schedule th { background: var(--hover); color: var(--ink); font-weight: 500; font-size: 13px; padding: 6px 0; border: 1px solid var(--line); }
.schedule td { border: 1px solid var(--line); padding: 0; }
.schedule input { width: 100%; border: 0; padding: 6px; background: transparent; outline: none; font-size: 13px; }
.schedule input:focus { background: var(--hover); }

/* ---------- Weekly ---------- */
.week-top { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 16px; color: var(--ink); font-weight: 700; }
.weather { display: flex; gap: 4px; }
.weather button { background: none; border: 1px solid transparent; border-radius: 6px; font-size: 18px; padding: 0 4px; opacity: .35; }
.weather button.on { opacity: 1; border-color: var(--line); }
.week-title { display: flex; align-items: baseline; gap: 16px; margin-bottom: 12px; }
.week-title .big { font-family: var(--serif); font-size: 44px; line-height: 1; color: var(--ink); }
.week-title .range { color: var(--ink-soft); font-size: 14px; }
.priorities .row { display: flex; gap: 8px; align-items: center; }
.priorities input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ink); }
.priorities .row.done input.inline { text-decoration: line-through; color: var(--muted); }
.box-head { display: flex; justify-content: space-between; align-items: baseline; }
.box-head .wk { font-weight: 700; color: var(--ink); }
.day { margin-bottom: 12px; }
.day h4 { margin: 16px 0 0; padding-bottom: 4px; border-bottom: 1.5px solid var(--ink); color: var(--ink); font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.day h4 span { color: var(--muted); font-weight: 400; font-size: 12px; }

.week-stats { margin-top: 24px; }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 8px; }
.stat b.alert { color: var(--alert); }

.sheet-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.sheet-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 28px; padding-top: 12px; border-top: 1px dashed var(--line);
  color: var(--muted); font-size: 13px;
}
.sheet-foot a { color: var(--ink); text-decoration: none; font-weight: 500; }

/* ---------- Bullet journal ---------- */
.bullet-key {
  max-width: 880px; margin: 0 auto 12px;
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline;
  font-size: 13px; color: var(--muted);
}
.bullet-key b { color: var(--ink); font-size: 15px; }
.bullet-key a { color: var(--ink); }
.bullets { list-style: none; margin: 0; padding: 0; }
.bullets li {
  display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); min-height: 2.2em;
  -webkit-touch-callout: none; transition: background .5s;
}
.bullets li.pressing { background: var(--hover); }
.menu-title {
  padding: 4px 10px 6px; font-size: 13px; color: var(--muted);
  max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sym-menu .menu-cancel { justify-content: center; color: var(--muted); border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; margin-top: 4px; }
.key-tip { opacity: .8; }
.sym {
  width: 28px; height: 28px; flex-shrink: 0; border: 0; border-radius: 6px; background: none;
  color: var(--ink); font-size: 16px; font-weight: 700; line-height: 1;
}
.sym:hover, .sym:focus-visible { background: var(--hover); }
.bullet-text { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 4px 2px; }
.bullets .del { border: 0; background: none; color: var(--muted); opacity: 0; font-size: 16px; padding: 0 6px; }
.bullets li:hover .del, .bullets li:focus-within .del { opacity: 1; }
@media (hover: none) { .bullets .del { opacity: .5; } }
.add-item { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 6px 2px; }
.add-item:hover { color: var(--ink); }

.sym-menu {
  position: absolute; z-index: 50; min-width: 180px; padding: 6px;
  display: flex; flex-direction: column;
  background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(30, 35, 60, .18);
}
.sym-menu button { display: flex; gap: 10px; align-items: center; border: 0; background: none; padding: 6px 10px; border-radius: 6px; text-align: left; }
.sym-menu button:hover, .sym-menu button:focus { background: var(--hover); outline: none; }
.sym-menu .sym-char { width: 20px; text-align: center; font-weight: 700; color: var(--ink); font-size: 16px; }
.sym-menu .sym-edit { border-top: 1px solid var(--line); margin-top: 4px; padding: 8px 10px 2px; font-size: 13px; color: var(--ink-soft); text-decoration: none; }

.sym-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sym-row input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); }
.sym-row .sym-input { width: 56px; flex-shrink: 0; text-align: center; font-size: 18px; font-weight: 700; color: var(--ink); }
.sym-row .sym-label { flex: 1; min-width: 0; }
.sym-row .btn:disabled { opacity: .35; cursor: default; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 20px; }
.palette button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); color: var(--ink); font-size: 16px; }
.palette button:hover { border-color: var(--ink); }

/* ---------- Summary ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; }
.stat b { display: block; font-family: var(--serif); font-size: 26px; color: var(--ink); }
.stat span { font-size: 13px; color: var(--muted); }
.keywords { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.keywords input { text-align: center; font-family: var(--serif); font-size: 18px; color: var(--ink); }

/* ---------- Settings ---------- */
.form-row { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center; margin-bottom: 16px; }
.form-row input, .form-row select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); max-width: 280px; }
.form-row .hint { grid-column: 2; font-size: 13px; color: var(--muted); margin-top: -8px; }

/* ---------- Dialog ---------- */
.dialog { background: var(--paper); color: var(--text); border: 0; border-radius: 12px; padding: 24px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(30, 35, 60, .35); }
.dialog h2 { font-family: var(--serif); color: var(--ink); margin: 0 0 16px; font-size: 20px; }
.dialog .field { margin-bottom: 12px; }
.dialog .field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.dialog .field input, .dialog .field textarea, .dialog .field select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.loading { text-align: center; color: var(--muted); padding: 64px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .sidebar {
    position: fixed; top: 57px; left: 0; bottom: 0; height: auto; z-index: 9;
    background: var(--desk); background-image: var(--desk-image); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .2s;
  }
  .sidebar.open { transform: none; }
  .view { padding: 16px 16px 48px; }
  .page { padding: 24px 18px 32px; }
  .jars { grid-template-columns: repeat(3, 1fr); }
  .bags { grid-template-columns: repeat(2, 1fr); }
  .shelf { gap: 3px; padding: 0 4px; }
  .spine { font-size: 11px; }
  #save-status { display: none; }
}
@media (max-width: 520px) {
  .jars { grid-template-columns: repeat(2, 1fr); }
  .stats, .keywords { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row .hint { grid-column: 1; }
  .schedule th, .schedule input { font-size: 11px; padding: 4px 2px; }
  .theme-grid { grid-template-columns: 1fr; }
}

/* ---------- Theme picker (settings) ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 8px; }
.theme-card {
  text-align: left; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--field); color: var(--text);
}
.theme-card[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.theme-card b { display: block; color: var(--ink); margin-top: 8px; }
.theme-card span.desc { font-size: 13px; color: var(--muted); }
.swatch { display: flex; height: 28px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(0,0,0,.1); }
.swatch i { flex: 1; }

/* =========================================================
   奇幻 Fantasy: starry night desk, parchment pages, gold leaf
   ========================================================= */
[data-theme="fantasy"] {
  --ink: #5b2a86;
  --ink-soft: #8a6a9e;
  --on-ink: #fdf6e3;
  --line: #d9c28f;
  --paper: #f8eed4;
  --desk: #140f26;
  --desk-image:
    radial-gradient(1.5px 1.5px at 30px 40px, #fff 50%, transparent 52%),
    radial-gradient(1px 1px at 120px 90px, #fde9a8 50%, transparent 52%),
    radial-gradient(1px 1px at 200px 160px, #fff 50%, transparent 52%),
    radial-gradient(2px 2px at 260px 30px, #e6d3ff 50%, transparent 52%),
    radial-gradient(ellipse at 50% -10%, #3d2b6b 0%, #1d1538 45%, #0d0a1a 100%);
  --chrome: rgba(16, 11, 32, .92);
  --chrome-text: #e9cf8a;
  --nav-text: #e8dcc0;
  --text: #3a2a1a;
  --muted: #8a7558;
  --hover: rgba(201, 162, 74, .18);
  --field: #fffaf0;
  --reading: #e7d9f3;
  --done: #e9c46a;
  --done-ink: #7a5310;
  --alert: #c0261e;
  --shadow: 0 0 0 1px rgba(201, 162, 74, .6), 0 12px 40px rgba(0, 0, 0, .55), 0 0 80px rgba(150, 110, 255, .18);
  --serif: "Cinzel", "Noto Serif TC", serif;
  --sans: "Noto Serif TC", "Songti TC", serif;
}
[data-theme="fantasy"] body { background-size: 300px 300px, 300px 300px, 300px 300px, 300px 300px, 100% 100%; }
[data-theme="fantasy"] .paper {
  background-image: radial-gradient(ellipse at center, #fcf6e4 35%, #efdcaa 100%);
}
[data-theme="fantasy"] .page { outline: 1px solid rgba(176, 138, 62, .55); outline-offset: -12px; }
[data-theme="fantasy"] .page-head h1::before { content: "✦"; color: #c9a24a; }
[data-theme="fantasy"] .box { border-color: #b08a3e; }
[data-theme="fantasy"] .box-title, [data-theme="fantasy"] .day h4 { color: var(--ink); }
[data-theme="fantasy"] .sidebar a.active { background: linear-gradient(90deg, #6b3a9c, #4a2470); box-shadow: 0 0 12px rgba(201, 162, 74, .35); }
[data-theme="fantasy"] .brand::before { content: "✧ "; }
[data-theme="fantasy"] .chip:not(.active) { background: var(--field); }
[data-theme="fantasy"] .picker .chip:not(.active), [data-theme="fantasy"] .bullet-key { color: #e8dcc0; }
[data-theme="fantasy"] .picker .chip:not(.active) { background: rgba(255, 255, 255, .06); border-color: rgba(233, 207, 138, .35); }
[data-theme="fantasy"] .bullet-key b, [data-theme="fantasy"] .bullet-key a { color: #e9cf8a; }
[data-theme="fantasy"] .home-hello h1 { color: #e9cf8a; }
[data-theme="fantasy"] .home-hello p { color: #cbbd9f; }

/* =========================================================
   中國風 Chinese: rice paper, ink wash, cinnabar seal
   ========================================================= */
[data-theme="chinese"] {
  --ink: #9e2a2b;
  --ink-soft: #6f5f52;
  --on-ink: #fbf6ea;
  --line: #d8cbb3;
  --paper: #fbf6ea;
  --desk: #e6dfcf;
  --desk-image:
    radial-gradient(ellipse 60% 40% at 85% 105%, rgba(40, 40, 40, .22), transparent 70%),
    radial-gradient(ellipse 50% 30% at 10% 110%, rgba(40, 40, 40, .16), transparent 70%),
    radial-gradient(ellipse 40% 25% at 50% 112%, rgba(40, 40, 40, .12), transparent 70%);
  --chrome: #2b2522;
  --chrome-text: #f3ead8;
  --nav-text: #3a302a;
  --text: #2b2522;
  --muted: #8b7d6b;
  --hover: rgba(158, 42, 43, .08);
  --field: #fffdf6;
  --reading: #e8dcc6;
  --done: #ecc7a8;
  --done-ink: #8c2f1b;
  --alert: #c0392b;
  --shadow: 0 2px 0 #d8cbb3, 0 14px 30px rgba(60, 40, 20, .14);
  --radius: 2px;
  --serif: "LXGW WenKai TC", "Noto Serif TC", "Kaiti TC", serif;
  --sans: "LXGW WenKai TC", "Noto Serif TC", "Kaiti TC", serif;
}
[data-theme="chinese"] body { font-size: 16px; }
[data-theme="chinese"] .page { border: 2px solid #9e2a2b; outline: 1px solid #9e2a2b; outline-offset: -8px; }
[data-theme="chinese"] .page-head h1::before {
  content: "記"; display: inline-grid; place-items: center; width: 30px; height: 30px;
  background: #9e2a2b; color: #fbf6ea; font-size: 18px; border-radius: 3px;
  box-shadow: inset 0 0 0 2px #fbf6ea, inset 0 0 0 3px #9e2a2b;
}
[data-theme="chinese"] .box { border-width: 1px; border-color: #6f5f52; }
[data-theme="chinese"] .box-title, [data-theme="chinese"] .day h4 { color: #2b2522; }
[data-theme="chinese"] .day h4 { border-bottom-color: #9e2a2b; }
[data-theme="chinese"] .btn, [data-theme="chinese"] .chip, [data-theme="chinese"] .sidebar a { border-radius: 2px; }
[data-theme="chinese"] .brand::before { content: "❀ "; color: #d9534f; }

/* =========================================================
   數位世界 Digital (The Matrix): black, phosphor green, code rain
   ========================================================= */
[data-theme="matrix"] {
  color-scheme: dark;
  --ink: #00ff41;
  --ink-soft: #00b32d;
  --on-ink: #001a07;
  --line: rgba(0, 255, 65, .28);
  --paper: rgba(0, 12, 3, .9);
  --desk: #000;
  --chrome: rgba(0, 0, 0, .92);
  --chrome-text: #00ff41;
  --nav-text: #6dff8e;
  --text: #b8ffc8;
  --muted: #3fa75a;
  --hover: rgba(0, 255, 65, .12);
  --field: #000d03;
  --reading: rgba(0, 255, 65, .18);
  --done: rgba(0, 255, 65, .35);
  --done-ink: #00ff41;
  --alert: #ff3b3b;
  --shadow: 0 0 0 1px rgba(0, 255, 65, .55), 0 0 28px rgba(0, 255, 65, .18);
  --radius: 0;
  --serif: "Share Tech Mono", "Noto Sans TC", monospace;
  --sans: "Share Tech Mono", "Noto Sans TC", monospace;
}
[data-theme="matrix"] * { caret-color: #00ff41; }
[data-theme="matrix"] .app, [data-theme="matrix"] .login { position: relative; z-index: 1; }
[data-theme="matrix"] .page-head h1, [data-theme="matrix"] .brand, [data-theme="matrix"] .week-title .big,
[data-theme="matrix"] .stat b { text-shadow: 0 0 8px rgba(0, 255, 65, .7); }
[data-theme="matrix"] .stat b.alert { text-shadow: 0 0 8px rgba(255, 59, 59, .8); }
[data-theme="matrix"] .page-head h1::before { content: ">_"; }
[data-theme="matrix"] .brand::before { content: "> "; }
[data-theme="matrix"] .paper, [data-theme="matrix"] .btn, [data-theme="matrix"] .chip,
[data-theme="matrix"] .sidebar a, [data-theme="matrix"] input, [data-theme="matrix"] select,
[data-theme="matrix"] textarea, [data-theme="matrix"] .dialog, [data-theme="matrix"] .sym-menu { border-radius: 0; }
[data-theme="matrix"] .sidebar a.active { box-shadow: 0 0 12px rgba(0, 255, 65, .6); }
[data-theme="matrix"] .sidebar { background: rgba(0, 0, 0, .85); }
[data-theme="matrix"] .picker, [data-theme="matrix"] .bullet-key, [data-theme="matrix"] .home-hello { background: rgba(0, 0, 0, .8); padding: 4px 6px; }
[data-theme="matrix"] .jar textarea, [data-theme="matrix"] .bag-fields input { color: var(--text); }
[data-theme="matrix"] .login-card h1 { letter-spacing: .1em; }
#matrix-rain { position: fixed; inset: 0; z-index: 0; opacity: .35; pointer-events: none; }

/* Weekly: carry open items over to next week */
.menu-title.wrap { white-space: normal; }
.move-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.move-row .btn:disabled { opacity: .5; cursor: default; filter: none; }
.move-note { font-size: 13px; color: var(--muted); }
.move-note.error { color: var(--alert); }
.move-note a { margin-left: 6px; color: var(--ink); }

/* Monthly to-dos linked to weekly tasks */
.sched { font: inherit; font-size: 12px; color: var(--muted); background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; max-width: 9.5em; flex: none; }
.sched-tag { flex: none; font-size: 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; text-decoration: none; white-space: nowrap; }
.sched-tag.done { color: var(--muted); }
a.sched-tag:hover { background: var(--hover); }
.link-tag { flex: none; font-size: 11px; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; text-decoration: none; line-height: 1.5; }
.month-todos { display: grid; gap: 6px; margin-top: 8px; }
.month-todo { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.month-todo .mt-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-todos .box-hint a { margin-left: 6px; color: var(--ink); }
