/* Kai onboarding — dark, glowing, "JARVIS for medical education" shell.
 *
 * §K1 (Ramy 2026-06-09 — PR-K1): foundation. Ships:
 *   - color tokens (deep navy + cyan glow)
 *   - .kai-backdrop full-page atmosphere
 *   - .kai-topbar minimal chrome
 *   - .kai-avatar with breathing + speaking animations
 *   - .kai-step-intro layout
 *   - .kai-dialogue typewriter text
 *   - .kai-cta-button primary action
 *
 * Loaded only by templates/_kai_onboarding_shell.html. Classic
 * wizard is unaffected.
 */

/* §K5b (Ramy 2026-06-09 — Ramy testing feedback):
 * Switched from the original "JARVIS dark" palette to a clinical
 * light palette. Medical context reads better on white surfaces
 * with a calm sky-blue accent than on deep navy with neon glows.
 * Existing structural rules keep working — only the token values
 * change here. Dark-specific glow/shadow values are softened
 * further down the file. */
:root {
  /* Backgrounds */
  --kai-bg-deep:        #f8fafc;        /* slate-50 — page backdrop */
  --kai-bg-panel:       #ffffff;        /* surfaces */
  --kai-bg-card:        #ffffff;        /* elevated cards */
  --kai-bg-input:       #ffffff;        /* form inputs */
  --kai-bg-soft:        #f1f5f9;        /* slate-100 — subtle wash */

  /* Accent — calm medical blue family */
  --kai-glow-primary:   #0284c7;        /* sky-600 — buttons, focus */
  --kai-glow-soft:      #0ea5e9;        /* sky-500 — secondary accent */
  --kai-glow-dim:       rgba(2, 132, 199, 0.10);
  --kai-glow-pulse:     rgba(2, 132, 199, 0.05);

  /* Text */
  --kai-text-primary:   #0f172a;        /* slate-900 */
  --kai-text-secondary: #475569;        /* slate-600 */
  --kai-text-kai:       #0369a1;        /* sky-700 — Kai's voice */
  --kai-text-muted:     #94a3b8;        /* slate-400 */

  /* Semantic */
  --kai-success:        #059669;        /* emerald-600 */
  --kai-warning:        #d97706;        /* amber-600 */
  --kai-error:          #dc2626;        /* red-600 */

  /* Borders */
  --kai-border:         #cbd5e1;        /* slate-300 */
  --kai-border-active:  #0284c7;
  --kai-border-dim:     #e2e8f0;        /* slate-200 */
}

/* ── Full-page backdrop ────────────────────────────────── */
.kai-backdrop {
  min-height: 100vh;
  background:
    /* Faint grid overlay (JARVIS style) */
    linear-gradient(rgba(2, 132, 199, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(2, 132, 199, 0.025) 1px, transparent 1px),
    /* Radial pool of light at the top */
    radial-gradient(ellipse at 50% -10%,
      rgba(2, 132, 199, 0.10) 0%,
      transparent 55%),
    var(--kai-bg-deep);
  background-size: 48px 48px, 48px 48px, 100% 100%, 100% 100%;
  color: var(--kai-text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  position: relative;
}

/* The base layout has its own white site chrome — hide it.
   The Kai shell is a takeover experience. */
.kai-backdrop ~ footer,
body:has(.kai-backdrop) footer,
body:has(.kai-backdrop) > header { display: none; }

/* ── Top chrome ────────────────────────────────────────── */
.kai-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.6rem;
  border-bottom: 1px solid var(--kai-border-dim);
  /* Reflow (Ramy 2026-06-24): pin the top banner so the progress steps +
     running item counter stay visible while the doctor scrolls a long screen. */
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--kai-bg-deep);
}

.kai-topbar-brand {
  display: inline-flex;
  align-items: baseline;
  gap: .35rem;
  text-decoration: none;
  color: var(--kai-text-primary);
}

.kai-topbar-brandmark {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .02em;
  color: var(--kai-glow-primary);
  text-shadow: 0 0 12px rgba(2, 132, 199, 0.4);
}

.kai-topbar-brand-label {
  font-weight: 500;
  font-size: .9rem;
  color: var(--kai-text-secondary);
  letter-spacing: .04em;
}

/* Step dots — minimal pip indicator */
.kai-topbar-progress {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
}

/* Ramy 2026-06-23: named steps (pip + label) instead of bare dots. */
.kai-step-dot {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .22rem .55rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--kai-text-secondary);
  transition: color .25s, background .25s;
}

.kai-step-pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(100, 116, 139, 0.30);
  flex-shrink: 0;
  transition: background .25s, box-shadow .25s, transform .25s;
}

/* Completed steps — pip filled (dimmed), label muted. */
.kai-step-dot.is-done .kai-step-pip {
  background: var(--kai-glow-primary);
  opacity: .55;
}

/* Current step — highlighted label + glowing pip. */
.kai-step-dot.is-active {
  color: var(--kai-glow-primary);
  background: rgba(2, 132, 199, 0.08);
}
.kai-step-dot.is-active .kai-step-pip {
  background: var(--kai-glow-primary);
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.6);
  transform: scale(1.3);
}

/* Tight screens: collapse to pips only (the old dot look). */
@media (max-width: 760px) {
  .kai-step-label { display: none; }
  .kai-step-dot { padding: 0; }
  .kai-topbar-progress { gap: .5rem; }
}

.kai-topbar-classic {
  color: var(--kai-text-secondary);
  font-size: .82rem;
  text-decoration: none;
  border: 1px solid var(--kai-border-dim);
  padding: .35rem .7rem;
  border-radius: .35rem;
  transition: color .15s, border-color .15s;
}

.kai-topbar-classic:hover {
  color: var(--kai-text-primary);
  border-color: var(--kai-border);
}

/* Reflow (Ramy 2026-06-24): persistent running item counter, top-right. */
.kai-topbar-count {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--kai-glow-primary);
  background: rgba(2, 132, 199, .1);
  border: 1px solid rgba(2, 132, 199, .25);
  padding: .3rem .7rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* ── Intro step (Step 0) ───────────────────────────────── */
.kai-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Reflow (Ramy 2026-06-24): tightened top/bottom padding so screens fit the
     viewport height without scrolling. min-height keeps short screens centred;
     overflow-y lets a genuinely tall screen still scroll as a fallback. */
  padding: 1.3rem 1.5rem 1.6rem;
  min-height: calc(100vh - 80px);
  overflow-y: auto;
}

/* Reflow: compact the content-source hub so the 4 stacked cards + the
   "I'm done — organize" CTA all fit above the fold on a laptop viewport. */
.kai-step-picker .kai-explain-stack { gap: .55rem; }
.kai-step-picker .kai-avatar { width: 68px; height: 68px; }
.kai-step-picker .kai-intro-name { margin-top: .3rem; }
.kai-step-picker .kai-explain-line {
  min-height: 0;
  font-size: 1.3rem;
  margin: .1rem 0 .2rem;
}
.kai-step-picker .kai-picker-grid { gap: .6rem; margin-top: .3rem; }
.kai-step-picker .kai-picker-card { padding: .85rem 1.1rem; }
.kai-step-picker .kai-picker-icon { width: 46px; height: 46px; }
.kai-step-picker .kai-picker-card { grid-template-columns: 46px 1fr auto; }
.kai-step-picker .kai-picker-hint { margin: .35rem 0 0; }

.kai-intro-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  /* §K9b (Ramy testing): bumped from 640px so the dialogue can
     breathe horizontally instead of running long vertically —
     keeps the "Let's Go" CTA above the fold on typical viewports. */
  max-width: 880px;
  gap: 1.2rem;
}

.kai-intro-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--kai-glow-primary);
  text-shadow: 0 0 12px rgba(2, 132, 199, 0.45);
  margin-top: .6rem;
}

.kai-intro-subtitle {
  font-size: .82rem;
  color: var(--kai-text-secondary);
  letter-spacing: .02em;
  margin-top: -1.2rem;
}

/* ── Kai's avatar — luminous halo around the photo ─────── */
.kai-avatar {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,
    rgba(2, 132, 199, 0.35) 0%,
    rgba(2, 132, 199, 0.12) 50%,
    transparent 75%);
  box-shadow:
    0 0 32px rgba(2, 132, 199, 0.25),
    0 0 96px rgba(2, 132, 199, 0.08);
  animation: kai-breathe 3.6s ease-in-out infinite;
  flex-shrink: 0;
}

.kai-avatar-lg {
  /* §K9b: was 140px — shrunk a bit so the intro screen fits
     above the fold on shorter viewports. */
  width: 112px;
  height: 112px;
}

.kai-avatar img {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  border-radius: 50%;
  object-fit: cover;
  /* Slight cyan tint via filter so Kai's photo reads as part of
     the world, not pasted on top of it. */
  filter:
    brightness(1.02)
    contrast(1.05)
    drop-shadow(0 0 6px rgba(2, 132, 199, 0.25));
}

@keyframes kai-breathe {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 32px rgba(2, 132, 199, 0.20), 0 0 96px rgba(2, 132, 199, 0.05);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 44px rgba(2, 132, 199, 0.35), 0 0 120px rgba(2, 132, 199, 0.10);
  }
}

.kai-avatar.is-speaking {
  animation: kai-speak 1.2s ease-in-out infinite;
}

@keyframes kai-speak {
  0%, 100% { box-shadow: 0 0 32px rgba(2, 132, 199, 0.25); }
  50%      { box-shadow: 0 0 52px rgba(2, 132, 199, 0.55); }
}

.kai-avatar.is-thinking {
  animation: kai-think 1.4s ease-in-out infinite;
}

@keyframes kai-think {
  0%, 100% { transform: scale(1)   rotate(0deg); }
  25%      { transform: scale(1.05) rotate(2deg); }
  75%      { transform: scale(0.97) rotate(-2deg); }
}

