/* ═══════════════════════════════════════════════
   proto.mind — Liquid Graph design system
   ═══════════════════════════════════════════════ */

:root {
  /* Surfaces (light) */
  --surface:             oklch(99% 0.005 280);
  --surface-2:           oklch(96% 0.01  280);
  --surface-glass:       oklch(99% 0.005 280 / 0.62);
  --surface-glass-strong: oklch(99% 0.005 280 / 0.82);
  --surface-hover:       oklch(94% 0.015 280);

  /* Ink (text) */
  --ink:        oklch(20% 0.02 280);
  --ink-dim:    oklch(45% 0.02 280);
  --ink-muted:  oklch(65% 0.02 280);

  /* Brand */
  --accent:        oklch(62% 0.18 295);   /* purple */
  --accent-hover:  oklch(56% 0.20 295);
  --accent-soft:   oklch(62% 0.18 295 / 0.14);
  --accent-ink:    white;

  /* Signal */
  --danger:        oklch(58% 0.18 25);
  --danger-soft:   oklch(58% 0.18 25 / 0.14);
  --ok:            oklch(68% 0.16 145);

  /* Lines + depth */
  --border:        oklch(90% 0.01 280);
  --border-glass:  oklch(99% 0.005 280 / 0.4);
  --shadow:        0 8px 32px oklch(20% 0.02 280 / 0.10), 0 2px 8px oklch(20% 0.02 280 / 0.06);
  --shadow-lg:     0 24px 60px oklch(20% 0.02 280 / 0.18), 0 4px 16px oklch(20% 0.02 280 / 0.08);

  /* Effects */
  --blur:          16px;
  --blur-strong:   24px;

  /* Geometry */
  --r-sm:   10px;
  --r:      16px;
  --r-lg:   24px;
  --r-pill: 999px;

  /* Spacing scale (1.25 ratio) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px;
  --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --s-7: 48px; --s-8: 64px;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --t-xs:  clamp(11px, 0.75vw + 9px, 12px);
  --t-sm:  clamp(12px, 0.85vw + 10px, 13px);
  --t-md:  clamp(14px, 1vw + 12px, 15px);
  --t-lg:  clamp(16px, 1.2vw + 14px, 18px);
  --t-xl:  clamp(20px, 1.6vw + 17px, 24px);

  /* Motion */
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-in:  cubic-bezier(0.4, 0, 0.6, 1);
  --t-fast:   0.14s;
  --t-base:   0.22s;
  --t-slow:   0.36s;
}

/* ── Dark theme ── */
.dark-mode, [data-theme="dark"] {
  --surface:              oklch(18% 0.02 280);
  --surface-2:            oklch(22% 0.02 280);
  --surface-glass:        oklch(18% 0.02 280 / 0.65);
  --surface-glass-strong: oklch(18% 0.02 280 / 0.85);
  --surface-hover:        oklch(26% 0.025 280);

  --ink:        oklch(96% 0.01 280);
  --ink-dim:    oklch(75% 0.02 280);
  --ink-muted:  oklch(55% 0.02 280);

  --accent:        oklch(75% 0.16 295);
  --accent-hover:  oklch(80% 0.16 295);
  --accent-soft:   oklch(75% 0.16 295 / 0.20);

  --danger:       oklch(68% 0.20 25);
  --danger-soft:  oklch(68% 0.20 25 / 0.18);
  --ok:           oklch(74% 0.18 145);

  --border:        oklch(32% 0.02 280);
  --border-glass:  oklch(96% 0.01 280 / 0.12);
  --shadow:        0 8px 32px oklch(0% 0 0 / 0.45), 0 2px 8px oklch(0% 0 0 / 0.30);
  --shadow-lg:     0 24px 60px oklch(0% 0 0 / 0.65), 0 4px 16px oklch(0% 0 0 / 0.45);
}

/* ═══════════════════════════════════════════════
   Base reset
   ═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-muted); border-radius: 4px; opacity: 0.4; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-dim); }

/* ═══════════════════════════════════════════════
   Edge-to-edge canvas
   ═══════════════════════════════════════════════ */
#mindmap {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, oklch(from var(--accent) l c h / 0.08), transparent 60%),
    radial-gradient(ellipse at 70% 80%, oklch(from var(--accent) l c h / 0.06), transparent 60%),
    var(--surface-2);
  transition: background var(--t-base);
}

/* ═══════════════════════════════════════════════
   Glass surface primitive
   ═══════════════════════════════════════════════ */
.glass {
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════════
   Search pill (top, floating)
   ═══════════════════════════════════════════════ */
.search-pill {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--s-3));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow);
  z-index: 50;
  min-width: 280px;
  max-width: min(640px, calc(100% - var(--s-5)));
  transition: width var(--t-base) var(--ease-out);
}

