/* ═══════════════════════════════════════════════════════════════════════════
   SageSchema AI — Main Stylesheet
   HubSpot official brand palette (Partner Brand Guidelines 2026): Orange #FF4800, Cream #F8F5EE, Neutral #141414, + secondary (Sage/Teal/Magenta/Pink/Lavender). Type: Lexend Deca.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* HubSpot official brand palette (Partner Brand Guidelines 2026) */
  --hs-orange: #FF4800;        /* HubSpot Orange — hero */
  --hs-orange-dark: #e03f00;
  --hs-orange-light: #fff0ea;
  --hs-cream: #F8F5EE;         /* HubSpot Cream — light bg */
  --hs-neutral: #141414;       /* HubSpot Neutral — near-black text */
  /* Secondary palette */
  --hs-sage: #B9CDBE;
  --hs-purple: #F9F5FF;
  --hs-pink: #FCC3DC;
  --hs-lavender: #D6C2D9;
  --hs-magenta: #46062B;
  --hs-teal: #042729;

  /* Back-compat aliases (older rules reference these) */
  --hs-blue: #042729;          /* map legacy 'blue' -> HubSpot Teal */
  --hs-blue-dark: #021a1b;
  --hs-blue-light: #eaf1f0;
  --hs-navy: #141414;
  --hs-navy-light: #2b2b2b;
  --hs-green: #B9CDBE;
  --hs-green-light: #eef4ef;
  --hs-yellow: #F5C518;
  --hs-red: #F2545B;

  /* Neutrals tuned warm to sit on cream */
  --grey-50: #F8F5EE;
  --grey-100: #F1EEE6;
  --grey-200: #E6E2D8;
  --grey-300: #CFC9BC;
  --grey-400: #9A9488;
  --grey-500: #6B665C;
  --grey-600: #4a4640;
  --grey-700: #3a3630;
  --grey-900: #141414;

  --font-primary: 'Lexend Deca', 'Lexend', system-ui, sans-serif;
  --font-body: 'Lexend Deca', 'Lexend', system-ui, sans-serif;

  /* Rounded-square 'hub' language — slightly larger radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 3px rgba(20,20,20,.06), 0 1px 2px rgba(20,20,20,.04);
  --shadow-md: 0 4px 12px rgba(20,20,20,.08), 0 2px 4px rgba(20,20,20,.04);
  --shadow-lg: 0 12px 40px rgba(20,20,20,.10), 0 4px 12px rgba(20,20,20,.06);
  --shadow-orange: 0 4px 20px rgba(255,72,0,.28);

  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--grey-50);
  color: var(--grey-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── TOP NAV ──────────────────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: white;
  border-bottom: 1px solid var(--grey-200);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 600px) {
  .topnav {
    height: 72px; /* Taller header on mobile for status bar / notch safe-areas */
    padding-top: env(safe-area-inset-top, 6px); /* Native notch safe-area support */
  }
}

.topnav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon { width: 36px; height: 36px; border-radius: 8px; }

.brand-name {
  font-family: var(--font-primary);
  font-size: 1.1rem;
  color: var(--grey-900);
  letter-spacing: -.02em;
}

.brand-name strong { color: var(--hs-orange); }

.nav-badge {
  margin-left: 4px;
  padding: 3px 10px;
  background: var(--hs-orange-light);
  color: var(--hs-orange-dark);
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.nav-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: none;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 500;
  color: var(--grey-700);
  cursor: pointer;
  transition: all .15s;
}

.btn-ghost svg { width: 16px; height: 16px; }
.btn-ghost:hover { background: var(--grey-100); border-color: var(--grey-300); color: var(--grey-900); }

/* ── HERO ─────────────────────────────────────────────────────────────────── */
.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 80px;
  padding: 80px 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.hero-content { flex: 1; max-width: 560px; }

.hero-eyebrow {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.pill-orange { background: var(--hs-orange-light); color: var(--hs-orange-dark); }
.pill-grey { background: var(--grey-100); color: var(--grey-500); }

.hero-title {
  font-family: var(--font-primary);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.03em;
  color: var(--grey-900);
  margin-bottom: 20px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--hs-orange) 0%, var(--hs-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--grey-500);
  margin-bottom: 32px;
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 36px;
  padding: 20px 24px;
  background: white;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat { text-align: center; }
.stat-val { display: block; font-family: var(--font-primary); font-size: 1.4rem; font-weight: 700; color: var(--hs-orange); }
.stat-label { font-size: .75rem; color: var(--grey-400); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.stat-divider { width: 1px; height: 40px; background: var(--grey-200); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--hs-orange);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-orange);
  text-decoration: none;
}

.btn-primary svg { width: 18px; height: 18px; }
.btn-primary:hover { background: var(--hs-orange-dark); transform: translateY(-1px); box-shadow: 0 6px 24px rgba(255,122,89,.4); }
.btn-primary:active { transform: none; }
.btn-large { padding: 16px 36px; font-size: 1.05rem; }
.btn-sm { padding: 8px 16px; font-size: .85rem; }

.hero-pillars {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.pillar-chip {
  padding: 6px 14px;
  background: white;
  border: 1px solid var(--grey-200);
  border-radius: 20px;
  font-size: .82rem;
  color: var(--grey-500);
  font-weight: 500;
}

/* Blueprint preview visual */
.hero-visual { flex: 0 0 380px; }

.blueprint-preview {
  background: white;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.bp-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--grey-50);
  border-bottom: 1px solid var(--grey-200);
}

