/* ai.pole — design tokens and base styles
   Built on Pole brand: black/white/yellow + electric blue accent for app chrome.
   Light mode is default for app surfaces; dark for hero/landing. */

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

/* "mono" в нашей системе — это Montserrat с tabular-nums и фиксированной шириной цифр.
   Один шрифт, две роли: проза (обычный) и техника/цифры (через var(--ap-mono)). */

:root {
  --ap-bg: #FFFFFF;
  --ap-bg-2: #F6F6F6;
  --ap-paper: #FFFFFF;
  --ap-paper-2: #F6F6F6;
  --ap-paper-3: #ECECEC;
  --ap-ink: #1A1A1A;
  --ap-ink-2: #333333;
  --ap-muted: #888888;
  --ap-muted-2: #BBBBBB;
  --ap-line: #1A1A1A;
  --ap-line-soft: #E0E0E0;
  --ap-line-softer: #EEEEEE;
  --ap-accent: #0047E1;
  --ap-accent-2: #34CDFE;
  --ap-yellow: #FFCC00;
  --ap-hl: #FFF4B8;       /* yellow tint for atomised rows */
  --ap-hl-strong: #FFE066;
  --ap-orange: #F08A24;   /* pending changes warning */
  --ap-green: #2EA043;
  --ap-red: #CC2936;

  --ap-kind-source: #888888;
  --ap-kind-atom: #0047E1;
  --ap-kind-insight: #FFCC00;
  --ap-kind-note: #1A1A1A;

  --ap-radius-sm: 4px;
  --ap-radius-md: 8px;
  --ap-radius-pill: 9999px;

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

  --ap-mono: "Montserrat", -apple-system, sans-serif;
}

/* 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"] {
  --ap-bg: #000000;
  --ap-bg-2: #0A0A0A;
  --ap-paper: #0A0A0A;
  --ap-paper-2: #111111;
  --ap-paper-3: #181818;
  --ap-ink: #FFFFFF;
  --ap-ink-2: rgba(255,255,255,0.85);
  --ap-muted: rgba(255,255,255,0.6);
  --ap-muted-2: rgba(255,255,255,0.4);
  --ap-line: rgba(255,255,255,0.5);
  --ap-line-soft: rgba(255,255,255,0.18);
  --ap-line-softer: rgba(255,255,255,0.08);
  --ap-hl: #4A3D00;
  --ap-hl-strong: #6B5800;
  --ap-kind-note: #FFFFFF;
}

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

/* === Accent override (TweaksPanel) ===
   Default accent (electric blue) lives in :root. These overrides flip the
   --ap-accent token globally; KindChanger pill, link colour, focus borders,
   and any other consumer of var(--ap-accent) follow automatically. */
[data-accent="yellow"] { --ap-accent: var(--ap-yellow); }
[data-accent="blue"]   { --ap-accent: #0047E1; }
[data-accent="mono"]   { --ap-accent: var(--ap-ink); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ap-bg);
  color: var(--ap-ink);
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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: "Montserrat", sans-serif;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 0.96;
  text-transform: lowercase;
}
.ap-h2 {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 64px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-transform: lowercase;
}
.ap-h3 {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-transform: lowercase;
}
.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: "Montserrat", sans-serif;
  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: "Montserrat";
  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: 5px 10px;
  border-radius: var(--ap-radius-pill);
  font-size: 11px;
  letter-spacing: 0.04em;
  border: 1px solid var(--ap-line-soft);
  background: transparent;
  color: var(--ap-ink-2);
  cursor: pointer;
  transition: all .12s ease;
  white-space: nowrap;
  font-family: inherit;
}
.ap-chip:hover { border-color: var(--ap-ink); }
.ap-chip.active { background: var(--ap-ink); color: var(--ap-bg); border-color: var(--ap-ink); }
.ap-chip.accent.active { background: var(--ap-accent); color: #fff; border-color: var(--ap-accent); }

.ap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--ap-radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--ap-line-soft);
  background: var(--ap-paper);
  color: var(--ap-ink);
  cursor: pointer;
  transition: all .12s ease;
  letter-spacing: -0.005em;
}
.ap-btn:hover { border-color: var(--ap-ink); }
.ap-btn.primary { background: var(--ap-ink); color: var(--ap-bg); border-color: var(--ap-ink); }
.ap-btn.primary:hover { background: var(--ap-ink-2); }
.ap-btn.yellow { background: var(--ap-yellow); border-color: var(--ap-yellow); color: #1A1A1A; }
.ap-btn.yellow:hover { background: #E6B800; border-color: #E6B800; }
.ap-btn.ghost { background: transparent; border: none; padding: 6px 10px; }
.ap-btn.ghost:hover { background: var(--ap-paper-2); }

.ap-kbd {
  font-family: var(--ap-mono);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--ap-line-soft);
  background: var(--ap-paper-2);
  color: var(--ap-muted);
  letter-spacing: 0;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* 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);
}

/* 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;
  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;
  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; }

/* === Sidebar internals === */
.sb-section { padding: 12px 14px; border-bottom: 1px solid var(--ap-line-softer); }
.sb-section.flex { flex: 1; min-height: 0; overflow: auto; }
.sb-label {
  font-family: var(--ap-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ap-muted);
  margin-bottom: 8px;
}

.sb-tree { font-size: 12px; }
.sb-tree-folder {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; cursor: pointer; border-radius: 3px;
  color: var(--ap-ink-2);
  font-weight: 500;
}
.sb-tree-folder:hover { background: var(--ap-paper-2); }
.sb-tree-file {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 22px; cursor: pointer; border-radius: 3px;
  color: var(--ap-ink-2);
}
.sb-tree-file:hover { background: var(--ap-paper-2); }
.sb-tree-file.active { background: var(--ap-paper-2); }
.sb-tree-file.active::before {
  content: ''; position: absolute; left: 0; width: 2px; height: 18px; background: var(--ap-accent);
}
.sb-tree-file { position: relative; }
.sb-tree-file .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === Note view === */
.note-body {
  padding: 32px 48px;
  flex: 1;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: 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 === */
.chat-msg {
  padding: 12px 16px;
  border-radius: var(--ap-radius-md);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}
.chat-msg.user { background: var(--ap-paper-2); margin-left: 32px; }
.chat-msg.assistant { background: var(--ap-paper); border: 1px solid var(--ap-line-softer); margin-right: 32px; }
.chat-msg.tool {
  background: transparent;
  font-family: var(--ap-mono);
  font-size: 11px;
  color: var(--ap-muted);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
}

.ref-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px;
  border: 1px dashed var(--ap-accent);
  border-radius: 3px;
  font-family: var(--ap-mono);
  font-size: 10px;
  color: var(--ap-accent);
  letter-spacing: 0;
  cursor: pointer;
  text-decoration: none;
}
.ref-pill:hover { background: rgba(0,71,225,0.06); }

/* === 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: rgba(232,179,11,0.16);
  color: #7A4F00;
  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: rgba(45,99,191,0.10);
  color: #1A4FA0;
  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); }

/* Pulse a transcript row briefly when AtomView jumps to its source.
   `!important` beats the inline `background` style on each `.row`; the
   first keyframe uses the strong yellow so atomised rows (which already
   have a soft yellow inline bg) still show a clear flash. */
.trx .row.pulse { animation: pulseRow 1.6s ease-out; }
@keyframes pulseRow {
  0%   { background: var(--ap-yellow) !important; }
  60%  { background: color-mix(in srgb, var(--ap-yellow) 60%, transparent) !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);
}
[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);
}
