:root {
  --bg: #ffffff; --surface: #f6f6f4; --text: #1a1a18; --muted: #6b6b66;
  --border: rgba(0,0,0,0.12); --accent: #185FA5; --accent-bg: #E6F1FB;
  --danger: #A32D2D; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1a; --surface: #262624; --text: #f1f0ea; --muted: #a3a29a;
    --border: rgba(255,255,255,0.14); --accent: #85B7EB; --accent-bg: #0C447C; --danger: #F09595;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c1a; --surface: #262624; --text: #f1f0ea; --muted: #a3a29a;
  --border: rgba(255,255,255,0.14); --accent: #85B7EB; --accent-bg: #0C447C; --danger: #F09595;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#app { max-width: 640px; margin: 0 auto; padding: 16px; padding-bottom: 40px; }
h1 { font-size: 22px; font-weight: 500; margin: 0; }
h2 { font-size: 18px; font-weight: 500; margin: 0 0 4px; }
.screen { padding-top: 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.muted { color: var(--muted); font-weight: 400; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0; }
.error { color: var(--danger); font-size: 14px; margin: 0; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > textarea, label > select { margin-top: 4px; }
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea, select {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 8px;
  border: 0.5px solid var(--border); background: var(--bg);
}
textarea { min-height: 64px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  min-height: 44px; padding: 0 16px; border-radius: 8px; cursor: pointer;
  border: 0.5px solid var(--border); background: transparent;
}
button:active { transform: scale(0.98); }
button.primary { background: var(--accent); color: #fff; border-color: transparent; }
button.ghost { background: transparent; }
button.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
button.danger { color: var(--danger); }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > input { flex: 1; }
.tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; }
.tab { min-height: 40px; padding: 0 4px; font-size: 13px; }
code { font-size: 13px; }
.tab.active { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.panel { display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  min-height: 36px; padding: 0 12px; border-radius: 8px; font-size: 14px;
  border: 0.5px solid var(--border); color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.tag-pill {
  font-size: 12px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface); color: var(--muted);
}
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--surface); border-radius: var(--radius); padding: 12px 14px;
  border: 0.5px solid var(--border); display: flex; flex-direction: column; gap: 4px;
  width: 100%; text-align: left; min-height: 0; padding-top: 12px;
}
.card .title { font-weight: 500; overflow-wrap: anywhere; }
.card .meta { font-size: 13px; color: var(--muted); }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag-row { display: flex; align-items: center; gap: 8px; }
.tag-row input { min-height: 36px; }
.tag-row .count { font-size: 13px; color: var(--muted); min-width: 28px; text-align: right; }
dialog { width: min(92vw, 520px); border: 0.5px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,0.4); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: 90vw;
}
[hidden] { display: none !important; }
