/* ============================================================================
   shared/shared-ui.css — styles for the shared modules in static_nlp/shared/
   (capabilities, drawer, diff, thread, spark). Every class is prefixed ipe-.
   Colours come only from the tokens in styles.css :root, which
   html[data-theme='dark'] redefines, so the dark theme needs no overrides.
   ============================================================================ */

/* capabilities.js: [data-cap] elements the user may not use */
.cap-hidden { display: none !important; }

/* ── chips ─────────────────────────────────────────────────────── */
.ipe-chip {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink-2);
  font-size: 0.68rem; font-weight: 700; line-height: 1.5; white-space: nowrap; vertical-align: middle;
  text-transform: none; letter-spacing: 0;
}
.ipe-chip--pos, .ipe-chip--live, .ipe-chip--added { background: var(--pos-soft); color: var(--pos); border-color: var(--pos-border); }
.ipe-chip--neg, .ipe-chip--removed, .ipe-chip--rejected { background: var(--neg-soft); color: var(--neg); border-color: var(--neg-border); }
.ipe-chip--warn, .ipe-chip--changed, .ipe-chip--pending { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.ipe-chip--note, .ipe-chip--new { background: var(--note-soft); color: var(--note); border-color: var(--note-border); }
.ipe-chip--muted { background: var(--surface-2); color: var(--ink-3); border-color: var(--border); }
.ipe-chip--accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }
button.ipe-chip { cursor: pointer; font-family: inherit; }
button.ipe-chip:hover { filter: brightness(0.97); border-color: currentColor; }
button.ipe-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ipe-vchip {
  display: inline-block; padding: 0 6px; border-radius: 4px; margin: 0 2px;
  background: var(--surface-3); color: var(--ink-2);
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600; line-height: 1.6;
}
.ipe-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--note); flex: none;
}
.ipe-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border);
  font-size: 0.62rem; font-weight: 700; line-height: 1;
}

/* ── drawer ────────────────────────────────────────────────────── */
.ipe-drawer-root { position: fixed; inset: 0; z-index: 9500; }
.ipe-drawer-backdrop {
  position: absolute; inset: 0; background: rgba(10, 19, 16, 0.42);
  opacity: 0; transition: opacity 0.18s ease;
}
.ipe-drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); transform: translateX(24px); opacity: 0;
  transition: transform 0.18s var(--ease-out-expo), opacity 0.18s ease;
}
.ipe-drawer--wide { width: min(760px, 100vw); }
.ipe-drawer-root.is-open .ipe-drawer-backdrop { opacity: 1; }
.ipe-drawer-root.is-open .ipe-drawer { transform: none; opacity: 1; }
.ipe-drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
}
.ipe-drawer-title {
  margin: 0; font-family: var(--font-sans); font-size: 1.1rem; font-weight: 600;
  text-transform: none; letter-spacing: 0; color: var(--ink); overflow-wrap: anywhere;
}
.ipe-drawer-sub { margin: 4px 0 0; font-size: 0.82rem; color: var(--ink-2); }
.ipe-drawer-x {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent; color: var(--ink-2); cursor: pointer;
}
.ipe-drawer-x:hover { background: var(--surface-2); color: var(--ink); }
.ipe-drawer-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ipe-drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px 28px; }
.ipe-drawer-section + .ipe-drawer-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.ipe-drawer-section-title { margin: 0 0 10px; font-size: 0.72rem; color: var(--ink-3); }
@media (prefers-reduced-motion: reduce) {
  .ipe-drawer, .ipe-drawer-backdrop { transition: none; }
}

/* ── diff ──────────────────────────────────────────────────────── */
.ipe-diff-head { margin: 0 0 12px; font-size: 0.88rem; color: var(--ink-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ipe-diff-kind {
  margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--note-soft); border: 1px solid var(--note-border); color: var(--ink); font-size: 0.88rem;
}
.ipe-diff-table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 0.84rem; }
.ipe-diff-table th, .ipe-diff-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; overflow-wrap: anywhere;
}
.ipe-diff-table thead th {
  font-size: 0.7rem; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.4px;
  background: var(--surface-1);
}
.ipe-diff-table tbody th { font-weight: 600; color: var(--ink); width: 34%; }
/* Before / After are labelled by the column headers, so the old value is
   shown plainly in a neutral tone (no strikethrough: it hurt readability,
   especially for numbers and dates) and the new value is emphasised. */