.search-pill-icon {
  color: var(--ink-dim);
  font-size: var(--t-sm);
}

.search-pill-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: var(--t-md);
  padding: 6px 0;
  outline: none;
  min-width: 0;
}
.search-pill-input::placeholder { color: var(--ink-muted); }

.search-pill-counter {
  font-size: var(--t-xs);
  color: var(--ink-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Results drop (under search pill) */
.results-drop {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100% - var(--s-5)));
  max-height: 55dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--border-glass);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  z-index: 49;
  opacity: 0;
  pointer-events: none;
  transform-origin: top center;
  transition: opacity var(--t-base), transform var(--t-base) var(--ease-out);
}
.results-drop.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-glass);
}
.results-title {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.sort-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  color: var(--ink-muted);
  transition: color var(--t-fast);
}
.sort-toggle:hover { color: var(--ink); }
.sort-toggle input { display: none; }
.sort-toggle input:checked + i { transform: rotate(180deg); }
.sort-toggle i { transition: transform var(--t-base) var(--ease-out); }

.results-list {
  overflow-y: auto;
  padding: var(--s-2);
}
.search-result-item {
  padding: var(--s-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  font-size: var(--t-sm);
  line-height: 1.4;
}
.search-result-item:hover,
.search-result-item.result-focused {
  background: var(--accent-soft);
}
.search-result-item strong {
  color: var(--ink);
  display: block;
  margin-bottom: 2px;
}
.quick-add-btn {
  padding: var(--s-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--accent);
  font-size: var(--t-sm);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.quick-add-btn:hover { background: var(--accent-soft); }

.tag-focus-btn {
  padding: var(--s-3);
  margin-bottom: var(--s-1);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: var(--t-sm);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  transition: background var(--t-fast);
}
.tag-focus-btn:hover { background: oklch(from var(--accent) l c h / 0.22); }
.tag-focus-btn strong { font-weight: 600; }

/* ═══════════════════════════════════════════════
   Focus chip
   ═══════════════════════════════════════════════ */
/* Focus chip — lives inside the search pill, only visible when focus is on. */
.focus-chip-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 2px var(--s-1) 2px var(--s-3);
  margin-left: var(--s-2);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-pill);
  font-size: var(--t-sm);
  max-width: 220px;
  overflow: hidden;
  flex-shrink: 0;
}
.focus-chip-inline[hidden] { display: none; }
.focus-chip-inline strong {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-close {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.chip-close:hover { background: oklch(from var(--accent) l c h / 0.22); }
.chip-close:active { background: oklch(from var(--accent) l c h / 0.32); }

/* ═══════════════════════════════════════════════
   Floating dock
   ═══════════════════════════════════════════════ */
.dock {
  view-transition-name: dock;
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s-4));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-2);
  background: var(--surface-glass-strong);
  backdrop-filter: blur(var(--blur-strong)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-strong)) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-width: calc(100% - var(--s-5));
}

.dock-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font-size: var(--t-md);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.dock-btn:hover { background: var(--surface-hover); color: var(--ink); }
.dock-btn:active { transform: scale(0.95); }
.dock-btn:disabled { opacity: 0.35; pointer-events: none; }

.dock-btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.dock-btn--primary:hover { background: var(--accent-hover); color: var(--accent-ink); }

.dock-btn--danger { color: var(--danger); }
.dock-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }

.dock-btn-label { font-weight: 500; }
.dock-btn i { font-size: 14px; }

.dock-tag-wrap {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding-left: var(--s-3);
  margin: 0 var(--s-1);
}
.dock-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: var(--t-sm);
  padding: 6px 0;
  width: 100px;
}
.dock-input::placeholder { color: var(--ink-muted); }

/* View Transitions */
@supports (view-transition-name: dock) {
  ::view-transition-old(dock) {
    animation: dockOut 0.18s var(--ease-in) both;
  }
  ::view-transition-new(dock) {
    animation: dockIn 0.32s var(--ease-out) both;
  }
}
@keyframes dockOut {
  to { opacity: 0; transform: translateY(8px); }
}
@keyframes dockIn {
  from { opacity: 0; transform: translateY(12px); }
}

/* ═══════════════════════════════════════════════
   Sheets (dialogs)
   ═══════════════════════════════════════════════ */
dialog.sheet {
  border: 1px solid var(--border-glass);
  border-radius: var(--r-lg);
  background: var(--surface-glass-strong);
  backdrop-filter: blur(var(--blur-strong)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-strong)) saturate(180%);
  color: var(--ink);
  padding: 0;
  max-width: min(640px, calc(100vw - var(--s-5)));
  width: 100%;
  max-height: calc(100dvh - var(--s-7));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin: auto;
}
/* Only render the flex layout when the dialog is actually open —
   otherwise the user-agent's `dialog:not([open]) { display: none }`
   gets overridden and every modal is permanently visible. */
