/* ai.pole — design tokens and base styles (v3, 2026-05-22).
   Universal Notion-like neutral minimalism. No more Pole-yellow / electric
   blue / Montserrat / lowercase — those are dead. Old --ap-* tokens are kept
   as aliases that resolve to the new neutral palette so legacy components
   continue to render until they're migrated. */

@import url('./design-system.css');

:root {
  /* ============================================================
     v3 canonical tokens (use these in all new code)
     ============================================================ */
  --bg:           #FFFFFF;
  --bg-soft:      #FAFAFA;
  --bg-hover:     #F5F5F5;
  --bg-active:    #EFEFEF;

  --fg:           #1A1A1A;
  --fg-mute:      #737373;
  --fg-faint:     #B5B5B5;

  --line:         #EEEEEE;
  --line-strong:  #E5E5E5;

  --accent:       #2383E2;
  --accent-soft:  rgba(35, 131, 226, 0.12);

  --success:      #0F7B0F;
  --warning:      #9A6700;
  --warning-bg:   #FEF8E5;
  --danger:       #C73838;

  --highlight-atom: #FFF9E5;
  --counter-red:    #C73838;
  --kbd-bg:         #F5F5F5;

  /* Warning/pending surfaces (chat-pending bar etc) */
  --warning-fg:      #5A3D00;
  --warning-border:  #E8C97A;
  --pending-row-bg:  rgba(255,255,255,0.55);

  /* Tag / mention inline pills (text color must adapt) */
  --tag-bg:          rgba(232,179,11,0.16);
  --tag-fg:          #7A4F00;
  --mention-bg:      rgba(45,99,191,0.10);
  --mention-fg:      #1A4FA0;

  /* Hover for "inverted" primary buttons (var(--fg) bg) */
  --fg-hover:        #333333;

  /* Pill / status colors */
  --pill-mint-bg:     rgba(15,123,15,0.10);   --pill-mint-fg:     #0F7B0F;
  --pill-sand-bg:     rgba(154,103,0,0.10);   --pill-sand-fg:     #9A6700;
  --pill-sky-bg:      rgba(35,131,226,0.10);  --pill-sky-fg:      #2383E2;
  --pill-lavender-bg: rgba(106,79,176,0.10);  --pill-lavender-fg: #6A4FB0;
  --pill-rose-bg:     rgba(199,56,56,0.10);   --pill-rose-fg:     #C73838;

  /* Comment highlight backgrounds (selection bg, ~0.30 alpha) */
  --comment-lavender: rgba(190, 175, 255, 0.30);
  --comment-sky:      rgba(170, 210, 255, 0.30);
  --comment-sand:     rgba(240, 215, 165, 0.30);
  --comment-mint:     rgba(170, 225, 200, 0.30);

  /* Shape */
  --radius-sm:    4px;
  --radius-md:    6px;
  --radius-lg:    8px;
  --radius-modal: 10px;
  --radius-pill:  6px;   /* v3: no more 9999px pill button */

  --ap-sidebar-w: 256px;
  --ap-chat-w:    380px;
  --ap-topbar-h:  48px;

  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* ============================================================
     Legacy --ap-* aliases. Same names, new neutral values. New
     code should reference the canonical tokens above; these stay
     until existing components are migrated.
     ============================================================ */
  --ap-bg:          var(--bg);
  --ap-bg-2:        var(--bg-soft);
  --ap-paper:       var(--bg);
  --ap-paper-2:     var(--bg-soft);
  --ap-paper-3:     var(--bg-active);
  --ap-ink:         var(--fg);
  --ap-ink-2:       #333333;
  --ap-muted:       var(--fg-mute);
  --ap-muted-2:     var(--fg-faint);
  --ap-line:        var(--line-strong);
  --ap-line-soft:   var(--line-strong);
  --ap-line-softer: var(--line);
  --ap-accent:      var(--accent);
  --ap-accent-2:    #5DAEEC;
  --ap-yellow:      #E0E0E0;          /* DEPRECATED — neutralised. Do not use. */
  --ap-hl:          var(--highlight-atom);
  --ap-hl-strong:   #FFE9A8;
  --ap-orange:      var(--warning);
  --ap-green:       var(--success);
  --ap-red:         var(--danger);

  /* Kind colors → neutral graphite per BRIEF.md §3.8 (icons inherit
     currentColor, so this only matters for the geometric kind-badge
     fallback — Lucide-style icons handled inside KindBadge JSX). */
  --ap-kind-source:  #5B5B5B;
  --ap-kind-atom:    #5B5B5B;
  --ap-kind-insight: #5B5B5B;
  --ap-kind-note:    #5B5B5B;

  --ap-radius-sm:   var(--radius-sm);
  --ap-radius-md:   var(--radius-lg);
  --ap-radius-pill: var(--radius-pill);

  --ap-mono:        var(--font-mono);
}

/* Anything tagged var(--ap-mono) — code, timecodes, paths, metrics — gets
   tabular figures + slightly tighter tracking so columns of numbers line up
   without switching font family. */