.ipe-diff-before { color: var(--ink-2); background: var(--surface-1); }
.ipe-diff-after { color: var(--ink); font-weight: 600; background: var(--pos-soft); }
.ipe-diff-none { color: var(--ink-3); font-style: italic; font-weight: 400; text-decoration: none; }
.ipe-diff-branch {
  margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  border-left-width: 3px; background: var(--surface);
}
.ipe-diff-branch--changed { border-left-color: var(--warn); }
.ipe-diff-branch--added { border-left-color: var(--pos); }
.ipe-diff-branch--removed { border-left-color: var(--neg); }
.ipe-diff-branch .ipe-diff-table { margin-bottom: 0; }
.ipe-diff-branch-title {
  margin: 0 0 10px; font-family: var(--font-sans); font-size: 0.86rem; font-weight: 600;
  text-transform: none; letter-spacing: 0; color: var(--ink); display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.ipe-diff-removed { opacity: 0.72; }
.ipe-diff-unchanged { margin: 4px 0 0; font-size: 0.8rem; color: var(--ink-3); }
.ipe-diff-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 18px; margin: 0 0 14px; }
.ipe-diff-facts dt { font-size: 0.72rem; color: var(--ink-3); }
.ipe-diff-facts dd { margin: 0; font-size: 0.86rem; color: var(--ink); overflow-wrap: anywhere; }

.ipe-anchor-btn {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; vertical-align: middle;
  padding: 1px 6px; border-radius: 999px; border: 1px solid transparent; background: transparent;
  color: var(--ink-3); font: inherit; font-size: 0.7rem; font-weight: 600; cursor: pointer;
  opacity: 0.55; transition: opacity 0.15s ease, color 0.15s ease;
}
li:hover > .ipe-anchor-btn, tr:hover .ipe-anchor-btn, .ipe-anchor-btn:focus-visible { opacity: 1; }
.ipe-anchor-btn:hover { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); opacity: 1; }
.ipe-anchor-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ipe-anchor-flash { animation: ipe-flash 1.6s ease; border-radius: 4px; }
@keyframes ipe-flash { 0%, 40% { background: var(--warn-soft); box-shadow: 0 0 0 2px var(--warn-border); } 100% { background: transparent; box-shadow: none; } }

