/* Clawmark — vanilla CSS, light theme, system fonts (offline-safe). UX_SPEC_V2 §5 contrast tokens applied. */

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;
  --text: #1f2430;
  --text-muted: #6b7280;
  --text-faint: #595f6b;
  --accent: #3b6ef5;
  --accent-hover: #2f5fd8;
  --accent-soft: #eaf0fe;
  --accent-ink: #ffffff;
  --danger: #d64545;
  --danger-text: #b32d2d;
  --danger-soft: #fdecec;
  --success: #2e9e5b;
  --success-text: #157347;
  --hl-bg: #ffe8a3;
  --hl-text: #1f2430;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-pill: 9999px;
  --chip-bg: #eef1f6;
  --chip-text: #3f4756;
  --brand-claw-accent: #d97706;
  --brand-squircle-bg: #fef3c7;
  --brand-squircle-border: #b45309;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.10);
  --sidebar-w: 320px;

  /* Responsive Breakpoint & Metric Tokens (#160, UX_SPEC_RESPONSIVE.md) */
  --breakpoint-mobile: 768px;
  --breakpoint-tablet: 1024px;
  --sidebar-w-desktop: 320px;
  --sidebar-w-tablet: 260px;
  --sidebar-w-mobile: 100vw;
  --touch-target-min: 44px;
  --touch-target-comfortable: 48px;
  --radius-sheet: 16px;

  /* v0.4 design tokens — syntax highlighting */
  --tok-kw: #ab5e00;
  --tok-str: #1b7c3d;
  --tok-num: #b35200;
  --tok-cmt: #6c757d;
  --tok-fn: #295bc2;

  /* v0.4 design tokens — callout alerts */
  --callout-note: #3b6ef5;
  --callout-note-bg: #f0f4ff;
  --callout-tip: #198754;
  --callout-tip-bg: #edf7f0;
  --callout-warn: #c07d00;
  --callout-warn-bg: #fff9eb;
  --callout-danger: #dc3545;
  --callout-danger-bg: #fdf2f2;

  /* v0.4 design tokens — knowledge graph */
  --graph-node: #5c6b84;
  --graph-node-active: #3b6ef5;
  --graph-node-orphan: #9aa1ad;
  --graph-edge: #cfd4dc;
  --graph-edge-highlight: #3b6ef5;
  --graph-canvas-bg: #ffffff;

  /* v0.4 design tokens — revision history diff */
  --diff-add-bg: #e6f4ea;
  --diff-add-text: #137333;
  --diff-del-bg: #fce8e6;
  --diff-del-text: #c5221f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b;
    --panel: #1c1f26;
    --panel-hover: #262626;
    --panel-selected: #2d2d2d;
    --border: #2a2f39;
    --border-strong: #4a5262;
    --text: #e8eaf0;
    --text-muted: #9aa1ad;
    --text-faint: #b4bac6;
    --accent: #6f9bff;
    --accent-ink: #0e1015;
    --accent-hover: #8ab0ff;
    --accent-soft: #22304f;
    --success: #2e9e5b;
    --success-text: #5cc98a;
    --danger: #f07c7c;
    --danger-text: #f07c7c;
    --danger-soft: #3a2326;
    --chip-bg: #262c39;
    --chip-text: #c3cad6;
    --brand-claw-accent: #f59e0b;
    --brand-squircle-bg: rgba(245, 158, 11, 0.15);
    --brand-squircle-border: rgba(245, 158, 11, 0.35);
    --hl-bg: #d9b64f;
    --hl-text: #14161b;

    /* v0.4 design tokens — syntax highlighting */
    --tok-kw: #f08d49;
    --tok-str: #7ec699;
    --tok-num: #f79759;
    --tok-cmt: #8a94a6;
    --tok-fn: #82aaff;

    /* v0.4 design tokens — callout alerts */
    --callout-note: #6f9bff;
    --callout-note-bg: #172338;
    --callout-tip: #46c07a;
    --callout-tip-bg: #162b20;
    --callout-warn: #e8a838;
    --callout-warn-bg: #2f2412;
    --callout-danger: #f07c7c;
    --callout-danger-bg: #321a1d;

    /* v0.4 design tokens — knowledge graph */
    --graph-node: #8692a6;
    --graph-node-active: #6f9bff;
    --graph-node-orphan: #4a5262;
    --graph-edge: #363c4a;
    --graph-edge-highlight: #6f9bff;
    --graph-canvas-bg: #181a20;

    /* v0.4 design tokens — revision history diff */
    --diff-add-bg: #183222;
    --diff-add-text: #5cc98a;
    --diff-del-bg: #381c1f;
    --diff-del-text: #f07c7c;
  }
}