[style*="--ap-mono"], .ap-mono,
[style*="font-family: var(--ap-mono)"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

[data-theme="dark"] {
  --bg:           #191919;
  --bg-soft:      #141414;
  --bg-hover:     #222222;
  --bg-active:    #262626;
  --fg:           #E8E8E8;
  --fg-mute:      #9B9B9B;
  --fg-faint:     #5B5B5B;
  --line:         rgba(255,255,255,0.08);
  --line-strong:  rgba(255,255,255,0.12);
  --accent:       #2383E2;
  --highlight-atom: #3A3320;
  --kbd-bg:       #222222;

  /* Warning palette retuned for dark — translucent amber + readable text */
  --warning-bg:      rgba(154,103,0,0.18);
  --warning-fg:      #E5C580;
  --warning-border:  rgba(232,201,122,0.30);
  --pending-row-bg:  rgba(0,0,0,0.30);

  --tag-bg:          rgba(232,179,11,0.18);
  --tag-fg:          #E5C580;
  --mention-bg:      rgba(93,174,236,0.18);
  --mention-fg:      #9BC9F0;

  /* Inverted-button hover: lighter, not darker, in dark mode */
  --fg-hover:        #C8C8C8;

  /* Pill bgs survive on dark (low-alpha colored tints), but lift fg
     toward readable variants */
  --pill-mint-fg:     #5BB868;
  --pill-sand-fg:     #E5C580;
  --pill-sky-fg:      #6FAEEC;
  --pill-lavender-fg: #B5A0E0;
  --pill-rose-fg:     #E68080;

  /* Legacy aliases retarget in dark too */
  --ap-bg:          var(--bg);
  --ap-bg-2:        var(--bg-soft);
  --ap-paper:       var(--bg);
  --ap-paper-2:     var(--bg-soft);
  --ap-paper-3:     var(--bg-active);
  --ap-ink:         var(--fg);
  --ap-ink-2:       rgba(255,255,255,0.85);
  --ap-muted:       var(--fg-mute);
  --ap-muted-2:     var(--fg-faint);
  --ap-line:        var(--line-strong);
  --ap-line-soft:   var(--line-strong);
  --ap-line-softer: var(--line);
  --ap-hl:          var(--highlight-atom);
  --ap-hl-strong:   #4B3F10;
  --ap-kind-source:  #9B9B9B;
  --ap-kind-atom:    #9B9B9B;
  --ap-kind-insight: #9B9B9B;
  --ap-kind-note:    #9B9B9B;
}

/* === Density (TweaksPanel) === */
[data-density="compact"]   { --ap-topbar-h: 40px; }
[data-density="spacious"]  { --ap-topbar-h: 56px; }

/* === Accent override (TweaksPanel) ===
   v3 universal: neutral default, optional blue, mono. Yellow option still
   exists as a Tweaks setting but resolves to the muted neutral accent to
   avoid bringing Pole branding back through the back door. */
[data-accent="yellow"] { --ap-accent: var(--accent); --accent: #2383E2; }
[data-accent="blue"]   { --ap-accent: #2383E2; --accent: #2383E2; }
[data-accent="mono"]   { --ap-accent: var(--fg);   --accent: var(--fg); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* v3: kill forced lowercase from legacy display classes — neutral product
   uses sentence case throughout. */
.ap-display, .ap-h2, .ap-h3 { text-transform: none !important; }

body {
  overflow-x: hidden;
}

/* === Type helpers === */
.ap-mono {
  font-family: var(--ap-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.ap-eyebrow {
  font-family: var(--ap-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ap-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.ap-display {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.ap-h2 {
  font-family: inherit;
  font-weight: 600;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.ap-h3 {
  font-family: inherit;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: -0.005em;
}
.ap-lead {
  font-size: 22px;
  line-height: 30px;
  letter-spacing: -0.015em;
  font-weight: 400;
}

/* === Kind badge — geometric variant (default) === */
.kind-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  position: relative;
}
.kind-badge[data-kind="source"]::before {
  content: '';
  width: 10px; height: 10px;
  border: 1.5px solid var(--ap-kind-source);
  background: transparent;
}
.kind-badge[data-kind="atom"]::before {
  content: '';
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--ap-kind-atom);
}
.kind-badge[data-kind="insight"]::before {
  content: '';
  width: 0; height: 0;
  border-left: 6.5px solid transparent;
  border-right: 6.5px solid transparent;
  border-bottom: 11px solid var(--ap-kind-insight);
}
.kind-badge[data-kind="note"]::before {
  content: '';
  width: 11px; height: 1.5px;
  background: var(--ap-kind-note);
}
/* size variants */
.kind-badge.lg { width: 22px; height: 22px; }
.kind-badge.lg[data-kind="source"]::before { width: 14px; height: 14px; }
.kind-badge.lg[data-kind="atom"]::before { width: 15px; height: 15px; }
.kind-badge.lg[data-kind="insight"]::before { border-left: 8.5px solid transparent; border-right: 8.5px solid transparent; border-bottom: 14px solid var(--ap-kind-insight); }
.kind-badge.lg[data-kind="note"]::before { width: 14px; height: 2px; }

/* dot variant — small (default size): bare coloured dot */
.kind-badge[data-style="dot"]::before { border-radius: 50%; border: none; }
.kind-badge[data-style="dot"][data-kind="source"]::before { background: var(--ap-kind-source); width: 8px; height: 8px; }
.kind-badge[data-style="dot"][data-kind="atom"]::before { background: var(--ap-kind-atom); width: 8px; height: 8px; }
.kind-badge[data-style="dot"][data-kind="insight"]::before { background: var(--ap-kind-insight); width: 8px; height: 8px; border: none; }
.kind-badge[data-style="dot"][data-kind="note"]::before { background: var(--ap-kind-note); width: 8px; height: 8px; border: none; }

/* dot variant — large: filled coloured circle with capital letter inside */
.kind-badge.lg[data-style="dot"] { width: 26px; height: 26px; }
.kind-badge.lg[data-style="dot"]::before {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  color: #fff;
}
.kind-badge.lg[data-style="dot"][data-kind="source"]::before  { content: 'S'; background: var(--ap-kind-source); }
.kind-badge.lg[data-style="dot"][data-kind="atom"]::before    { content: 'A'; background: var(--ap-kind-atom); }
.kind-badge.lg[data-style="dot"][data-kind="insight"]::before { content: 'I'; background: var(--ap-kind-insight); color: #1A1A1A; }
.kind-badge.lg[data-style="dot"][data-kind="note"]::before    { content: 'N'; background: var(--ap-kind-note); }

/* letter variant */
.kind-badge[data-style="letter"] { font-family: var(--ap-mono); font-weight: 700; font-size: 11px; }
.kind-badge[data-style="letter"]::before { display: none; }
.kind-badge[data-style="letter"][data-kind="source"] { color: var(--ap-kind-source); }
.kind-badge[data-style="letter"][data-kind="atom"] { color: var(--ap-kind-atom); }
.kind-badge[data-style="letter"][data-kind="insight"] { color: #B8941A; }
.kind-badge[data-style="letter"][data-kind="note"] { color: var(--ap-kind-note); }

/* outlined letter variant */
.kind-badge[data-style="outlined"] {
  font-family: inherit;
  font-weight: 700;
  font-size: 9px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  width: 16px; height: 16px;
}
.kind-badge[data-style="outlined"]::before { display: none; }
.kind-badge[data-style="outlined"][data-kind="source"] { color: var(--ap-kind-source); }
.kind-badge[data-style="outlined"][data-kind="atom"] { color: var(--ap-kind-atom); }
.kind-badge[data-style="outlined"][data-kind="insight"] { color: #B8941A; background: var(--ap-kind-insight); border-color: var(--ap-kind-insight); }
.kind-badge[data-style="outlined"][data-kind="note"] { color: var(--ap-kind-note); }

/* === Pills, chips, buttons === */
.ap-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--ap-radius-pill);
  font-size: 11px;
  letter-spacing: 0.06em;
  font-family: var(--ap-mono);
  text-transform: uppercase;
  color: var(--ap-muted);
  border: 1px solid var(--ap-line-soft);
  background: transparent;
  white-space: nowrap;
}
.ap-pill.active { background: var(--ap-ink); color: var(--ap-bg); border-color: var(--ap-ink); }
.ap-pill.accent { color: var(--ap-accent); border-color: var(--ap-accent); }

.ap-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  letter-spacing: 0;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
  white-space: nowrap;
  font-family: inherit;
}
.ap-chip:hover { background: var(--bg-hover); }
.ap-chip.active { background: var(--bg-active); color: var(--fg); border-color: var(--line-strong); font-weight: 500; }
.ap-chip.accent.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.ap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
  letter-spacing: 0;
}
.ap-btn:hover { background: var(--bg-hover); }
.ap-btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.ap-btn.primary:hover { background: var(--fg-hover); border-color: var(--fg-hover); }
/* `yellow` was the Pole CTA. Neutralised in v3 — same look as primary. */
.ap-btn.yellow { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.ap-btn.yellow:hover { background: var(--fg-hover); border-color: var(--fg-hover); }
.ap-btn.ghost { background: transparent; border: none; padding: 5px 10px; color: var(--fg); }
.ap-btn.ghost:hover { background: var(--bg-hover); }

.ap-kbd, .kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--kbd-bg);
  color: var(--fg-mute);
  letter-spacing: 0;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
}

/* hairline */
.hr { height: 1px; background: var(--ap-line-soft); border: 0; margin: 0; }
.hr-strong { height: 1px; background: var(--ap-line); border: 0; }

/* scroll polish */
.scrollable { overflow: auto; }
.scrollable::-webkit-scrollbar { width: 8px; height: 8px; }
.scrollable::-webkit-scrollbar-track { background: transparent; }
.scrollable::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
[data-theme="dark"] .scrollable::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }

/* Card */
.ap-card {
  background: var(--ap-paper);
  border: 1px solid var(--ap-line-soft);
  border-radius: var(--ap-radius-md);
}
.ap-card.hover-row { transition: border-color .15s, background .15s; }
.ap-card.hover-row:hover {
  border-color: var(--line-strong);
  background: var(--bg-hover);
}

/* Pulsing dot (index status, tool calls) */
.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* === Frame styles for design canvas === */
.frame {
  background: var(--ap-bg);
  color: var(--ap-ink);
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  font-size: 13px;
}
.frame.dark { background: #000; color: #fff; }

/* === App shell === */
.app-shell {
  display: grid;
  grid-template-columns: var(--ap-sidebar-w) 1fr var(--ap-chat-w);
  height: 100%;
  width: 100%;
  background: var(--ap-bg);
}
.app-shell.no-chat { grid-template-columns: var(--ap-sidebar-w) 1fr; }

.sidebar {
  border-right: 1px solid var(--ap-line-soft);
  background: var(--ap-paper);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.main-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--ap-bg);
  overflow: hidden;
}
.chat-col {
  border-left: 1px solid var(--ap-line-soft);
  background: var(--ap-paper);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.topbar {
  height: var(--ap-topbar-h);
  border-bottom: 1px solid var(--ap-line-soft);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ap-muted);
  font-family: var(--ap-mono);
}
.crumbs .sep { color: var(--ap-muted-2); }
.crumbs .last { color: var(--ap-ink); font-weight: 500; }

/* === TabBar (DESIGN-03-04) ===
   Shown above the main content when more than one tab is open. The bar
   itself sits between Topbar and the scrollable note area; tabs scroll
   horizontally when they overflow. */
.tabbar { font-family: var(--font-sans); }
.tabbar::-webkit-scrollbar { height: 4px; }
.tabbar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }
.tab { user-select: none; transition: background .12s ease; }
.tab:not(.active):hover { background: var(--bg-hover); color: var(--fg); }
.tab.active { font-weight: 500; }
/* Крестик закрытия — по ховеру СЛЕВА, на месте иконки файла (2026-07-14).
   Иконка и крестик занимают один 16px-слот; ховер таба меняет их местами. */
.tab .tab-close-left { display: none; }
.tab:hover .tab-icon { display: none !important; }
.tab:hover .tab-close-left { display: inline-flex; }

/* === Sidebar internals === */
.sb-section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sb-section.flex { flex: 1; min-height: 0; overflow: auto; }
.sb-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 8px;
  font-weight: 500;
}

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
}

.sb-tree { font-size: 13px; }
.sb-tree-folder {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; cursor: pointer; border-radius: 6px;
  color: var(--fg);
  font-weight: 500;
  height: 30px;
  user-select: none;
}
.sb-tree-folder:hover { background: var(--bg-hover); }
.sb-tree-file {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px 5px 26px;
  cursor: pointer; border-radius: 6px;
  color: var(--fg);
  height: 30px;
  position: relative;
  user-select: none;
}
.sb-tree-file:hover { background: var(--bg-hover); }
.sb-tree-file.active { background: var(--bg-active); font-weight: 500; }
.sb-tree-file.active::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 2px; border-radius: 1px;
  background: var(--accent);
}
.sb-tree-file .name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* AIKB-336: hover-only folder action buttons (… and +). */
.sb-folder-actions {
  display: none !important;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.sb-tree-folder:hover .sb-folder-actions { display: inline-flex !important; }
.sb-tree-folder:hover .sb-folder-count { display: none; }
.sb-folder-action-btn {
  width: 20px; height: 20px; padding: 0;
  background: transparent; border: none; border-radius: 4px;
  color: var(--fg-mute); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.sb-folder-action-btn:hover { background: var(--bg-active); color: var(--fg); }

/* AIKB-336: drag-and-drop visuals. */
.sb-tree-folder.drop-target,
.sb-tree-file.drop-target {
  background: var(--bg-active);
  box-shadow: inset 0 -2px 0 0 var(--accent);
}
.sb-tree-folder.dragging,
.sb-tree-file.dragging { opacity: 0.45; }
.sb-tree-folder.just-moved,
.sb-tree-file.just-moved {
  animation: aikb336-flash 1s ease-out;
}
@keyframes aikb336-flash {
  0%   { background: var(--accent-soft, rgba(78, 130, 255, 0.16)); }
  100% { background: transparent; }
}

/* AIKB-336: inline new-note row. */
.sb-tree-new {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 6px;
  height: 30px;
  background: var(--bg-hover);
}
.sb-tree-new input {
  flex: 1; min-width: 0;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line-strong); border-radius: 4px;
  padding: 2px 6px; font-size: 13px; font-family: inherit;
  outline: none;
}
.sb-tree-new input:focus { border-color: var(--accent); }
.sb-tree-new .kind-picker {
  display: inline-flex; align-items: center;
  background: transparent; border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 1px 4px; cursor: pointer;
  color: var(--fg);
}
.sb-tree-new .kind-picker:hover { background: var(--bg-active); }

/* === Note view === */
.note-body {
  padding: 24px 56px;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
  align-content: start;
}
.note-body.single { grid-template-columns: 1fr; }
.no-rail .note-body { grid-template-columns: 1fr !important; gap: 0 !important; }
.no-rail .note-body > *:nth-child(2) { display: none !important; }
.note-meta {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--ap-mono); font-size: 11px; color: var(--ap-muted);
  letter-spacing: 0.04em;
  margin: 6px 0 24px;
}
.note-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ap-muted-2); }