/* ── Dialogue ──────────────────────────────────────────── */
.kai-dialogue-stack {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 560px;
  width: 100%;
  margin-top: .4rem;
}

/* §K1b (Ramy 2026-06-09): swapped typewriter for sentence fade-in.
   Bigger, bolder display type so Kai's voice carries — readers
   shouldn't have to chase character-by-character text. */
.kai-dialogue {
  font-family: 'Space Grotesk', 'Inter', -apple-system,
               BlinkMacSystemFont, sans-serif;
  /* §K9b (Ramy testing): nudged from 1.55rem so a 4-line intro
     fits without scrolling on a 13" laptop viewport. */
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--kai-text-primary);
  letter-spacing: -0.005em;
  margin: 0;
  /* Hidden by default; the JS adds .is-shown to fade each line in
     one at a time. */
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .55s ease, transform .55s cubic-bezier(.16,1,.3,1);
  will-change: opacity, transform;
}

.kai-dialogue.is-shown {
  opacity: 1;
  transform: translateY(0);
}

/* First line gets a touch larger — it's the greeting. */
/* §K9b (Ramy testing): trimmed greeting size + main copy size so
   the four lines fit in the viewport above the "Let's Go" CTA. */
.kai-dialogue:first-child {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--kai-text-kai);
  letter-spacing: -0.01em;
}

/* ── CTA button ────────────────────────────────────────── */
.kai-cta-button {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  background: linear-gradient(135deg, var(--kai-glow-primary), var(--kai-glow-soft));
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  padding: .85rem 1.8rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    0 0 24px rgba(2, 132, 199, 0.35),
    0 4px 16px rgba(15, 23, 42, 0.10);
  opacity: 0;
  transform: translateY(8px) scale(.96);
  transition: opacity .35s ease, transform .35s cubic-bezier(.16,1,.3,1),
              box-shadow .2s, filter .15s;
  margin-top: .8rem;
}

.kai-cta-button.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.kai-cta-button:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 0 32px rgba(2, 132, 199, 0.55), 0 6px 20px rgba(15, 23, 42, 0.10);
}

.kai-cta-button:active:not(:disabled) {
  transform: translateY(1px) scale(.99);
}

.kai-cta-button:disabled {
  cursor: progress;
  opacity: .7;
}

.kai-cta-arrow {
  display: inline-block;
  transition: transform .15s;
}

.kai-cta-button:hover:not(:disabled) .kai-cta-arrow {
  transform: translateX(3px);
}

/* ══════════════════════════════════════════════════════════
 * §K2 — Step 1 form panel
 * ══════════════════════════════════════════════════════════ */

/* Two-column layout: Kai sidebar (left) + form actions (right).
   On screens < 1000px collapses to a single stacked column. */
.kai-step-form {
  display: grid;
  grid-template-columns: minmax(280px, 32%) 1fr;
  gap: 2rem;
  align-items: start;
  padding: 2.4rem clamp(1rem, 4vw, 3rem) 5rem;
  min-height: calc(100vh - 80px);
}

/* Panels are mutually exclusive — only .is-active is visible. */
.kai-panel:not(.is-active) { display: none; }

.kai-panel-enter {
  animation: kaiPanelIn 0.48s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes kaiPanelIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.kai-panel-exit {
  animation: kaiPanelOut 0.26s ease-in both;
}

@keyframes kaiPanelOut {
  to { opacity: 0; transform: translateY(-12px) scale(.985); }
}

/* ── Kai's sidebar (form steps) ───────────────────────── */
.kai-side {
  position: sticky;
  top: 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.8rem 1.4rem 1.4rem;
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border);
  border-radius: 18px;
  box-shadow: 0 0 1px var(--kai-glow-dim),
              0 4px 24px rgba(15, 23, 42, 0.10);
  text-align: center;
}

.kai-side-name {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--kai-glow-primary);
  text-shadow: 0 0 12px rgba(2, 132, 199, .35);
}

.kai-side-dialogue {
  width: 100%;
  margin-top: .2rem;
  gap: .9rem;
}

.kai-side-dialogue .kai-dialogue {
  font-size: 1.1rem;
  line-height: 1.45;
  font-weight: 500;
  text-align: left;
}

.kai-side-dialogue .kai-dialogue:first-child {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--kai-text-kai);
}

/* Rotating feedback slot — Kai's per-field reaction. Sits at
   the bottom of the sidebar so the user knows Kai is listening. */
.kai-dialogue-feedback {
  margin-top: .4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--kai-border-dim);
  font-style: italic;
  color: var(--kai-text-kai) !important;
}

/* ── Form right pane ─────────────────────────────────── */
.kai-actions {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

/* Ramy 2026-06-23: Step 1 (basics) and Step 3 (Review/confirm) have no left
   "Kai" sidebar — render them as a single centered column with the animated
   avatar above the title for a cleaner look. Other form steps keep their
   two-column sidebar layout. */
#kaiPanel1Step1,
#kaiPanel1Confirm,
#kaiPanel1Search,
#kaiPanelDiscovery {
  grid-template-columns: 1fr;
  justify-items: center;
}
#kaiPanel1Step1 .kai-actions,
#kaiPanel1Confirm .kai-actions,
#kaiPanel1Search .kai-actions,
#kaiPanelDiscovery .kai-actions {
  width: 100%;
  max-width: 760px;
}
.kai-step1-hero,
.kai-form-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  text-align: center;
}
.kai-step1-hero .kai-form-title,
.kai-form-hero .kai-form-title { margin: 0; }

/* Ramy 2026-06-24: drop the left Kai sidebar on the four content-source
   panels (Library / Upload / Import / Browse) — parity with the search
   screen. Single column, with Kai's animated avatar centered above the
   title. The avatar keeps its base breathe animation; name + dialogue +
   status lines in the old sidebar are hidden. */
#kaiPanel3Library.kai-step-form,
#kaiPanel3Upload.kai-step-form,
#kaiPanel3Url.kai-step-form,
#kaiPanel3Browse.kai-step-form {
  grid-template-columns: 1fr;
  max-width: 960px;
  margin: 0 auto;
}
#kaiPanel3Library > .kai-side,
#kaiPanel3Upload > .kai-side,
#kaiPanel3Url > .kai-side,
#kaiPanel3Browse > .kai-side {
  position: static;
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0 0 .25rem;
  gap: .5rem;
}
#kaiPanel3Library > .kai-side .kai-side-name,
#kaiPanel3Upload > .kai-side .kai-side-name,
#kaiPanel3Url > .kai-side .kai-side-name,
#kaiPanel3Browse > .kai-side .kai-side-name,
#kaiPanel3Library > .kai-side .kai-side-dialogue,
#kaiPanel3Upload > .kai-side .kai-side-dialogue,
#kaiPanel3Url > .kai-side .kai-side-dialogue,
#kaiPanel3Browse > .kai-side .kai-side-dialogue {
  display: none !important;
}
#kaiPanel3Library > .kai-actions .kai-actions-head,
#kaiPanel3Upload > .kai-actions .kai-actions-head,
#kaiPanel3Url > .kai-actions .kai-actions-head,
#kaiPanel3Browse > .kai-actions .kai-actions-head {
  text-align: center;
}

.kai-form-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--kai-text-primary);
  letter-spacing: -.015em;
  margin: 0;
}

.kai-form-subtitle {
  font-size: 1rem;
  color: var(--kai-text-secondary);
  margin: -.4rem 0 0;
}

.kai-form {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.kai-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.3rem;
}

@media (max-width: 720px) {
  .kai-field-grid { grid-template-columns: 1fr; }
}

.kai-field {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.kai-label {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--kai-text-secondary);
}

.kai-req {
  color: var(--kai-glow-primary);
  margin-left: .12rem;
}

.kai-optional {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: .7rem;
  font-style: italic;
  color: var(--kai-text-muted);
  margin-left: .35rem;
}

.kai-input {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--kai-text-primary);
  background: var(--kai-bg-input);
  border: 1px solid var(--kai-border);
  border-radius: 10px;
  padding: .85rem 1rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 180ms, box-shadow 180ms, background 180ms;
  -webkit-appearance: none;
  appearance: none;
}

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

.kai-input:hover:not(:focus) {
  border-color: rgba(2, 132, 199, .3);
}

.kai-input:focus {
  border-color: var(--kai-border-active);
  box-shadow: 0 0 0 4px var(--kai-glow-dim);
  outline: none;
  background: #ffffff;
}

.kai-textarea {
  min-height: 110px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

/* ── §K2b: chip-input (multi-entry specialty / affiliation) ── */
.kai-chip-input {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--kai-text-primary);
  background: var(--kai-bg-input);
  border: 1px solid var(--kai-border);
  border-radius: 10px;
  padding: .5rem .55rem;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  transition: border-color 180ms, box-shadow 180ms;
  cursor: text;
}

.kai-chip-input:hover {
  border-color: rgba(2, 132, 199, .3);
}

.kai-chip-input:focus-within {
  border-color: var(--kai-border-active);
  box-shadow: 0 0 0 4px var(--kai-glow-dim);
  background: #ffffff;
}

.kai-chip-row {
  display: contents;
}

.kai-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .35rem .3rem .65rem;
  background: rgba(2, 132, 199, .14);
  border: 1px solid var(--kai-border);
  color: var(--kai-text-kai);
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 500;
  line-height: 1.2;
  max-width: 100%;
}

.kai-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 18ch;
}

.kai-chip-x {
  background: transparent;
  border: none;
  color: var(--kai-text-secondary);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0 .25rem;
  cursor: pointer;
  border-radius: 50%;
  transition: color .12s, background .12s;
}

.kai-chip-x:hover {
  color: var(--kai-text-primary);
  background: rgba(248, 113, 113, .2);
}