.bp-dot { width: 10px; height: 10px; border-radius: 50%; }
.bp-dot.red { background: #FF5F57; }
.bp-dot.yellow { background: #FFBD2E; }
.bp-dot.green { background: #28C941; }
.bp-title { margin-left: 8px; font-family: monospace; font-size: .78rem; color: var(--grey-400); }

.bp-body { padding: 20px 20px 24px; }

.bp-line {
  height: 8px;
  background: var(--grey-200);
  border-radius: 4px;
  margin-bottom: 8px;
}

.bp-line.bold { height: 10px; }
.bp-line.orange { background: linear-gradient(90deg, var(--hs-orange) 0%, var(--hs-orange-light) 100%); }
.bp-line.blue { background: var(--hs-blue-light); border-left: 3px solid var(--hs-blue); }
.bp-line.w-30 { width: 30%; }
.bp-line.w-40 { width: 40%; }
.bp-line.w-50 { width: 50%; }
.bp-line.w-60 { width: 60%; }
.bp-line.w-70 { width: 70%; }
.bp-line.w-75 { width: 75%; }
.bp-line.w-80 { width: 80%; }
.bp-line.w-90 { width: 90%; }

.bp-spacer { height: 14px; }

.bp-table { border: 1px solid var(--grey-200); border-radius: 6px; overflow: hidden; }
.bp-row { display: flex; border-bottom: 1px solid var(--grey-200); }
.bp-row:last-child { border-bottom: none; }
.bp-cell { height: 20px; background: var(--grey-100); margin: 5px 6px; border-radius: 3px; }
.bp-cell.head { background: var(--grey-200); }
.bp-cell.w-20 { flex: 0 0 20%; }
.bp-cell.w-30 { flex: 0 0 30%; }
.bp-cell.w-40 { flex: 0 0 40%; }
.pill-cell { flex: 0 0 20%; display: flex; align-items: center; justify-content: center; background: transparent; }
.bp-pill { height: 14px; width: 48px; border-radius: 10px; margin: 0; }
.green-pill { background: var(--hs-green-light); border: 1px solid var(--hs-green); }
.orange-pill { background: var(--hs-orange-light); border: 1px solid var(--hs-orange); }
.blue-pill { background: var(--hs-blue-light); border: 1px solid var(--hs-blue); }

/* ── CHAT LAYOUT ──────────────────────────────────────────────────────────── */
/*
 * Fixed layout: sidebar + chat main fill the entire viewport below the nav.
 * Sidebar is fixed-width and scrolls independently.
 * Chat main fills remaining width as a flex-column:
 *   - .messages scrolls its content
 *   - .input-area stays pinned at the bottom
 */
.chat-layout {
  position: fixed;
  top: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  /* --kb-inset is set from JS when the on-screen keyboard opens (visualViewport),
     keeping the input area visible above the keyboard on mobile. */
  bottom: var(--kb-inset, 0px);
  display: flex;
  overflow: hidden;
  z-index: 1;
}

/* Sidebar — fixed-height column. Only the pillar list scrolls; the head and the
   Marketplace Research panel + footer stay pinned so research is always visible. */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  height: 100%;
  background: white;
  border-right: 1px solid var(--grey-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pillar-list::-webkit-scrollbar { width: 4px; }
.pillar-list::-webkit-scrollbar-track { background: transparent; }
.pillar-list::-webkit-scrollbar-thumb { background: var(--grey-200); border-radius: 2px; }

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 20px 16px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--grey-100);
  flex-shrink: 0;
}

.sidebar-head svg { width: 16px; height: 16px; }

/* Only this region scrolls — keeps the research panel below it always on screen */
.pillar-list {
  padding: 12px 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--grey-200) transparent;
}

.pillar-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  cursor: default;
  transition: background .15s;
  position: relative;
}

.pillar-item::before {
  content: '';
  position: absolute;
  left: 30px;
  top: 38px;
  bottom: -10px;
  width: 2px;
  background: var(--grey-200);
}

.pillar-item:last-child::before { display: none; }

.pillar-item.active .pillar-num {
  background: var(--hs-orange);
  color: white;
  box-shadow: 0 2px 8px rgba(255,122,89,.4);
}

.pillar-item.done .pillar-num {
  background: var(--hs-green);
  color: white;
}

.pillar-item.done::before { background: var(--hs-green); opacity: .3; }

.pillar-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--grey-100);
  color: var(--grey-400);
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
}

.pillar-info { flex: 1; min-width: 0; padding-top: 2px; }
.pillar-name { font-size: .85rem; font-weight: 600; color: var(--grey-700); }
.pillar-item.active .pillar-name { color: var(--hs-navy); }
.pillar-desc { font-size: .75rem; color: var(--grey-400); margin-top: 1px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--grey-100);
  flex-shrink: 0;
}

.sf-label { font-size: .7rem; color: var(--grey-400); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.sf-brand { display: flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 600; color: var(--grey-700); }
.sf-icon { width: 20px; height: 20px; border-radius: 4px; }

/* Chat main — fills remaining space, flex-column so input stays at bottom */
.chat-main {
  flex: 1;
  min-width: 0;        /* prevent flex overflow */
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--grey-50);
}

/* Messages — scrollable, fills space above input */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  /* Enable smooth momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

/* Message bubbles */
.message {
  display: flex;
  gap: 12px;
  max-width: min(800px, 90%);
  animation: msgIn .25s ease;
  width: 100%;
}
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: min(600px, 80%);
  width: auto;
}
.message.bot {
  align-self: flex-start;
  max-width: min(800px, 95%);
  flex-wrap: wrap;
}

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

.bot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--hs-orange);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(255,122,89,.3);
}

.bot-avatar svg { width: 22px; height: 22px; }

.bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: .93rem;
  line-height: 1.65;
  max-width: 680px;
}

.message.bot .bubble {
  background: white;
  border: 1px solid var(--grey-200);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  color: var(--grey-900);
}

.message.user .bubble {
  background: var(--hs-orange);
  color: white;
  border-top-right-radius: 4px;
}

/* ── Clickable option controls (single buttons / multi checklist) ──────────── */
.msg-options {
  /* Force onto its own line below the bubble, indented under the avatar gutter */
  flex-basis: 100%;
  margin-left: 48px; /* avatar (36px) + gap (12px) */
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  animation: msgIn .2s ease;
}
@media (max-width: 640px) { .msg-options { margin-left: 0; } }

.msg-options-multi { flex-direction: column; align-items: flex-start; }

/* Single-select buttons */
.opt-btn {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--hs-orange);
  background: #fff;
  color: var(--hs-orange);
  font-size: .88rem;
  font-weight: 600;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all .15s;
  line-height: 1.3;
}
.opt-btn:hover:not(:disabled) {
  background: var(--hs-orange);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255,122,89,.3);
}
.opt-btn:disabled { cursor: default; opacity: .55; }
.opt-btn.opt-chosen {
  background: var(--hs-orange);
  color: #fff;
  opacity: 1;
  border-color: var(--hs-orange);
}

/* Multi-select checklist */
.opt-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  min-width: 260px;
}
.opt-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  color: var(--grey-900);
  cursor: pointer;
  padding: 4px 2px;
  user-select: none;
}
.opt-check input[type=checkbox] {
  width: 17px; height: 17px;
  accent-color: var(--hs-orange);
  cursor: pointer;
  flex-shrink: 0;
}
.opt-check input:disabled { cursor: default; }
.opt-submit {
  align-self: flex-start;
  padding: 9px 22px;
  border-radius: 10px;
  border: none;
  background: var(--hs-orange);
  color: #fff;
  font-size: .88rem;
  font-weight: 700;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all .15s;
}
.opt-submit:hover:not(:disabled) { background: var(--hs-orange-dark, #e85c3f); transform: translateY(-1px); }
.opt-submit:disabled { opacity: .5; cursor: default; }

.msg-options.opt-used { opacity: .85; }

/* Markdown inside bot bubbles */
.bubble h1, .bubble h2 { font-family: var(--font-primary); font-weight: 700; margin: 16px 0 10px; color: var(--hs-navy); }
.bubble h1 { font-size: 1.3rem; border-bottom: 2px solid var(--hs-orange); padding-bottom: 6px; }
.bubble h2 { font-size: 1.1rem; color: var(--hs-navy); }
.bubble h3 { font-size: .95rem; font-weight: 600; margin: 12px 0 6px; color: var(--grey-700); }
.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { color: var(--hs-navy); }
.bubble em { color: var(--grey-500); }
.bubble ul, .bubble ol { padding-left: 20px; margin-bottom: 10px; }
.bubble li { margin-bottom: 4px; }
.bubble code {
  font-family: 'Fira Code', monospace;
  font-size: .82em;
  background: var(--grey-100);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--hs-orange-dark);
}
.bubble pre {
  background: var(--grey-900);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
}
.bubble pre code { background: none; color: #e8f4f8; padding: 0; font-size: .83rem; }
.bubble table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .88rem; }
.bubble th {
  background: var(--hs-navy);
  color: white;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .03em;
}
.bubble td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--grey-200);
  color: var(--grey-700);
}
.bubble tr:nth-child(even) td { background: var(--grey-50); }
.bubble hr { border: none; border-top: 1px solid var(--grey-200); margin: 16px 0; }
.bubble blockquote {
  border-left: 3px solid var(--hs-orange);
  margin: 10px 0;
  padding: 8px 14px;
  background: var(--hs-orange-light);
  border-radius: 0 6px 6px 0;
  color: var(--grey-700);
  font-style: italic;
}