/* ── conversation ──────────────────────────────────────────────── */
.ipe-thread-state, .ipe-thread-closed { margin: 0; font-size: 0.86rem; color: var(--ink-2); }
.ipe-thread-closed { margin-top: 10px; font-style: italic; }
.ipe-thread-list, .ipe-c-replies { list-style: none; margin: 0; padding: 0; }
.ipe-thread-list { display: flex; flex-direction: column; gap: 12px; }
.ipe-c {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.ipe-c.has-anchor { border-left: 3px solid var(--note-border); }
.ipe-c.is-resolved { background: var(--surface-1); }
.ipe-c.is-resolved .ipe-c-body { color: var(--ink-2); }
.ipe-c-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.8rem; color: var(--ink-3); }
.ipe-c-name { color: var(--ink); font-weight: 600; font-size: 0.84rem; }
.ipe-c-meta { font-style: italic; }
.ipe-c-anchor {
  display: inline-flex; margin: 6px 0 0; padding: 2px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--note-border); background: var(--note-soft); color: var(--note);
  font: inherit; font-size: 0.74rem; font-weight: 600; cursor: pointer; text-align: left;
}
.ipe-c-anchor:hover { filter: brightness(0.97); }
.ipe-c-anchor:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ipe-c-body { margin: 6px 0 0; font-size: 0.88rem; line-height: 1.5; color: var(--ink); overflow-wrap: anywhere; }
.ipe-c-deleted { color: var(--ink-3); font-style: italic; }
.ipe-c-actions { display: flex; gap: 2px; margin-top: 6px; flex-wrap: wrap; }
.ipe-c-actions button {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 0.76rem; font-weight: 600;
  padding: 2px 6px; border-radius: 4px; cursor: pointer;
}
.ipe-c-actions button:hover { color: var(--accent); background: var(--accent-soft); }
.ipe-c-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ipe-c-pick { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 0.8rem; color: var(--ink-2); cursor: pointer; text-transform: none; letter-spacing: 0; }
.ipe-c-replies { margin: 10px 0 0 14px; padding-left: 12px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.ipe-c-replies .ipe-c { border: 0; padding: 4px 0; background: transparent; }

.ipe-tl { display: flex; gap: 10px; align-items: flex-start; padding: 2px 0; }
.ipe-tl-dot { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); }
.ipe-tl--pos .ipe-tl-dot { background: var(--pos); border-color: var(--pos); }
.ipe-tl--neg .ipe-tl-dot { background: var(--neg); border-color: var(--neg); }
.ipe-tl--warn .ipe-tl-dot { background: var(--warn); border-color: var(--warn); }
.ipe-tl-body { min-width: 0; }
.ipe-tl-body p { margin: 0; font-size: 0.84rem; color: var(--ink-2); line-height: 1.5; }
.ipe-tl-body b { color: var(--ink); font-weight: 600; }
.ipe-tl-by { color: var(--ink-3); }
.ipe-tl-by::before { content: '· '; }
.ipe-tl-quote {
  margin: 6px 0 0; padding: 4px 0 4px 12px; border-left: 3px solid var(--border-strong);
  color: var(--ink); font-size: 0.86rem; line-height: 1.5; overflow-wrap: anywhere;
}
.ipe-thread time { color: var(--ink-3); font-size: 0.76rem; }

.ipe-composer { margin-top: 14px; }
.ipe-composer--inline { margin-top: 8px; }
.ipe-composer-label { display: block; margin-bottom: 6px; font-size: 0.72rem; color: var(--ink-3); }
.ipe-textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 54px; padding: 8px 10px;
  font: inherit; font-size: 0.86rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.ipe-textarea::placeholder { color: var(--ink-3); }
.ipe-textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ipe-composer-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ipe-composer-actions .btn-primary, .ipe-composer-actions .btn-ghost { padding: 7px 14px; }
.ipe-thread button:disabled { opacity: 0.6; cursor: progress; }

/* ── sparkline ─────────────────────────────────────────────────── */
.ipe-spark { display: block; overflow: visible; color: var(--accent); }
.ipe-spark-line { stroke: var(--accent); }
.ipe-spark-dot { fill: var(--accent); }
.ipe-spark-band { fill: var(--note-soft); stroke: var(--note-border); stroke-width: 0.5; stroke-dasharray: 2 2; }
/* Stroke only on the line: a CSS fill would beat its fill="none" attribute
   and flood the area under the polyline. */
.ipe-spark--stale .ipe-spark-line { stroke: var(--warn); }
.ipe-spark--stale .ipe-spark-dot { fill: var(--warn); }

/* ── shared state boxes ────────────────────────────────────────── */
.ipe-empty { padding: 28px 20px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.ipe-empty-title { margin: 0 0 4px; font-weight: 600; color: var(--ink); }
.ipe-empty-text { margin: 0; font-size: 0.86rem; color: var(--ink-2); }
.ipe-empty .btn-ghost { margin: 14px auto 0; }
.ipe-banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; margin: 0 0 14px;
  border-radius: var(--radius-sm); border: 1px solid; font-size: 0.86rem; line-height: 1.5;
}
.ipe-banner--warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--ink); }
.ipe-banner--note { background: var(--note-soft); border-color: var(--note-border); color: var(--ink); }
.ipe-banner b { font-weight: 600; }