dialog.sheet[open] {
  display: flex;
  flex-direction: column;
}

dialog.sheet--sm { max-width: 420px; }
dialog.sheet--lg { max-width: min(900px, calc(100vw - var(--s-5))); }

dialog.sheet::backdrop {
  background: oklch(0% 0 0 / 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-glass);
}
.sheet-title {
  font-size: var(--t-md);
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.sheet-title i { color: var(--ink-dim); }

.sheet-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.sheet-close:hover { background: var(--surface-hover); color: var(--ink); }

.sheet-body {
  padding: var(--s-5);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-padding-bottom: 96px;
  flex: 1 1 auto;
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border-glass);
  flex-shrink: 0;
}
.sheet-footer-left  { flex: 1; display: flex; gap: var(--s-2); }
.sheet-footer-right { display: flex; gap: var(--s-2); }

/* Sheet open/close transitions */
dialog.sheet[open] {
  animation: sheetIn 0.32s var(--ease-out) both;
}
dialog.sheet[open]::backdrop {
  animation: backdropIn 0.32s var(--ease-out) both;
}
@keyframes sheetIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ═══════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 8px 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  color: var(--ink-dim);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--ink); }

.btn-outline {
  border-color: var(--border);
  background: var(--surface);
}
.btn-outline:hover { background: var(--surface-hover); border-color: var(--ink-muted); }

.btn-danger {
  background: var(--danger);
  color: var(--accent-ink);
}
.btn-danger-ghost {
  color: var(--danger);
}
.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-block { width: 100%; justify-content: flex-start; }

/* ═══════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════ */
.form-group { margin-bottom: var(--s-4); }
.form-label {
  display: block;
  margin-bottom: var(--s-2);
  font-size: var(--t-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-sm);
  font-size: var(--t-md);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-input[readonly] {
  background: var(--surface-2);
  color: var(--ink-muted);
}

.form-hint {
  font-size: var(--t-xs);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  margin-top: var(--s-2);
}
.form-hint-inline {
  font-size: var(--t-xs);
  color: var(--ink-muted);
  font-weight: normal;
  text-transform: none;
}

/* Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast);
}
.switch-track::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--t-base) var(--ease-out);
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.2);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }

/* ═══════════════════════════════════════════════
   Settings list
   ═══════════════════════════════════════════════ */
.settings-list { display: flex; flex-direction: column; gap: var(--s-2); }
.setting-hint {
  font-size: var(--t-xs);
  color: var(--ink-muted);
  margin: 0 0 var(--s-2);
  line-height: 1.4;
}
.setting-hint code {
  font-family: ui-monospace, monospace;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) 0;
}
.setting-label {
  font-size: var(--t-md);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.divider {
  height: 1px;
  background: var(--border-glass);
  margin: var(--s-3) 0;
}
.section-label {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}

.vault-status {
  font-size: var(--t-xs);
  color: var(--ink-muted);
  padding: var(--s-2) var(--s-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  margin-top: var(--s-2);
}
.vault-status--connected { color: var(--ok); }

/* Shortcuts grid */
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border-glass);
}
.shortcuts-heading {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: var(--s-2) 0 var(--s-1);
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) 0;
  font-size: var(--t-sm);
}
.shortcut-row > kbd {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  min-width: 22px;
  text-align: center;
}
.shortcut-row > span { color: var(--ink-dim); }

/* ═══════════════════════════════════════════════
   Mindmap list (in manager sheet)
   ═══════════════════════════════════════════════ */
.mindmap-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.mindmap-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast);
}
.mindmap-item:hover { border-color: var(--accent); }
.truncateName {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════
   Tag management table
   ═══════════════════════════════════════════════ */
.tag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}
.tag-table th {
  text-align: left;
  font-weight: 600;
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border-glass);
}
.tag-table td {
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border-glass);
}
.tag-table input[type="text"] {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  color: inherit;
  outline: none;
}
.tag-table input[type="text"]:hover,
.tag-table input[type="text"]:focus {
  border-color: var(--border);
  background: var(--surface);
}
.tag-table input[type="color"] {
  width: 36px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border-radius: var(--r-sm);
}

/* ═══════════════════════════════════════════════
   Note info content
   ═══════════════════════════════════════════════ */