/* === Chat (DESIGN-03-10) === */

/* --- Header --- */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  height: var(--ap-topbar-h);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.chat-header-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.chat-header-new {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px;
  color: var(--fg-mute);
  padding: 4px 8px;
  border-radius: 4px;
  transition: color .12s, background .12s;
}
.chat-header-new:hover { color: var(--fg); background: var(--bg-hover); }

/* --- History collapsible --- */
.chat-history {
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.chat-history-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--fg-mute);
  cursor: pointer;
  user-select: none;
}
.chat-history-toggle:hover { background: var(--bg-hover); color: var(--fg); }
.chat-history-toggle .chev {
  display: inline-flex;
  transition: transform .12s;
}
.chat-history-toggle.open .chev { transform: rotate(90deg); }
.chat-history-toggle .label { flex: 1; }
.chat-history-toggle .count { color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.chat-history-list {
  max-height: 160px; overflow: auto;
  padding-bottom: 4px;
}
.chat-history-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px 6px 30px;
  font-size: 12px;
  cursor: pointer;
  color: var(--fg);
}
.chat-history-item:hover { background: var(--bg-hover); }
.chat-history-item.active { background: var(--bg-active); font-weight: 500; }
.chat-history-item .title {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-history-item .date {
  font-family: var(--ap-mono); font-size: 10px;
  color: var(--fg-faint);
  flex-shrink: 0;
}
.chat-history-item .close {
  opacity: 0; transition: opacity .12s;
  background: transparent; border: none; cursor: pointer;
  color: var(--fg-mute);
  padding: 0 2px; line-height: 1;
  font-size: 14px;
}
.chat-history-item:hover .close { opacity: 0.7; }
.chat-history-item .close:hover { opacity: 1; color: var(--fg); }

/* --- Scope chips (segmented) --- */
.chat-scope {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.chat-scope-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 6px;
}
.chat-scope-chips {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.chat-scope-chip {
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 12px;
  color: var(--fg-mute);
  padding: 4px 10px;
  border-radius: 4px;
  transition: background .12s, color .12s;
}
.chat-scope-chip:hover { color: var(--fg); }
.chat-scope-chip.active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.chat-scope-hint {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--fg-mute);
}

/* --- Messages --- */
.chat-empty {
  color: var(--fg-mute); font-size: 13px; font-style: italic;
}

.chat-msg-user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--bg-active);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg-tool {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 4px;
  font-family: var(--ap-mono);
  font-size: 12px;
  color: var(--fg-mute);
}
.chat-msg-tool .tool-icon { display: inline-flex; flex-shrink: 0; }
.chat-msg-tool .tool-icon.done { color: var(--success); }
.chat-msg-tool .tool-icon.error { color: var(--danger); }
.chat-msg-tool .count { margin-left: auto; color: var(--fg-faint); }

