/* ==========================================================================
   Brein — stijl
   Rustig en functioneel: neutrale tinten, één accentkleur, weinig schaduw.
   Pas --accent aan om de app een andere merkkleur te geven.
   ========================================================================== */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #efefeb;
  --surface-3: #e5e5e0;
  --text: #1b1b19;
  --muted: #696964;
  --border: #e2e2dc;
  --border-strong: #c9c9c2;
  --accent: #1d6b57;
  --accent-soft: #e3efe9;
  --on-ink: #ffffff;
  --danger: #b4321f;
  --ok: #2c7a4b;
  --warn: #a8670a;

  /* Typekleuren (graph, stippen) */
  --c-project: #3a5bc7;
  --c-idee: #b97c10;
  --c-gebied: #8b5a9f;
  --c-kennis: #1f8296;
  --c-doc: #8a8a84;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-float: 0 12px 32px -12px rgb(20 20 18 / 0.28), 0 2px 6px rgb(20 20 18 / 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1a1a18;
    --surface-2: #232320;
    --surface-3: #2c2c29;
    --text: #ecebe6;
    --muted: #a3a29b;
    --border: #2c2c28;
    --border-strong: #42423d;
    --accent: #6cc0a5;
    --accent-soft: #1d2e28;
    --on-ink: #121211;
    --danger: #e8735f;
    --ok: #6cc08a;
    --warn: #e0a64a;
    --c-project: #8299ec;
    --c-idee: #ddb05a;
    --c-gebied: #c294d4;
    --c-kennis: #5fbccc;
    --c-doc: #8f8f88;
    --shadow-float: 0 16px 40px -12px rgb(0 0 0 / 0.7), 0 2px 6px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
kbd {
  font: 500 0.7rem var(--mono);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  color: var(--muted);
  background: var(--surface);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; font-size: 0.9rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* Iconen (Lucide sprite) */
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.ic.sm { width: 15px; height: 15px; vertical-align: -3px; }
.ic.lg { width: 22px; height: 22px; }

/* ---------- Knoppen ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 550; font-size: 0.9rem; white-space: nowrap;
  cursor: pointer; text-decoration: none !important;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--on-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--text) 85%, var(--bg)); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 0.82rem; }
.icon-btn {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Inputs ---------- */
input[type=text], input[type=password], input[type=search], input[type=url], select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 5px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
label.field > * { font-weight: 400; font-size: 0.93rem; color: var(--text); }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(340px, 100%); display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 24px;
}
.login-card h1 { font-size: 1.3rem; }
.login-card p { margin: 0; }
.login-card .btn { width: 100%; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 10px; padding: 0 20px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.02rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.topnav { display: flex; gap: 2px; margin-left: 14px; }
.topnav a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 550; font-size: .9rem; padding: 6px 10px; border-radius: var(--radius-sm); }
.topnav a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.topnav a.active { color: var(--text); background: var(--surface-3); }
.search-trigger {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  min-width: 260px; height: 36px; padding: 0 8px 0 10px;
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; text-align: left;
}
.search-trigger .search-label { flex: 1; font-size: .88rem; }
.search-trigger:hover { border-color: var(--muted); }

.banner {
  margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius-sm);
  display: flex; gap: 8px; align-items: flex-start;
  background: color-mix(in srgb, var(--danger) 9%, var(--surface)); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); font-size: .9rem;
}

.bottombar { display: none; }

/* ---------- View ---------- */
#view { max-width: 1160px; margin: 0 auto; padding: 28px 20px 64px; outline: none; }
.view-enter { animation: enter .18s ease-out; }
@keyframes enter { from { opacity: 0; } }