/* Blueprint blueprint (extra styling for the big doc) */
.blueprint-doc {
  border: 2px solid var(--hs-orange);
  border-radius: var(--radius-lg);
  background: white;
  padding: 28px;
  margin: 4px 0;
  max-width: 760px;
}

.blueprint-doc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--grey-100);
}

.blueprint-doc-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--hs-orange-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.blueprint-doc-title { font-family: var(--font-primary); font-weight: 700; font-size: 1rem; color: var(--hs-navy); }
.blueprint-doc-sub { font-size: .78rem; color: var(--grey-400); }

/* Typing indicator */
.typing-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 32px 8px;
}

.bot-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--hs-orange);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bot-avatar-sm svg { width: 18px; height: 18px; }

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--grey-200);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grey-300);
  animation: bounce .8s ease infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: .15s; }
.typing-bubble span:nth-child(3) { animation-delay: .30s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); background: var(--grey-300); }
  30% { transform: translateY(-5px); background: var(--hs-orange); }
}

/* Blueprint banner — legacy, kept hidden */
.blueprint-banner { display: none !important; }

/* ── Completion Modal ─────────────────────────────────────────────────────── */
.completion-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10, 18, 35, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: overlayIn .25s ease;
}
@keyframes overlayIn {
  from { opacity: 0; } to { opacity: 1; }
}

.completion-modal {
  background: #fff;
  border-radius: 24px;
  padding: 44px 40px 40px;
  max-width: 460px;
  width: calc(100% - 40px);
  text-align: center;
  box-shadow: 0 24px 64px rgba(10,18,35,.22), 0 4px 16px rgba(10,18,35,.12);
  animation: modalIn .3s cubic-bezier(.34,1.56,.64,1);
  position: relative;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.completion-confetti {
  font-size: 3.2rem;
  margin-bottom: 18px;
  animation: bounce .6s ease 0.1s both;
}
@keyframes bounce {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.completion-title {
  font-family: 'Lexend', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 12px;
  line-height: 1.2;
}

.completion-body {
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 28px;
}

.completion-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.completion-btn-primary {
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}

.completion-btn-secondary {
  width: 100%;
  padding: 13px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.completion-btn-secondary:hover {
  background: #e8eef6;
  color: #0f172a;
  border-color: #c7d4e4;
}

@media (max-width: 480px) {
  .completion-modal { padding: 32px 22px 28px; }
  .completion-title { font-size: 1.35rem; }
}

/* Input area — always at bottom, never shrinks */
.input-area {
  flex-shrink: 0;
  background: white;
  border-top: 1px solid var(--grey-200);
  padding: 16px 32px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); /* clear the iOS home indicator */
  z-index: 2;
}

.input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--grey-50);
  border: 1.5px solid var(--grey-300);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  transition: border-color .15s, box-shadow .15s;
}

.input-wrap:focus-within {
  border-color: var(--hs-orange);
  box-shadow: 0 0 0 3px rgba(255,122,89,.12);
  background: white;
}

textarea#userInput {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: .95rem;
  line-height: 1.5;
  color: var(--grey-900);
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 160px;
  overflow-y: auto;
}

textarea#userInput::placeholder { color: var(--grey-300); }

textarea#userInput:disabled { cursor: not-allowed; opacity: .5; }

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--hs-orange);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(255,122,89,.3);
}

.send-btn:hover { background: var(--hs-orange-dark); transform: scale(1.05); }
.send-btn:disabled { background: var(--grey-200); box-shadow: none; cursor: not-allowed; transform: none; color: var(--grey-400); }
.send-btn svg { width: 16px; height: 16px; }

.input-hint {
  font-size: .72rem;
  color: var(--grey-300);
  text-align: right;
  margin-top: 6px;
}

/* Footer */
.footer {
  background: var(--hs-navy);
  color: rgba(255,255,255,.4);
  padding: 14px 24px;
  font-size: .75rem;
  flex-shrink: 0;
}

/* When chat is active, footer is hidden (body is in fixed-layout mode) */
body.chat-active .footer {
  display: none;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--grey-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--grey-300); }

/* Welcome message */
.welcome-message {
  align-self: center;
  max-width: 540px;
  text-align: center;
  padding: 60px 20px;
  opacity: 0;
  animation: fadeIn .5s ease .1s forwards;
}

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

.welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--hs-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: var(--shadow-orange);
}

.welcome-icon svg { width: 36px; height: 36px; }

.welcome-message h2 {
  font-family: var(--font-primary);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--hs-navy);
  margin-bottom: 10px;
}

.welcome-message p { font-size: .95rem; color: var(--grey-500); line-height: 1.6; }

/* Responsive */
@media (max-width: 900px) {
  .hero { flex-direction: column; padding: 40px 24px; gap: 40px; }
  .hero-visual { display: none; }
  /* Hide sidebar on mobile — full-width chat */
  .sidebar { display: none; }
  .chat-layout { left: 0; }
  .messages { padding: 16px 16px; }
  .input-area { padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .typing-wrap { padding: 0 16px 8px; }
  .blueprint-banner { margin: 0 16px 12px; }
}

@media (max-width: 480px) {
  .hero-stats { flex-direction: column; gap: 12px; }
  .stat-divider { width: 80px; height: 1px; }
  .messages { padding: 12px; }
}

@media (max-width: 480px) {
  .hero-stats { flex-direction: column; gap: 12px; }
  .stat-divider { width: 80px; height: 1px; }
}

/* Stream cursor */
.stream-cursor::after {
  content: '▋';
  color: var(--hs-orange);
  animation: blink .7s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ── Tech Stack Panel ──────────────────────────────────────────────────────── */
.stack-panel {
  border-top: 1px solid var(--grey-100);
  padding: 14px 16px;
  flex-shrink: 0;
  background: white;
}

.stack-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}

.stack-head svg { width: 14px; height: 14px; }

.stack-input-wrap {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.stack-input-wrap input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .8rem;
  color: var(--grey-900);
  background: white;
  outline: none;
  transition: border-color .15s;
}

.stack-input-wrap input:focus { border-color: var(--hs-orange); }

.stack-input-wrap button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--hs-orange);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}