html[data-theme="dark"] {
  --bg: #14161b;
  --panel: #1c1f26;
  --panel-hover: #262626;
  --panel-selected: #2d2d2d;
  --border: #2a2f39;
  --border-strong: #4a5262;
  --text: #e8eaf0;
  --text-muted: #9aa1ad;
  --text-faint: #b4bac6;
  --accent: #6f9bff;
  --accent-ink: #0e1015;
  --accent-hover: #8ab0ff;
  --accent-soft: #22304f;
  --success: #2e9e5b;
  --success-text: #5cc98a;
  --danger: #f07c7c;
  --danger-text: #f07c7c;
  --danger-soft: #3a2326;
  --chip-bg: #262c39;
  --chip-text: #c3cad6;
  --brand-claw-accent: #f59e0b;
  --brand-squircle-bg: rgba(245, 158, 11, 0.15);
  --brand-squircle-border: rgba(245, 158, 11, 0.35);
  --hl-bg: #d9b64f;
  --hl-text: #14161b;

  /* v0.4 design tokens — syntax highlighting */
  --tok-kw: #f08d49;
  --tok-str: #7ec699;
  --tok-num: #f79759;
  --tok-cmt: #8a94a6;
  --tok-fn: #82aaff;

  /* v0.4 design tokens — callout alerts */
  --callout-note: #6f9bff;
  --callout-note-bg: #172338;
  --callout-tip: #46c07a;
  --callout-tip-bg: #162b20;
  --callout-warn: #e8a838;
  --callout-warn-bg: #2f2412;
  --callout-danger: #f07c7c;
  --callout-danger-bg: #321a1d;

  /* v0.4 design tokens — knowledge graph */
  --graph-node: #8692a6;
  --graph-node-active: #6f9bff;
  --graph-node-orphan: #4a5262;
  --graph-edge: #363c4a;
  --graph-edge-highlight: #6f9bff;
  --graph-canvas-bg: #181a20;

  /* v0.4 design tokens — revision history diff */
  --diff-add-bg: #183222;
  --diff-add-text: #5cc98a;
  --diff-del-bg: #381c1f;
  --diff-del-text: #f07c7c;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */

.sidebar {
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  min-width: 260px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 12px;
  position: relative;
}

.brand {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.empty-hint {
  padding: 20px 20px 4px;
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ---------- Search Launcher Row (#136) ---------- */

.search-launcher-btn {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.search-launcher-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--text);
}

.search-launcher-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.search-launcher-btn .tb-ico {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  color: var(--text-muted);
}

.search-launcher-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.search-launcher-btn:hover .search-launcher-label {
  color: var(--text);
}

.shortcut-chip {
  flex: 0 0 auto;
  margin-left: 6px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

mark.hl {
  background: var(--hl-bg);
  color: var(--hl-text);
  border-radius: 2px;
  padding: 0 1px;
}

.search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 0;
}

.search-empty .empty-hint { padding: 16px 4px 0; }

.search-empty .btn { font-size: 13px; padding: 5px 12px; }

.note-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0 8px 12px;
  margin: 4px 0 0;
}

.note-row { margin: 2px 0; }

.note-row-btn {
  position: relative; /* anchor for .pin-btn */
  display: block;
  width: 100%;
  min-height: 52px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 12px 66px 12px 12px; /* right gutter keeps title/time clear of pin and menu buttons */
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.note-row-btn:hover { background: var(--bg); }

.note-row-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.note-row-btn[aria-current="true"] {
  background: var(--accent-soft);
  border-color: #c6d6fb;
}

.note-row-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px 10px;
}

.note-row-title {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.note-row-time {
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 12px;
}

.note-row-preview {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tag chips & overflow in rows (UX_SPEC_V02 §3) */
.note-row-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  margin-top: 4px;
}

/* Pin/favorite affordance (UX_SPEC_V02 §2). Sits on the timestamp line at the
 * row's right edge; 24px hit target, quiet at rest, no layout shift on hover. */
.pin-btn {
  position: absolute;
  top: 8px;
  right: 36px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.12s, background 0.12s;
}

.pin-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.pin-btn[aria-pressed="true"] {
  opacity: 1;
  color: var(--accent);
}

.pin-btn[aria-pressed="true"] svg {
  fill: var(--accent);
  stroke: var(--accent);
}

.pin-btn:hover,
.pin-btn:focus-visible {
  opacity: 1;
  background: var(--bg);
}

.pin-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Non-colour-alone cue for pinned rows: 2px accent stripe on the left edge. */
.note-row-btn.pinned {
  border-left: 2px solid var(--accent);
}

/* Section headers between pinned/unpinned runs. */
.list-section-li {
  list-style: none;
}

.list-section {
  margin: 10px 6px 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------- Editor ---------- */

.editor {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px 28px 18px;
  gap: 8px;
}

.field-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.title-input {
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 6px 2px 10px;
  outline: none;
  transition: border-color 0.15s;
}

.title-input:focus { border-bottom-color: var(--accent); }

.title-input.input-error { border-bottom-color: var(--danger); }

.inline-error {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}

.content-input {
  flex: 1;
  resize: none;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 4px 2px;
  outline: none;
  line-height: 1.65;
}

.editor-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.save-status {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.save-status.dirty {
  color: var(--text-faint);
  font-weight: 400;
}

/* Saved ✓ flash — reuse of v1 fade (opacity/transform transition). */
.save-status.saved-flash {
  color: var(--success);
  animation: saved-pop 0.18s ease;
}

@keyframes saved-pop {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Conflict panel (§2) ---------- */

.conflict-panel {
  background: var(--danger-soft);
  border: 1px solid #f2c1c1;
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.conflict-message {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.conflict-actions {
  display: flex;
  gap: 8px;
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.65;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }

.btn-sm {
  padding: 5px 12px;
  font-size: 13.5px;
}

/* ---------- Confirm-and-protect modal (§1) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 40, 0.45);
  z-index: 60;
}

.modal {
  width: min(420px, calc(100vw - 48px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 22px 24px 18px;
}

.modal-message {
  margin: 0 0 18px;
  font-size: 15px;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Toasts (incl. delete-undo) ---------- */

.toast-region {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 30;
  pointer-events: none;
}

.toast {
  background: #2a2f3a;
  color: #f3f4f6;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: min(480px, calc(100vw - 48px));
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast-undo {
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
  cursor: pointer;
}

.toast-undo-btn {
  font: inherit;
  font-weight: 700;
  color: #cfe0ff;
  background: transparent;
  border: 1px solid #56607a;
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
}

.toast-undo-btn:hover { background: #3a4152; }

.toast-undo-btn:focus-visible {
  outline: 2px solid #9db9f7;
  outline-offset: 2px;
}

/* ---------- Formatting toolbar + Edit/Preview (v2.1, DESIGN.md Components) ----------
   Composed only of existing tokens: ghost buttons, rounded.sm (6px, already used
   by the toast undo affordance), border / bg / panel / text / text-muted /
   accent / accent-soft, spacing.sm 8px and spacing.xs 4px. No new colors,
   shadows, or font sizes. */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 8px;
  column-gap: 6px;
  padding: 6px 0;
  background: transparent;
}

.formatting-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  row-gap: 8px;
}

.formatting-tools[hidden] {
  display: none !important;
}

.tb-div {
  flex: 0 0 auto;
  width: 1px;
  height: 20px;
  background: var(--border);
}

.tb-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.tb-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.tb-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tb-btn:disabled { opacity: 0.65; cursor: default; }

.tb-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.tb-btn:active { transform: translateY(1px); }

.tb-ico { display: inline-flex; width: 16px; height: 16px; }

.tb-ico svg {
  width: 16px;
  height: 16px;
  display: block;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.segmented {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.seg-btn {
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 5px 12px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.seg-btn:last-child { border-right: none; }

.seg-btn:hover { background: var(--bg); color: var(--text); }

.seg-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.seg-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ---------- Preview surface ----------
   Body type inherits the shipped 15px / 1.65 editor rhythm. H1/H2 map to
   existing scale steps (24px / 700 editor-title and 15px bold per the PO
   ruling); H3 renders at default body size - no new values. */

.preview-surface {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
  font: inherit;
  line-height: 1.65;
  color: var(--text);
  background: transparent;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.preview-surface:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.preview-surface h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.preview-surface h2 {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.preview-surface h3 {
  margin: 16px 0 8px;
  font-weight: 700;
}

.preview-surface p { margin: 0 0 8px; }

.preview-surface a {
  color: var(--accent);
  text-decoration: underline;
}

.preview-surface ul,
.preview-surface ol {
  margin: 0 0 8px;
  padding-left: 24px;
}

.preview-surface pre {
  margin: 0 0 8px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre;
}

.preview-surface code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.preview-surface pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
}

.preview-surface :not(pre) > code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 4px;
}

.preview-surface ::selection { background: var(--accent-soft); }

/* ---------- Responsive Layout System & Viewports (#160, UX_SPEC_RESPONSIVE.md) ---------- */

/* Mobile Master-Detail Navigation (< 768px) */
@media (max-width: 767.98px) {
  html, body {
    overflow-x: hidden;
  }

  .title-input {
    font-size: 20px;
  }

  /* Master view: sidebar occupies 100vw, editor is hidden */
  .app.view-master .sidebar,
  .app:not(.view-detail) .sidebar {
    display: flex !important;
    width: 100vw !important;
    flex: 1 1 100% !important;
    min-width: 0 !important;
    border-right: none !important;
  }

  .app.view-master .editor,
  .app:not(.view-detail) .editor {
    display: none !important;
  }

  /* Detail view: editor occupies 100vw with defined padding, sidebar is hidden */
  .app.view-detail .sidebar {
    display: none !important;
  }

  .app.view-detail .editor {
    display: flex !important;
    width: 100vw !important;
    flex: 1 1 100% !important;
    padding: 16px 18px 14px !important;
    min-width: 0 !important;
  }

  /* Mobile back button header */
  .app.view-detail .editor-mobile-header,
  .editor-mobile-header {
    display: flex;
    align-items: center;
    min-height: var(--touch-target-min, 44px);
    margin-bottom: 8px;
  }

  #mobile-back-btn,
  .mobile-back-btn {
    min-height: var(--touch-target-min, 44px);
    min-width: var(--touch-target-min, 44px);
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm, 6px);
  }

  #mobile-back-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  /* Touch ergonomics (< 768px) */
  #new-btn,
  #save-btn,
  .btn-primary,
  .btn-secondary,
  .btn-danger {
    min-height: var(--touch-target-min, 44px);
  }

  #new-btn,
  #save-btn {
    min-width: var(--touch-target-min, 44px);
  }

  #settings-btn {
    width: var(--touch-target-min, 44px) !important;
    height: var(--touch-target-min, 44px) !important;
    min-width: var(--touch-target-min, 44px);
    min-height: var(--touch-target-min, 44px);
  }

  #logout-btn {
    min-height: var(--touch-target-min, 44px);
    padding: 0 12px;
  }

  .user-email,
  #user-email {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #status-tabs .seg-btn {
    min-height: var(--touch-target-min, 44px);
    height: var(--touch-target-min, 44px);
    padding: 0 12px;
  }

  .note-row-btn {
    min-height: 52px;
    padding: 12px 90px 12px 12px;
  }

  .pin-btn {
    top: 4px;
    right: 44px;
    width: var(--touch-target-min, 44px);
    height: var(--touch-target-min, 44px);
  }

  .note-row-menu-btn {
    top: 4px;
    right: 2px;
    width: var(--touch-target-min, 44px);
    height: var(--touch-target-min, 44px);
  }

  .toolbar .tb-btn {
    min-width: var(--touch-target-min, 44px);
    min-height: var(--touch-target-min, 44px);
  }

  .toolbar .seg-btn {
    min-height: var(--touch-target-min, 44px);
    padding: 0 12px;
  }

  .settings-close-btn,
  #settings-close-btn,
  #share-close-btn,
  #shortcuts-close-btn,
  #search-modal-clear,
  .modal-header .tb-btn {
    min-width: var(--touch-target-min, 44px) !important;
    min-height: var(--touch-target-min, 44px) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Responsive bottom-sheet modals (< 768px) */
  .modal-backdrop:not([hidden]),
  .search-modal-backdrop:not([hidden]),
  .settings-modal-backdrop:not([hidden]),
  .conflict-modal-backdrop:not([hidden]),
  .cmd-palette-backdrop:not([hidden]) {
    display: flex;
    align-items: flex-end !important;
    justify-content: center;
    padding: 0 !important;
  }

  .modal:not([hidden]),
  .modal-card:not([hidden]),
  .settings-modal-panel:not([hidden]),
  .settings-card:not([hidden]),
  .search-modal-panel:not([hidden]),
  #search-modal .modal-card:not([hidden]),
  .share-modal-card:not([hidden]),
  #share-modal .modal-card:not([hidden]),
  .template-modal-card:not([hidden]),
  .history-card:not([hidden]),
  .shortcuts-modal-panel:not([hidden]),
  .conflict-dialog:not([hidden]),
  .import-modal-panel:not([hidden]),
  .cmd-palette-card:not([hidden]) {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 92vh !important;
    max-height: 92dvh !important;
    border-radius: var(--radius-sheet, 16px) var(--radius-sheet, 16px) 0 0 !important;
    margin: 0 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .modal-header,
  .settings-modal-header,
  .search-modal-header,
  .cmd-palette-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: var(--panel) !important;
    flex-shrink: 0 !important;
    min-height: var(--touch-target-min, 44px);
  }

  .modal-actions,
  .modal-footer,
  .settings-modal-footer,
  .settings-modal-actions,
  .search-modal-footer,
  .conflict-dialog-actions {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 10 !important;
    background: var(--panel) !important;
    flex-shrink: 0 !important;
  }

  .modal-body,
  .settings-modal-body,
  .share-modal-body,
  .template-body,
  .history-body,
  .search-modal-results,
  .shortcuts-body,
  .conflict-columns {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* Ultra-compact screen fallback (< 360px) */
@media (max-width: 360px) {
  .toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .toolbar::-webkit-scrollbar {
    display: none;
  }
}

/* Tablet Viewport (768px - 1024px) */
@media (min-width: 768px) {
  .editor-mobile-header {
    display: none !important;
  }

  .sidebar {
    flex: 0 0 var(--sidebar-w-tablet, 260px) !important;
    width: var(--sidebar-w-tablet, 260px) !important;
    min-width: var(--sidebar-w-tablet, 260px) !important;
  }

  .editor {
    flex: 1 !important;
    display: flex !important;
  }
}

/* Desktop Viewport (> 1024px) */
@media (min-width: 1024.02px) {
  .sidebar {
    flex: 0 0 var(--sidebar-w-desktop, 320px) !important;
    width: var(--sidebar-w-desktop, 320px) !important;
    min-width: var(--sidebar-w-desktop, 320px) !important;
  }
}

/* ---------- Tag chips, filter bar & editor combobox (UX_SPEC_V02 §3) ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  color: var(--chip-text);
  background: var(--chip-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.chip:hover {
  background: #e2e6ee;
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chip.chip-active {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.chip-more {
  padding: 0 6px;
  font-weight: 600;
  color: var(--text-muted);
}

.chip.chip-more:hover {
  color: var(--text);
  background: #e2e6ee;
}

.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  margin-left: 2px;
  color: inherit;
}

/* Filter bar under search box */
.tag-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 12px 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.tag-filter-label {
  font-size: 12px;
  color: var(--text-muted);
}

.tag-filter-chips {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-filter-clear {
  font-size: 12px;
  padding: 2px 6px;
  height: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.tag-filter-clear:hover {
  color: var(--text);
}

/* Editor header tags */
.editor-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
  min-height: 24px;
}

.editor-chips {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.editor-chips .chip {
  position: relative;
}

.editor-chips .chip .chip-remove {
  opacity: 0;
  transition: opacity 0.12s;
}

.editor-chips .chip:hover .chip-remove,
.editor-chips .chip:focus .chip-remove,
.editor-chips .chip:focus-visible .chip-remove,
.editor-chips .chip:focus-within .chip-remove {
  opacity: 1;
}

.tag-add-btn {
  font-size: 11.5px;
  font-weight: 500;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tag-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.tag-combo-wrapper {
  display: inline-flex;
  align-items: center;
  position: relative;
  gap: 6px;
}

.tag-input {
  width: 160px;
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  outline: none;
  box-sizing: border-box;
}

.tag-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tag-input.input-error {
  border-color: var(--danger);
  outline-color: var(--danger);
}

.tag-combo-wrapper .inline-error {
  margin: 0;
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- Scrollbars (subtle) ---------- */

.note-list::-webkit-scrollbar,
.content-input::-webkit-scrollbar,
.preview-surface::-webkit-scrollbar { width: 10px; }

.note-list::-webkit-scrollbar-thumb,
.content-input::-webkit-scrollbar-thumb,
.preview-surface::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 3px solid var(--panel);
}


/* ---------- Archive & Trash UI (UX_SPEC_V02 §5, #12) ---------- */

.sidebar-footer {
  flex: 0 0 auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.status-tabs {
  display: flex;
  width: 100%;
}

.status-tabs .seg-btn {
  flex: 1 1 0;
  text-align: center;
  padding: 6px 4px;
  font-size: 13px;
}

.trash-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 16px 4px;
}

.menu-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.12s, background 0.12s;
}

.menu-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.menu-btn:hover,
.menu-btn:focus-visible {
  opacity: 1;
  background: var(--bg);
}

.menu-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.menu-panel {
  position: fixed;
  z-index: 50;
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 4px;
  display: flex;
  flex-direction: column;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.menu-shortcut {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-family: inherit;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--bg);
  outline: none;
}

.menu-item-danger {
  color: var(--danger);
}

.menu-item-danger:hover,
.menu-item-danger:focus-visible {
  background: var(--danger-soft);
  color: var(--danger);
}

.menu-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
  padding: 0;
}

.pin-btn:disabled,
.pin-btn.pin-disabled {
  opacity: 0.15;
  cursor: not-allowed;
  pointer-events: none;
}


/* ---------- Conflict Recovery Dialog (#11, UX_SPEC_V02 §4) ---------- */

.conflict-modal-backdrop .conflict-dialog {
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  padding: 20px 24px 18px;
  overflow: hidden;
}

.conflict-dialog-header {
  margin-bottom: 14px;
}

.conflict-dialog-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.conflict-dialog-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.conflict-columns {
  display: flex;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 16px;
}

.conflict-col {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.conflict-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.conflict-col-header-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.conflict-col-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.conflict-col-time {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.conflict-col-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conflict-view-toggle .seg-btn {
  padding: 2px 8px;
  font-size: 12px;
}

.conflict-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  height: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.conflict-copy-btn:hover {
  color: var(--text);
}

.conflict-copy-btn .tb-ico {
  width: 13px;
  height: 13px;
}

.conflict-col-meta {
  margin-bottom: 8px;
}

.conflict-note-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conflict-my-title-input {
  font-size: 16px;
  padding: 2px 0 4px;
  width: 100%;
}

.conflict-col-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 20px;
}

.conflict-col-content-wrap {
  flex: 1 1 auto;
  min-height: 200px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.conflict-preview-surface {
  padding: 0;
  font-size: 13.5px;
}

.conflict-raw-content {
  margin: 0;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.conflict-my-textarea {
  width: 100%;
  height: 100%;
  min-height: 190px;
  border: none;
  padding: 0;
  font-size: 13.5px;
}

.conflict-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Save status component styles (§4) */
.save-status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.save-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  display: inline-block;
}

.save-status-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: save-spin 0.6s linear infinite;
}

@keyframes save-spin {
  to { transform: rotate(360deg); }
}

.save-status-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--success-text);
  font-weight: 700;
}

.save-status-saved {
  color: var(--success-text);
  font-weight: 600;
}

.save-status-conflict-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}

.save-status-conflict-btn:hover {
  background: #fbd6d6;
}

.save-status-conflict-btn:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 1px;
}

.save-status-conflict-btn svg {
  width: 14px;
  height: 14px;
  stroke: var(--danger);
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .conflict-columns {
    flex-direction: column;
  }
}

/* ---------- Export & Import (#14, UX_SPEC_V02 §7) ---------- */

#header-menu-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  opacity: 0.7;
  font-size: 16px;
  line-height: 1;
}

#header-menu-btn:hover,
#header-menu-btn:focus-visible {
  opacity: 1;
}

.modal.import-modal-panel {
  max-width: 540px;
  width: min(540px, calc(100vw - 32px));
}

.modal-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.import-summary {
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text);
}

.import-counts {
  font-weight: 600;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.import-details {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.import-details li {
  display: flex;
  justify-content: space-between;
}

.import-details li span:last-child {
  font-weight: 600;
  color: var(--text);
}

/* ---------- Note links, backlinks & link-suggest (#13, UX_SPEC_V02 §6) ---------- */

.note-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.note-link:hover {
  color: var(--accent-hover);
}

.note-link.unresolved {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1.5px dotted var(--border-strong);
  cursor: pointer;
}

.note-link.unresolved:hover {
  border-bottom-color: var(--text-faint);
}

.backlinks {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.backlinks-header {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 4px;
}

.backlinks-unavailable {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0;
}

.backlinks-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.backlink-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  width: 100%;
  transition: background 0.12s, border-color 0.12s;
}

.backlink-row:hover,
.backlink-row:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  outline: none;
}

.backlink-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.backlink-row-self {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.backlink-row-snippet {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  line-height: 1.4;
}

.link-suggest {
  position: absolute;
  z-index: 100;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  width: 280px;
  max-width: calc(100vw - 32px);
  overflow-y: auto;
  padding: 4px 0;
  margin: 0;
  list-style: none;
}

.link-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text);
}

.link-suggest-item:hover,
.link-suggest-item.selected {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.link-suggest-title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-suggest-meta {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--text-faint);
}

.link-suggest-create {
  font-style: italic;
  color: var(--text-muted);
}


/* ---------- Split Mode & Editor Body (UX_SPEC_V02 §10, #17) ---------- */

.editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
  width: 100%;
}

.editor-body.mode-split .content-input {
  width: 50%;
  border-right: 1px solid var(--border);
  padding-right: 12px;
}

.editor-body.mode-split .preview-surface {
  width: 50%;
  padding-left: 12px;
}

@media (min-width: 900px) and (max-width: 1099px) {
  .editor-body.mode-split .content-input {
    width: 60%;
  }
  .editor-body.mode-split .preview-surface {
    width: 40%;
  }
}

@media (max-width: 899px) {
  #mode-split {
    display: none !important;
  }
}

/* ---------- Task Checkboxes (UX_SPEC_V02 §10, #17) ---------- */

.task {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.task input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--accent);
}

.task-done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.preview-surface ul.task-list {
  list-style: none;
  padding-left: 0;
}

.preview-surface ul.task-list > li {
  list-style: none;
}

/* ---------- Image Preview (UX_SPEC_V02 §10, #17) ---------- */

.preview-surface img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin: 4px 0;
}

