/* ══════════════════════════════════════════════
   WHATREPO — style.css  v3
   ══════════════════════════════════════════════ */

/* ── Variables ── */
:root {
  --bg:           #08090c;
  --surface:      #0f1117;
  --surface2:     #141720;
  --surface3:     #1a1f2e;
  --border:       #1e2535;
  --border2:      #252d40;
  --accent:       #3b82f6;
  --accent-glow:  rgba(59, 130, 246, 0.15);
  --accent-soft:  rgba(59, 130, 246, 0.08);
  --accent2:      #60a5fa;
  --warn:         #f59e0b;
  --warn-bg:      rgba(245, 158, 11, 0.08);
  --red:          #f87171;
  --green:        #34d399;
  --text:         #e2e8f4;
  --text-dim:     #94a3b8;
  --muted:        #475569;
  --font-mono:    'Space Mono', monospace;
  --font-head:    'Syne', sans-serif;
  --header-h:     58px;
  --footer-h:     86px;
  --max-chat:     800px;
  --radius:       10px;
  --radius-sm:    6px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════ HEADER ══════════════ */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(8, 9, 12, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 200;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark svg { display: block; }

.logo-text {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.25em;
  color: var(--text);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 12px 5px 9px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: border-color 0.3s, background 0.3s;
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

.status-dot.done { background: var(--green); }
.status-dot.chat { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ══════════════ WARNING BANNER ══════════════ */
.warning-banner {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  background: var(--warn-bg);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warn);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 20px;
  z-index: 190;
  letter-spacing: 0.04em;
  animation: bannerIn 0.35s cubic-bezier(0.4,0,0.2,1);
}

.warning-banner.hidden { display: none; }
.warn-icon { font-size: 0.95rem; }

#dismissWarning {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--warn);
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0.5;
  transition: opacity 0.2s;
  line-height: 1;
  padding: 2px 4px;
}
#dismissWarning:hover { opacity: 1; }

@keyframes bannerIn {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ══════════════ MAIN ══════════════ */
main {
  flex: 1;
  margin-top: var(--header-h);
  position: relative;
}

.page {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.page.active {
  opacity: 1;
  pointer-events: all;
  position: relative;
  min-height: calc(100vh - var(--header-h));
}

/* ══════════════ PAGE 1: LANDING ══════════════ */
#landingPage {
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.noise-overlay {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 200px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
}

.grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.25;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 30%, transparent 100%);
  z-index: 1;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  filter: blur(80px);
  opacity: 0.35;
}

.orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(59,130,246,0.4) 0%, transparent 70%);
  top: -120px; left: -80px;
  animation: orbDrift 12s ease-in-out infinite alternate;
}

.orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,0.3) 0%, transparent 70%);
  bottom: -80px; right: -60px;
  animation: orbDrift 16s ease-in-out infinite alternate-reverse;
}

@keyframes orbDrift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.08); }
}

.landing-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 60px 24px 80px;
  text-align: center;
  max-width: 720px;
  width: 100%;
}

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 28px;
  animation: fadeUp 0.6s ease both;
}

.eyebrow-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.hero-title {
  font-family: var(--font-head);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.title-line {
  font-size: clamp(3rem, 8vw, 5.5rem);
  color: var(--text);
  display: block;
  animation: fadeUp 0.6s ease both;
}

.title-line:nth-child(1) { animation-delay: 0.05s; }
.title-line:nth-child(2) { animation-delay: 0.12s; }
.title-line:nth-child(3) { animation-delay: 0.19s; }

.accent-line {
  color: var(--accent);
  position: relative;
  display: inline-block;
}

.hero-sub {
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.7;
  max-width: 460px;
  letter-spacing: 0.01em;
  margin-bottom: 40px;
  animation: fadeUp 0.6s ease 0.25s both;
}

.input-card {
  width: min(620px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 6px 6px 6px 0;
  display: flex;
  align-items: center;
  gap: 0;
  transition: border-color 0.25s, box-shadow 0.25s;
  animation: fadeUp 0.6s ease 0.32s both;
  margin-bottom: 20px;
}

.input-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 8px 40px rgba(59,130,246,0.08);
}

.input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0;
}