.stack-input-wrap button:hover { background: var(--hs-orange-dark); }
.stack-input-wrap button svg { width: 14px; height: 14px; }

.stack-results { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }

.stack-result-card {
  padding: 9px 10px;
  background: white;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  animation: fadeIn .2s ease;
}

.stack-result-card.not-found {
  border-color: var(--grey-200);
  background: var(--grey-50);
}

.result-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.result-name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--hs-navy);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-badge {
  padding: 1px 7px;
  border-radius: 10px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .02em;
  flex-shrink: 0;
}

.badge-native { background: var(--hs-green-light); color: var(--hs-green); }
.badge-datasync { background: var(--hs-blue-light); color: var(--hs-blue-dark); }
.badge-middleware { background: var(--grey-100); color: var(--grey-500); }
.badge-custom { background: #fff3cd; color: #856404; }
.badge-certified { background: var(--hs-orange-light); color: var(--hs-orange-dark); }

.result-direction {
  font-size: .73rem;
  color: var(--grey-400);
  margin-bottom: 3px;
}

.result-notes {
  font-size: .73rem;
  color: var(--grey-500);
  line-height: 1.4;
}

.result-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: .72rem;
  color: var(--hs-orange);
  text-decoration: none;
  margin-top: 4px;
  font-weight: 500;
}

.result-link:hover { text-decoration: underline; }
.result-link svg { width: 10px; height: 10px; }

.marketplace-link {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  color: var(--hs-blue);
  text-decoration: none;
  margin-top: 8px;
  font-weight: 500;
  padding: 6px 8px;
  background: var(--hs-blue-light);
  border-radius: var(--radius-sm);
  transition: background .15s;
}

.marketplace-link:hover { background: #ccedf2; }
.marketplace-link svg { width: 12px; height: 12px; }

.result-flag {
  padding: 6px 8px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  color: #856404;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Research feed additions */
.research-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--hs-orange);
  color: white;
  font-size: .7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.research-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  text-align: center;
}

.research-empty svg { width: 24px; height: 24px; color: var(--grey-300); }
.research-empty span { font-size: .75rem; color: var(--grey-400); line-height: 1.4; }

.result-synced {
  font-size: .72rem;
  color: var(--hs-blue);
  font-weight: 500;
  margin-bottom: 3px;
}

.result-features {
  font-size: .72rem;
  color: var(--grey-500);
  line-height: 1.45;
  margin-bottom: 3px;
}

/* Pulsing dot for "researching" state */
.researching-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: .75rem;
  color: var(--grey-500);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hs-orange);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.7); }
}

/* ── CHAT TOPNAV (minimal header during discovery session) ─────────────────── */
.chat-topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px); /* push content below the notch / status bar */
  z-index: 200;
  background: var(--hs-navy);
  border-bottom: none;
  box-shadow: 0 2px 16px rgba(0,0,0,.18);
}

.chat-nav-inner {
  max-width: 100%;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Back to home button */
.chat-nav-back {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.8);
  font-family: var(--font-body);
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.chat-nav-back svg { width: 15px; height: 15px; flex-shrink: 0; }
.chat-nav-back:hover {
  background: rgba(255,255,255,.14);
  color: white;
  border-color: rgba(255,255,255,.22);
}

/* Centre brand */
.chat-nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-primary);
  font-size: .9rem;
  font-weight: 600;
  color: white;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.chat-nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 6px rgba(52,211,153,.6);
  animation: navPulse 2s ease-in-out infinite;
}

@keyframes navPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .6; transform: scale(.8); }
}

/* New session button */
.chat-nav-new {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255,122,89,.15);
  border: 1px solid rgba(255,122,89,.3);
  border-radius: var(--radius-md);
  color: var(--hs-orange);
  font-family: var(--font-body);
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.chat-nav-new svg { width: 14px; height: 14px; }
.chat-nav-new:hover {
  background: rgba(255,122,89,.25);
  border-color: rgba(255,122,89,.5);
  color: #ff9a82;
}

.chat-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.chat-nav-save {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.88);
  font-family: var(--font-body);
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.chat-nav-save svg { width: 14px; height: 14px; }
.chat-nav-save:hover {
  background: rgba(255,255,255,.14);
  color: white;
  border-color: rgba(255,255,255,.24);
}

.chat-nav-save-status {
  font-size: .78rem;
  color: #34d399;
  font-weight: 600;
  padding-right: 2px;
}

.disc-badge-inprogress {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 8px;
}

.eng-panel-inprogress {
  background: #fffdf8;
  border-left-color: #d97706;
}

.discovery-progress-block { padding: 4px 0 8px; }

.discovery-phase-label {
  font-size: .9rem;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 10px;
}

.discovery-progress-bar-wrap {
  height: 8px;
  background: #fde68a;
  border-radius: 999px;
  overflow: hidden;
}

.discovery-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #d97706);
  border-radius: 999px;
  transition: width .3s ease;
}

.discovery-progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: .78rem;
  color: #78716c;
}

.discovery-resume-btn {
  margin-top: 14px;
  width: 100%;
  justify-content: center;
}

.discovery-steps-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.discovery-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.discovery-step-done {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.discovery-step-active {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, .25);
}

/* Hide landing topnav when in chat mode */
body.chat-active #navLanding {
  display: none !important;
}

/* ── My Discoveries overlay ──────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════════════════════
   Discoveries list — engagement cards with a beautiful pipeline flow
   ══════════════════════════════════════════════════════════════════════════════ */