.kai-chip-typed {
  flex: 1 1 12ch;
  min-width: 12ch;
  border: none;
  background: transparent;
  color: var(--kai-text-primary);
  font: inherit;
  padding: .35rem .5rem;
  outline: none;
}

.kai-chip-typed::placeholder {
  color: var(--kai-text-muted);
}

/* ── §K2b: optional-fields accordion ────────────────────── */
.kai-details {
  background: #f8fafc;
  border: 1px solid var(--kai-border-dim);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color .15s;
}

.kai-details[open] {
  border-color: var(--kai-border);
}

.kai-details-summary {
  list-style: none;
  cursor: pointer;
  padding: .9rem 1.1rem;
  font-size: .92rem;
  font-weight: 600;
  color: var(--kai-text-kai);
  display: flex;
  align-items: center;
  gap: .55rem;
  user-select: none;
}

/* Strip browser default disclosure triangle */
.kai-details-summary::-webkit-details-marker { display: none; }
.kai-details-summary::marker { content: ''; }

.kai-details-chevron {
  display: inline-block;
  font-size: 1.15rem;
  color: var(--kai-glow-primary);
  transition: transform .2s ease;
  transform-origin: center;
  line-height: 1;
}

.kai-details[open] .kai-details-chevron {
  transform: rotate(90deg);
}

.kai-details-hint {
  font-weight: 400;
  color: var(--kai-text-secondary);
  font-size: .85rem;
}

.kai-details-body {
  padding: .2rem 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  border-top: 1px solid var(--kai-border-dim);
}

@media (max-width: 640px) {
  .kai-details-hint { display: none; }
}

/* ══════════════════════════════════════════════════════════
 * §K3 — Step 1.25 search panel + Step 1.5 confirm
 * ══════════════════════════════════════════════════════════ */

/* Search panel: two-column area inside .kai-actions —
   snippet feed on the left, social anchors on the right. */
.kai-search-grid {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 1.4rem;
  align-items: start;
  margin-top: .4rem;
}

@media (max-width: 720px) {
  .kai-search-grid { grid-template-columns: 1fr; }
}

.kai-snippet-feed-wrap {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.kai-search-progress {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: .8rem;
  letter-spacing: .05em;
  color: var(--kai-glow-primary);
  text-shadow: 0 0 8px rgba(2, 132, 199, .35);
}

.kai-snippet-feed {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  min-height: 220px;
  max-height: 340px;
  overflow-y: auto;
  padding: .6rem;
  background: #f8fafc;
  border: 1px solid var(--kai-border-dim);
  border-radius: 12px;
  position: relative;
}

/* Subtle scan-line accent on the snippet feed — sells the "Kai
   is reading" feel without being distracting. */
.kai-snippet-feed::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--kai-glow-primary) 50%,
    transparent 100%);
  opacity: .35;
  animation: kaiSnippetScan 2.6s linear infinite;
}

@keyframes kaiSnippetScan {
  0%   { top: 0; opacity: 0; }
  20%  { opacity: .5; }
  80%  { opacity: .5; }
  100% { top: 100%; opacity: 0; }
}

.kai-snippet {
  padding: .55rem .7rem;
  background: rgba(2, 132, 199, .07);
  border: 1px solid rgba(2, 132, 199, .12);
  border-radius: 8px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .35s ease, transform .35s cubic-bezier(.16,1,.3,1);
}

.kai-snippet.is-shown {
  opacity: 1;
  transform: translateY(0);
}

.kai-snippet-text {
  font-size: .88rem;
  line-height: 1.45;
  color: var(--kai-text-primary);
}

.kai-snippet-source {
  margin-top: .3rem;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: .72rem;
  color: var(--kai-text-secondary);
  letter-spacing: .04em;
}

/* Social anchor pips — dim by default, glow when found. */
.kai-social-anchors {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.kai-social-anchors-title {
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--kai-text-secondary);
  margin-bottom: .15rem;
}

.kai-social-pip {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem .7rem;
  border: 1px solid var(--kai-border-dim);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--kai-text-secondary);
  font-size: .88rem;
  transition: all .25s ease;
}

.kai-social-pip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(100, 116, 139, .12);
  font-size: .8rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
}

.kai-social-pip.is-found {
  background: rgba(52, 211, 153, .12);
  border-color: rgba(52, 211, 153, .4);
  color: var(--kai-text-primary);
  box-shadow: 0 0 18px rgba(52, 211, 153, .22);
}

.kai-social-pip.is-found .kai-social-pip-icon {
  background: rgba(52, 211, 153, .25);
  color: var(--kai-success);
}

/* ── F3: "Is this you?" social preview card ─────────────────────── */
/* Rendered under an AI-filled social input on the confirm panel so the
   doctor can eyeball the fetched profile and confirm or reject it. */
.kai-social-preview-card {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  margin-top: .45rem;
  padding: .55rem .65rem;
  border: 1px solid var(--kai-border-dim);
  border-radius: 10px;
  background: var(--kai-bg-soft);
}
.kai-social-preview-thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #e2e8f0;
}
.kai-social-preview-body {
  flex: 1 1 auto;
  min-width: 0;
}
.kai-social-preview-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--kai-text-primary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kai-social-preview-desc {
  font-size: .76rem;
  color: var(--kai-text-secondary);
  line-height: 1.35;
  margin-top: .12rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kai-social-preview-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-top: .35rem;
}
.kai-social-preview-verify {
  font-size: .78rem;
  font-weight: 600;
  color: var(--kai-text-kai);
  text-decoration: none;
}
.kai-social-preview-verify:hover { text-decoration: underline; }
.kai-social-preview-reject {
  font-size: .76rem;
  color: var(--kai-text-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.kai-social-preview-reject:hover { color: var(--kai-text-secondary); }

/* ── F9: Research & Publications badges (h-index / pub count / link) ── */
.kai-research-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.kai-research-badge {
  display: inline-flex;
  align-items: center;
  padding: .3rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--kai-border-dim);
  background: var(--kai-bg-soft);
  font-size: .82rem;
  font-weight: 600;
  color: var(--kai-text-primary);
  white-space: nowrap;
}
.kai-research-link {
  color: var(--kai-text-kai);
  text-decoration: none;
  border-color: rgba(2, 132, 199, .35);
  background: #f0f9ff;
}
.kai-research-link:hover { background: #e0f2fe; }

/* ── F10: online-resource cards ("I also found your content online") ── */
.kai-resources-hint {
  font-size: .8rem;
  color: var(--kai-text-secondary);
  margin: 0 0 .6rem;
}
.kai-resources-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.kai-resource-card {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .6rem .7rem;
  border: 1px solid var(--kai-border-dim);
  border-radius: 12px;
  background: var(--kai-bg-soft);
  transition: border-color .15s ease, background .15s ease;
}
.kai-resource-card.is-added {
  border-color: rgba(2, 132, 199, .45);
  background: #f0f9ff;
}
.kai-resource-thumb {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: #e2e8f0;
}
.kai-resource-thumb-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: #eef2f7;
}
.kai-resource-body {
  flex: 1 1 auto;
  min-width: 0;
}
.kai-resource-title {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  color: var(--kai-text-primary);
  text-decoration: none;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kai-resource-title:hover { text-decoration: underline; }
.kai-resource-desc {
  font-size: .77rem;
  color: var(--kai-text-secondary);
  line-height: 1.35;
  margin-top: .15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kai-resource-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-top: .35rem;
  font-size: .72rem;
  color: var(--kai-text-muted);
}
.kai-resource-type {
  text-transform: capitalize;
  font-weight: 600;
  color: var(--kai-text-secondary);
}
.kai-resource-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-top: .45rem;
}
.kai-resource-add {
  font-size: .78rem;
  font-weight: 600;
  color: #fff;
  background: var(--kai-text-kai);
  border: 1px solid var(--kai-text-kai);
  border-radius: 999px;
  padding: .28rem .7rem;
  cursor: pointer;
}
.kai-resource-card.is-added .kai-resource-add {
  color: var(--kai-text-kai);
  background: #fff;
}
.kai-resource-reject {
  font-size: .76rem;
  color: var(--kai-text-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.kai-resource-reject:hover { color: var(--kai-text-secondary); }

/* ── F11: content preview modal ── */
.kai-lib-item-controls {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex: 0 0 auto;
}
.kai-lib-item-preview {
  height: 30px;
  padding: 0 .7rem;
  border-radius: 8px;
  border: 1px solid var(--kai-border-dim);
  background: #fff;
  font-size: .8rem;
  font-weight: 600;
  color: var(--kai-text-secondary);
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.kai-lib-item-preview:hover {
  background: var(--kai-bg-soft);
  color: var(--kai-text-primary);
}

.kai-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(15, 23, 42, .55);
}
.kai-preview-overlay[hidden] { display: none; }
.kai-preview-modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
}
.kai-preview-close {
  position: absolute;
  top: .55rem;
  right: .65rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, .06);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--kai-text-secondary);
  cursor: pointer;
}
.kai-preview-close:hover { background: rgba(15, 23, 42, .12); }
.kai-preview-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #eef2f7;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
}
.kai-preview-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kai-preview-thumb-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--kai-text-muted);
}
.kai-preview-body { padding: 1rem 1.2rem 1.2rem; }
.kai-preview-type {
  font-size: .76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--kai-text-kai);
}
.kai-preview-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--kai-text-primary);
  margin: .3rem 0 .15rem;
  line-height: 1.3;
}
.kai-preview-author {
  font-size: .82rem;
  color: var(--kai-text-secondary);
  margin-bottom: .5rem;
}
.kai-preview-desc {
  font-size: .9rem;
  color: var(--kai-text-secondary);
  line-height: 1.5;
  margin: .5rem 0 1rem;
}
/* F12-C2b: time-range bookmark section in the preview modal. */
.kai-preview-timerange {
  margin: 0 0 1rem;
  padding: .7rem .8rem;
  background: #f5f3ff;
  border: 1px solid #e0d9fb;
  border-radius: .5rem;
}
.kai-preview-tr-label {
  font-size: .82rem;
  font-weight: 700;
  color: #4338ca;
  margin-bottom: .5rem;
}
.kai-preview-tr-label span {
  font-weight: 500;
  color: var(--kai-text-secondary);
}
.kai-preview-tr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .5rem;
}
.kai-preview-tr-chip {
  border: 1px solid #c7d2fe;
  background: #fff;
  color: #4338ca;
  border-radius: 999px;
  padding: .15rem .55rem;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.kai-preview-tr-chip:hover { background: #eef2ff; }
.kai-preview-tr-inputs {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.kai-preview-tr-input {
  width: 4.5rem;
  padding: .3rem .45rem;
  border: 1px solid #cbd5e1;
  border-radius: .35rem;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.kai-preview-tr-dash { color: var(--kai-text-secondary); }
.kai-preview-tr-clear {
  margin-left: .25rem;
  border: none;
  background: none;
  color: #6b7280;
  font-size: .78rem;
  cursor: pointer;
  text-decoration: underline;
}
.kai-preview-tr-hint {
  margin-top: .45rem;
  font-size: .75rem;
  color: var(--kai-text-secondary);
  min-height: 1em;
}
.kai-preview-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.kai-preview-full {
  font-size: .85rem;
  font-weight: 600;
  color: var(--kai-text-kai);
  text-decoration: none;
}
.kai-preview-full:hover { text-decoration: underline; }

/* F11: inline player (YouTube iframe / hosted video) fills the media box */
.kai-preview-player {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}
/* Audio bar sits in the body, beneath the thumbnail */
.kai-preview-audio-slot:empty { display: none; }
.kai-preview-audio {
  width: 100%;
  margin: 0 0 .8rem;
}

/* ── F13-A: batch URL paste + preview cards ── */
.kai-url-textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
  line-height: 1.4;
}
.kai-url-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .5rem;
}
.kai-url-form-row .kai-hint { margin: 0; }
.kai-url-preview {
  margin-top: 1rem;
}
.kai-url-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .6rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--kai-text-secondary);
}
.kai-url-preview-controls {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.kai-url-pv-check {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: .15rem;
  cursor: pointer;
  accent-color: var(--kai-text-kai);
}
.kai-resource-card.is-disabled {
  opacity: .55;
}
.kai-url-collection-note {
  margin-bottom: .6rem;
  padding: .55rem .7rem;
  border-radius: 10px;
  border: 1px solid rgba(2, 132, 199, .3);
  background: #f0f9ff;
  font-size: .82rem;
  color: var(--kai-text-primary);
  line-height: 1.4;
}

/* ── F12-A3: transcript "mentioned at MM:SS" time chips ── */
.kai-lib-timechips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .4rem;
}
.kai-timechip {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .2rem .5rem;
  border-radius: 999px;
  border: 1px solid rgba(2, 132, 199, .35);
  background: #f0f9ff;
  color: var(--kai-text-kai);
  font-size: .72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
}
.kai-timechip:hover { background: #e0f2fe; }

/* ── F12-B: two-section smart library picker ── */
.kai-lib-section { margin-bottom: .9rem; }

/* §K14 (Feedback #6): "Add all" — select every shown item at once. */
.kai-lib-sec-actions {
  display: flex;
  justify-content: flex-end;
  margin: .15rem 0 .35rem;
}
.kai-lib-addall {
  background: rgba(2, 132, 199, .08);
  border: 1px solid var(--kai-glow-primary);
  color: var(--kai-glow-primary);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  padding: .3rem .75rem;
  border-radius: 999px;
  transition: background .15s, transform .12s;
}
.kai-lib-addall:hover { background: rgba(2, 132, 199, .16); }
.kai-lib-addall:active { transform: translateY(1px); }
.kai-lib-section-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .2rem;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 1px solid var(--kai-border-dim);
}
.kai-lib-section-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--kai-text-primary);
}
.kai-lib-section-title span {
  color: var(--kai-text-secondary);
  font-weight: 600;
}
.kai-lib-section-caret {
  color: var(--kai-text-muted);
  transition: transform .15s ease;
}
.kai-lib-section.is-collapsed .kai-lib-section-caret { transform: rotate(-90deg); }
.kai-lib-section.is-collapsed .kai-lib-section-body { display: none; }
.kai-lib-section-body { margin-top: .4rem; }