.input-icon {
  padding: 0 12px 0 16px;
  color: var(--accent);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

input, textarea {
  -webkit-user-select: auto;
  user-select: auto;
  cursor: text;
}

.input-wrap input {
  flex: 1;
  background: none;
  border: none;
  padding: 13px 12px 13px 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  outline: none;
  letter-spacing: 0.01em;
}

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

.analyse-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 11px 20px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  white-space: nowrap;
}

.analyse-btn:hover {
  background: var(--accent2);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(59,130,246,0.35);
}

.analyse-btn:active { transform: translateY(0); }

.btn-arrow-icon {
  transition: transform 0.2s;
}

.analyse-btn:hover .btn-arrow-icon { transform: translateX(2px); }

.landing-hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  animation: fadeUp 0.6s ease 0.4s both;
}

.hint-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 13px;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  transition: border-color 0.2s, color 0.2s;
  cursor: default;
}

.hint-chip:hover {
  border-color: var(--border2);
  color: var(--text);
}

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

/* ══════════════ PAGE 2: PROCESSING ══════════════ */
#processingPage {
  align-items: center;
  justify-content: center;
}

.processing-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 24px;
  padding: 48px 24px;
  width: min(560px, 92vw);
}

.processing-header {
  display: flex;
  align-items: center;
  gap: 18px;
}

.proc-spinner {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.spinner-ring {
  width: 100%;
  height: 100%;
  animation: spinRing 1.1s linear infinite;
  transform-origin: center;
}

@keyframes spinRing {
  to { transform: rotate(360deg); }
}

.proc-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.proc-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: 0.05em;
}

.proc-subtitle {
  font-size: 0.73rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: opacity 0.3s;
}

/* ── Steps container ── */
.steps-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Step box ── */
.step-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  opacity: 0;
  transform: translateY(8px);
  animation: stepIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  /* Only transition the properties we animate manually via JS */
  transition: height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
              padding-top 0.38s cubic-bezier(0.4, 0, 0.2, 1),
              padding-bottom 0.38s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.3s ease,
              border-color 0.3s ease;
  overflow: hidden;
}

.step-box.done-green {
  background: rgba(52, 211, 153, 0.04);
  border-color: rgba(52, 211, 153, 0.18);
}

.step-box.warn-yellow {
  background: var(--warn-bg);
  border-color: rgba(245, 158, 11, 0.22);
}

.step-box.err-red {
  background: rgba(248, 113, 113, 0.05);
  border-color: rgba(248, 113, 113, 0.22);
}

/* ── Step title row ── */
.step-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 22px; /* fixed so collapsed height = padding*2 + 22 = ~46 */
  /* margin-bottom: 10px; */
}

.step-box .sub-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.2s;
}

/* ── Step icon wrapper ── */
.step-icon-wrap {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* CSS ring spinner — replaces the old character spinner */
.step-ring-spinner {
  display: block;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinRing 0.7s linear infinite;
}

/* Status icon that replaces spinner when done */
.step-status-icon {
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
  display: block;
}
.step-status-icon.green { color: var(--green); }
.step-status-icon.warn  { color: var(--warn); }
.step-status-icon.err   { color: var(--red); }

/* Collapsed badge (Done / Warning / Error label) */
.step-collapsed-badge {
  font-size: 0.67rem;
  letter-spacing: 0.04em;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.25s ease 0.25s;
  font-family: var(--font-mono);
}

/* Badge becomes visible only when height has settled */
.step-box.done-green  .step-collapsed-badge { color: var(--green); }
.step-box.warn-yellow .step-collapsed-badge { color: var(--warn);  }
.step-box.err-red     .step-collapsed-badge { color: var(--red);   }

/* We reveal badge via JS after transition ends, not via .collapsed class */
.step-collapsed-badge.visible { opacity: 1; }

@keyframes stepIn {
  to { opacity: 1; transform: translateY(0); }
}

.sub-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.73rem;
  color: var(--muted);
}