.chat-msg-assistant {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
}
.chat-msg-assistant.error {
  border-color: var(--danger);
  color: var(--danger);
}
.chat-msg-assistant > .body {
  white-space: pre-wrap; word-break: break-word;
}
.chat-msg-assistant .refs {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 8px;
}

.chat-ref-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.chat-ref-pill:hover {
  background: var(--bg-hover);
  border-color: var(--line-strong);
}

/* --- Pending bar --- */
.chat-pending-bar {
  background: var(--warning-bg);
  border-top: 1px solid var(--warning-border);
  flex-shrink: 0;
}
.chat-pending-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
}
.chat-pending-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}
.chat-pending-head .label {
  flex: 1; font-size: 13px; color: var(--warning-fg);
}
.chat-pending-actions { display: inline-flex; gap: 6px; }
.chat-pending-btn {
  font-family: inherit; font-size: 12px; cursor: pointer;
  padding: 4px 10px; border-radius: 4px;
  background: transparent; border: 1px solid transparent;
  color: var(--warning-fg);
}
.chat-pending-btn:hover { background: rgba(154,103,0,0.08); }
.chat-pending-btn.primary {
  background: var(--fg); color: var(--bg);
  border-color: var(--fg);
}
.chat-pending-btn.primary:hover { background: var(--fg-hover); border-color: var(--fg-hover); }
.chat-pending-list {
  border-top: 1px solid var(--warning-border);
  padding: 8px 16px 10px;
  max-height: 220px; overflow: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-pending-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px;
  background: var(--pending-row-bg);
  border-radius: 4px;
  font-size: 12px;
}
.chat-pending-row .op-badge {
  font-family: var(--ap-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px; border-radius: 3px;
  color: #fff;
  flex-shrink: 0;
}
.chat-pending-row .op-badge.create { background: var(--success); }
.chat-pending-row .op-badge.update { background: #5B5B5B; }
.chat-pending-row .op-badge.delete { background: var(--danger); }
.chat-pending-row .path {
  flex: 1; min-width: 0;
  font-family: var(--ap-mono); font-size: 11px;
  color: var(--warning-fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-pending-row .reason {
  font-size: 11px; color: var(--warning);
  font-style: italic;
  flex-shrink: 0;
}

/* --- Input area --- */
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-input-box {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color .12s, box-shadow .12s;
}
.chat-input-box:focus-within {
  border-color: var(--fg-mute);
  background: var(--bg);
}
.chat-input-textarea {
  width: 100%;
  border: none; outline: none; resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  min-height: 22px;
  max-height: 200px;
}
.chat-input-textarea::placeholder { color: var(--fg-faint); }
.chat-input-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
}
.chat-input-hint {
  font-family: var(--ap-mono);
  font-size: 11px;
  color: var(--fg-mute);
}
.chat-input-hint kbd {
  font-family: inherit;
  display: inline-block;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font-size: 10px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.4;
}
.chat-send-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--fg); color: var(--bg);
  border: 1px solid var(--fg);
  font-family: inherit; font-size: 12px; font-weight: 500;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s;
}
.chat-send-btn:hover:not(:disabled) { background: var(--fg-hover); border-color: var(--fg-hover); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-send-btn.stop { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.chat-send-btn.stop:hover { background: var(--bg-hover); }

.chat-quick-prompts {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.chat-quick-prompt {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: inherit;
  font-size: 11px;
  color: var(--fg-mute);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.chat-quick-prompt:hover {
  background: var(--bg-hover);
  color: var(--fg);
  border-color: var(--fg-mute);
}

/* --- Toast --- */
.chat-toast {
  position: absolute; bottom: 90px; right: 16px; z-index: 200;
  padding: 8px 12px; border-radius: 6px;
  font-size: 12px;
  background: var(--fg); color: var(--bg);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}

/* Legacy .chat-msg (kept for any callers; new code uses .chat-msg-user/tool/assistant) */
.chat-msg.user { align-self: flex-end; max-width: 85%; background: var(--bg-active); padding: 8px 12px; border-radius: 8px; font-size: 14px; line-height: 1.5; }
.chat-msg.assistant { background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; font-size: 14px; line-height: 1.55; }
.chat-msg.tool { background: transparent; font-family: var(--ap-mono); font-size: 12px; color: var(--fg-mute); display: flex; align-items: center; gap: 8px; padding: 2px 4px; }

.ref-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
}
.ref-pill:hover { background: var(--bg-hover); border-color: var(--line-strong); }

/* === Hero === */
.hero {
  background: #000;
  color: #fff;
  padding: 80px 100px 100px;
  position: relative;
  overflow: hidden;
}

/* === Anchor nav (right side) === */
.anchor-nav {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--ap-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}
.anchor-nav a {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ap-muted-2);
  padding: 4px 0;
  cursor: pointer;
  transition: color .12s ease;
  white-space: nowrap;
}
.anchor-nav a::before {
  content: '';
  width: 10px; height: 1px; background: currentColor; opacity: 0.5;
  transition: width .15s ease, opacity .15s ease;
}
.anchor-nav a:hover { color: var(--ap-ink); }
.anchor-nav a.active { color: var(--ap-ink); }
.anchor-nav a.active::before { width: 24px; opacity: 1; }
.anchor-nav .label-text { opacity: 0; transition: opacity .15s ease; }
.anchor-nav a:hover .label-text, .anchor-nav a.active .label-text { opacity: 1; }

/* === Misc === */
.flex { display: flex; }
.col { display: flex; flex-direction: column; }
.row { display: flex; flex-direction: row; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.muted { color: var(--ap-muted); }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; }

.no-select { user-select: none; }

/* === Block editor === */
.ap-editor { font-family: inherit; color: var(--ap-ink); padding: 8px 0; }
.ap-block { transition: background .12s; border-radius: 3px; }
.ap-block.drag-over { background: rgba(240,138,36,0.05); }
.ap-block-handle:hover { color: var(--ap-ink) !important; }
.ap-editable {
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ap-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--ap-muted-2);
  pointer-events: none;
}
.ap-editable:focus:empty::before { color: var(--ap-muted); }

/* Inline tokens */
.ap-wikilink {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  margin: 0 1px;
  background: var(--ap-paper-2);
  border: 1px solid var(--ap-line-soft);
  border-bottom: 1px solid var(--ap-accent);
  border-radius: 3px;
  font-size: 0.92em;
  color: var(--ap-ink);
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  user-select: all;
}
.ap-wikilink:hover { background: rgba(240,138,36,0.08); }
.ap-extlink {
  color: var(--ap-accent);
  text-decoration: underline;
  text-decoration-color: rgba(240,138,36,0.45);
  text-underline-offset: 2px;
  cursor: pointer;
  user-select: text;
}
.ap-extlink:hover { text-decoration-color: var(--ap-accent); }
.ap-taglink {
  display: inline-block;
  padding: 0 5px;
  margin: 0 1px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  border-radius: 2px;
  font-family: var(--ap-mono);
  font-size: 0.86em;
  user-select: all;
}
.ap-mention {
  display: inline-block;
  padding: 0 5px;
  margin: 0 1px;
  background: var(--mention-bg);
  color: var(--mention-fg);
  border-radius: 2px;
  font-weight: 500;
  font-size: 0.92em;
  user-select: all;
}
.ap-embed {
  border: 1px solid var(--ap-line-soft);
  border-left: 3px solid var(--ap-accent);
  border-radius: 3px;
  padding: 10px 12px;
  background: var(--ap-paper-2);
  cursor: pointer;
  transition: background .12s;
}
.ap-embed:hover { background: rgba(240,138,36,0.04); }

/* Transcript row hover — light grey highlight (Notion-style).
   `!important` overrides the inline `background` style applied per-row
   so plain rows highlight on hover without erasing the atom yellow. */
.trx .trx-row:hover:not(.is-atom) { background: var(--bg-hover) !important; }

/* Flash a transcript row when AtomView jumps to its source. Blue
   accent pulse (v3 neutral). `!important` beats the inline `background`
   style on each row; final state returns to transparent so the row's
   own background (atom yellow / candidate / plain) is restored. */
.trx .row.flash-tc, .trx .flash-tc { animation: flashTc 2.2s ease-out; }
@keyframes flashTc {
  0%   { background: var(--accent-soft) !important; }
  60%  { background: rgba(35, 131, 226, 0.06) !important; }
  100% { background: transparent !important; }
}

/* ── Inline comment anchors ─────────────────────────────────────────────── */
.ap-comment-anchor {
  border-radius: 2px;
  padding: 0 1px;
  cursor: pointer;
  transition: background .15s;
}
.ap-comment-anchor[data-color="purple"] { background: rgba(157,132,230,0.30); }
.ap-comment-anchor[data-color="blue"]   { background: rgba(132,174,230,0.30); }
.ap-comment-anchor[data-color="yellow"] { background: rgba(255,204,0,0.30); }
.ap-comment-anchor[data-color="green"]  { background: rgba(46,160,67,0.18); }
.ap-comment-anchor.resolved             { opacity: 0.35; }
.ap-comment-anchor:hover                { outline: 1px solid currentColor; }

/* ── Floating comment thread card ───────────────────────────────────────── */
.ap-comment-thread {
  position: fixed;
  z-index: 200;
  width: 360px;
  background: var(--ap-paper);
  border: 1px solid var(--ap-line-soft);
  border-radius: var(--ap-radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
}
.ap-comment-thread .ct-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--ap-line-softer);
}
.ap-comment-thread .ct-anchor-text {
  flex: 1;
  font-size: 11px;
  color: var(--ap-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-comment-thread .ct-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.ap-comment-thread .ct-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--ap-radius-sm);
  font-size: 11px;
  color: var(--ap-muted);
  transition: background .12s, color .12s;
}
.ap-comment-thread .ct-btn:hover {
  background: var(--ap-paper-2);
  color: var(--ap-ink);
}
.ap-comment-thread .ct-btn.resolve {
  color: var(--ap-green);
}
.ap-comment-thread .ct-body {
  max-height: 280px;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ap-comment-thread .ct-msg {
  display: flex;
  gap: 8px;
}
.ap-comment-thread .ct-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ap-green);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ap-comment-thread .ct-msg-inner {
  flex: 1;
  min-width: 0;
}
.ap-comment-thread .ct-meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 2px;
}
.ap-comment-thread .ct-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--ap-ink);
}
.ap-comment-thread .ct-time {
  font-size: 10px;
  color: var(--ap-muted);
}
.ap-comment-thread .ct-text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--ap-ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.ap-comment-thread .ct-reply {
  border-top: 1px solid var(--ap-line-softer);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ap-comment-thread .ct-reply textarea {
  resize: none;
  border: 1px solid var(--ap-line-soft);
  border-radius: var(--ap-radius-sm);
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--ap-ink);
  background: var(--ap-paper-2);
  outline: none;
  transition: border-color .15s;
  width: 100%;
  box-sizing: border-box;
  min-height: 56px;
}
.ap-comment-thread .ct-reply textarea:focus {
  border-color: var(--ap-accent);
}
.ap-comment-thread .ct-reply-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.ap-comment-thread .ct-send-btn {
  background: var(--ap-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--ap-radius-sm);
  font-size: 12px;
  font-weight: 600;
  transition: opacity .12s;
}
.ap-comment-thread .ct-send-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.ap-comment-thread .ct-cancel-btn {
  background: none;
  border: 1px solid var(--ap-line-soft);
  color: var(--ap-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--ap-radius-sm);
  font-size: 12px;
  transition: background .12s;
}
.ap-comment-thread .ct-cancel-btn:hover {
  background: var(--ap-paper-2);
}