/* ---------- Keyboard shortcuts modal (#15) ---------- */
#shortcuts-modal .shortcuts-modal-panel {
  max-width: 480px;
  width: min(480px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.shortcuts-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shortcuts-modal-header .modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.shortcuts-close-btn {
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  color: var(--text-muted);
}

.shortcuts-close-btn:hover {
  color: var(--text);
}

.shortcuts-table-wrap {
  overflow-x: auto;
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.shortcuts-table th,
.shortcuts-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.shortcuts-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shortcuts-table td {
  color: var(--text);
}

.shortcuts-table kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--chip-text);
  background-color: var(--chip-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}


/* ---------- Auth & Multi-user (#16, UX_SPEC_V02 §9, #98 UX_SPEC_AUTH_V2) ---------- */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 28px 24px 24px;
}

.auth-card.sso-card {
  max-width: 440px;
  padding: 36px 32px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.12);
}

.auth-brand-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--accent);
}

.auth-brand-header .auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px 0;
}

.auth-brand-header .auth-subtitle {
  font-size: 14.5px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.auth-brand-header .brand {
  font-size: 28px;
  margin-bottom: 6px;
}

.auth-subtitle {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.auth-tabs {
  display: flex;
  width: 100%;
  margin-bottom: 16px;
}

.auth-tabs .seg-btn {
  flex: 1 1 0;
  text-align: center;
  padding: 7px 12px;
}

.auth-session-banner {
  margin: 0 0 14px;
  padding: 8px 12px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid #c6d6fb;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
}

.auth-alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin: 0 0 20px 0;
  text-align: left;
}

.auth-alert-banner.alert-danger {
  background-color: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger-text);
}

