:root {
  --bg: #161616; --dot: #2e2e2e; --accent: #ff9f43; --paper: #f3e7c3; --paper-ink: #2b2415; --placeholder: #262626;
  --bar: rgba(28,28,28,.86); --bar-line: rgba(255,255,255,.08); --ink: #e8e5df; --ink-2: #9a968f; --ink-3: #66625c;
  --panel: #1f1f1f; --hover: rgba(255,255,255,.07); --kbd: rgba(255,255,255,.08);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #ecebe7; --dot: #d3d1cb; --accent: #e0673a; --paper: #fff5cf; --paper-ink: #2b2415; --placeholder: #dcdad4;
  --bar: rgba(255,255,255,.82); --bar-line: rgba(0,0,0,.08); --ink: #1c1b19; --ink-2: #5d5a54; --ink-3: #8f8b84;
  --panel: #fbfaf7; --hover: rgba(0,0,0,.06); --kbd: rgba(0,0,0,.07);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ecebe7; --dot: #d3d1cb; --accent: #e0673a; --paper: #fff5cf; --paper-ink: #2b2415; --placeholder: #dcdad4;
    --bar: rgba(255,255,255,.82); --bar-line: rgba(0,0,0,.08); --ink: #1c1b19; --ink-2: #5d5a54; --ink-3: #8f8b84;
    --panel: #fbfaf7; --hover: rgba(0,0,0,.06); --kbd: rgba(0,0,0,.07);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 14px/1.4 var(--sans); }
body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
body.dropping #c { outline: 2px dashed var(--accent); outline-offset: -8px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:disabled { opacity: .35; cursor: default; }
kbd { font: 11.5px/1 var(--mono); background: var(--kbd); border-radius: 4px; padding: 3px 5px; color: var(--ink-2); white-space: nowrap; }
code { font-family: var(--mono); font-size: .92em; }
a { color: var(--accent); }
.dim { color: var(--ink-2); }

/* ---- toolbar */
.bar {
  position: fixed; top: 12px; left: 12px; right: 12px; height: 44px; display: flex; align-items: center; gap: 2px; padding: 4px 6px;
  background: var(--bar); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--bar-line); border-radius: 12px; z-index: 5; box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
.bar > button { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.bar > button:hover:not(:disabled) { background: var(--hover); }
.bar > button.on { background: var(--accent); color: #fff; }
.bar > button svg { width: 18px; height: 18px; flex: none; }
.bar .logo { font-weight: 700; letter-spacing: .01em; color: var(--accent); padding-left: 8px; }
.bar .logo span { color: var(--ink); }
.bar .sep { width: 1px; height: 22px; background: var(--bar-line); margin: 0 6px; }
.bar .grow { flex: 1; }
.bar .count { color: var(--ink-3); font-size: 12.5px; margin-right: 8px; font-variant-numeric: tabular-nums; }
#zoom { font-variant-numeric: tabular-nums; min-width: 58px; justify-content: center; color: var(--ink-2); }
#board-name { color: var(--ink-2); max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 34px; }
@media (max-width: 760px) { .bar > button span { display: none; } .bar .logo span { display: inline; } .count, #board-name, #zoom, .bar .sep { display: none; } .bar { gap: 0; } }

/* ---- menus */
.menu { position: fixed; z-index: 20; min-width: 190px; padding: 5px; background: var(--panel); border: 1px solid var(--bar-line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.28); }
#zoom-menu { top: 60px; left: 300px; }
.menu button { display: flex; justify-content: space-between; align-items: center; gap: 18px; width: 100%; padding: 7px 10px; border-radius: 6px; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--bar-line); margin: 5px 4px; }

/* ---- panels */
.panel {
  position: fixed; top: 68px; right: 12px; width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 84px); overflow: auto; z-index: 10;
  background: var(--panel); border: 1px solid var(--bar-line); border-radius: 14px; padding: 14px 16px 16px; box-shadow: 0 16px 50px rgba(0,0,0,.3);
}
.panel header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel h2 { margin: 0; font-size: 15px; font-weight: 650; }
.panel h3 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.panel .x { width: 28px; height: 28px; border-radius: 6px; font-size: 20px; line-height: 1; color: var(--ink-2); }
.panel .x:hover { background: var(--hover); }
.panel table { width: 100%; border-collapse: collapse; font-size: 13px; }
.panel td, .panel th { padding: 5px 0; vertical-align: top; }
.panel td:first-child { width: 40%; padding-right: 10px; }
.panel th { text-align: left; padding-top: 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.panel p { margin: 12px 0 0; font-size: 13px; }
.panel .row { display: flex; gap: 8px; flex-wrap: wrap; }
.panel .row button { padding: 8px 13px; border-radius: 8px; background: var(--hover); font-weight: 500; }
.panel .row button:hover { background: var(--accent); color: #fff; }
#board-list { list-style: none; margin: 0 0 12px; padding: 0; }
#board-list li { display: flex; align-items: stretch; border-radius: 8px; }
#board-list li:hover { background: var(--hover); }
#board-list li.cur { background: var(--hover); box-shadow: inset 2px 0 0 var(--accent); }
#board-list .pick { flex: 1; display: flex; flex-direction: column; align-items: flex-start; padding: 8px 10px; text-align: left; gap: 1px; }
#board-list .pick small { color: var(--ink-3); font-size: 12px; }
#board-list .del { width: 34px; color: var(--ink-3); font-size: 18px; border-radius: 8px; }
#board-list .del:hover { color: #fff; background: #c0392b; }

/* ---- empty state */
.empty { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 2; padding: 24px; }
.empty > div { max-width: 460px; text-align: center; pointer-events: auto; }
.empty h1 { font-size: clamp(28px, 5vw, 44px); font-weight: 700; letter-spacing: -.02em; margin: 0 0 12px; }
.empty p { margin: 0 0 8px; font-size: 16px; color: var(--ink-2); }
.empty .link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }

/* ---- toast, note editor */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 12px); opacity: 0; transition: .18s; z-index: 30; pointer-events: none;
  background: var(--panel); border: 1px solid var(--bar-line); color: var(--ink); padding: 9px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: 80vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#note-edit { position: fixed; z-index: 4; margin: 0; border: 0; outline: 2px solid var(--accent); border-radius: 6px; resize: none; overflow: hidden;
  background: var(--paper); color: var(--paper-ink); font-family: var(--sans); transform-origin: center; }
body[data-mode="crop"] #c { cursor: crosshair; }