/* Animated dots while searching */
.kai-dots {
  display: inline-block;
  font-size: .55rem;
  letter-spacing: .15em;
  animation: kaiDots 1.4s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes kaiDots {
  0%, 100% { opacity: .3; }
  50%      { opacity: 1; }
}

/* Ghost / secondary button (Skip search, Edit basics) */
.kai-btn-ghost {
  background: transparent;
  border: 1px solid var(--kai-border-dim);
  color: var(--kai-text-secondary);
  font-size: .88rem;
  font-weight: 500;
  padding: .55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.kai-btn-ghost:hover {
  border-color: var(--kai-border);
  color: var(--kai-text-primary);
  background: rgba(2, 132, 199, .05);
}

/* AI-filled field accent — fades a cyan border in. Persists
   until the field is focused (user edits it). */
.kai-input.is-ai-filled {
  border-color: rgba(2, 132, 199, .55);
  box-shadow: 0 0 0 1px rgba(2, 132, 199, .15),
              0 0 18px rgba(2, 132, 199, .12);
  background: rgba(2, 132, 199, .04);
}

.kai-input.is-ai-filled:focus {
  /* Once the user edits, drop the AI accent so the standard focus
     ring shows. */
  border-color: var(--kai-border-active);
  background: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  .kai-snippet-feed::after,
  .kai-snippet,
  .kai-dots {
    animation: none;
    transition: none;
  }
  .kai-snippet { opacity: 1; transform: none; }
}

/* ══════════════════════════════════════════════════════════
 * §K4 — Step 2 structure explainer (hierarchy teaching moment)
 * ══════════════════════════════════════════════════════════ */

.kai-step-explain {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.2rem clamp(1rem, 3vw, 2rem) 4rem;
  min-height: calc(100vh - 80px);
}

.kai-explain-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  max-width: 820px;
  width: 100%;
  text-align: center;
}

.kai-explain-line {
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--kai-text-kai);
  letter-spacing: -.005em;
  line-height: 1.45;
  min-height: 2.6em;          /* prevent layout jump between beats */
  max-width: 640px;
  margin: 0;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .42s ease, transform .42s cubic-bezier(.16,1,.3,1);
}

.kai-explain-line.is-shown {
  opacity: 1;
  transform: translateY(0);
}

/* ── The hierarchy stage ──────────────────────────────── */
.kai-explain-stage {
  position: relative;
  width: 100%;
  max-width: 680px;
  /* Aspect-ratio keeps the stage square-ish so the SVG-style
     diagram doesn't squish. */
  aspect-ratio: 5 / 3;
  margin-top: .8rem;
}

.kai-explain-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Beat 1 — Space frame (outermost rectangle) */
.kai-explain-space-frame {
  position: absolute;
  inset: 4% 6%;
  border: 2px solid var(--kai-glow-primary);
  border-radius: 18px;
  box-shadow: 0 0 32px rgba(2, 132, 199, .25),
              inset 0 0 32px rgba(2, 132, 199, .08);
  background: rgba(2, 132, 199, .04);
  opacity: 0;
  transform: scale(.98);
  transition: opacity .55s ease, transform .55s cubic-bezier(.16,1,.3,1),
              box-shadow .55s ease;
}

.kai-explain-label-tl {
  position: absolute;
  top: -12px;
  left: 20px;
  background: var(--kai-bg-deep);
  padding: 0 .55rem;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--kai-glow-primary);
  text-shadow: 0 0 10px rgba(2, 132, 199, .5);
}

.kai-explain-stage[data-kai-beat="0"] .kai-explain-space-frame,
.kai-explain-stage[data-kai-beat="1"] .kai-explain-space-frame,
.kai-explain-stage[data-kai-beat="2"] .kai-explain-space-frame,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-space-frame {
  opacity: 1;
  transform: scale(1);
}

/* Beat 0 only: the Space pulses to draw the eye */
.kai-explain-stage[data-kai-beat="0"] .kai-explain-space-frame {
  animation: kaiExplainPulse 2.4s ease-in-out infinite;
}

@keyframes kaiExplainPulse {
  0%, 100% { box-shadow: 0 0 32px rgba(2, 132, 199,.25),
                          inset 0 0 32px rgba(2, 132, 199,.08); }
  50%      { box-shadow: 0 0 56px rgba(2, 132, 199,.45),
                          inset 0 0 40px rgba(2, 132, 199,.14); }
}

/* ── Beat 2 — 3 playbooks slide in from inside the Space ── */
/* §K5b (Ramy testing): redesigned the playbook layout so beat 2
   and beat 3 don't overlap. In beat 1 all 3 playbooks sit side by
   side (1/3 each). From beat 2, playbook A grows to span the left
   half of the Space and stacks vertically: title pinned to its
   top, 3 categories below it, content icons inside the middle
   category. Playbooks B and C shrink to half-height and stack on
   the right column. No more text overlaps. */
.kai-explain-pb {
  position: absolute;
  border-radius: 10px;
  border: 1.5px solid var(--kai-glow-primary);
  background: #ffffff;
  display: flex;
  align-items: flex-start;        /* title at the top */
  justify-content: flex-start;
  padding: .55rem .8rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--kai-text-primary);
  letter-spacing: -.01em;
  opacity: 0;
  transform: translateY(20px) scale(.94);
  transition: opacity .45s ease,
              transform .45s cubic-bezier(.16,1,.3,1),
              top .45s cubic-bezier(.16,1,.3,1),
              left .45s cubic-bezier(.16,1,.3,1),
              width .45s cubic-bezier(.16,1,.3,1),
              height .45s cubic-bezier(.16,1,.3,1),
              background .25s,
              box-shadow .25s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Beat 1: 3 equal columns inside the Space frame */