/* ── Comment count badge ─────────────────────────────────────────────────── */
.ap-comment-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ap-muted);
  background: var(--ap-paper-2);
  border: 1px solid var(--ap-line-soft);
  border-radius: var(--ap-radius-pill);
  padding: 1px 6px;
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.ap-comment-badge:hover {
  background: var(--ap-paper-3);
  color: var(--ap-ink);
}

/* ── Read-only comment compose overlay ──────────────────────────────────── */
.ap-comment-compose {
  position: fixed;
  z-index: 201;
  background: var(--ap-paper);
  border: 1px solid var(--ap-line-soft);
  border-radius: var(--ap-radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 300px;
}
.ap-comment-compose textarea {
  resize: none;
  border: 1px solid var(--ap-line-soft);
  border-radius: var(--ap-radius-sm);
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--ap-ink);
  background: var(--ap-paper-2);
  outline: none;
  width: 100%;
  box-sizing: border-box;
  min-height: 64px;
}
.ap-comment-compose textarea:focus { border-color: var(--ap-accent); }
.ap-comment-compose .cc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* dark-mode overrides for comment thread */
[data-theme="dark"] .ap-comment-thread,
[data-theme="dark"] .ap-comment-compose {
  background: var(--ap-paper);
  border-color: var(--ap-line-soft);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.18);
}
/* DESIGN-03-05 — PropList */
.prop-row { transition: background 80ms; }
.prop-row:hover { background: var(--bg-hover); }
.prop-row .row-actions { opacity: 0; transition: opacity 80ms; }
.prop-row:hover .row-actions { opacity: 1; }
.prop-pop-row { transition: background 60ms; }
.prop-pop-row:hover { background: var(--bg-hover); }
.ap-mono { font-family: var(--ap-mono); }