.sub-item.done { color: var(--green); }

.sub-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.sub-item.done .sub-dot { background: var(--green); }

/* ── Processing action card (error / warning gate) ── */
.proc-action-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-radius: var(--radius);
  padding: 18px 20px;
  opacity: 0;
  transform: translateY(8px);
  animation: stepIn 0.35s 0.1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  margin-top: 4px;
}

.proc-action-card.proc-action-error {
  background: rgba(248, 113, 113, 0.06);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.proc-action-card.proc-action-warning {
  background: var(--warn-bg);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.proc-action-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.proc-action-card.proc-action-error   .proc-action-icon { color: var(--red);  }
.proc-action-card.proc-action-warning .proc-action-icon { color: var(--warn); }

.proc-action-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.proc-action-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.proc-action-card.proc-action-error   .proc-action-title { color: var(--red);  }
.proc-action-card.proc-action-warning .proc-action-title { color: var(--warn); }

.proc-action-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.proc-action-btn {
  margin-top: 10px;
  align-self: flex-start;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
}

.proc-action-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.proc-action-btn:active { transform: translateY(0); }

.proc-btn-error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.proc-btn-error:hover { box-shadow: 0 4px 16px rgba(248, 113, 113, 0.15); }

.proc-btn-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.proc-btn-warning:hover { box-shadow: 0 4px 16px rgba(245, 158, 11, 0.12); }

/* ══════════════ PAGE 3: CHAT ══════════════ */
#chatPage {
  align-items: stretch;
}

.chat-messages {
  flex: 1;
  width: 100%;
  max-width: var(--max-chat);
  margin: 0 auto;
  padding: 32px 28px calc(var(--footer-h) + 40px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  height: calc(100vh - var(--header-h));
  scroll-behavior: smooth;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* Welcome state */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  gap: 12px;
  animation: fadeUp 0.5s ease both;
}

.welcome-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.6;
}

.welcome-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  color: var(--text);
  letter-spacing: 0.02em;
}