.kai-explain-pb-a { left: 10%;  top: 16%; width: 25%; height: 64%; }
.kai-explain-pb-b { left: 38%;  top: 16%; width: 25%; height: 64%; }
.kai-explain-pb-c { left: 66%;  top: 16%; width: 25%; height: 64%; }

.kai-explain-pb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kai-explain-stage[data-kai-beat="1"] .kai-explain-pb,
.kai-explain-stage[data-kai-beat="2"] .kai-explain-pb,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-pb {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Stagger entrance */
.kai-explain-stage[data-kai-beat="1"] .kai-explain-pb-b,
.kai-explain-stage[data-kai-beat="2"] .kai-explain-pb-b,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-pb-b { transition-delay: 120ms; }
.kai-explain-stage[data-kai-beat="1"] .kai-explain-pb-c,
.kai-explain-stage[data-kai-beat="2"] .kai-explain-pb-c,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-pb-c { transition-delay: 240ms; }

/* Beats 2 & 3: playbook A expands left half, gets the focus
   styling; B and C shrink + stack on the right column. */
.kai-explain-stage[data-kai-beat="2"] .kai-explain-pb-a,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-pb-a {
  left: 8%;
  top: 14%;
  width: 44%;
  height: 72%;
  background: rgba(2, 132, 199, .04);
  box-shadow: 0 0 18px rgba(2, 132, 199, .14);
}

.kai-explain-stage[data-kai-beat="2"] .kai-explain-pb-b,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-pb-b {
  left: 56%;
  top: 14%;
  width: 36%;
  height: 32%;
}

.kai-explain-stage[data-kai-beat="2"] .kai-explain-pb-c,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-pb-c {
  left: 56%;
  top: 54%;
  width: 36%;
  height: 32%;
}

/* ── Beat 3 — Categories nest inside playbook A ─────────── */
/* Sized + positioned so all 3 categories sit comfortably BELOW
   playbook A's title, inside playbook A's bounds (which are
   left:8% width:44% top:14% height:72% during beats 2 & 3). */
.kai-explain-cat {
  position: absolute;
  left: 12%;
  width: 36%;
  height: 10%;
  border-radius: 6px;
  border: 1px solid rgba(2, 132, 199, .45);
  background: rgba(2, 132, 199, .08);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 .55rem;
  font-size: .68rem;
  font-weight: 500;
  color: var(--kai-text-kai);
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity .35s ease, transform .35s cubic-bezier(.16,1,.3,1);
}

.kai-explain-cat-1 { top: 31%; }
.kai-explain-cat-2 { top: 46%; }
.kai-explain-cat-3 { top: 61%; }

.kai-explain-stage[data-kai-beat="2"] .kai-explain-cat,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-cat {
  opacity: 1;
  transform: translateX(0);
}

.kai-explain-stage[data-kai-beat="2"] .kai-explain-cat-2,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-cat-2 { transition-delay: 90ms; }
.kai-explain-stage[data-kai-beat="2"] .kai-explain-cat-3,
.kai-explain-stage[data-kai-beat="3"] .kai-explain-cat-3 { transition-delay: 180ms; }

/* ── Beat 4 — content icons fly in ────────────────────── */
/* Land in a horizontal row INSIDE the middle category (cat-2),
   which sits at top:46% inside playbook A (left:8% w:44%). The
   middle of cat-2 is roughly at top:51%, and we want 4 icons
   tucked into the right side of cat-2 so the "Open" / "Lap…" /
   "Robotic" labels still read on the left. */
.kai-explain-item {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid var(--kai-glow-primary);
  color: var(--kai-glow-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(2, 132, 199, .22);
  opacity: 0;
  transform: translate(0, 40px) scale(.6);
  transition: opacity .5s ease, transform .55s cubic-bezier(.34,1.4,.6,1);
}

/* Inside cat-2 (top:46% h:10% → middle ~51%). Anchor by the
   center vertically using top:48.2% (height 22px ≈ 3% of stage). */
.kai-explain-item-1 { left: 31%; top: 48.2%; }
.kai-explain-item-2 { left: 36%; top: 48.2%; }
.kai-explain-item-3 { left: 41%; top: 48.2%; }
.kai-explain-item-4 { left: 46%; top: 48.2%; }

.kai-explain-stage[data-kai-beat="3"] .kai-explain-item {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.kai-explain-stage[data-kai-beat="3"] .kai-explain-item-2 { transition-delay: 120ms; }
.kai-explain-stage[data-kai-beat="3"] .kai-explain-item-3 { transition-delay: 240ms; }
.kai-explain-stage[data-kai-beat="3"] .kai-explain-item-4 { transition-delay: 360ms; }

/* ── Controls (dots + skip / continue) ──────────────────── */
.kai-explain-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.kai-explain-dots {
  display: inline-flex;
  gap: .55rem;
  align-items: center;
}

.kai-explain-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(100, 116, 139, .25);
  cursor: pointer;
  transition: background .25s, box-shadow .25s, transform .25s;
}

.kai-explain-dot:hover {
  background: rgba(2, 132, 199, .35);
}

.kai-explain-dot.is-active {
  background: var(--kai-glow-primary);
  box-shadow: 0 0 12px rgba(2, 132, 199, .6);
  transform: scale(1.35);
}

@media (prefers-reduced-motion: reduce) {
  .kai-explain-space-frame,
  .kai-explain-pb,
  .kai-explain-cat,
  .kai-explain-item,
  .kai-explain-line {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

@media (max-width: 720px) {
  .kai-explain-line { font-size: 1.1rem; }
  .kai-explain-stage { aspect-ratio: 5 / 4; }
  .kai-explain-pb { font-size: .7rem; }
  .kai-explain-cat { font-size: .58rem; height: 8%; }
}

/* ══════════════════════════════════════════════════════════
 * §K5 — Step 3 content-source picker (4 cards)
 * ══════════════════════════════════════════════════════════ */

.kai-step-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem clamp(1rem, 3vw, 2rem) 4rem;
  min-height: calc(100vh - 80px);
}

.kai-step-picker .kai-explain-stack { max-width: 980px; }

.kai-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
  width: 100%;
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .kai-picker-grid { grid-template-columns: 1fr; }
}

/* Onboarding reflow (Ramy 2026-06-24): hub sources stacked vertically. */
.kai-picker-grid--stacked { grid-template-columns: 1fr; }

/* "(we found N related to you)" badge on the Library card title. */
.kai-picker-badge {
  margin-left: .4rem;
  font-family: 'Inter', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  color: var(--kai-glow-primary);
  letter-spacing: 0;
}

.kai-picker-card {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "icon title arrow"
    "icon desc  arrow";
  gap: .1rem .9rem;
  align-items: center;
  padding: 1.4rem 1.4rem 1.4rem 1.2rem;
  background: var(--kai-bg-card);
  border: 1px solid var(--kai-border-dim);
  border-radius: 16px;
  text-align: left;
  cursor: pointer;
  color: var(--kai-text-primary);
  font: inherit;
  /* Entrance state — JS toggles .is-in after a stagger */
  opacity: 0;
  transform: translateY(14px) scale(.985);
  transition:
    opacity .45s ease,
    transform .45s cubic-bezier(.16,1,.3,1),
    border-color .2s,
    background .2s,
    box-shadow .2s;
}

.kai-picker-card.is-in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.kai-picker-card:hover {
  border-color: var(--kai-border-active);
  background: rgba(2, 132, 199, .05);
  box-shadow: 0 0 28px rgba(2, 132, 199, .12),
              0 6px 18px rgba(15, 23, 42, 0.10);
}

.kai-picker-card:hover .kai-picker-arrow {
  transform: translateX(4px);
  color: var(--kai-glow-primary);
}

.kai-picker-card:active {
  transform: scale(.99);
}

.kai-picker-card.is-going {
  opacity: .55;
  pointer-events: none;
}

.kai-picker-icon {
  grid-area: icon;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(2, 132, 199, .1);
  color: var(--kai-glow-primary);
  border: 1px solid rgba(2, 132, 199, .25);
  box-shadow: inset 0 0 18px rgba(2, 132, 199, .08);
  transition: background .2s, color .2s, box-shadow .2s;
}

.kai-picker-card:hover .kai-picker-icon {
  background: rgba(2, 132, 199, .18);
  box-shadow: inset 0 0 22px rgba(2, 132, 199, .18),
              0 0 18px rgba(2, 132, 199, .18);
}

.kai-picker-title {
  grid-area: title;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--kai-text-primary);
}

.kai-picker-desc {
  grid-area: desc;
  font-size: .9rem;
  line-height: 1.4;
  color: var(--kai-text-secondary);
  margin-top: .15rem;
}

.kai-picker-arrow {
  grid-area: arrow;
  align-self: center;
  font-size: 1.4rem;
  color: var(--kai-text-secondary);
  transition: transform .2s, color .2s;
}

.kai-picker-hint {
  margin: 1.1rem 0 0;
  font-size: .82rem;
  color: var(--kai-text-muted);
  letter-spacing: .01em;
}

@media (prefers-reduced-motion: reduce) {
  .kai-picker-card { opacity: 1; transform: none; transition: none; }
}

/* ══════════════════════════════════════════════════════════
 * §K6 — Step 3 Library inline source
 * ══════════════════════════════════════════════════════════ */

/* The library panel reuses .kai-step-form (sidebar + actions) so
   Kai's voice sits left and the search UI takes the right column. */

.kai-actions-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Search bar ───────────────────────────────────────── */
.kai-lib-searchbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .65rem .85rem;
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border);
  border-radius: 12px;
  transition: border-color .18s, box-shadow .18s;
}