.auth-alert-banner .alert-icon-wrapper {
  flex-shrink: 0;
  color: var(--danger);
  margin-top: 2px;
}

.auth-alert-banner .alert-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.auth-alert-banner .alert-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--danger-text);
}

.auth-alert-banner .alert-desc {
  font-size: 13px;
  color: var(--danger-text);
  margin: 0;
  line-height: 1.4;
}

.auth-alert-banner .alert-dismiss-btn {
  background: transparent;
  border: 0;
  color: var(--danger-text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}

.auth-alert-banner .alert-dismiss-btn:hover {
  opacity: 0.8;
}

.auth-alert-banner .alert-dismiss-btn:focus-visible {
  outline: 2px solid var(--danger);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.auth-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.auth-cta-btn .btn-icon {
  flex-shrink: 0;
}

.auth-security-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
}

.auth-security-footer .security-icon {
  flex-shrink: 0;
  color: var(--text-faint);
}

.auth-error {
  margin: 0 0 14px;
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-input {
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.auth-input.input-error {
  border-color: var(--danger);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper .auth-input {
  padding-right: 36px;
}

.pw-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.pw-toggle-btn:hover {
  color: var(--text);
}

.pw-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pw-toggle-btn .tb-ico {
  width: 16px;
  height: 16px;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.auth-submit-btn {
  width: 100%;
  margin-top: 4px;
  padding: 9px 16px;
  font-size: 14.5px;
}

.auth-footer-row {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.btn-link {
  font: inherit;
  font-size: 13.5px;
  color: var(--accent);
  background: transparent;
  border: 0;
  padding: 4px 6px;
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.btn-link:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.btn-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* User Account in Sidebar Footer */
.user-profile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.user-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-notes-count {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.settings-btn,
#settings-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.settings-btn:hover:not(:disabled),
#settings-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.settings-btn:focus-visible,
#settings-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  color: var(--text);
}

.settings-btn .tb-ico,
#settings-btn .tb-ico {
  width: 16px;
  height: 16px;
  display: block;
}

.logout-btn {
  flex-shrink: 0;
}

/* ---------- Version History & Diff Viewer (#42, UX_SPEC_V04 §2) ---------- */

.tb-btn.tb-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.tb-btn.tb-ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}

.history-card {
  width: min(860px, calc(100vw - 32px));
  max-width: 860px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  padding: 20px 24px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.history-card .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.history-card .modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.history-body {
  display: flex;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 380px;
  max-height: calc(100vh - 160px);
  overflow: hidden;
}

.history-sidebar {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  padding: 8px;
}

.revision-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.revision-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  user-select: none;
  outline: none;
  transition: background 0.12s, border-color 0.12s;
}

.revision-item:hover {
  background: var(--panel);
  border-color: var(--border);
}

.revision-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.revision-item.active,
.revision-item[aria-selected="true"] {
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.revision-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.revision-item-version {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--accent);
}

.revision-item-time {
  font-size: 11.5px;
  color: var(--text-muted);
}

.revision-item-title {
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.revision-list .empty-state {
  padding: 16px 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.history-diff-view {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.diff-meta {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  background: var(--panel);
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-line {
  display: block;
  padding: 1px 4px;
  border-radius: 2px;
  white-space: pre-wrap;
}

.diff-line.diff-add {
  background: var(--diff-add-bg);
  color: var(--diff-add-text);
}

.diff-line.diff-del {
  background: var(--diff-del-bg);
  color: var(--diff-del-text);
}

.diff-line.diff-ctx {
  color: var(--text-muted);
}

.diff-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: var(--danger-text);
  font-family: inherit;
}



/* ---------- Folders / Notebooks & Hierarchical Tags (#43) ---------- */

.sidebar-section {
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 6px;
}

.sidebar-section-header .section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.folder-tree {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 180px;
  overflow-y: auto;
  font-size: 13px;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  padding-left: calc(8px + var(--depth, 0) * 14px);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

.folder-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.folder-item.active,
.folder-item.is-active,
.folder-item[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.folder-item .folder-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.folder-item .folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-item .folder-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  padding-left: 4px;
}

.folder-item.active .folder-count,
.folder-item.is-active .folder-count {
  color: var(--accent);
}

.folder-item .folder-actions {
  display: none;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}

.folder-item:hover .folder-actions {
  display: flex;
}

.folder-action-btn {
  background: transparent;
  border: none;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.folder-action-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.folder-action-btn.btn-delete:hover {
  color: var(--danger-text);
}

.folder-inline-input {
  width: 100%;
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}

/* Editor folder selector */
.folder-select {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  outline: none;
  max-width: 160px;
  text-overflow: ellipsis;
  transition: border-color 0.12s;
}

.folder-select:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

/* Hierarchical tag pill styling */
.tag-pill.tag-nested {
  display: inline-flex;
  align-items: center;
}

.tag-sep {
  opacity: 0.45;
  margin: 0 1px;
  user-select: none;
}

/* ---------- Note Templates & Daily Notes (#44, UX_SPEC_V04 §4) ---------- */

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

#daily-note-btn,
#template-btn,
#save-as-template-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

#daily-note-btn:hover:not(:disabled),
#template-btn:hover:not(:disabled),
#save-as-template-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

#daily-note-btn:focus-visible,
#template-btn:focus-visible,
#save-as-template-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#daily-note-btn[aria-expanded="true"],
#template-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

#daily-note-btn:disabled,
#template-btn:disabled,
#save-as-template-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.template-modal-card {
  width: min(520px, calc(100vw - 32px));
  max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  padding: 20px 24px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.template-modal-card .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.template-modal-card .modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.template-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 200px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px 0;
}

.template-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.template-item:hover {
  background: var(--panel-hover);
  border-color: var(--border-strong);
}

.template-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.template-item[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.template-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.template-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.template-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.template-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-muted);
}

.template-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.template-delete-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-soft);
}

.template-delete-btn:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 1px;
}

.template-empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}


/* ---------- Knowledge Graph View (#45, UX_SPEC_V04 §5) ---------- */

#graph-toggle-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.graph-view {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--graph-canvas-bg);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.graph-view[hidden] {
  display: none !important;
}

.graph-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.graph-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.graph-filter-input {
  max-width: 240px;
  width: 100%;
  height: 30px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.graph-filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.graph-control-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.graph-control-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}

.graph-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

#graph-reset-btn {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
}

.graph-canvas-container {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--graph-canvas-bg);
}

#graph-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#graph-canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.graph-empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
  background: var(--panel);
  padding: 16px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.graph-empty-state[hidden] {
  display: none !important;
}



/* ---------- Modal Search Overlay (#136) ---------- */

.search-modal-backdrop {
  z-index: 1000;
  background: rgba(16, 24, 40, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  align-items: flex-start;
  padding-top: min(12vh, 100px);
}

.search-modal-panel {
  width: min(640px, calc(100vw - 32px));
  max-width: 640px;
  max-height: min(560px, calc(100vh - 140px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  animation: searchModalIn 0.12s ease-out;
}

@keyframes searchModalIn {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.search-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: relative;
}

.search-modal-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-modal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 0;
  min-width: 0;
}

.search-modal-input::placeholder {
  color: var(--text-muted);
}

.search-modal-clear {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.search-modal-clear:hover {
  background: var(--bg);
  color: var(--text);
}

.search-modal-clear:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.search-modal-results {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  min-height: 140px;
  max-height: 400px;
}

.search-modal-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.search-modal-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.05s ease;
}

.search-modal-item:last-child {
  border-bottom: none;
}

.search-modal-item:hover,
.search-modal-item.active,
.search-modal-item.is-selected,
.search-modal-item[aria-selected="true"] {
  background: var(--accent-soft);
}

.search-modal-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.search-modal-item:hover .search-modal-item-title,
.search-modal-item.active .search-modal-item-title,
.search-modal-item.is-selected .search-modal-item-title,
.search-modal-item[aria-selected="true"] .search-modal-item-title {
  color: var(--accent-hover);
}

.search-modal-item-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-modal-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.search-modal-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--chip-bg);
  color: var(--chip-text);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.search-modal-badge-folder {
  background: var(--bg);
  border: 1px solid var(--border);
}

.search-modal-badge-tag {
  background: var(--chip-bg);
  color: var(--chip-text);
}

.search-modal-item-snippet {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.search-modal-item:hover .search-modal-item-snippet,
.search-modal-item.active .search-modal-item-snippet,
.search-modal-item.is-selected .search-modal-item-snippet,
.search-modal-item[aria-selected="true"] .search-modal-item-snippet {
  color: var(--text);
}

.search-modal-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11.5px;
  user-select: none;
}

.search-modal-footer span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.search-modal-footer kbd {
  display: inline-block;
  padding: 1px 4px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
}

/* ---------- Command Palette & Slash Commands (#46, UX_SPEC_V04 §6) ---------- */

.cmd-palette-backdrop {
  z-index: 1000;
  background: rgba(16, 24, 40, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  align-items: flex-start;
  padding-top: min(15vh, 120px);
}

.cmd-palette-backdrop[hidden] {
  display: none !important;
}

.cmd-palette-card {
  width: min(640px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 160px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cmdPaletteIn 0.12s ease-out;
}

@keyframes cmdPaletteIn {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.cmd-palette-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.cmd-palette-header .tb-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.cmd-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 0;
  min-width: 0;
}

.cmd-palette-input::placeholder {
  color: var(--text-muted);
}

.cmd-palette-results {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  min-height: 120px;
  max-height: 360px;
}

.cmd-section-header {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  user-select: none;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.05s ease;
}

.cmd-item:hover,
.cmd-item.active,
.cmd-item.is-selected,
.cmd-item[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.cmd-item-icon {
  font-size: 14px;
  line-height: 1;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.cmd-item:hover .cmd-item-icon,
.cmd-item.active .cmd-item-icon,
.cmd-item.is-selected .cmd-item-icon,
.cmd-item[aria-selected="true"] .cmd-item-icon {
  color: var(--accent);
}

.cmd-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmd-item-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--chip-bg);
  color: var(--chip-text);
  flex-shrink: 0;
}

.cmd-item-shortcut {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cmd-item-shortcut kbd {
  display: inline-block;
  padding: 2px 5px;
  font-family: inherit;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.cmd-palette-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.cmd-palette-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11.5px;
  user-select: none;
}

.cmd-palette-footer span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cmd-palette-footer kbd {
  display: inline-block;
  padding: 1px 4px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
}

/* Slash Commands Popover Menu */

.slash-menu {
  position: absolute;
  z-index: 100;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 240px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
  animation: slashMenuIn 0.1s ease-out;
}

.slash-menu[hidden] {
  display: none !important;
}

@keyframes slashMenuIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slash-menu-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.slash-item:hover,
.slash-item.active,
.slash-item.is-selected,
.slash-item[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.slash-icon {
  font-size: 13px;
  font-weight: 600;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
  border-radius: 4px;
  color: var(--chip-text);
  flex-shrink: 0;
}

.slash-item:hover .slash-icon,
.slash-item.active .slash-icon,
.slash-item.is-selected .slash-icon,
.slash-item[aria-selected="true"] .slash-icon {
  background: var(--accent);
  color: #ffffff;
}

.slash-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Code Blocks, Syntax Highlighting & Copy Button (#47) ---------- */

.code-block-wrapper {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.code-lang-badge,
.code-lang-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: lowercase;
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-muted);
  background: transparent;
  transition: all 0.15s ease;
}

.code-copy-btn:hover {
  background: var(--chip-bg);
  color: var(--text);
  border-color: var(--border);
}

.code-copy-btn .tb-ico {
  width: 14px;
  height: 14px;
}

.code-copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
  background: var(--accent-soft);
}

.code-pre {
  margin: 0;
  padding: 12px 16px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  background: transparent;
}

.code-block {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

/* Syntax tokens */
.tok-kw {
  color: var(--tok-kw);
  font-weight: 600;
}

.tok-str {
  color: var(--tok-str);
}

.tok-num {
  color: var(--tok-num);
}

.tok-cmt {
  color: var(--tok-cmt);
  font-style: italic;
}

.tok-fn {
  color: var(--tok-fn);
}

/* ---------- Callout Blocks (#47) ---------- */

.callout {
  border-left: 4px solid var(--border-strong);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 16px 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.callout-header,
.callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.callout-icon {
  font-size: 15px;
  line-height: 1;
}

.callout-label {
  font-size: 13.5px;
}

.callout-body,
.callout-content {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.callout-body > *:first-child,
.callout-content > *:first-child {
  margin-top: 0;
}

.callout-body > *:last-child,
.callout-content > *:last-child {
  margin-bottom: 0;
}

.callout-note {
  border-left-color: var(--callout-note);
  background: var(--callout-note-bg);
}
.callout-note .callout-header,
.callout-note .callout-title {
  color: var(--callout-note);
}

.callout-tip {
  border-left-color: var(--callout-tip);
  background: var(--callout-tip-bg);
}
.callout-tip .callout-header,
.callout-tip .callout-title {
  color: var(--callout-tip);
}

.callout-warning,
.callout-warn {
  border-left-color: var(--callout-warn);
  background: var(--callout-warn-bg);
}
.callout-warning .callout-header,
.callout-warning .callout-title,
.callout-warn .callout-header,
.callout-warn .callout-title {
  color: var(--callout-warn);
}

.callout-danger {
  border-left-color: var(--callout-danger);
  background: var(--callout-danger-bg);
}
.callout-danger .callout-header,
.callout-danger .callout-title {
  color: var(--callout-danger);
}


/* ==========================================================================
   Share & Collaboration (#49 & #50)
   ========================================================================== */

/* Note Shared Badge */
.note-shared-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm, 4px);
  background: var(--color-primary-subtle, rgba(59, 130, 246, 0.12));
  color: var(--color-primary, #2563eb);
  margin-left: 0.375rem;
  vertical-align: middle;
}

/* Collab Banner inside editor */
.collab-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--color-warning-subtle, #fef3c7);
  color: var(--color-warning-text, #92400e);
  border: 1px solid var(--color-warning-border, #fcd34d);
  border-radius: var(--radius-md, 6px);
  font-size: 0.875rem;
  line-height: 1.4;
  animation: slideDown 0.15s ease-out;
}
[data-theme="dark"] .collab-banner {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.collab-banner-text {
  flex: 1;
  font-weight: 500;
}

.collab-banner-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Share & Collab Modal */
.share-modal-card {
  max-width: 580px;
  width: 90vw;
  padding: 1.5rem;
}

.share-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.share-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.share-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-text, #111827);
}

.share-section-desc {
  font-size: 0.8125rem;
  color: var(--color-text-muted, #6b7280);
  margin: 0;
}

.share-controls-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.share-expiry-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text, #374151);
}

.share-expiry-select {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius-sm, 4px);
  background: var(--color-surface, #ffffff);
  color: var(--color-text, #111827);
}

.share-active-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: var(--radius-md, 6px);
  background: var(--color-bg-secondary, #f9fafb);
  border: 1px solid var(--color-border, #e5e7eb);
}
[data-theme="dark"] .share-active-box {
  background: var(--color-bg-secondary, #1f2937);
  border-color: var(--color-border, #374151);
}

.share-url-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.share-url-input {
  flex: 1;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-family: var(--font-mono, monospace);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius-sm, 4px);
  background: var(--color-surface, #ffffff);
  color: var(--color-text, #111827);
}

.share-expiry-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted, #6b7280);
  margin: 0;
}

.share-divider {
  border: 0;
  height: 1px;
  background: var(--color-border, #e5e7eb);
  margin: 0.5rem 0;
}

/* Collaborators Section */
.collab-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.collab-invite-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.collab-email-input {
  flex: 1;
  min-width: 200px;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius-sm, 4px);
  background: var(--color-surface, #ffffff);
  color: var(--color-text, #111827);
}

.collab-role-select {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius-sm, 4px);
  background: var(--color-surface, #ffffff);
  color: var(--color-text, #111827);
}

.collab-error {
  font-size: 0.8125rem;
  color: var(--color-danger, #ef4444);
  margin: 0;
}

.collab-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 220px;
  overflow-y: auto;
}

.collab-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm, 4px);
  background: var(--color-bg-secondary, #f9fafb);
  border: 1px solid var(--color-border, #e5e7eb);
  font-size: 0.875rem;
}
[data-theme="dark"] .collab-item {
  background: var(--color-bg-secondary, #1f2937);
  border-color: var(--color-border, #374151);
}

.collab-item-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
}

.collab-item-email {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collab-role-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm, 4px);
  background: var(--color-bg-tertiary, #e5e7eb);
  color: var(--color-text, #374151);
}
[data-theme="dark"] .collab-role-badge {
  background: var(--color-bg-tertiary, #374151);
  color: var(--color-text, #d1d5db);
}

.collab-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.collab-empty-hint {
  font-size: 0.8125rem;
  color: var(--color-text-muted, #6b7280);
  font-style: italic;
  padding: 0.5rem 0;
}

/* Public Share View (?share=<token>) */
.public-share-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem 4rem 1rem;
  background: var(--color-bg, #ffffff);
  color: var(--color-text, #111827);
  box-sizing: border-box;
}

.public-share-container {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.public-share-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.public-share-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.public-share-badge {
  background: var(--color-primary-subtle, rgba(59, 130, 246, 0.12));
  color: var(--color-primary, #2563eb);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm, 4px);
}

.shared-note-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
  color: var(--color-text, #111827);
}

.shared-note-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--color-text-muted, #6b7280);
}

.shared-note-tags {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.public-share-article {
  min-height: 200px;
}

.public-share-body {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text, #111827);
}

.shared-note-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 3rem 1.5rem;
  text-align: center;
  background: var(--color-bg-secondary, #f9fafb);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-lg, 8px);
}
[data-theme="dark"] .shared-note-error {
  background: var(--color-bg-secondary, #1f2937);
  border-color: var(--color-border, #374151);
}

.shared-error-msg {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--color-text, #111827);
  margin: 0;
}

/* ---------- Settings Modal (#107, UX_SPEC_SETTINGS, TECH_CONTRACT_SETTINGS) ---------- */

#settings-modal .settings-modal-panel {
  width: min(540px, calc(100vw - 32px));
  max-width: 540px;
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.settings-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-modal-header .modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.settings-close-btn {
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-close-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.settings-close-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-modal-body {
  padding: 24px;
  max-height: calc(85vh - 140px);
  overflow-y: auto;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin: 0;
}

.settings-section-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 4px 0 16px;
}

.theme-options-grid,
.settings-theme-group,
.theme-radio-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.theme-card-option,
.settings-theme-option,
.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
  user-select: none;
}

.theme-card-option input[type="radio"],
.settings-theme-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  margin: 0;
}

.theme-card-preview {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  color: var(--text);
}

.theme-card-icon {
  width: 24px;
  height: 24px;
}

.theme-card-badge {
  display: none;
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.settings-theme-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-card-title,
.settings-theme-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.theme-card-caption,
.settings-theme-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.3;
}

.theme-card-option:hover,
.settings-theme-option:hover,
.theme-card:hover {
  border-color: var(--border-strong);
  background: var(--panel-hover, var(--border));
}

.theme-card-option[aria-checked="true"],
.settings-theme-option[aria-checked="true"],
.theme-card[aria-checked="true"],
.theme-card-option.selected,
.settings-theme-option.selected,
.theme-card.selected,
.theme-card-option.active,
.settings-theme-option.active,
.theme-card.active {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  padding: 15px 11px;
}

.theme-card-option[aria-checked="true"] .theme-card-badge,
.settings-theme-option[aria-checked="true"] .theme-card-badge,
.theme-card[aria-checked="true"] .theme-card-badge,
.theme-card-option.selected .theme-card-badge,
.settings-theme-option.selected .theme-card-badge,
.theme-card.selected .theme-card-badge,
.theme-card-option.active .theme-card-badge,
.settings-theme-option.active .theme-card-badge,
.theme-card.active .theme-card-badge {
  display: flex;
}

.theme-card-option[aria-checked="true"] .theme-card-title,
.settings-theme-option[aria-checked="true"] .settings-theme-name,
.theme-card[aria-checked="true"] .theme-card-title,
.theme-card-option.selected .theme-card-title,
.settings-theme-option.selected .settings-theme-name,
.theme-card.selected .theme-card-title,
.theme-card-option.active .theme-card-title,
.settings-theme-option.active .settings-theme-name,
.theme-card.active .theme-card-title {
  font-weight: 600;
  color: var(--accent);
}

.theme-card-option:focus-visible,
.settings-theme-option:focus-visible,
.theme-card:focus-visible,
.theme-card-option:has(input[type="radio"]:focus-visible),
.settings-theme-option:has(input[type="radio"]:focus-visible),
.theme-card:has(input[type="radio"]:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-system-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 4px 0 0;
  font-style: italic;
}

.settings-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-app-version {
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .theme-options-grid,
  .settings-theme-group,
  .theme-radio-group {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .theme-card-option,
  .settings-theme-option,
  .theme-card {
    flex-direction: row;
    text-align: left;
    padding: 12px;
    gap: 12px;
  }

  .theme-card-option[aria-checked="true"],
  .settings-theme-option[aria-checked="true"],
  .theme-card[aria-checked="true"],
  .theme-card-option.selected,
  .settings-theme-option.selected,
  .theme-card.selected,
  .theme-card-option.active,
  .settings-theme-option.active,
  .theme-card.active {
    padding: 11px;
  }

  .theme-card-preview {
    margin-bottom: 0;
    flex-shrink: 0;
  }
}

/* Universal hidden guard to ensure [hidden] is never overridden by media query rules */
[hidden], [hidden][hidden], .modal-backdrop[hidden], .modal[hidden] {
  display: none !important;
}


/* ==========================================================================
   Marketing Landing Website (#176, UX_SPEC_MARKETING.md, TECH_CONTRACT_MARKETING.md)
   ========================================================================== */

/* Theme and Container Invariants */
#auth-container.marketing-landing {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  min-height: 100vh !important;
  height: auto !important;
  padding: 0 !important;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scroll-behavior: smooth;
  position: relative;
  z-index: 100;
}

#auth-container[hidden],
#auth-container.marketing-landing[hidden] {
  display: none !important;
}

/* Sticky Top Navigation Bar */
.marketing-header {
  position: sticky;
  top: 0;
  z-index: 110;
  width: 100%;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] .marketing-header {
  background: rgba(20, 22, 27, 0.88);
  border-bottom: 1px solid var(--border);
}

.marketing-nav {
  max-width: 1240px;
  margin: 0 auto;
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.marketing-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.marketing-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.brand-logo-img {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 6px;
  display: block;
}

.footer-logo-img {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 5px;
  display: block;
}

.sidebar-brand-lockup {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-brand-mark {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 5px;
  flex-shrink: 0;
  display: block;
}

.marketing-badge-version {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(59, 110, 245, 0.2);
}

.marketing-nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.marketing-nav-link {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.marketing-nav-link:hover,
.marketing-nav-link:focus-visible {
  color: var(--text);
}

.marketing-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.marketing-nav-btn {
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

/* Responsive Defensive Resets */
.marketing-main,
.marketing-hero,
.marketing-hero-content,
.marketing-hero-preview,
.marketing-window-mockup,
.window-body,
.mock-editor,
.mock-editor-content,
.marketing-feature-card,
.workflow-step-card,
.security-pillar-card,
.marketing-team,
.team-grid,
.team-card,
.marketing-cta-banner,
.cta-banner-inner,
.marketing-footer-inner > * {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Main Container */
.marketing-main {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 80px;
  flex: 1 0 auto;
}

/* Hero Section */
.marketing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 48px;
  align-items: center;
  padding: 56px 0 72px;
}

.marketing-hero-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.marketing-eyebrow {
  margin-bottom: 20px;
}

.marketing-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(59, 110, 245, 0.25);
  border-radius: var(--radius-pill);
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.marketing-hero-title {
  font-size: clamp(2.2rem, 3.8vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 18px;
}

.marketing-hero-subtitle {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 28px;
  max-width: 540px;
}

.marketing-hero .auth-session-banner {
  width: 100%;
  max-width: 540px;
  margin-bottom: 20px;
}

.marketing-hero .auth-alert-banner {
  width: 100%;
  max-width: 540px;
  margin-bottom: 20px;
}

.marketing-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  width: 100%;
}

.marketing-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.marketing-cta-btn:hover {
  transform: translateY(-1px);
}

.marketing-cta-btn:active {
  transform: translateY(0);
}

.marketing-trust-micro {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Interactive Product Preview Window Mockup */
.marketing-hero-preview {
  position: relative;
  width: 100%;
}

.marketing-window-mockup {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 24px 48px -12px rgba(16, 24, 40, 0.18), 0 0 1px rgba(16, 24, 40, 0.2);
  overflow: hidden;
  position: relative;
}

[data-theme="dark"] .marketing-window-mockup {
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.1);
}

.window-chrome {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: 38px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.window-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.control-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-close { background: #ff5f56; }
.dot-minimize { background: #ffbd2e; }
.dot-maximize { background: #27c93f; }

.window-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.window-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--success);
  flex-shrink: 0;
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.window-body {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  height: 380px;
  position: relative;
  overflow: hidden;
}

.mock-sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  overflow: hidden;
}

.mock-sidebar-header {
  font-weight: 600;
  color: var(--text);
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mock-note-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mock-note-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.mock-note-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mock-tags-widget {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.mock-tag-header {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-faint);
  margin-bottom: 4px;
  display: block;
}

.mock-tags-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mock-tag {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.mock-editor {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.mock-editor-toolbar {
  height: 34px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  font-size: 12px;
}

.mock-tab {
  color: var(--text-muted);
  padding: 2px 4px;
  font-weight: 500;
}

.mock-tab.active-split {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  font-weight: 600;
}

.mock-meta {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
}

.mock-editor-content {
  padding: 16px 20px;
  overflow: hidden;
}

.mock-doc-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.mock-tag-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.mock-paragraph {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 10px;
}

.mock-slash-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  margin-bottom: 10px;
  border: 1px solid rgba(59, 110, 245, 0.2);
}

.mock-wikilink {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.mock-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
}

.mock-checklist li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.check-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  font-size: 10px;
  border: 1px solid var(--border-strong);
}

.check-box.checked {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Floating Mock Knowledge Graph Card */
.mock-graph-card {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 250px;
  height: 155px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 5;
}

[data-theme="dark"] .mock-graph-card {
  background: rgba(28, 31, 38, 0.92);
}

.mock-graph-header {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  background: var(--bg);
}

.graph-title {
  font-weight: 600;
  color: var(--text);
}

.graph-pill {
  font-size: 9.5px;
  color: var(--text-faint);
}

.mock-graph-canvas {
  flex: 1;
  position: relative;
}

.mini-graph-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Section Header Shared */
.marketing-section-header {
  text-align: center;
  margin-bottom: 48px;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

.marketing-section-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.marketing-section-title {
  font-size: clamp(1.8rem, 2.5vw, 2.4rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 12px;
}

.marketing-section-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

/* Features Grid (Bento) */
.marketing-features {
  padding: 64px 0 80px;
}

.marketing-features-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.marketing-feature-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.marketing-feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.feature-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--chip-bg);
  color: var(--chip-text);
}

.feature-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.feature-headline {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 10px;
  line-height: 1.4;
}

.feature-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 20px;
  flex: 1;
}

.feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.feature-chip {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--chip-bg);
  color: var(--chip-text);
  border: 1px solid var(--border);
}

/* Workflow Section */
.marketing-workflow {
  padding: 64px 0 80px;
}

.marketing-workflow-steps {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
}

.workflow-step-card {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.workflow-step-number {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 12px;
  line-height: 1;
  opacity: 0.9;
}

.workflow-step-icon {
  color: var(--text);
  margin-bottom: 16px;
}

.workflow-step-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
}

.workflow-step-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 16px;
  flex: 1;
}

.workflow-step-hint {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  display: block;
}

.workflow-step-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border-strong);
  padding: 0 4px;
}

/* Security Section */
.marketing-security {
  padding: 64px 0 80px;
}

.security-pillars-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.security-pillar-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
}

.pillar-icon {
  color: var(--accent);
  margin-bottom: 16px;
}

.pillar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
}

.pillar-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

/* Team Showcase Section (#198) */
.marketing-team {
  padding: 64px 0 80px;
}

.studio-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--brand-squircle-bg, #fef3c7);
  border: 1px solid var(--brand-squircle-border, #b45309);
  color: var(--brand-claw-accent, #d97706);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
  line-height: 1.4;
}

[data-theme="dark"] .studio-badge {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--brand-claw-accent, #f59e0b);
}

.studio-badge .bear-hex-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  flex-shrink: 0;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 40px;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 1024px) {
  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
  }
}

@media (max-width: 639.98px) {
  .team-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }
}

.team-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
  min-width: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.team-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-claw-accent, #d97706);
  box-shadow: 0 8px 24px -4px rgba(217, 119, 6, 0.15);
}

[data-theme="dark"] .team-card {
  background: var(--panel);
  border-color: var(--border);
}

[data-theme="dark"] .team-card:hover {
  border-color: var(--brand-claw-accent, #f59e0b);
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.5);
}

.team-card-avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 10px;
  background: var(--brand-squircle-bg, #fef3c7);
  border: 1px solid var(--brand-squircle-border, #b45309);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

[data-theme="dark"] .team-card-avatar {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
}

.team-card-content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.team-card-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
}

.team-card-role {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-hover, #f1f5f9);
  color: var(--brand-claw-accent, #d97706);
  border: 1px solid var(--border);
  display: inline-block;
  align-self: flex-start;
  margin-bottom: 4px;
  line-height: 1.4;
}

[data-theme="dark"] .team-card-role {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--brand-claw-accent, #f59e0b);
}

.team-card-bio {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
}

/* Settings Modal About & Team Attribution (#198) */
.settings-about-section {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.settings-about-card {
  background: var(--bg-hover, #f8fafc);
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  min-width: 0;
}

[data-theme="dark"] .settings-about-card {
  background: var(--panel);
}

.settings-about-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-about-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
}

.settings-about-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-about-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
}

.settings-about-studio {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.settings-about-desc {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0;
}

.settings-team-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.team-pill {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 9999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.3;
}

[data-theme="dark"] .team-pill {
  background: var(--bg-hover);
  border-color: var(--border);
}

/* Bottom CTA Banner */
.marketing-cta-banner {
  margin: 40px 0 60px;
  background: linear-gradient(135deg, rgba(59, 110, 245, 0.08), rgba(14, 165, 233, 0.05));
  border: 1px solid rgba(59, 110, 245, 0.25);
  border-radius: 16px;
  padding: 56px 32px;
  text-align: center;
  box-shadow: 0 12px 36px -8px rgba(59, 110, 245, 0.12);
}

[data-theme="dark"] .marketing-cta-banner {
  background: linear-gradient(135deg, rgba(59, 110, 245, 0.15), rgba(14, 165, 233, 0.08));
  border-color: rgba(59, 110, 245, 0.35);
  box-shadow: 0 12px 36px -8px rgba(0, 0, 0, 0.5);
}

.cta-banner-inner {
  max-width: 640px;
  margin: 0 auto;
}

.cta-banner-title {
  font-size: clamp(1.8rem, 2.5vw, 2.3rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 12px;
}

.cta-banner-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 28px;
}

.cta-banner-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.cta-banner-trust {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}

/* Global Semantic Footer */
.marketing-footer {
  width: 100%;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 56px 0 40px;
}

.marketing-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.3fr);
  gap: 40px;
}

.footer-brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.footer-brand-title svg {
  color: var(--accent);
}

.footer-tagline {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.footer-copy {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0;
}

.footer-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 14px;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-badge-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trust-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: inline-block;
}

/* ==========================================================================
   Responsive Breakpoints for Marketing Landing Page
   ========================================================================== */

/* Tablet (768px – 1023px) */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .marketing-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
    padding: 40px 0 56px;
  }

  .marketing-hero-content {
    align-items: center;
    text-align: center;
    max-width: 640px;
    margin: 0 auto;
  }

  .marketing-hero-actions {
    justify-content: center;
  }

  .marketing-trust-micro {
    justify-content: center;
  }

  .marketing-features-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .security-pillars-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .marketing-workflow-steps {
    flex-direction: column;
  }

  .workflow-step-divider {
    transform: rotate(90deg);
    padding: 8px 0;
  }

  .marketing-footer-inner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767.98px) {
  .marketing-nav-links {
    display: none;
  }

  .marketing-nav {
    padding: 0 12px;
    height: 56px;
    gap: 8px;
  }

  .marketing-brand {
    min-width: 0;
    gap: 6px;
    font-size: 0.95rem;
  }

  .marketing-brand-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .marketing-badge-version {
    display: none;
  }

  .marketing-nav-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  .marketing-nav-btn {
    padding: 6px 10px;
    font-size: 12.5px;
  }

  .marketing-main {
    padding: 0 16px 60px;
  }

  .marketing-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding: 28px 0 48px;
  }

  .marketing-hero-content {
    align-items: center;
    text-align: center;
  }

  .marketing-eyebrow {
    max-width: 100%;
  }

  .marketing-pill-badge {
    max-width: 100%;
    white-space: normal;
    text-align: left;
    line-height: 1.35;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 14px;
  }

  .pill-dot {
    flex-shrink: 0;
  }

  .marketing-hero-title {
    font-size: clamp(1.65rem, 6.5vw, 2.25rem);
    line-height: 1.2;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
  }

  .marketing-hero-subtitle {
    font-size: 0.975rem;
    line-height: 1.55;
    max-width: 100%;
    overflow-wrap: break-word;
  }

  .marketing-hero-actions {
    flex-direction: column;
    width: 100%;
  }

  .marketing-cta-btn {
    width: 100%;
    max-width: 100%;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
    padding: 12px 16px;
    font-size: 14px;
  }

  .marketing-cta-btn .btn-icon {
    flex-shrink: 0;
  }

  .marketing-trust-micro {
    max-width: 100%;
    overflow-wrap: break-word;
    text-align: center;
    font-size: 12px;
    flex-direction: column;
    gap: 4px;
  }

  .window-chrome {
    padding: 0 10px;
    gap: 8px;
  }

  .window-title {
    flex: 1 1 0%;
    min-width: 0;
    max-width: none;
    font-size: 11px;
  }

  .window-status {
    font-size: 10px;
  }

  .window-body {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .mock-sidebar {
    display: none;
  }

  .mock-editor-toolbar {
    height: auto;
    min-height: 34px;
    padding: 6px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .mock-meta {
    font-size: 10.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .mock-editor-content {
    padding: 14px 12px;
  }

  .mock-doc-title {
    font-size: 0.95rem;
    line-height: 1.35;
    overflow-wrap: break-word;
  }

  .mock-tag-chips {
    flex-wrap: wrap;
  }

  .mock-slash-pill {
    display: flex;
    max-width: 100%;
    white-space: normal;
    line-height: 1.35;
    font-size: 11px;
    padding: 6px 10px;
  }

  .mock-checklist li {
    align-items: flex-start;
    line-height: 1.4;
  }

  .check-box {
    flex-shrink: 0;
    margin-top: 2px;
  }

  .mock-graph-card {
    position: static;
    width: 100%;
    height: 145px;
    margin-top: 12px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  .marketing-section-title,
  .cta-banner-title {
    font-size: clamp(1.45rem, 5.5vw, 1.9rem);
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .marketing-features-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .security-pillars-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .marketing-workflow-steps {
    flex-direction: column;
  }

  .workflow-step-divider {
    transform: rotate(90deg);
    padding: 8px 0;
  }

  .cta-banner-actions {
    flex-direction: column;
    width: 100%;
  }

  .marketing-cta-banner {
    padding: 36px 20px;
  }

  .marketing-footer-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .trust-badge {
    white-space: normal;
    overflow-wrap: break-word;
    max-width: 100%;
  }
}

/* Compact Mobile (< 480px) */
@media (max-width: 480px) {
  .window-status span:not(.status-indicator) {
    display: none;
  }
}

/* ---------- v0.7.2 Markdown Editor & Knowledge Graph Usability (#182, #183, #184) ---------- */

.markdown-help-btn {
  margin-left: auto;
  font-weight: 700;
  font-size: 13px;
}

.markdown-help-popover {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.14));
  padding: 14px 16px;
  margin-bottom: 10px;
  z-index: 95;
  max-height: 360px;
  overflow-y: auto;
}

.markdown-help-popover[hidden] {
  display: none !important;
}

.md-help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.md-help-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.md-help-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.md-help-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.md-help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

.md-help-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.md-help-row-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.md-help-category {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.md-help-syntax {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--accent);
}

.md-help-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.md-help-insert-btn {
  flex-shrink: 0;
}

.graph-help-btn {
  width: auto;
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 500;
}

.graph-help-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 70px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.14));
  padding: 14px 16px;
  z-index: 20;
  color: var(--text);
}

.graph-help-panel[hidden] {
  display: none !important;
}

.graph-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.graph-help-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.graph-help-section {
  margin-bottom: 10px;
}

.graph-help-section:last-child {
  margin-bottom: 0;
}

.graph-help-section-title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.graph-help-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}

.graph-help-legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.graph-help-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.graph-help-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.graph-help-swatch.swatch-active {
  background: var(--graph-node-active, #3b6ef5);
}

.graph-help-swatch.swatch-connected {
  background: var(--graph-node, #5c6b84);
}

.graph-help-swatch.swatch-orphan {
  background: var(--graph-node-orphan, #9aa1ad);
}

.graph-help-swatch.swatch-edge {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--graph-edge, #cfd4dc);
}

.graph-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  pointer-events: none;
}

.graph-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.graph-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.graph-legend-dot.dot-active {
  background: var(--graph-node-active, #3b6ef5);
}

.graph-legend-dot.dot-connected {
  background: var(--graph-node, #5c6b84);
}

.graph-legend-dot.dot-orphan {
  background: var(--graph-node-orphan, #9aa1ad);
}

.graph-legend-line {
  width: 12px;
  height: 2px;
  background: var(--graph-edge, #cfd4dc);
  display: inline-block;
}

.graph-empty-state {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  z-index: 16;
}

.graph-empty-state.is-zero-edges {
  top: auto;
  bottom: 52px;
  transform: translateX(-50%);
}

.graph-empty-title {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.graph-empty-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
}

.backlinks-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.backlinks-header-row .backlinks-header {
  margin: 0;
}