/* === DESIGN-03-07 · Atom view (v3) === */
.atom-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ap-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.atom-title {
  font-family: inherit;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ap-ink);
  margin: 0;
  flex: 1;
}
.atom-title-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin: 10px 0 22px;
}
.atom-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--ap-ink);
  color: var(--ap-bg);
  border: 1px solid var(--ap-ink);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 4px;
}
.atom-thesis {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 18px;
  margin: 22px 0 32px;
}
.atom-thesis .rich-field {
  font-size: 20px;
  line-height: 1.55;
  color: var(--ap-ink);
}
.atom-quote-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 36px;
}
.atom-quote-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--fg-mute);
  flex-wrap: wrap;
}
.atom-quote-tc {
  font-family: var(--ap-mono);
  font-size: 12px;
  color: var(--accent);
  background: transparent;
  border: none;
  outline: none;
  padding: 1px 0;
  width: 80px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
  font-variant-numeric: tabular-nums;
}
.atom-quote-tc:focus {
  text-decoration-style: solid;
}
.atom-quote-nav {
  font-family: var(--ap-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent);
  cursor: pointer;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.atom-quote-nav:hover {
  text-decoration-style: solid;
}
.atom-quote-text .rich-field {
  font-size: 16px;
  line-height: 1.7;
  font-style: italic;
  color: var(--ap-ink);
}
.atom-backlinks-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ap-line-softer);
  cursor: pointer;
}