.info-title { font-size: var(--t-xl); margin: 0 0 var(--s-1); color: var(--ink); }
.info-date  { font-size: var(--t-xs); color: var(--ink-muted); margin: 0 0 var(--s-4); }
.info-description {
  font-size: var(--t-md);
  color: var(--ink-dim);
  line-height: 1.6;
  margin-bottom: var(--s-4);
  overflow-wrap: anywhere;
}
.info-description p { margin: 0 0 var(--s-3); }
.info-description code {
  font-family: ui-monospace, monospace;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}
.info-description a { color: var(--accent); }
/* Images in note descriptions: never wider than the sheet body. */
.info-description img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-sm);
  margin: var(--s-2) 0;
}
.info-description pre,
.info-description table { max-width: 100%; overflow-x: auto; }
.info-url { margin-bottom: var(--s-4); word-break: break-all; }
.info-url a { color: var(--accent); }
.info-url img {
  max-width: 100%;
  border-radius: var(--r-sm);
  display: block;
  margin-top: var(--s-2);
}
.info-tags { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.info-tags > span {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-pill);
  padding: 2px 10px;
  font-size: var(--t-xs);
  cursor: pointer;
  transition: background var(--t-fast);
}
.info-tags > span:hover { background: oklch(from var(--accent) l c h / 0.25); }
.badge { display: inline-block; }

/* ═══════════════════════════════════════════════
   Image lightbox
   ═══════════════════════════════════════════════ */
dialog.lightbox {
  border: none;
  padding: 0;
  margin: 0;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  background: transparent;
  color: var(--ink);
  overflow: hidden;
}
dialog.lightbox::backdrop {
  background: oklch(0% 0 0 / 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
dialog.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.22s var(--ease-out) both;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  cursor: grab;
  will-change: transform;
}
.lightbox-img:active { cursor: grabbing; }

.lightbox-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + var(--s-3));
  right: calc(env(safe-area-inset-right, 0px) + var(--s-3));
  width: 44px;
  height: 44px;
  border: none;
  background: var(--surface-glass-strong);
  color: var(--ink);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border-glass);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: var(--shadow);
}
.lightbox-close:hover { background: var(--surface-hover); }

/* ═══════════════════════════════════════════════
   Toast
   ═══════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 100px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-glass-strong);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-size: var(--t-sm);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity var(--t-base), transform var(--t-base) var(--ease-out);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════
   Toast UI Editor — light touch overrides
   ═══════════════════════════════════════════════ */
.toastui-editor-defaultUI {
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
}
.toastui-editor-toolbar { border-bottom: 1px solid var(--border) !important; }
.dark-mode .toastui-editor-defaultUI,
[data-theme="dark"] .toastui-editor-defaultUI {
  background: var(--surface);
}

/* ═══════════════════════════════════════════════
   intro.js theme tweaks
   ═══════════════════════════════════════════════ */
.introjs-tooltip {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border-radius: var(--r) !important;
  box-shadow: var(--shadow-lg) !important;
}
.introjs-tooltipReferenceLayer { visibility: visible !important; }

/* ═══════════════════════════════════════════════
   Mobile
   ═══════════════════════════════════════════════ */
@media (max-width: 767px) {
  .search-pill {
    min-width: 0;
    width: calc(100% - var(--s-5));
    max-width: none;
  }
  .results-drop {
    width: calc(100% - var(--s-4));
    max-height: 50dvh;
  }

  /* Sheets pin to bottom of viewport on mobile */
  dialog.sheet {
    margin: auto auto 0 auto;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-width: 100vw;
    width: 100%;
    max-height: 92dvh;
    transform-origin: bottom center;
  }
  dialog.sheet--sm,
  dialog.sheet--lg { max-width: 100vw; }

  /* Drag affordance bar */
  dialog.sheet::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--ink-muted);
    opacity: 0.4;
    border-radius: 2px;
    margin: 8px auto 0;
  }

  @keyframes sheetIn {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .sheet-footer {
    padding-bottom: calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }

  .dock-btn { padding: 10px 12px; }
  .dock-btn-label { display: none; }
  .dock-btn--primary .dock-btn-label { display: inline; }
}

/* ═══════════════════════════════════════════════
   Watermark — quiet brand mark in the corner
   ═══════════════════════════════════════════════ */
#watermark {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s-3));
  right:  calc(env(safe-area-inset-right,  0px) + var(--s-3));
  z-index: 5;
  pointer-events: none;
  opacity: 0.18;
  transition: opacity var(--t-base);
}
#watermark img {
  width: 48px;
  height: auto;
  display: block;
  filter: invert(1);   /* invert in light mode so the dark-mode-designed logo reads */
}
[data-theme="dark"] #watermark,
.dark-mode #watermark { opacity: 0.12; }
[data-theme="dark"] #watermark img,
.dark-mode #watermark img { filter: none; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