.kai-lib-searchbar:focus-within {
  border-color: var(--kai-border-active);
  box-shadow: 0 0 0 4px var(--kai-glow-dim);
}

.kai-lib-search-icon {
  display: flex;
  align-items: center;
  color: var(--kai-text-secondary);
  flex-shrink: 0;
}

.kai-lib-search {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 1rem;
  color: var(--kai-text-primary);
  padding: .3rem 0;
}

.kai-lib-search::placeholder {
  color: var(--kai-text-muted);
}

.kai-lib-search-spinner {
  display: inline-flex;
  align-items: center;
  color: var(--kai-glow-primary);
  font-size: .55rem;
}

/* ── Result list ──────────────────────────────────────── */
.kai-lib-results {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-height: 56vh;
  overflow-y: auto;
  padding-right: .25rem;
}

.kai-lib-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--kai-text-secondary);
  font-size: .9rem;
  border: 1px dashed var(--kai-border-dim);
  border-radius: 10px;
  background: var(--kai-bg-soft);
}

.kai-lib-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: .85rem;
  align-items: center;
  padding: .7rem .85rem;
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border-dim);
  border-radius: 10px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.kai-lib-item:hover {
  border-color: var(--kai-border);
  background: var(--kai-bg-soft);
}

.kai-lib-item.is-selected {
  border-color: var(--kai-border-active);
  background: rgba(2, 132, 199, .04);
  box-shadow: 0 0 0 1px rgba(2, 132, 199, .2),
              0 0 16px rgba(2, 132, 199, .08);
}

.kai-lib-item-type {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  color: var(--kai-glow-primary);
}

.kai-lib-item-glyph {
  font-size: 1.35rem;
  line-height: 1;
}

.kai-lib-item-type-label {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--kai-text-secondary);
}

.kai-lib-item-body {
  min-width: 0;
}

.kai-lib-item-title {
  font-weight: 600;
  color: var(--kai-text-primary);
  font-size: .95rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kai-lib-item-meta {
  font-size: .78rem;
  color: var(--kai-text-secondary);
  margin-top: .2rem;
}

.kai-lib-item-desc {
  font-size: .82rem;
  color: var(--kai-text-secondary);
  margin-top: .35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.kai-lib-item-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--kai-border);
  background: var(--kai-bg-panel);
  color: var(--kai-glow-primary);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
  flex-shrink: 0;
}

.kai-lib-item-toggle:hover {
  background: rgba(2, 132, 199, .08);
  border-color: var(--kai-glow-primary);
  transform: scale(1.05);
}

.kai-lib-item.is-selected .kai-lib-item-toggle {
  background: var(--kai-glow-primary);
  border-color: var(--kai-glow-primary);
  color: #ffffff;
}

.kai-lib-item.is-selected .kai-lib-item-toggle:hover {
  background: var(--kai-glow-soft);
  border-color: var(--kai-glow-soft);
}

/* ── Sticky bottom counter / CTA ──────────────────────── */
.kai-lib-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: .8rem;
  border-top: 1px solid var(--kai-border-dim);
  margin-top: .3rem;
  gap: 1rem;
}

.kai-lib-counter {
  display: inline-flex;
  align-items: baseline;
  gap: .35rem;
  color: var(--kai-text-secondary);
  font-size: .95rem;
  transition: color .2s;
}

.kai-lib-counter strong {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--kai-text-primary);
}

.kai-lib-counter.is-active {
  color: var(--kai-glow-primary);
}

.kai-lib-counter.is-active strong {
  color: var(--kai-glow-primary);
}

.kai-lib-counter-label {
  letter-spacing: .005em;
}

/* §K8b (Ramy testing): flipped the footer CTA hierarchy.
 * Big primary cyan button = "Pick another source" (the safe,
 * obvious continuation since most users want to keep adding).
 * Quiet text link below = "done adding content" (the rarer
 * terminal action — has to be sought out).
 *
 * Users were hitting Continue assuming it meant "add more"; this
 * stops the accidental commit. */
.kai-source-cta {
  /* §K9b (Ramy testing): the small "done adding content" was
     invisibly tucked under the big CTA. Side-by-side makes it
     obvious it exists. The done button is still styled as the
     quieter of the two so users still read "Pick another
     source" as the primary inviting action. */
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Left-pointing arrow variant for "Pick another source" — the
 * existing .kai-cta-arrow always slides right on hover, this one
 * slides left so the affordance reads as "go back". */
.kai-cta-arrow-l {
  display: inline-block;
  transition: transform .15s;
}

.kai-cta-button:hover:not(:disabled) .kai-cta-arrow-l {
  transform: translateX(-3px);
}

/* §K9b: small outlined-button look (was a text link before) so
 * users see it as a clickable affordance — but still visually
 * lighter than the prominent cyan CTA next to it. */
.kai-done-link {
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border);
  color: var(--kai-text-secondary);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  padding: .55rem 1rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s, transform .12s;
}

.kai-done-link:hover:not(:disabled) {
  color: var(--kai-glow-primary);
  border-color: var(--kai-glow-primary);
  background: rgba(2, 132, 199, .06);
}

.kai-done-link:active:not(:disabled) {
  transform: translateY(1px);
}

.kai-done-link:disabled {
  opacity: .55;
  cursor: not-allowed;
}

/* §K13 (Ramy testing 2026-06-22): every content screen now shows the
 * SAME three-button row under its sections so users are never confused
 * or trapped:
 *   [← Pick another source]  [I'm done — publish]  [done adding content →]
 * - "done adding content" is the loud forward CTA and is ALWAYS clickable
 *   (no more faded/disabled state).
 * - "I'm done — publish my Space" (green) is the persistent escape that
 *   publishes immediately — moved out of the easy-to-miss top bar. */
.kai-back-link {
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border);
  color: var(--kai-text-secondary);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  padding: .55rem 1rem;
  border-radius: 999px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: color .15s, border-color .15s, background .15s, transform .12s;
}
.kai-back-link:hover:not(:disabled) {
  color: var(--kai-glow-primary);
  border-color: var(--kai-glow-primary);
  background: rgba(2, 132, 199, .06);
}
.kai-back-link:hover:not(:disabled) .kai-cta-arrow-l { transform: translateX(-3px); }
.kai-back-link:active:not(:disabled) { transform: translateY(1px); }

.kai-done-publish {
  background: #059669;
  border: none;
  color: #ffffff;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  padding: .72rem 1.25rem;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(5, 150, 105, .25);
  transition: filter .15s, transform .12s, box-shadow .2s;
}
.kai-done-publish:hover:not(:disabled) {
  filter: brightness(1.07);
  box-shadow: 0 4px 16px rgba(5, 150, 105, .35);
}
.kai-done-publish:active:not(:disabled) { transform: translateY(1px); }
.kai-done-publish:disabled { opacity: .65; cursor: progress; }

/* Size the loud forward CTA to sit level with its quieter siblings in
 * the footer row (the standalone .kai-cta-button has a big margin-top). */
.kai-source-cta .kai-cta-button {
  margin-top: 0;
  font-size: .92rem;
  padding: .72rem 1.4rem;
}

@media (max-width: 720px) {
  .kai-lib-item {
    grid-template-columns: 48px 1fr auto;
    gap: .6rem;
  }
  .kai-lib-item-glyph { font-size: 1.1rem; }
  .kai-lib-item-toggle { width: 32px; height: 32px; font-size: 1.05rem; }
  .kai-lib-footer { flex-direction: column; align-items: stretch; gap: .8rem; }
  .kai-lib-footer .kai-cta-button { width: 100%; justify-content: center; }
  .kai-source-cta { align-items: stretch; }
  .kai-done-link { text-align: center; }
}

/* ══════════════════════════════════════════════════════════
 * §K7 — Step 3 Browse Spaces inline source
 * ══════════════════════════════════════════════════════════ */

.kai-browse-back-row {
  display: inline-flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.kai-bspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .9rem;
  margin-top: .4rem;
}

@media (max-width: 480px) {
  .kai-bspace-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

.kai-bspace-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: 1rem .7rem .8rem;
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border-dim);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color .18s, background .18s, box-shadow .18s, transform .12s;
}

.kai-bspace-card:hover {
  border-color: var(--kai-border-active);
  background: rgba(2, 132, 199, .04);
  box-shadow: 0 0 18px rgba(2, 132, 199, .12),
              0 4px 14px rgba(15, 23, 42, .06);
}

.kai-bspace-card:active {
  transform: scale(.985);
}

.kai-bspace-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--kai-bg-soft);
  border: 1px solid var(--kai-border-dim);
}

.kai-bspace-photo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--kai-glow-primary);
  background: rgba(2, 132, 199, .08);
  border-color: var(--kai-border);
}