.discoveries-list { display: flex; flex-direction: column; gap: 20px; }
.disc-loading { color: #64748b; padding: 20px; text-align: center; }
.discoveries-empty { color: #94a3b8; padding: 28px; text-align: center; }

/* ── Engagement card ──────────────────────────────────────────────────────── */
.disc-card {
  border: 1px solid #e8eef5;
  border-left: 4px solid var(--hs-orange, #ff7a59);
  border-radius: 20px;
  padding: 22px 26px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.04);
  transition: box-shadow .2s, transform .2s;
}
.disc-card:hover {
  box-shadow: 0 4px 12px rgba(15,23,42,.06), 0 12px 32px rgba(15,23,42,.08);
  transform: translateY(-2px);
}
.disc-head-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.disc-name { font-family: 'Lexend', sans-serif; font-size: 1.15rem; font-weight: 700; color: #0f172a; }
.disc-date {
  color: #64748b; font-size: 0.78rem; margin-left: auto;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 20px;
  padding: 3px 11px; white-space: nowrap; font-weight: 500;
}
.disc-summary { color: #475569; font-size: 0.88rem; margin: -8px 0 0; line-height: 1.55; }

/* ── Pipeline: premium horizontal step flow ───────────────────────────────── */
.disc-pipeline {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 0;
  padding: 4px 0 2px;
}

/* Step cell */
.pp-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Connector arrow between steps */
.pp-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  margin-bottom: 42px; /* align with icon vertical center */
}
.pp-connector svg {
  width: 22px; height: 22px;
  transition: color .25s;
}
.pp-connector.done svg   { color: var(--hs-orange, #ff7a59); }
.pp-connector.pending svg { color: #d4dce8; }

/* Step top-area: icon + badge */
.pp-step-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

/* Icon circle */
.pp-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700;
  flex-shrink: 0;
  transition: all .25s;
  position: relative; z-index: 2;
}
.pp-icon svg { width: 24px; height: 24px; }
.pp-num { font-size: 1.05rem; font-weight: 700; }

/* Step label area */
.pp-label-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.pp-title {
  font-family: 'Lexend', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pp-sub {
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.3;
  font-weight: 500;
}

/* ── States ───────────────────────────────────────────────────────────────── */

/* Done */
.pp-done .pp-icon {
  background: linear-gradient(135deg, #ff7a59 0%, #ff5c38 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255,92,56,.45), 0 0 0 6px rgba(255,122,89,.10);
}
.pp-done .pp-title { color: #0f172a; }
.pp-done .pp-sub   { color: #e05a38; font-weight: 700; }

/* Current / next action */
.pp-current .pp-icon {
  background: #fff;
  color: var(--hs-orange, #ff7a59);
  border: 2.5px solid var(--hs-orange, #ff7a59);
  box-shadow: 0 0 0 5px rgba(255,122,89,.12), 0 4px 12px rgba(255,122,89,.18);
}
.pp-current .pp-title { color: var(--hs-orange, #ff7a59); }
.pp-current .pp-sub   { color: #64748b; }

/* Locked / future */
.pp-locked .pp-icon {
  background: #f1f5f9;
  color: #94a3b8;
  border: 2px solid #e2e8f0;
  box-shadow: none;
}
.pp-locked .pp-title { color: #94a3b8; }
.pp-locked .pp-sub   { color: #c0ccd8; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.pp-btn {
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 0.74rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  cursor: pointer; transition: all .15s; border: none;
  white-space: nowrap; letter-spacing: 0.015em;
}
/* When .pp-btn is used as a full-width block (teaser/preview area only) */
.pp-btn-block {
  width: 100%; margin-top: 4px;
}

/* Download: orange-tinted solid look */
.pp-download {
  background: linear-gradient(135deg, #fff5f2 0%, #fff 100%);
  color: #c94a2a;
  border: 1.5px solid rgba(255,122,89,.3);
  box-shadow: 0 1px 3px rgba(255,122,89,.10);
  font-weight: 700;
}
.pp-download:hover {
  background: linear-gradient(135deg, #ffe8e2 0%, #fff5f2 100%);
  border-color: rgba(255,92,56,.5);
  color: #a83418;
  box-shadow: 0 3px 8px rgba(255,92,56,.18);
  transform: translateY(-1px);
}
.pp-download:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }

/* Generate: orange CTA */
.pp-generate {
  background: linear-gradient(135deg, #ff7a59 0%, #ff5c38 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255,92,56,.35);
}
.pp-generate:hover {
  background: linear-gradient(135deg, #ff5c38 0%, #e84520 100%);
  box-shadow: 0 4px 12px rgba(255,92,56,.45);
  transform: translateY(-1px);
}
.pp-generate:disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; box-shadow: none; transform: none; }

/* Locked placeholder */
.pp-locked-btn {
  background: #f8fafc;
  color: #b0bec8;
  border: 1.5px dashed #dce4ed;
  cursor: not-allowed;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Engagement panels (new stats/teaser layout) ──────────────────────────── */
.eng-panels {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.eng-panel {
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  background: #fff;
  transition: box-shadow 0.15s;
}
.eng-panel:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.07); }
.eng-panel-icp  { border-left: 3px solid #ff7a59; }
.eng-panel-bp   { border-left: 3px solid #3b82f6; }
.eng-panel-pb   { border-left: 3px solid #8b5cf6; }
.eng-panel-empty     { background: #fafbff; }
.eng-panel-locked    { background: #f8fafc; opacity: .7; }
.eng-panel-agent  { border-left: 3px solid #0ea5e9; }
.eng-panel-audit  { border-left: 3px solid #10b981; }

/* Coming-soon panels — muted, dashed border, pointer-events locked */
.eng-panel-coming-soon {
  background: #f8fafc;
  border-style: dashed;
  border-color: #cbd5e1;
  opacity: 0.72;
  pointer-events: none;
  user-select: none;
  position: relative;
}
.eng-panel-coming-soon::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 6px,
    rgba(148,163,184,0.04) 6px,
    rgba(148,163,184,0.04) 12px
  );
  pointer-events: none;
}
.eng-panel-coming-soon .eng-panel-title { color: #94a3b8; }


.eng-panel-coming-soon .eng-teaser-desc { color: #94a3b8; }
.eng-panel-coming-soon .eng-teaser-items span { color: #b0bec8; }

/* Coming-soon badge */
.eng-coming-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f1f5f9;
  color: #64748b;
  border: 1.5px dashed #cbd5e1;
  white-space: nowrap;
}
.eng-coming-badge::before {
  content: '⏳';
  font-size: 0.72rem;
}

/* ── Add-on modules section ─────────────────────────────────────────────── */
.addons-section {
  margin-top: 14px;
  pointer-events: none;
  user-select: none;
}
.addons-section-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1.5px dashed #e2e8f0;
}
.addons-section-header span:first-of-type {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
}
.addons-section-sub {
  font-size: 0.7rem !important;
  color: #94a3b8 !important;
  font-weight: 400 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  margin-left: 4px;
}
.addons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.addon-tile {
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 13px 13px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0.72;
  position: relative;
  overflow: hidden;
}
.addon-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 6px,
    rgba(148,163,184,0.04) 6px,
    rgba(148,163,184,0.04) 12px
  );
  pointer-events: none;
}
.addon-tile-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.addon-tile-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
  line-height: 1.25;
}
.addon-tile-desc {
  font-size: 0.71rem;
  color: #64748b;
  line-height: 1.45;
  flex: 1;
}
.addon-tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  gap: 6px;
}
.addon-tile-price {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
}
/* Responsive: 2 cols on narrower screens */
@media (max-width: 640px) {
  .addons-grid { grid-template-columns: repeat(2, 1fr); }
}
.eng-panel-generating { background: #fffdf5; border-left-color: #f59e0b; }

/* ── Generation progress block ──────────────────────────────────────────── */
.gen-progress-block { padding: 4px 0 6px; }

.gen-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 3px;
  transition: background 0.3s, color 0.3s;
}
.gen-step-active {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}
.gen-step-done {
  color: #15803d;
  text-decoration: none;
}
.gen-dot-anim {
  display: inline-block;
  animation: genDots 1.4s steps(4, end) infinite;
  letter-spacing: 1px;
  width: 18px;
}
@keyframes genDots {
  0%   { content: ''; clip-path: inset(0 75% 0 0); }
  25%  { clip-path: inset(0 50% 0 0); }
  50%  { clip-path: inset(0 25% 0 0); }
  75%  { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 75% 0 0); }
}

.gen-meta {
  display: flex;
  gap: 8px;
  margin: 6px 8px 4px;
  font-size: 11px;
  color: #9ca3af;
}
.gen-chars { color: #6366f1; font-weight: 600; }
.gen-batch { color: #9ca3af; }

.gen-bar-wrap {
  height: 3px;
  background: #f3f4f6;
  border-radius: 99px;
  overflow: hidden;
  margin: 6px 8px 8px;
}
.gen-bar {
  height: 100%;
  border-radius: 99px;
  animation: genBarPulse 2s ease-in-out infinite;
  width: 60%;
}
.gen-bar-bp { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.gen-bar-pb { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.gen-bar-icp { background: linear-gradient(90deg, #ff7a59, #ff9a7a); }
@keyframes genBarPulse {
  0%   { transform: translateX(-60%); opacity: 0.7; }
  50%  { opacity: 1; }
  100% { transform: translateX(160%); opacity: 0.7; }
}

.gen-hint {
  font-size: 11px;
  color: #9ca3af;
  margin: 0 8px;
  line-height: 1.5;
  font-style: italic;
}
.eng-panel-header {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
  flex-wrap: nowrap;
  min-width: 0;
}
.eng-panel-header .eng-panel-icon {
  flex-shrink: 0;
}
.eng-panel-header .eng-panel-title {
  flex: 1 1 0;
  min-width: 0;
}
.eng-panel-header .eng-view-btn,
.eng-panel-header .eng-upd-btn,
.eng-panel-header .eng-dl-btn,
.eng-panel-header .eng-gen-btn {
  flex-shrink: 0;
  margin-right: 0;
}
.eng-panel-icon {
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eng-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.eng-dl-btn, .eng-gen-btn {
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.eng-dl-btn { background: #f1f5f9; color: #334155; justify-self: end; }
.eng-gen-btn { justify-self: end; }
.eng-dl-btn:hover { background: #e2e8f0; }
.eng-gen-btn {
  background: linear-gradient(135deg, #ff7a59, #e05a38);
  color: #fff;
  box-shadow: 0 2px 6px rgba(224,90,56,0.3);
  width: auto !important;
  align-self: flex-start;
}
.eng-gen-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(224,90,56,0.35); }
.eng-archetype { font-size: 0.88rem; font-weight: 700; color: #0f172a; margin-bottom: 4px; }
.eng-icp-sentence { font-size: 0.82rem; color: #475569; line-height: 1.5; margin: 0 0 8px 0; }
.eng-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.eng-tiers { margin-top: 5px; }
.eng-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip-green  { background: #dcfce7; color: #15803d; }
.chip-yellow { background: #fef9c3; color: #a16207; }
.chip-red    { background: #fee2e2; color: #b91c1c; }
.chip-blue   { background: #dbeafe; color: #1d4ed8; }
.chip-hs     { background: #fff1ed; color: #c2410c; }
.chip-neutral { background: #f1f5f9; color: #475569; }
.chip-amber  { background: #fef3c7; color: #b45309; }
.eng-teaser-desc { font-size: 0.82rem; color: #64748b; margin: 0 0 8px 0; line-height: 1.4; }
.eng-teaser-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
  margin-top: 6px;
}
.eng-teaser-items span { font-size: 0.76rem; color: #64748b; }
.spin-icon { display: inline-block; animation: spin 1.5s linear infinite; }


/* ── Responsive: stack to 2×2 on mobile ───────────────────────────────────── */
@media (max-width: 640px) {
  .disc-card { padding: 18px 16px; }
  .disc-pipeline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 16px 8px;
  }
  .pp-connector { display: none; }
  .pp-icon { width: 42px; height: 42px; }
}

/* ══ App Home (SageSchema AI workspace) ══════════════════════════════ */
#appHome { min-height: 100vh; background: #f8fafc; }
.app-topnav { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid #e2e8f0; }
.app-nav-inner { max-width: 980px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-brand { display: inline-flex; align-items: center; gap: 9px; background: none; border: none; cursor: pointer; font-family: 'Lexend', sans-serif; font-size: 1.1rem; color: #0f172a; padding: 0; }
.app-brand strong { color: var(--hs-orange, #ff7a59); font-weight: 800; }
.app-home-exit { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.app-main { max-width: 980px; margin: 0 auto; padding: 32px 20px 64px; }
.app-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.app-title { font-family: 'Lexend', sans-serif; font-size: 1.7rem; margin: 0 0 6px; color: #0f172a; }
.app-sub { color: #64748b; font-size: 0.92rem; margin: 0; max-width: 620px; line-height: 1.5; }
.app-start-btn { white-space: nowrap; flex: 0 0 auto; }
.app-empty { text-align: center; padding: 56px 20px; border: 1px dashed #cbd5e1; border-radius: 16px; background: #fff; }
.app-empty-icon { font-size: 2.4rem; margin-bottom: 10px; }
.app-empty h3 { font-family: 'Lexend', sans-serif; margin: 0 0 6px; color: #0f172a; }
.app-empty p { color: #64748b; margin: 0 0 18px; }
.app-empty .app-start-btn { margin: 0 auto; }
@media (max-width: 640px) {
  .app-head { flex-direction: column; }
  .app-start-btn { width: 100%; justify-content: center; }
}

/* ── Chat Topnav Mobile adjustments (Show only icons) ─────────────────────── */
@media (max-width: 850px) {
  .chat-topnav .nav-btn-text {
    display: none !important;
  }
  .chat-nav-back, .chat-nav-new, .chat-nav-save {
    padding: 7px 10px !important;
    gap: 0 !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .chat-nav-brand span {
    font-size: 0.95rem !important;
  }
}

/* ══ Update Chat Modal ═══════════════════════════════════════════════════════ */

/* "Update" button that appears next to Download on each panel */
.eng-upd-btn {
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  border: 1.5px solid rgba(255,122,89,.35);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  background: linear-gradient(135deg, #fff5f2 0%, #fff 100%);
  color: #c94a2a;
  margin-right: 4px;
}
.eng-upd-btn:hover {
  background: linear-gradient(135deg, #ffe8e2 0%, #fff5f2 100%);
  border-color: rgba(255,92,56,.5);
  color: #a83418;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(255,92,56,.18);
}

/* View button — sits before Update, uses an indigo/blue tint */
.eng-view-btn {
  padding: 4px 8px;
  font-size: 0.72rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  border: 1.5px solid rgba(99,102,241,.3);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  background: linear-gradient(135deg, #f0f1ff 0%, #fff 100%);
  color: #4338ca;
}
.eng-view-btn:hover {
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f1ff 100%);
  border-color: rgba(99,102,241,.55);
  color: #3730a3;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99,102,241,.18);
}

/* ── Document viewer / editor modal ─────────────────────────────────── */
.dv-shell {
  background: #fff;
  width: 100%;
  max-width: 1040px;
  height: 92vh;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0,0,0,.35);
}
.dv-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid #e8ecf0;
  background: #fafbfc;
  flex-shrink: 0;
  border-top: 3px solid transparent; /* overridden per doc type */
}
.dv-hdr-icon { font-size: 20px; flex-shrink: 0; }
.dv-hdr-titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dv-hdr-title  { font-weight: 700; font-size: 15px; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dv-hdr-sub    { font-size: 11px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dv-hdr-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.dv-save-status {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}
/* Shared button base */
.dv-btn {
  padding: 5px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  border: none;
}
.dv-btn-edit {
  background: #f0f1ff;
  color: #4338ca;
  border: 1.5px solid rgba(99,102,241,.3);
}
.dv-btn-edit:hover  { background: #e0e7ff; border-color: rgba(99,102,241,.55); }
.dv-btn-save {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 2px 6px rgba(34,197,94,.3);
}
.dv-btn-save:hover   { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(34,197,94,.35); }
.dv-btn-save:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }
.dv-btn-dl {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}
.dv-btn-dl:hover    { background: #e2e8f0; }
.dv-btn-close {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 16px;
  justify-content: center;
  border-radius: 8px;
}
.dv-btn-close:hover { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
/* Body layout */
.dv-body-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
}
/* TOC sidebar */
.dv-toc {
  width: 210px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid #e8ecf0;
  padding: 12px 0;
  background: #f8fafc;
}
.dv-toc-label {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 0 14px 8px;
}
.dv-toc-item {
  display: block;
  padding: 5px 14px;
  font-size: 12px;
  color: #334155;
  font-weight: 500;
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.35;
  transition: all .15s;
}
.dv-toc-h3    { padding-left: 22px; font-size: 11px; font-weight: 400; color: #64748b; }
.dv-toc-item:hover { background: #f1f5f9; border-left-color: #94a3b8; }
.dv-toc-item.dv-toc-active { background: #eef2ff; border-left-color: var(--toc-accent, #6366f1); color: #3730a3; }
/* Read pane */
.dv-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 36px 44px;
  scroll-behavior: smooth;
}
/* Edit pane — Quill host */
.dv-edit-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}
/* Quill toolbar strip */
.dv-quill-toolbar {
  flex-shrink: 0;
  background: #f8fafc;
  border: none !important;
  border-bottom: 1px solid #e2e8f0 !important;
  padding: 6px 12px !important;
}
.dv-quill-toolbar .ql-formats { margin-right: 10px !important; }
.dv-quill-toolbar button, .dv-quill-toolbar .ql-picker { color: #334155 !important; }
.dv-quill-toolbar button:hover, .dv-quill-toolbar button.ql-active { color: #4338ca !important; }
.dv-quill-toolbar .ql-picker-label { color: #334155 !important; }
/* Quill editor area */
.dv-quill-editor {
  flex: 1;
  overflow: hidden;
}
.dv-quill-editor .ql-editor {
  height: 100%;
  padding: 28px 44px;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1.8;
  color: #1e293b;
  overflow-y: auto;
}
.dv-quill-editor .ql-editor h1 { font-size: 1.65rem; font-weight: 800; margin: 0 0 .6rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; }
.dv-quill-editor .ql-editor h2 { font-size: 1.22rem; font-weight: 700; margin: 2rem 0 .5rem; border-left: 4px solid #3b82f6; padding-left: 12px; }
.dv-quill-editor .ql-editor h3 { font-size: 1.03rem; font-weight: 700; margin: 1.5rem 0 .4rem; color: #334155; }
.dv-quill-editor .ql-editor p  { margin: 0 0 .9rem; }
.dv-quill-editor .ql-editor strong { color: #0f172a; }
.dv-quill-editor .ql-editor blockquote { border-left: 4px solid #3b82f6; background: #eff6ff; color: #1d4ed8; padding: 8px 14px; margin: 0 0 1rem; border-radius: 0 6px 6px 0; font-style: italic; }
.dv-quill-editor .ql-editor pre.ql-syntax { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 14px 18px; font-size: .87rem; }
.dv-quill-editor .ql-editor a { color: #4338ca; }
/* Hide Quill border */
.dv-quill-editor.ql-container.ql-snow { border: none !important; }
.ql-container.ql-snow { border: none !important; }
.ql-toolbar.ql-snow { border: none !important; border-bottom: 1px solid #e2e8f0 !important; }
/* Footer */
.dv-footer {
  height: 24px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: #f8fafc;
  border-top: 1px solid #e8ecf0;
  flex-shrink: 0;
  gap: 10px;
}
.dv-mode-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #94a3b8;
}
.dv-progress-bar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  width: 0%;
  transition: width .1s;
  background: #3b82f6;
}
.dv-loading { color: #94a3b8; }

/* Book-like prose rendering */
.dv-prose {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1.8;
  color: #1e293b;
  max-width: 740px;
}
.dv-prose h1 {
  font-size: 1.65rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
  line-height: 1.25;
}
.dv-prose h2 {
  font-size: 1.22rem;
  font-weight: 700;
  color: #1e293b;
  margin: 2.2rem 0 .6rem;
  padding-left: 12px;
  border-left: 4px solid #3b82f6;
  line-height: 1.3;
}
.dv-prose h3 {
  font-size: 1.03rem;
  font-weight: 700;
  color: #334155;
  margin: 1.6rem 0 .4rem;
}
.dv-prose h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #475569;
  margin: 1.2rem 0 .3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dv-prose p { margin: 0 0 .9rem; }
.dv-prose ul, .dv-prose ol {
  margin: 0 0 .9rem 1.1rem;
  padding: 0;
}
.dv-prose li { margin-bottom: .35rem; }
.dv-prose li > ul, .dv-prose li > ol { margin-top: .25rem; }
.dv-prose strong { color: #0f172a; }
.dv-prose em { color: #475569; }
.dv-prose code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .88em;
  font-family: 'ui-monospace', 'Menlo', 'Consolas', monospace;
  color: #7c3aed;
}
.dv-prose pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 0 0 1rem;
  font-size: .87rem;
  line-height: 1.6;
}
.dv-prose pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.dv-prose blockquote {
  margin: 0 0 1rem;
  padding: 10px 16px;
  border-left: 4px solid #3b82f6;
  background: #eff6ff;
  border-radius: 0 6px 6px 0;
  color: #1d4ed8;
  font-style: italic;
}
.dv-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.2rem;
  font-size: .9rem;
}
.dv-prose th {
  background: #f8fafc;
  font-weight: 700;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dv-prose td {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  vertical-align: top;
}
.dv-prose tr:nth-child(even) td { background: #f8fafc; }
.dv-prose hr {
  border: none;
  border-top: 2px dashed #e2e8f0;
  margin: 2rem 0;
}
a.dv-toc-active {
  background: #eef2ff !important;
  border-left-color: #6366f1 !important;
  color: #3730a3 !important;
}

/* Overlay backdrop */
.upd-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 14, 0.55);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Modal card */
.upd-modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.22);
  width: 100%;
  max-width: 1240px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Split body layout ── */
.upd-split {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Preview pane (left) ── */
.upd-preview {
  width: 48%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
}
.upd-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: #f1f5f9;
  flex-shrink: 0;
}
.upd-preview-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
}
.upd-preview-status {
  font-size: 11px;
  color: #94a3b8;
}
.upd-preview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  scroll-behavior: smooth;
}
/* Divider */
.upd-divider {
  width: 1px;
  background: #e2e8f0;
  flex-shrink: 0;
}

/* ── Chat pane (right) ── */
.upd-chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Mobile tab toggle ── */
.upd-tab-toggle {
  display: none;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.upd-tab-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .15s;
}
.upd-tab-btn.upd-tab-active {
  background: #fff;
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* ── Responsive: stack vertically on narrow screens ── */
@media (max-width: 720px) {
  .upd-modal { max-width: 100%; border-radius: 12px; }
  .upd-split  { flex-direction: column; }
  .upd-preview { width: 100%; border-right: none; border-bottom: 1px solid #e2e8f0; display: none; }
  .upd-preview.upd-tab-visible { display: flex; }
  .upd-chat-pane { display: flex; }
  .upd-chat-pane.upd-tab-hidden { display: none; }
  .upd-divider { display: none; }
  .upd-tab-toggle { display: flex; }
}

/* Header */
.upd-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #fafafa;
  flex-shrink: 0;
}
.upd-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Lexend', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}
.upd-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}
.upd-close-btn:hover { color: #334155; background: #f1f5f9; }

/* Message list */
.upd-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;    /* allow shrinking so input stays pinned at bottom */
  background: #f8fafc;
}

/* Message row */
.upd-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 100%;
}
.upd-msg-user {
  flex-direction: row-reverse;
}
.upd-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #FF4800;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upd-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: calc(100% - 46px);
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.upd-msg-bot .upd-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  border-radius: 4px 12px 12px 12px;
}
.upd-msg-user .upd-bubble {
  background: #FF4800;
  color: #fff;
  border-radius: 12px 4px 12px 12px;
}
.upd-bubble p { margin: 0 0 6px; }
.upd-bubble p:last-child { margin: 0; }
.upd-bubble ul, .upd-bubble ol { padding-left: 18px; margin: 6px 0; }
.upd-bubble li { margin-bottom: 3px; }
.upd-bubble strong { font-weight: 700; }
.upd-bubble code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; font-size: 0.82em; }

/* Save status banner */
.upd-save-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  font-size: 0.83rem;
  color: #92400e;
  flex-shrink: 0;
}
.upd-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #fde68a;
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Input area */
.upd-input-area {
  padding: 14px 16px 14px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}
.upd-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  transition: border-color .15s;
}
.upd-input-wrap:focus-within { border-color: #FF4800; }

#updateInput {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Lexend Deca', sans-serif;
  font-size: 0.875rem;
  color: #0f172a;
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 24px;
  max-height: 120px;
}
#updateInput::placeholder { color: #94a3b8; }
#updateInput:disabled { opacity: .5; }

.upd-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: #FF4800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
}
.upd-send-btn:hover:not(:disabled) { background: #e03f00; transform: scale(1.05); }
.upd-send-btn:disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; }
.upd-send-btn svg { width: 16px; height: 16px; }

/* Footer row */
.upd-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  min-height: 28px;
}
.upd-hint {
  font-size: 0.73rem;
  color: #94a3b8;
}

/* Save & Regenerate button */
.upd-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #1e8a3c, #157a33);
  color: #fff;
  font-family: 'Lexend Deca', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(30,138,60,.3);
}
.upd-save-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #166d30, #0f5a26);
  box-shadow: 0 4px 14px rgba(30,138,60,.4);
  transform: translateY(-1px);
}
.upd-save-btn:disabled { background: #e2e8f0; color: #94a3b8; cursor: not-allowed; box-shadow: none; transform: none; }

@media (max-width: 700px) {
  .upd-modal { max-height: 100vh; border-radius: 0; max-width: 100%; }
  .upd-messages { min-height: 0; }
  .upd-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
  .upd-save-btn { width: 100%; justify-content: center; }
}

/* ── Regenerate nudge bar ────────────────────────────────────────────────── */
.eng-regen-nudge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #92400e;
  flex-wrap: wrap;
}
.eng-regen-nudge svg {
  flex-shrink: 0;
  color: #d97706;
}
.eng-regen-btn {
  margin-left: auto;
  padding: 5px 12px;
  border-radius: 6px;
  border: none;
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  font-family: 'Lexend Deca', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(217,119,6,.3);
}
.eng-regen-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #b45309, #92400e);
  box-shadow: 0 3px 10px rgba(217,119,6,.4);
  transform: translateY(-1px);
}
.eng-regen-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ── Delete discovery button ────────────────────────────────────────────────── */
.disc-delete-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid #e2e2e9;
  border-radius: 6px;
  background: #fff;
  color: #9a2020;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, border-color .15s;
  flex-shrink: 0;
}
.disc-card:hover .disc-delete-btn,
.disc-card-inprogress:hover .disc-delete-btn { opacity: 1; }
.disc-delete-btn:hover {
  background: #fff0f0;
  border-color: #e8b4b4;
  color: #c0392b;
}

/* ── Delete confirm modal ────────────────────────────────────────────────────── */
.del-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16,18,27,.55);
  backdrop-filter: blur(4px);
  padding: 20px;
  animation: authPop .15s ease;
}
.del-modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px 28px 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(10,12,20,.28);
  border: 1px solid #ececf2;
  text-align: center;
}
.del-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff0f0;
  color: #c0392b;
  margin: 0 auto 16px;
}
.del-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0 0 10px;
}
.del-modal-body {
  font-size: 14px;
  color: #555;
  line-height: 1.55;
  margin: 0 0 22px;
}
.del-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.del-btn-cancel {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #e0e0ea;
  border-radius: 8px;
  background: #fff;
  color: #555;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.del-btn-cancel:hover { background: #f5f5fa; }
.del-btn-confirm {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #c0392b;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.del-btn-confirm:hover { background: #a93226; }
.del-btn-confirm:disabled { background: #e08080; cursor: not-allowed; }

/* ── Mobile: prevent iOS Safari auto-zoom on input focus ──────────────────────
   Any focusable text field smaller than 16px makes iOS zoom the whole page in
   (and leaves it zoomed). Force a 16px floor on touch / small screens only, so
   the desktop type scale is unaffected. */
@media (max-width: 640px) {
  textarea#userInput,
  #updateInput,
  .stack-input-wrap input {
    font-size: 16px;
  }
}
