:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1c1b19; --muted: #6d6a63; --line: #e3e0d8;
  --accent: #b4532a; --accent-ink: #ffffff; --idea: #7a5cc4; --todo: #1f7a5c; --warn: #b3261e;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151412; --panel: #1f1e1b; --ink: #ece9e2; --muted: #9a968d; --line: #33312c;
          --accent: #e0835a; --accent-ink: #1c1206; --idea: #a892e6; --todo: #5fc7a2; --warn: #f2948c; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 15px/1.5 system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
     margin: 28px 0 10px; font-weight: 600; }
.card h2:first-child { margin-top: 0; }
code { font-size: 13px; word-break: break-all; }

header { display: flex; align-items: center; gap: 16px; padding: 10px 16px; position: sticky; top: 0;
         background: var(--bg); border-bottom: 1px solid var(--line); z-index: 2; }
.brand { letter-spacing: .02em; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; white-space: nowrap; }
nav a.on { background: var(--ink); color: var(--bg); }
.tab, main { max-width: 760px; margin: 0 auto; padding: 16px; }

input, select, textarea, button, .button {
  font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; min-width: 0; }
textarea { width: 100%; resize: vertical; }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button:hover, .button:hover { border-color: var(--muted); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.ghost { background: none; border-color: transparent; color: var(--muted); }
.danger { color: var(--warn); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 16px; margin-bottom: 16px; }
.login { max-width: 320px; margin: 18vh auto 0; display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label input, label select, label textarea { color: var(--ink); font-size: 15px; }
.check { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; margin-top: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.error { color: var(--warn); margin: 0; font-size: 13px; min-height: 1em; }

.toolbar, .add { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search], .add input { flex: 1 1 180px; }
.chips { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.chips button { border: 0; border-radius: 0; background: var(--panel); color: var(--muted); }
.chips button.on { background: var(--ink); color: var(--bg); }

.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line);
        border-radius: var(--radius); }
.list:empty { display: none; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .body { flex: 1; min-width: 0; }
.list .title { font-weight: 550; overflow-wrap: anywhere; cursor: pointer; }
.done .title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.said { color: var(--muted); font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
       padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; }
.tag.idea { color: var(--idea); } .tag.todo, .tag.task, .tag.event { color: var(--todo); } .tag.warn { color: var(--warn); }
.portrait { width: 104px; height: 140px; border-radius: 8px; background: #222; image-rendering: pixelated; }
.actions { display: flex; gap: 2px; }
.actions button { padding: 4px 8px; font-size: 13px; }
.list input[type=checkbox] { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--todo); }
.dot { width: 18px; height: 18px; margin-top: 3px; display: grid; place-items: center; color: var(--idea); }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }
audio { height: 30px; max-width: 100%; margin-top: 6px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 130px; background: var(--panel);
         border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bar.zero { background: var(--line); }
.bar.today { opacity: 1; outline: 2px solid var(--ink); outline-offset: 1px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line);
        border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); border-top: 0; font-weight: 600; }
td:not(:first-child), th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.banner { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--line); background: var(--panel); }
.banner.live { border-color: var(--warn); }
.plate { font-size: 24px; font-weight: 700; letter-spacing: .04em; }
.token { background: var(--bg); border: 1px dashed var(--accent); border-radius: 8px; padding: 10px;
         font-family: ui-monospace, monospace; word-break: break-all; margin: 10px 0 0; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink);
         width: min(520px, calc(100vw - 32px)); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin-top: 0; }
dialog label { margin-top: 10px; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink);
         color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 14px; z-index: 5;
         max-width: calc(100vw - 32px); }
@media (max-width: 520px) {
  .actions { flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
}