/* DESIGN-03-08 — Insight view (UnifiedInsightEditor) */
.insight-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ap-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.insight-title-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin: 10px 0 22px;
}
.insight-title {
  font-family: inherit;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ap-ink);
  margin: 0;
  flex: 1;
}
.insight-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--ap-ink);
  color: var(--ap-bg);
  border: 1px solid var(--ap-ink);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 4px;
}
.insight-paragraphs .rich-field {
  font-size: 16px;
  line-height: 1.75;
  color: var(--ap-ink);
}
.insight-so-what {
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 24px 0;
  margin: 32px 0;
}
.insight-so-what .rich-field {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ap-ink);
}
.insight-confidence-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.insight-confidence-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.insight-confidence-cell .icf-label {
  font-family: var(--ap-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 8px;
  line-height: 1.3;
}
.insight-confidence-cell.invert .icf-label,
.insight-confidence-cell.invert .icf-value {
  color: var(--counter-red);
}
.insight-confidence-cell .icf-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}
.insight-confidence-cell .icf-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  color: var(--ap-ink);
  font-variant-numeric: tabular-nums;
}
.insight-confidence-cell .icf-total {
  font-size: 11px;
  color: var(--fg-mute);
}
.insight-confidence-cell .icf-bar {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.insight-confidence-cell .icf-bar-fill {
  height: 100%;
  background: var(--fg);
  border-radius: 2px;
}
.insight-confidence-cell.invert .icf-bar-fill {
  background: var(--counter-red);
}
.insight-confidence-cell .icf-caption {
  font-size: 12px;
  color: var(--fg-mute);
  line-height: 1.4;
}

.insight-evidence-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
}
.insight-evidence-header:hover .insight-eyebrow {
  color: var(--ap-ink);
}
.insight-evidence-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.insight-evidence-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.insight-evidence-card.insight-evidence-counter {
  border-color: var(--counter-red);
  background: rgba(199, 56, 56, 0.03);
}
.insight-evidence-card .iev-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--ap-mono);
  font-size: 11px;
  color: var(--fg-mute);
  min-width: 0;
}
.insight-evidence-card.insight-evidence-counter .iev-head {
  color: var(--counter-red);
}
.insight-evidence-card .iev-tc {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.insight-evidence-card.insight-evidence-counter .iev-tc {
  color: var(--counter-red);
}
.insight-evidence-card .iev-tc:hover {
  text-decoration-style: solid;
}
.insight-evidence-card .iev-src {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insight-evidence-card .iev-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--counter-red);
  flex-shrink: 0;
}
.insight-evidence-card .iev-body {
  font-family: inherit;
  font-size: 13px;
  font-style: italic;
  line-height: 1.5;
  color: var(--ap-ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.insight-evidence-card .iev-foot {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  min-width: 0;
}
.insight-evidence-card .iev-foot:hover .iev-foot-label {
  text-decoration-style: solid;
}
.insight-evidence-card .iev-foot-label {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.insight-revisions-row {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  margin-top: 12px;
}
.insight-revision-dot {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: default;
}
.insight-revision-dot.past {
  background: var(--bg);
  border: 1.5px solid var(--line-strong);
}
.insight-revision-dot.current {
  background: var(--fg);
  border: 1.5px solid var(--fg);
}
.insight-revision-link {
  flex: 0 0 24px;
  height: 1px;
  background: var(--line-strong);
}
.insight-revision-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.insight-revision-label {
  font-family: var(--ap-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-mute);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.insight-revision-label.current {
  color: var(--ap-ink);
  font-weight: 600;
}

[data-theme="dark"] .ap-comment-thread .ct-reply textarea,
[data-theme="dark"] .ap-comment-compose textarea {
  background: var(--ap-paper-2);
  border-color: var(--ap-line-soft);
}

/* ── DESIGN-03-09: AI sparkles spin + tag pending highlight ───────── */
@keyframes apAiSpin {
  0%   { transform: rotate(0deg)   scale(1); }
  50%  { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}
.ap-ai-spark {
  animation: apAiSpin 1.4s linear infinite;
  transform-origin: center;
}
/* While the user is mid-typing `#word` (before space/Enter triggers the
   token), give the popover-pending text a subtle highlight so the tag
   intent is visible. Real `.ap-taglink` spans (already-tokenised) keep
   their existing yellow chip styling. */
.ap-tag-pending {
  background: rgba(35,131,226,0.08);
  border-radius: 2px;
  padding: 0 2px;
}

/* ── TG_SURVEY-02: дашборд опросов ─────────────────────────────────────── */
/* Мягкая подсветка изменившегося счётчика (дискретный polling 4с). */
@keyframes svyFlash {
  0%   { background: var(--accent-soft, rgba(35,131,226,0.18)); }
  100% { background: transparent; }
}
.svy-flash { animation: svyFlash 1s ease-out; border-radius: 4px; }

/* Пульс live-индикатора «обновлено только что». */
@keyframes svyPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}
.svy-live-dot { animation: svyPulse 1.6s ease-in-out infinite; }

/* Панель предложений: патч research_update (правки полей проекта агентом) */
.chat-pending-research { border-top: 1px solid var(--line); }
.chat-pending-research:first-child { border-top: none; }
.chat-pending-diff { padding: 4px 12px 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-pending-diff .cpd-reason { font-size: 12px; color: var(--fg-mute); line-height: 1.45; }
.chat-pending-diff .cpd-warn { font-size: 12px; line-height: 1.45; color: #9A6700; background: #FEF8E5;
  border: 1px solid #E8C97A; border-radius: 6px; padding: 6px 10px; }
.chat-pending-diff .cpd-warn.cpd-error { color: #C73838; background: rgba(199,56,56,0.06); border-color: rgba(199,56,56,0.3); }
.chat-pending-diff .cpd-change { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.chat-pending-diff .cpd-head { display: flex; align-items: center; gap: 8px; padding: 5px 10px;
  background: var(--bg-soft); font-size: 11px; }
.chat-pending-diff .cpd-field { font-weight: 600; color: var(--fg); }
.chat-pending-diff .cpd-kind { margin-left: auto; text-transform: uppercase; letter-spacing: .04em; font-size: 10px; color: var(--fg-mute); }
.chat-pending-diff .cpd-kind.added { color: var(--success, #0F7B0F); }
.chat-pending-diff .cpd-kind.removed { color: var(--danger, #C73838); }
.chat-pending-diff .cpd-before, .chat-pending-diff .cpd-after { padding: 6px 10px; font-size: 12px;
  line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.chat-pending-diff .cpd-before { color: var(--fg-mute); text-decoration: line-through;
  text-decoration-color: rgba(199,56,56,0.5); background: rgba(199,56,56,0.04); }
.chat-pending-diff .cpd-after { color: var(--fg); background: rgba(15,123,15,0.05); }