.welcome-sub {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.welcome-chip {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.75rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s;
  letter-spacing: 0.02em;
}

.welcome-chip:hover {
  border-color: var(--accent);
  color: var(--accent2);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* ── Message groups ── */
.msg-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: msgIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.msg-group.user { align-items: flex-end; }
.msg-group.bot  { align-items: flex-start; }

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

.msg-sender {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
}

/* ── User bubble: stays boxed ── */
.msg-bubble.user {
  max-width: min(520px, 88%);
  padding: 11px 16px;
  border-radius: var(--radius);
  border-bottom-right-radius: 3px;
  font-size: 0.87rem;
  line-height: 1.7;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: var(--text);
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}

/* ── Bot bubble: transparent, no border ── */
.msg-bubble.bot {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.87rem;
  line-height: 1.75;
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
  padding: 2px 0;
  width: 100%;
}

/* ── Markdown elements inside bot bubble ── */
.msg-bubble.bot p {
  margin-bottom: 0.75em;
}
.msg-bubble.bot p:last-child {
  margin-bottom: 0;
}

.msg-bubble.bot h1,
.msg-bubble.bot h2,
.msg-bubble.bot h3,
.msg-bubble.bot h4 {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--text);
  margin: 1.1em 0 0.45em;
  letter-spacing: 0.02em;
}
.msg-bubble.bot h1 { font-size: 1.2rem; }
.msg-bubble.bot h2 { font-size: 1.05rem; }
.msg-bubble.bot h3 { font-size: 0.95rem; }

.msg-bubble.bot ul,
.msg-bubble.bot ol {
  padding-left: 1.4em;
  margin-bottom: 0.75em;
}
.msg-bubble.bot li { margin-bottom: 0.25em; }

.msg-bubble.bot strong { color: var(--text); font-weight: 700; }
.msg-bubble.bot em     { color: var(--text-dim); }

.msg-bubble.bot a {
  color: var(--accent2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.msg-bubble.bot blockquote {
  border-left: 3px solid var(--border2);
  padding-left: 12px;
  color: var(--text-dim);
  margin: 0.75em 0;
  font-style: italic;
}

/* Inline code */
.msg-bubble.bot :not(pre) > code {
  font-family: var(--font-mono);
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.8em;
  color: var(--accent2);
  word-break: break-all;
}

/* ── Code block wrapper ── */
.code-block-wrap {
  margin: 10px 0;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface2);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: var(--surface3);
  border-bottom: 1px solid var(--border);
}

.code-lang-label {
  font-size: 0.67rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 0.67rem;
  font-family: var(--font-mono);
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.code-copy-btn:hover {
  color: var(--text-dim);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.msg-bubble.bot pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.6;
  border: none;
  border-radius: 0;
  background: transparent;
}

.msg-bubble.bot pre code {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  word-break: normal;
}

/* ── Copy response button ── */
.msg-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.2s, border-color 0.2s;
  margin-top: 2px;
  align-self: flex-start;
}

.msg-copy-btn:hover {
  color: var(--text-dim);
  border-color: var(--border2);
}

.msg-meta {
  font-size: 0.62rem;
  color: var(--muted);
  padding: 0 4px;
  letter-spacing: 0.04em;
}

/* ══════════════ THINKING / TOOL-USE SECTION ══════════════ */
.thinking-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-self: flex-start;
  /* Indent + left accent bar to distinguish from main response */
  padding-left: 14px;
  border-left: 2px solid var(--border2);
  margin-left: 2px;
  width: calc(100% - 16px);
  animation: msgIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.thinking-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  background: transparent;
  border: none;
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
  user-select: none;
  letter-spacing: 0.04em;
  width: 100%;
  text-align: left;
}

.thinking-toggle:hover { color: var(--text-dim); }

.thinking-toggle.active { color: var(--accent2); }

.thinking-spinner {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.thinking-spinner svg {
  animation: spinRing 0.9s linear infinite;
  display: block;
}

.thinking-spinner.done svg { animation: none; }

.thinking-chevron {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform 0.25s ease;
  opacity: 0.45;
}

.thinking-toggle.open .thinking-chevron { transform: rotate(180deg); }

/* Panel */
.thinking-steps-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  opacity: 0;
}

.thinking-steps-panel.open {
  max-height: 400px;
  opacity: 1;
}

.thinking-steps-inner {
  padding: 8px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  max-height: 380px;
}

/* Individual thinking step */
.thinking-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.75rem;
  color: #ffffff;
  line-height: 1.55;
  opacity: 0.75;
}

.thinking-step-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  margin-top: 6px;
}

.thinking-step-text {
  flex: 1;
}

.thinking-step.current {
  color: var(--text-dim);
  opacity: 1;
}

.thinking-step.current .thinking-step-dot {
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent);
}

.thinking-step.done-step {
  opacity: 0.55;
}

.thinking-step.done-step .thinking-step-dot {
  background: var(--green);
}

/* ══════════════ FOOTER ══════════════ */
#footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 12px 20px 14px;
  background: rgba(8, 9, 12, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#footer.hidden { display: none; }

.chat-input-card {
  width: min(var(--max-chat), calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-end;
  gap: 0;
  transition: border-color 0.25s, box-shadow 0.25s;
  padding: 4px 4px 4px 0;
}

.chat-input-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#chatInput {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  resize: none;
  line-height: 1.55;
  max-height: 160px;
  overflow-y: auto;
  letter-spacing: 0.01em;
}

#chatInput::placeholder { color: var(--muted); }

.send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  margin: 5px 0px;
}

.send-btn:hover {
  background: var(--accent2);
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(59,130,246,0.35);
}

.send-btn:active { transform: scale(0.96); }

.footer-hint {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

kbd {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-dim);
}

/* ══════════════ UTILITIES ══════════════ */
.hidden { display: none !important; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