.kai-bspace-name {
  font-weight: 600;
  font-size: .92rem;
  color: var(--kai-text-primary);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kai-bspace-specialty {
  font-size: .76rem;
  color: var(--kai-text-secondary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kai-bspace-count {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: .68rem;
  letter-spacing: .04em;
  color: var(--kai-text-muted);
  margin-top: .15rem;
}

/* Chosen-space hero strip above the content list */
.kai-browse-chosen-space {
  margin-top: .2rem;
  margin-bottom: .4rem;
}

.kai-browse-chosen-meta {
  font-size: .9rem;
  color: var(--kai-text-secondary);
  padding: .6rem .85rem;
  background: var(--kai-bg-soft);
  border: 1px solid var(--kai-border-dim);
  border-radius: 10px;
}

.kai-browse-chosen-meta strong {
  color: var(--kai-text-primary);
}

/* §K7b: borrow-a-playbook list ─────────────────────────── */
.kai-bpb-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-height: 56vh;
  overflow-y: auto;
  padding-right: .25rem;
}

.kai-bpb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem .9rem;
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border-dim);
  border-radius: 10px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.kai-bpb-row:hover {
  border-color: var(--kai-border);
  background: var(--kai-bg-soft);
}

.kai-bpb-row.is-borrowed {
  border-color: var(--kai-success);
  background: rgba(5, 150, 105, .04);
  box-shadow: 0 0 0 1px rgba(5, 150, 105, .15);
}

.kai-bpb-row-head {
  min-width: 0;
  flex: 1;
}

.kai-bpb-row-title {
  font-weight: 600;
  font-size: .95rem;
  color: var(--kai-text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kai-bpb-row-meta {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: .7rem;
  letter-spacing: .04em;
  color: var(--kai-text-secondary);
  margin-top: .25rem;
}

.kai-bpb-borrow-btn {
  border: 1px solid var(--kai-glow-primary);
  background: rgba(2, 132, 199, .07);
  color: var(--kai-glow-primary);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  padding: .45rem .85rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, transform .12s;
}

.kai-bpb-borrow-btn:hover {
  background: rgba(2, 132, 199, .14);
}

.kai-bpb-row.is-borrowed .kai-bpb-borrow-btn {
  background: var(--kai-success);
  border-color: var(--kai-success);
  color: #ffffff;
}

.kai-bpb-row.is-borrowed .kai-bpb-borrow-btn:hover {
  filter: brightness(1.06);
}

/* ── §K7c: unified Browse-Space view ───────────────────── */

.kai-browse-space-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.kai-browse-space-search {
  margin-top: .2rem;
}

.kai-browse-section {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.kai-browse-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 .2rem;
}

.kai-browse-section-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.005em;
  color: var(--kai-text-primary);
  margin: 0;
}

.kai-browse-section-hint {
  font-size: .78rem;
  color: var(--kai-text-secondary);
}

/* Tighten the bpb list when it shares a wrap with the content
   list so the page doesn't sprawl. */
.kai-browse-space-wrap .kai-bpb-list {
  max-height: 32vh;
}

.kai-browse-space-wrap .kai-lib-results {
  max-height: 38vh;
}

/* ══════════════════════════════════════════════════════════
 * §K8 — Step 3 Import-from-URL inline source
 * ══════════════════════════════════════════════════════════ */

.kai-url-form {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

/* URL searchbar gets an inline Import button on the right edge. */
.kai-url-bar {
  padding: .55rem .65rem;
  gap: .55rem;
}

.kai-url-bar .kai-lib-search {
  font-size: 1rem;
  min-width: 0; /* allow shrink so the button stays visible */
}

.kai-url-import-btn {
  padding: .55rem 1.05rem;
  font-size: .92rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.kai-url-import-btn:disabled {
  opacity: .7;
  cursor: progress;
}

/* Queue list — same row chrome as library/browse results so it
   reads as part of the same family, but the right-side toggle is
   replaced with a status pill. */
.kai-url-queue {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: .25rem;
}

.kai-url-row {
  border-color: var(--kai-border-dim);
}

.kai-url-row.is-imported {
  border-color: rgba(5, 150, 105, .35);
  background: rgba(5, 150, 105, .04);
}

.kai-url-row.is-failed {
  border-color: rgba(220, 38, 38, .35);
  background: rgba(220, 38, 38, .04);
}

.kai-url-status {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: .72rem;
  letter-spacing: .04em;
  padding: .25rem .55rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  background: rgba(5, 150, 105, .12);
  color: var(--kai-success);
  border: 1px solid rgba(5, 150, 105, .35);
}

.kai-url-row.is-failed .kai-url-status {
  background: rgba(220, 38, 38, .1);
  color: var(--kai-error);
  border-color: rgba(220, 38, 38, .35);
}

/* ══════════════════════════════════════════════════════════
 * §K9 — Step 3 Upload Your Own inline source
 * ══════════════════════════════════════════════════════════ */

/* §K9b: classic parity — visibility (HIPAA gate) + AI-mode picker. */
.kai-upload-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: .9rem;
}

@media (max-width: 720px) {
  .kai-upload-options { grid-template-columns: 1fr; }
}

/* Reflow (Ramy 2026-06-24): upload screen — visibility beside the drop zone so
   the whole step fits one viewport without scrolling. */
.kai-upload-grid {
  display: grid;
  grid-template-columns: minmax(250px, 330px) 1fr;
  gap: 1.2rem;
  align-items: start;
  width: 100%;
}
.kai-upload-grid > * { min-width: 0; }
.kai-upload-main { display: flex; flex-direction: column; gap: .6rem; }
@media (max-width: 760px) {
  .kai-upload-grid { grid-template-columns: 1fr; }
}

/* Compact the upload panel chrome so it doesn't overflow the viewport. */
#kaiPanel3Upload .kai-actions { gap: .7rem; }
#kaiPanel3Upload .kai-avatar { width: 60px; height: 60px; }
#kaiPanel3Upload .kai-drop-zone { padding: 1.4rem 1.5rem; }
#kaiPanel3Upload .kai-option-card { margin: 0; }

.kai-option-card {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: 1rem 1.1rem;
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border);
  border-radius: 12px;
}

.kai-option-card .kai-label {
  /* Reuse the form label style. The * marker keeps the
     "required" affordance consistent with Step 1. */
}

.kai-radio {
  display: flex;
  gap: .55rem;
  align-items: flex-start;
  padding: .5rem .6rem;
  border: 1px solid var(--kai-border-dim);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.kai-radio:hover {
  border-color: var(--kai-border);
  background: var(--kai-bg-soft);
}

.kai-radio input[type="radio"] {
  margin-top: .2rem;
  accent-color: var(--kai-glow-primary);
}

.kai-radio strong {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  color: var(--kai-text-primary);
  line-height: 1.3;
}

.kai-radio .kai-hint {
  display: block;
  margin-top: .15rem;
}

.kai-drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: 2.4rem 1.5rem;
  background: var(--kai-bg-soft);
  border: 2px dashed var(--kai-border);
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s, transform .12s;
}

/* §K9b: when no visibility chosen yet, the drop zone is locked. */
.kai-drop-zone.is-disabled {
  opacity: .55;
  cursor: not-allowed;
  background: var(--kai-bg-soft);
  border-style: dotted;
}

.kai-drop-zone.is-disabled:hover { transform: none; border-color: var(--kai-border); }

.kai-drop-zone:hover,
.kai-drop-zone:focus-within {
  border-color: var(--kai-border-active);
  background: rgba(2, 132, 199, .05);
}

.kai-drop-zone.is-dragover {
  border-color: var(--kai-glow-primary);
  background: rgba(2, 132, 199, .10);
  box-shadow: 0 0 0 4px var(--kai-glow-dim);
  transform: scale(1.005);
}

.kai-drop-icon {
  color: var(--kai-glow-primary);
  opacity: .85;
}

.kai-drop-zone:hover .kai-drop-icon,
.kai-drop-zone.is-dragover .kai-drop-icon {
  opacity: 1;
}

.kai-drop-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--kai-text-primary);
  letter-spacing: -.005em;
}

.kai-drop-hint {
  font-size: .82rem;
  color: var(--kai-text-secondary);
}

/* Upload queue — same outer frame as the URL queue. */
.kai-upload-queue {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-height: 38vh;
  overflow-y: auto;
  padding-right: .25rem;
}

/* Per-row state coloring + progress bar. */
.kai-up-row { border-color: var(--kai-border-dim); }

.kai-up-row.is-presigning,
.kai-up-row.is-uploading,
.kai-up-row.is-finalizing {
  border-color: rgba(2, 132, 199, .35);
  background: rgba(2, 132, 199, .03);
}

.kai-up-row.is-uploaded {
  border-color: rgba(5, 150, 105, .35);
  background: rgba(5, 150, 105, .04);
}

.kai-up-row.is-failed {
  border-color: rgba(220, 38, 38, .35);
  background: rgba(220, 38, 38, .04);
}

.kai-up-progress {
  position: relative;
  margin-top: .45rem;
  height: 4px;
  border-radius: 999px;
  background: var(--kai-border-dim);
  overflow: hidden;
}

.kai-up-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, var(--kai-glow-primary), var(--kai-glow-soft));
  border-radius: 999px;
  transition: width .15s linear;
}

.kai-up-row.is-uploaded .kai-up-progress-bar {
  background: var(--kai-success);
}

.kai-up-row.is-failed .kai-up-progress-bar {
  background: var(--kai-error);
  width: 100%;
  opacity: .35;
}

/* Status pill — reuses .kai-url-status with the .kai-up-status
   modifier handling the in-flight states. */
.kai-up-row.is-presigning .kai-up-status,
.kai-up-row.is-uploading .kai-up-status,
.kai-up-row.is-finalizing .kai-up-status {
  background: rgba(2, 132, 199, .12);
  color: var(--kai-glow-primary);
  border-color: rgba(2, 132, 199, .35);
}

.kai-up-row.is-uploaded .kai-up-status {
  background: rgba(5, 150, 105, .12);
  color: var(--kai-success);
  border-color: rgba(5, 150, 105, .35);
}

.kai-up-row.is-failed .kai-up-status {
  background: rgba(220, 38, 38, .12);
  color: var(--kai-error);
  border-color: rgba(220, 38, 38, .35);
}

/* ══════════════════════════════════════════════════════════
 * §K9c — Inline AI processing screen (process_now mode)
 * ══════════════════════════════════════════════════════════ */

.kai-pr-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .6rem .9rem;
  background: var(--kai-bg-soft);
  border: 1px solid var(--kai-border-dim);
  border-radius: 10px;
  font-size: .9rem;
  color: var(--kai-text-secondary);
}

.kai-pr-summary strong {
  color: var(--kai-text-primary);
  font-weight: 700;
}

.kai-pr-elapsed {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .82rem;
  color: var(--kai-text-secondary);
}

.kai-pr-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  max-height: 56vh;
  overflow-y: auto;
  padding-right: .25rem;
}