.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.section-head h2 { font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.count { font-size: .75rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Capture */
.capture { display: grid; gap: 10px; }
.capture-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.capture-head h1 { font-size: 1.5rem; letter-spacing: -0.02em; }
.capture-box { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); transition: border-color .12s, box-shadow .12s; }
.capture-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.capture textarea { resize: none; min-height: 52px; max-height: 40vh; font-size: 1.02rem; border: 0; box-shadow: none !important; padding: 14px 14px 6px; background: transparent; }
.capture-foot { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px 14px; }
.capture-foot input { flex: 1; min-width: 120px; border: 0; padding: 6px 0; font-size: .88rem; background: transparent; box-shadow: none !important; }
.capture-hint { font-size: .8rem; color: var(--muted); }
.capture-box textarea:focus-visible, .capture-box input:focus-visible { outline: none; } /* het blok zelf toont de focus */

/* Cards */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; color: var(--text);
  transition: border-color .12s;
}
.card:hover { text-decoration: none; border-color: var(--border-strong); }
.card-type { display: flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; color: var(--muted); }
.card h3 { font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); }
.card .foot span { display: inline-flex; align-items: center; gap: 5px; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.list-item {
  display: flex; gap: 12px; align-items: center; padding: 10px 8px; margin: 0 -8px;
  border-radius: var(--radius-sm); color: var(--text);
}
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-item:hover { text-decoration: none; background: var(--surface-2); }
.list-item:hover + .list-item, .list-item:hover { border-top-color: transparent; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .main span { display: block; color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item time { font-size: .78rem; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tc, var(--muted)); flex: none; display: inline-block; }

.empty { color: var(--muted); padding: 16px 0; font-size: .92rem; margin: 0; }
.two-col { display: grid; gap: 0 40px; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }

/* Chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 550; line-height: 1.5;
  padding: 1px 8px; border-radius: 4px;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent; white-space: nowrap;
}
.chip.type { background: transparent; border-color: var(--border-strong); color: var(--text); }
.chip.status-actief { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.chip.status-pauze { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.chip.status-klaar { color: var(--c-kennis); background: color-mix(in srgb, var(--c-kennis) 10%, transparent); }
.chip.status-idee { color: var(--c-idee); background: color-mix(in srgb, var(--c-idee) 12%, transparent); }
.chip.status-archief { color: var(--muted); }
.chip.stack { background: transparent; border-color: var(--border); }
.chip.tag::before { content: "#"; opacity: .6; }

.t-project { --tc: var(--c-project); }
.t-idee { --tc: var(--c-idee); }
.t-gebied { --tc: var(--c-gebied); }
.t-kennis { --tc: var(--c-kennis); }
.t-doc { --tc: var(--c-doc); }
.is-archief { opacity: .55; }

.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: .85rem; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- Notitie ---------- */
.crumbs { font-size: .85rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.crumbs a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.note-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 24px; }
.note-head h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); letter-spacing: -0.025em; margin-bottom: 10px; }
.note-head .summary { color: var(--muted); margin: 10px 0 0; max-width: 68ch; font-size: 1.02rem; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.note-layout { display: grid; gap: 32px; grid-template-columns: minmax(0, 1fr) 290px; align-items: start; }
.panel { padding: 0 0 18px; }
.panel + .panel { padding-top: 18px; border-top: 1px solid var(--border); }
.panel h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.aside { position: sticky; top: calc(var(--top-h) + 20px); }
.conn { display: grid; gap: 1px; }
.conn a { display: flex; align-items: center; gap: 8px; padding: 5px 6px; margin: 0 -6px; border-radius: var(--radius-sm); color: var(--text); font-size: .9rem; }
.conn a:hover { background: var(--surface-2); text-decoration: none; }
.conn .dir { color: var(--muted); display: inline-flex; }
.conn .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-graph { height: 210px; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.meta-list { display: grid; gap: 6px; font-size: .85rem; margin: 0; }
.meta-list div { display: flex; justify-content: space-between; gap: 10px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* Markdown */
.prose {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: clamp(18px, 3vw, 36px); overflow-wrap: break-word; min-width: 0; line-height: 1.7;
}
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose h1 { font-size: 1.6rem; margin: 0 0 .6em; }
.prose h2 { font-size: 1.2rem; margin: 1.8em 0 .5em; }
.prose h3 { font-size: 1.02rem; margin: 1.4em 0 .4em; }
.prose p, .prose ul, .prose ol, .prose table, .prose pre, .prose blockquote { margin: 0 0 1em; }
.prose p, .prose li { max-width: 72ch; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .2em 0; }
.prose li:has(> input[type=checkbox]) { list-style: none; margin-left: -1.3em; }
.prose input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; margin-right: 8px; cursor: pointer; }
.prose code { font: .86em var(--mono); background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
.prose pre { background: var(--surface-2); padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: .85rem; line-height: 1.55; }
.prose blockquote { border-left: 3px solid var(--border-strong); padding: 2px 14px; color: var(--muted); }
.prose blockquote p { margin: .3em 0; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: .9rem; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: 7px 12px 7px 0; text-align: left; vertical-align: top; }
.prose th { font-weight: 600; border-bottom-color: var(--border-strong); }
.prose img { max-width: 100%; border-radius: var(--radius-sm); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 1.8em 0; }
.prose em { color: var(--muted); }
.wikilink { color: var(--accent); font-weight: 550; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 3px; }
.wikilink:hover { text-decoration-color: currentColor; }
.wikilink.dead { color: var(--danger); text-decoration-style: dashed; cursor: pointer; }

/* ---------- Editor ---------- */
.editor { display: grid; gap: 16px; }
.editor-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.save-state { font-size: .82rem; color: var(--muted); }
.save-state.dirty { color: var(--warn); }
.title-input { font-size: 1.7rem !important; font-weight: 650; letter-spacing: -0.02em; background: transparent !important; padding: 4px 0 !important; border-radius: 0 !important; border: 0 !important; border-bottom: 1px solid var(--border-strong) !important; box-shadow: none !important; }
.title-input:focus { border-bottom-color: var(--accent) !important; }
.meta-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.meta-grid .wide { grid-column: 1 / -1; }
.link-picker { position: relative; display: grid; gap: 6px; }
.link-picker .chip { padding-right: 2px; background: var(--surface-2); color: var(--text); }
.link-picker .chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 3px; display: inline-flex; border-radius: 3px; }
.link-picker .chip button:hover { color: var(--danger); }
.toolbar { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; padding: 4px; background: var(--surface); border: 1px solid var(--border-strong); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: var(--top-h); z-index: 5; }
.toolbar button { border: 0; background: none; border-radius: var(--radius-sm); min-width: 32px; height: 32px; padding: 0 7px; cursor: pointer; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: .85rem; }
.toolbar button:hover { background: var(--surface-2); }
.toolbar button.on { background: var(--surface-3); }
.toolbar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.toolbar .spacer { flex: 1; }
.body-wrap { position: relative; }
.body-input {
  display: block; min-height: 50vh; resize: vertical;
  font: 0.93rem/1.7 var(--mono) !important; tab-size: 2;
  border-radius: 0 0 var(--radius) var(--radius) !important; padding: 18px !important;
}
.preview-pane { border-radius: 0 0 var(--radius) var(--radius); min-height: 50vh; border-color: var(--border-strong); }

/* Autocomplete */
.ac {
  position: absolute; z-index: 40; min-width: 240px; max-width: 360px; max-height: 260px; overflow: auto;
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-float);
}
.ac li { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: .9rem; }
.ac li small { color: var(--muted); margin-left: auto; font-size: .75rem; }
.ac li.sel, .ac li:hover { background: var(--surface-2); }

/* ---------- Graph ---------- */
.graph-view { position: relative; margin: -28px -20px -64px; height: calc(100dvh - var(--top-h)); overflow: hidden; }
.graph-canvas { position: absolute; inset: 0; }
.graph-ui { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; pointer-events: none; }
.graph-ui > * { pointer-events: auto; }
.graph-ui .panel-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px;
  display: flex; gap: 2px; flex-wrap: wrap; align-items: center;
}
.graph-ui input[type=search] { width: 190px; border: 0; padding: 5px 8px; box-shadow: none !important; }
.legend-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 5px 9px; border-radius: var(--radius-sm); cursor: pointer; font-size: .82rem; font-weight: 550; color: var(--text); }
.legend-btn.off { opacity: .35; }
.legend-btn:hover { background: var(--surface-2); }
.graph-tip {
  position: absolute; bottom: 16px; left: 16px; max-width: 340px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow-float); font-size: .88rem;
}
.graph-tip b { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.graph-tip p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Dialogs ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgb(18 18 17 / 0.45); }
.sheet {
  width: min(520px, calc(100% - 24px)); max-height: 90dvh; padding: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-float);
}
.sheet[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.sheet form { display: grid; gap: 14px; padding: 18px 20px 20px; }
.sheet section { display: grid; gap: 6px; }
.sheet section + section { padding-top: 14px; border-top: 1px solid var(--border); }
.sheet h3 { font-size: .92rem; }
.sheet p { margin: 0; }
.sheet pre { margin: 0; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); font: .78rem/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-head h2 { font-size: 1.1rem; }
.type-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-pick label { cursor: pointer; }
.type-pick input { position: absolute; opacity: 0; pointer-events: none; }
.type-pick span { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); height: 100%; transition: border-color .12s, background .12s; }
.type-pick .ic { grid-row: span 2; color: var(--tc); }
.type-pick b { font-size: .92rem; font-weight: 600; }
.type-pick small { font-size: .76rem; color: var(--muted); line-height: 1.35; }
.type-pick input:checked + span { border-color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--text); }
.type-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.palette {
  width: min(620px, calc(100% - 24px)); margin: 10vh auto auto; padding: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-float); overflow: hidden;
}
.palette input { border-radius: 0; border: 0 !important; border-bottom: 1px solid var(--border) !important; box-shadow: none !important; padding: 15px 16px; font-size: 1rem; }
.palette-results { list-style: none; margin: 0; padding: 4px; max-height: 55vh; overflow: auto; }
.palette-results li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.palette-results li.sel { background: var(--surface-2); }
.palette-results .main { flex: 1; min-width: 0; }
.palette-results .main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-results .main span { display: block; font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-results small { color: var(--muted); font-size: .75rem; }
.palette-results .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 4px; cursor: default; }
.palette-hint { margin: 0; padding: 8px 14px; border-top: 1px solid var(--border); font-size: .75rem; color: var(--muted); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 100;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--on-ink); font-weight: 500; font-size: .88rem;
  padding: 9px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-float);
  transition: opacity .16s, transform .16s; max-width: calc(100% - 32px); display: flex; gap: 10px; align-items: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast a { color: inherit; text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .note-layout { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  :root { --top-h: 52px; }
  .topbar { padding: 0 16px; gap: 8px; }
  .topnav, .hide-mobile, .search-trigger kbd, .topbar > [data-action=menu] { display: none; }
  .search-trigger { min-width: 0; flex: 1; }
  #view { padding: 20px 16px calc(92px + var(--safe-b)); }
  .graph-view { margin: -20px -16px calc(-92px - var(--safe-b)); height: calc(100dvh - var(--top-h) - 62px - var(--safe-b)); }
  .graph-ui { top: 8px; left: 8px; right: 8px; gap: 6px; }
  .legend-btn { font-size: .74rem; padding: 4px 7px; }
  .graph-ui input[type=search] { width: 110px; font-size: .85rem; }
  .graph-tip { bottom: 10px; left: 10px; right: 10px; max-width: none; }
  .banner { margin: 10px 16px 0; }
  .bottombar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 6px calc(6px + var(--safe-b)); justify-content: space-around; align-items: center;
    background: var(--bg); border-top: 1px solid var(--border);
  }
  .bottombar a, .bottombar button {
    display: grid; justify-items: center; gap: 2px; border: 0; background: none; cursor: pointer;
    color: var(--muted); font-size: .68rem; font-weight: 550; padding: 4px 6px; min-width: 58px; min-height: 44px; text-decoration: none;
  }
  .bottombar .ic { width: 21px; height: 21px; }
  .bottombar a.active { color: var(--text); }
  .bottombar .new-btn { color: var(--on-ink); background: var(--text); border-radius: var(--radius); min-width: 48px; width: 48px; place-items: center; }
  .toast { bottom: calc(82px + var(--safe-b)); }
  .sheet { margin: auto auto 0; width: 100%; max-width: none; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }
  .sheet form { padding-bottom: calc(20px + var(--safe-b)); }
  .palette { margin-top: 12px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  .note-head h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