.kai-pr-row {
  background: var(--kai-bg-panel);
  border: 1px solid var(--kai-border-dim);
  border-radius: 12px;
  padding: .8rem 1rem;
  transition: border-color .15s, background .15s;
}

.kai-pr-row.is-started {
  border-color: rgba(2, 132, 199, .35);
  background: rgba(2, 132, 199, .03);
}

.kai-pr-row.is-done {
  border-color: rgba(5, 150, 105, .35);
  background: rgba(5, 150, 105, .04);
}

.kai-pr-row.is-failed {
  border-color: rgba(220, 38, 38, .35);
  background: rgba(220, 38, 38, .04);
}

.kai-pr-head {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.kai-pr-glyph {
  font-size: 1.15rem;
  width: 32px;
  text-align: center;
  color: var(--kai-glow-primary);
}

.kai-pr-info { flex: 1; min-width: 0; }

.kai-pr-name {
  font-weight: 600;
  color: var(--kai-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.kai-pr-meta {
  font-size: .8rem;
  color: var(--kai-text-secondary);
  text-transform: capitalize;
}

.kai-pr-state {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
  padding: .25rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--kai-border-dim);
  background: var(--kai-bg-soft);
  color: var(--kai-text-secondary);
  white-space: nowrap;
}

.kai-pr-row.is-started .kai-pr-state {
  background: rgba(2, 132, 199, .12);
  color: var(--kai-glow-primary);
  border-color: rgba(2, 132, 199, .35);
}

.kai-pr-row.is-done .kai-pr-state {
  background: rgba(5, 150, 105, .12);
  color: var(--kai-success);
  border-color: rgba(5, 150, 105, .35);
}

.kai-pr-row.is-failed .kai-pr-state {
  background: rgba(220, 38, 38, .12);
  color: var(--kai-error);
  border-color: rgba(220, 38, 38, .35);
}

.kai-pr-pipes {
  margin: .65rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .35rem .85rem;
}

.kai-pr-pipe {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .82rem;
  color: var(--kai-text-secondary);
}

.kai-pr-tick {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--kai-border);
  position: relative;
  background: var(--kai-bg-soft);
  flex-shrink: 0;
}

.kai-pr-pipe.is-done .kai-pr-tick {
  background: var(--kai-success);
  border-color: var(--kai-success);
}

.kai-pr-pipe.is-done .kai-pr-tick::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  width: 5px;
  height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}

.kai-pr-pipe.is-done .kai-pr-pipe-label {
  color: var(--kai-text-primary);
}

.kai-pr-msg {
  margin-top: .6rem;
  font-size: .82rem;
  color: var(--kai-text-secondary);
  opacity: 0;
  transition: opacity .15s;
  font-style: italic;
}

.kai-pr-msg.is-shown { opacity: 1; }

.kai-pr-note {
  font-size: .82rem;
  color: var(--kai-text-secondary);
  flex: 1;
}

/* §K10b: skip-state Continue on the processing screen — visible
 * and clickable but quieter than the primary gradient, so the
 * default read is "watch Kai work", with leaving always possible.
 * On all_complete the class drops and the button reverts to the
 * full primary treatment. */
.kai-cta-button.is-skip {
  background: var(--kai-bg-panel);
  color: var(--kai-glow-primary);
  box-shadow: none;
  border: 1px solid rgba(2, 132, 199, .45);
  font-weight: 600;
}

/* Reflow (Ramy 2026-06-24): faded "Add items" primary when nothing is
   selected — the standalone Back button stays the way out. */
.kai-cta-button.is-faded {
  opacity: .45;
  cursor: default;
  box-shadow: none;
}

.kai-cta-button.is-skip:hover:not(:disabled) {
  background: rgba(2, 132, 199, .06);
  box-shadow: none;
}

.kai-hint {
  font-size: .78rem;
  color: var(--kai-text-muted);
}

/* Per-field chip validation error (e.g. invalid "Other emails" entry). */
.kai-chip-err {
  margin-top: .35rem;
  font-size: .78rem;
  color: #dc2626;
}

.kai-error {
  background: rgba(248, 113, 113, .08);
  border: 1px solid rgba(248, 113, 113, .35);
  color: var(--kai-error);
  padding: .65rem .9rem;
  border-radius: 8px;
  font-size: .9rem;
}

.kai-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: .6rem;
  border-top: 1px solid var(--kai-border-dim);
}

.kai-form-step-label {
  font-size: .8rem;
  letter-spacing: .04em;
  color: var(--kai-text-secondary);
}

/* On wider screens give the form pane a comfortable max-width. */
@media (min-width: 1280px) {
  .kai-actions { max-width: 720px; }
}

/* ── Step-form responsive collapse ─────────────────── */
@media (max-width: 999px) {
  .kai-step-form {
    grid-template-columns: 1fr;
    gap: 1.4rem;
    padding-top: 1.6rem;
  }
  .kai-side {
    position: static;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 1rem;
    padding: 1rem 1.2rem;
  }
  .kai-side .kai-avatar {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
  }
  .kai-side-name {
    display: none;
  }
  .kai-side-dialogue { margin-top: 0; gap: .35rem; }
  .kai-side-dialogue .kai-dialogue {
    font-size: .95rem;
  }
  .kai-side-dialogue .kai-dialogue:first-child {
    font-size: 1rem;
  }
  .kai-dialogue-feedback {
    border-top: 0;
    padding-top: 0;
    margin-top: .25rem;
  }
}

/* ── Reduced motion ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .kai-avatar,
  .kai-avatar.is-speaking,
  .kai-avatar.is-thinking,
  .kai-cta-button,
  .kai-panel-enter,
  .kai-panel-exit {
    animation: none;
    transition: none;
  }
  .kai-cta-button {
    opacity: 1;
    transform: none;
  }
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .kai-topbar {
    padding: .9rem 1rem;
    gap: .8rem;
    flex-wrap: wrap;
  }
  .kai-topbar-classic {
    font-size: .75rem;
    padding: .3rem .55rem;
  }
  .kai-avatar-lg {
    width: 112px;
    height: 112px;
  }
  .kai-dialogue {
    font-size: 1.2rem;
  }
  .kai-dialogue:first-child {
    font-size: 1.4rem;
  }
}

/* ── Confirm-step profile photo uploader ──────────────────────────── */
.kai-photo-field .kai-photo-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
/* §K13: a short lead so the photo step reads as a clear ask, not an
 * optional afterthought. */
.kai-photo-lead {
  margin: .15rem 0 .7rem;
  font-size: .85rem;
  color: var(--kai-text-secondary);
  line-height: 1.45;
}
.kai-photo-preview {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px dashed var(--kai-border);
  background: var(--kai-bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease;
}
.kai-photo-preview:hover { border-color: var(--kai-border-active); }
.kai-photo-preview .kai-photo-placeholder {
  font-size: 1.6rem;
  line-height: 1;
}
.kai-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.kai-photo-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}
.kai-photo-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--kai-text-muted);
}

/* §K13 (Ramy testing 2026-06-22): doctors reported "no profile picture
 * upload during onboarding" because the control was a tiny ghost button.
 * The prominent variant makes it a large, obviously-clickable circular
 * drop-target with an explicit call to action + a real upload button. */
.kai-photo-field-prominent .kai-photo-preview {
  width: 116px;
  height: 116px;
  border-width: 2.5px;
  border-color: var(--kai-glow-primary);
  background: rgba(2, 132, 199, .05);
  flex-direction: column;
  gap: .3rem;
}
.kai-photo-field-prominent .kai-photo-preview:hover {
  background: rgba(2, 132, 199, .1);
}
.kai-photo-field-prominent .kai-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  color: var(--kai-glow-primary);
  font-size: 1rem;
}
.kai-photo-field-prominent .kai-photo-cta {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .01em;
  text-align: center;
  line-height: 1.15;
  max-width: 88px;
}
.kai-photo-field-prominent .kai-photo-btn {
  background: var(--kai-glow-primary);
  border: none;
  color: #fff;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  padding: .6rem 1.2rem;
  border-radius: 999px;
  transition: filter .15s, transform .12s;
}
.kai-photo-field-prominent .kai-photo-btn:hover { filter: brightness(1.07); }
.kai-photo-field-prominent .kai-photo-btn:active { transform: translateY(1px); }

/* Reflow (Ramy 2026-06-24): review & remove duplicates step (before organize). */
.kai-dedup-list {
  width: 100%; max-width: 720px; margin: 0 auto; text-align: left;
  max-height: 48vh; overflow-y: auto;
}
.kai-dedup-group {
  border: 1px solid #fde68a; background: #fffbeb; border-radius: 10px;
  padding: .5rem .6rem; margin: .5rem 0;
}
.kai-dedup-uniques { margin: .5rem 0; }
.kai-dedup-group-head {
  font-size: .8rem; font-weight: 700; color: #92400e; text-transform: uppercase;
  letter-spacing: .03em; margin: .2rem 0 .35rem;
}
.kai-dedup-uniques .kai-dedup-group-head { color: #64748b; }
.kai-dedup-item {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem;
  border-radius: 8px; cursor: pointer;
}
.kai-dedup-item:hover { background: rgba(2, 132, 199, .05); }
.kai-dedup-item.is-removing { opacity: .6; }
.kai-dedup-item.is-removing .kai-dedup-title { text-decoration: line-through; }
.kai-dedup-cb { width: 18px; height: 18px; flex-shrink: 0; cursor: pointer; }
.kai-dedup-main { flex: 1; min-width: 0; }
.kai-dedup-title {
  font-size: .92rem; font-weight: 600; color: #1e293b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kai-dedup-meta { font-size: .75rem; color: #64748b; }
.kai-dedup-tag {
  flex-shrink: 0; font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; padding: 1px 7px; border-radius: 5px;
  background: #f1f5f9; color: #64748b;
}
