/* ══════════════════════════════════════════════
   KODIO — Design System

   Concept: The interface IS the product metaphor.
   Left = dark = raw code = complexity.
   Right = light = analysis = clarity.
   The vertical seam between panels is KODIO doing its job.

   Colors carry meaning, not decoration:
   --s-blue   → structure / logic (cold, precise)
   --s-orange → bottleneck / warning (heat, pressure)
   --s-red    → risk (danger)
   --s-green  → suggestion / safe (growth)
   --s-purple → flow / async (depth)

   Color only has power when it's rare.
   No primary color on default interactive elements.
   Buttons are ink-on-surface. Color appears only when
   there's something to signal.
══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Source+Code+Pro:wght@400;500&display=swap');

/* ── Design tokens ── */
:root {
  /* Light side (analysis panel) */
  --bg:       #f5f5f2;
  --surface:  #ffffff;
  --ink-1:    #111111;
  --ink-2:    #3d3d3d;
  --ink-3:    #7a7a7a;
  --ink-4:    #b8b8b2;
  --border:   #e4e4de;
  --border-2: #d0d0c8;

  /* Dark side (code panel) */
  --code-bg:      #13131a;
  --code-surface: #1c1c26;
  --code-text:    #c8c8df;
  --code-muted:   #3c3c52;
  --code-border:  #252535;
  --code-dim:     #5a5a78;

  /* Signal colors — used sparingly */
  --s-blue:   #0047ff;
  --s-orange: #ff4d00;
  --s-red:    #e5001c;
  --s-green:  #00924a;
  --s-purple: #6600cc;

  --navbar-h: 48px;
  --panel-left-w: 44%;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', 'Fira Code', monospace;
  --ease: 0.16s ease;
}

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

/* Hide all scrollbars — clean tool feel */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; }
body {
  font-family: var(--font);
  background: var(--code-bg);
  color: var(--ink-1);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; }
a { text-decoration: none; color: inherit; }


/* ══════════════════════════════════════════════
   NAVBAR
   Structurally split: brand on dark, actions on light.
   The header seam mirrors the panel seam below — intentional.
══════════════════════════════════════════════ */
.navbar {
  display: flex;
  height: var(--navbar-h);
  position: relative;
  z-index: 50;
}

.nav-brand {
  width: var(--panel-left-w);
  min-width: 280px;
  flex-shrink: 0;
  background: var(--code-bg);
  border-bottom: 1px solid var(--code-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
}

.nav-actions {
  flex: 1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
  gap: 2px;
}

.logo-text {
  font-family: 'Source Code Pro', monospace;
  font-size: 1.05rem;
  font-weight: 400;
  color: #ffffff;
  letter-spacing: -0.04em;
}

.nav-btn {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-3);
  padding: 5px 10px;
  border-radius: 5px;
  transition: color var(--ease), background var(--ease);
}
.nav-btn:hover { color: var(--ink-1); background: rgba(0,0,0,0.05); }


/* ══════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════ */
.app-shell {
  display: flex;
  height: calc(100vh - var(--navbar-h));
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Left panel: dark code editor ── */
.panel-left {
  width: var(--panel-left-w);
  min-width: 280px;
  flex-shrink: 0;
  background: var(--code-bg);
  /* Seam: default shadow. Intensifies on connection events. */
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.22);
  position: relative;
  z-index: 1;
  transition: box-shadow 0.35s ease;
}
/* Hovering a card / trace playback — connection is active */
.panel-left.panel-connected {
  box-shadow: 5px 0 32px rgba(0, 0, 0, 0.32);
}
/* Analysis completes — brief pulse as the two panels sync */
.panel-left.analysis-pulse {
  box-shadow: 7px 0 44px rgba(0, 0, 0, 0.42);
}

/* ── Right panel: light analysis ── */
.panel-right {
  flex: 1;
  background: var(--bg);
  overflow-y: auto;
  min-width: 0;
}


/* ══════════════════════════════════════════════
   LEFT PANEL — Code Editor
══════════════════════════════════════════════ */
.left-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--code-border);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 8px; }

.panel-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--code-dim);
}

/* Language badge — appears on dark panel */
.lang-badge {
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--s-blue);
  background: rgba(0, 71, 255, 0.15);
  border: 1px solid rgba(0, 71, 255, 0.2);
  padding: 1px 7px;
  border-radius: 3px;
  display: none;
  letter-spacing: 0.04em;
}
.lang-badge.visible {
  display: inline-block;
  animation: badgeEnter 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes badgeEnter {
  from { opacity: 0; transform: scale(0.8) translateY(1px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.upload-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--code-dim);
  padding: 4px 8px;
  border-radius: 4px;
  transition: color var(--ease), background var(--ease);
}
.upload-btn:hover { color: var(--code-text); background: var(--code-surface); }

/* Editor area */
.editor-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.mode-input .code-textarea { display: block; }
.mode-input .code-display  { display: none; }
.mode-input .edit-btn      { display: none !important; }

.mode-display .code-textarea { display: none; }
.mode-display .code-display  { display: block; }
.mode-display .edit-btn      { display: inline-flex !important; }

.code-textarea {
  width: 100%;
  height: 100%;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.85;
  color: var(--code-text);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 18px 18px 18px 12px;
  caret-color: var(--s-orange);
}
.code-textarea::placeholder {
  color: var(--code-muted);
  font-style: normal;
}

/* Annotated code display (post-analysis) */
.code-display {
  width: 100%;
  height: 100%;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.85;
  color: var(--code-text);
  background: transparent;
  overflow: auto;
  padding: 18px 0;
  white-space: pre;
}

/* Line spans with line numbers */
.code-line {
  display: block;
  padding: 0 18px 0 0;
  padding-left: 0;
  transition: background 0.22s ease, color 0.22s ease, opacity 0.22s ease, border-left-color 0.22s ease;
  border-left: 2px solid transparent;
}
.code-line::before {
  content: attr(data-line);
  display: inline-block;
  min-width: 3em;
  text-align: right;
  padding-right: 14px;
  color: var(--code-muted);
  font-size: 0.72em;
  user-select: none;
  opacity: 0.5;
}

/* Line highlight states — triggered by hovering insight cards */
.code-line.line-dimmed { opacity: 0.2; }
.code-line.line-active {
  background: rgba(255, 77, 0, 0.07);
  border-left-color: var(--s-orange);
  color: #e8e8f8;
}
.code-line.line-active::before { opacity: 1; color: var(--s-orange); }

/* Shake on empty submit */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}
.shake { animation: shake 0.28s ease; }

/* Left panel footer */
.left-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid var(--code-border);
  flex-shrink: 0;
  background: var(--code-bg);
}

.edit-btn {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--code-dim);
  padding: 6px 11px;
  border-radius: 5px;
  transition: color var(--ease), background var(--ease);
}
.edit-btn:hover { color: var(--code-text); background: var(--code-surface); }

/* Primary action button — ink on surface, not a colored pill */
.explain-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--code-bg);
  background: var(--code-text);
  padding: 8px 16px;
  border-radius: 5px;
  letter-spacing: -0.01em;
  transition: opacity var(--ease), transform var(--ease);
}
.explain-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.explain-btn:active { transform: translateY(0); }
.explain-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

@keyframes spin { to { transform: rotate(360deg); } }
.explain-btn.loading .btn-icon { animation: spin 0.6s linear infinite; }


/* ══════════════════════════════════════════════
   MODE SELECTOR
   The full-width header of the right panel.
   This is the product's defining UX feature —
   it earns its visual weight.
══════════════════════════════════════════════ */
.mode-selector {
  display: flex;
  border-bottom: 1px solid var(--border-2);
  background: var(--surface);
  flex-shrink: 0;
}

.mode-opt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 11px 16px 9px;
  position: relative;
  border-bottom: 2px solid transparent;
  transition: border-color var(--ease);
  gap: 2px;
}
.mode-opt + .mode-opt { border-left: 1px solid var(--border); }

.mode-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-4);
  transition: color var(--ease);
  letter-spacing: -0.01em;
}
.mode-desc {
  font-size: 0.63rem;
  font-family: var(--mono);
  color: var(--ink-4);
  opacity: 0;
  transition: opacity var(--ease);
  letter-spacing: 0.02em;
}

/* Active tab: underline + text color shift */
.mode-opt.active {
  border-bottom-color: var(--s-blue);
}
.mode-opt.active .mode-name { color: var(--ink-1); }
.mode-opt.active .mode-desc { color: var(--ink-3); opacity: 1; }

/* Non-active gets its desc on hover */
.mode-opt:not(.active):hover .mode-name { color: var(--ink-2); }
.mode-opt:not(.active):hover .mode-desc { opacity: 0.6; }


/* ══════════════════════════════════════════════
   OUTPUT STATES
══════════════════════════════════════════════ */
.output-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--navbar-h) - 62px);
  padding: 40px 28px;
  gap: 0;
}

/* Empty state */
.empty-copy { text-align: center; margin-bottom: 32px; }
.empty-headline {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.empty-sub { font-size: 0.82rem; color: var(--ink-4); }

/* Skeleton preview — communicates the card format without a tutorial */
.skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.skel-card {
  background: var(--border-2);
  border-radius: 6px;
  animation: skelPulse 2.2s ease-in-out infinite;
}
.skel-tall  { height: 78px; }
.skel-mid   { height: 58px; animation-delay: 0.35s; opacity: 0.7; }
.skel-short { height: 44px; animation-delay: 0.7s;  opacity: 0.45; }

@keyframes skelPulse {
  0%, 100% { opacity: 0.18; }
  50%       { opacity: 0.32; }
}

/* Loading steps */
.loading-steps { display: flex; flex-direction: column; gap: 16px; }
.loading-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--ink-4);
  opacity: 0.3;
  transition: opacity 0.22s, color 0.22s;
}
.loading-step.active { opacity: 1; color: var(--s-blue); }
.loading-step.done   { opacity: 0.65; color: var(--s-green); }

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
@keyframes pulse {
  0%,100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.6); opacity: 0.5; }
}
.loading-step.active .step-dot { animation: pulse 0.75s ease infinite; }


/* ══════════════════════════════════════════════
   OUTPUT CONTENT
══════════════════════════════════════════════ */
.output-content {
  padding: 18px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Entrance fade — results appear, not pop */
  opacity: 0;
  transition: opacity 0.24s ease;
}
.output-content.results-visible {
  opacity: 1;
}

/* ── Complexity readout — data-forward, not a widget ── */
.complexity-readout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.readout-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  flex-shrink: 0;
}

.readout-bar-wrap { flex: 1; }
.readout-track {
  height: 3px;
  background: var(--border-2);
  border-radius: 100px;
  overflow: hidden;
}
.readout-fill {
  height: 100%;
  width: 0;
  border-radius: 100px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.readout-value {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-1);
  flex-shrink: 0;
  min-width: 5.5em;
  text-align: right;
}


/* ══════════════════════════════════════════════
   INSIGHT CARDS

   Numbered (01, 02...) — data format, not dashboard format.
   Top accent line based on type — replaces the generic left border.
   Signal dot in the meta row — color only where it signals something.
   Hover: lift + right-translate to connect to the code panel.
══════════════════════════════════════════════ */
.insights {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Base transition so mode-switching snap-back fades in, not jumps */
  transition: opacity 0.18s ease, transform 0.18s ease;
}
/* Junior = breathing room. Senior = tight and dense. */
.insights[data-mode="junior"] { gap: 10px; }
.insights[data-mode="senior"] { gap: 6px;  }

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

/* Mode transition — timing driven by JS via CSS var.
   Junior: 160ms (relaxed). Senior: 90ms (sharp). */
.insights.mode-switching {
  opacity: 0;
  transform: translateY(3px);
  transition: opacity var(--switch-duration, 130ms) ease,
              transform var(--switch-duration, 130ms) ease;
}

.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px 13px;
  position: relative;
  overflow: hidden;
  cursor: default;
  animation: slideIn 0.22s ease both;
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}

/* Top accent line — 2px, type-specific color */
.insight-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--s-blue);
}
.insight-card[data-type="warning"]::before { background: var(--s-orange); }
.insight-card[data-type="tip"]    ::before { background: var(--s-green); }
.insight-card[data-type="risk"]   ::before { background: var(--s-red); }
.insight-card[data-type="logic"]  ::before { background: var(--s-purple); }

/* Hover: lift + nudge rightward (toward the code panel) */
.insight-card:hover {
  box-shadow: -3px 4px 18px rgba(0,0,0,0.07);
  transform: translateX(-2px) translateY(-1px);
}

/* Meta row: index · label · signal dot */
.insight-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.insight-index {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}

.insight-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

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

.insight-spacer { flex: 1; }
.insight-card[data-type="warning"] .insight-dot { background: var(--s-orange); }
.insight-card[data-type="tip"]     .insight-dot { background: var(--s-green); }
.insight-card[data-type="risk"]    .insight-dot { background: var(--s-red); }
.insight-card[data-type="logic"]   .insight-dot { background: var(--s-purple); }

.insight-headline {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-1);
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 6px;
}

.insight-body {
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--ink-2);
}
.insight-body code {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: rgba(0,0,0,0.05);
  color: var(--s-blue);
  padding: 1px 4px;
  border-radius: 3px;
}


/* ── Output footer ── */
.output-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 2px;
  gap: 10px;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--ink-4);
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  transition: color var(--ease), border-color var(--ease);
}
.copy-btn:hover { color: var(--ink-1); border-color: var(--border-2); }


/* ══════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 18, 0.6);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-overlay.open .modal { transform: translateY(0) scale(1); opacity: 1; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  box-shadow: 0 28px 72px rgba(10, 10, 18, 0.28);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 0.88rem; font-weight: 700; color: var(--ink-1); letter-spacing: -0.01em; }
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  color: var(--ink-3);
  transition: color var(--ease), background var(--ease);
}
.modal-close:hover { color: var(--ink-1); background: rgba(0,0,0,0.05); }
.modal-body { overflow-y: auto; padding: 16px 20px; flex: 1; }

/* History items */
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.history-item-top  { display: flex; align-items: center; gap: 8px; }
.history-lang {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--s-blue);
  background: rgba(0,71,255,0.08);
  padding: 1px 6px;
  border-radius: 3px;
}
.history-time { font-size: 0.68rem; color: var(--ink-4); }
.history-preview {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.history-item-actions { display: flex; gap: 5px; flex-shrink: 0; }
.history-reopen, .history-delete {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 4px;
  transition: background var(--ease);
}
.history-reopen { background: rgba(0,71,255,0.08); color: var(--s-blue); }
.history-reopen:hover { background: rgba(0,71,255,0.15); }
.history-delete { background: rgba(229,0,28,0.07); color: var(--s-red); }
.history-delete:hover { background: rgba(229,0,28,0.14); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 0;
  color: var(--ink-4);
  text-align: center;
}
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 0.82rem; line-height: 1.6; }

/* Docs */
.docs-content { display: flex; flex-direction: column; gap: 14px; }
.docs-content h3 { font-size: 0.82rem; font-weight: 700; color: var(--ink-1); margin-bottom: -6px; }
.docs-content p  { font-size: 0.81rem; color: var(--ink-2); line-height: 1.7; }
.docs-content strong { color: var(--ink-1); font-weight: 600; }
kbd {
  font-family: var(--mono);
  font-size: 0.71rem;
  background: rgba(0,0,0,0.06);
  border: 1px solid var(--border-2);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--ink-1);
}


/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
/* ══════════════════════════════════════════════
   PRIMARY CARD — first insight, dominant
══════════════════════════════════════════════ */
.insight-card--primary {
  padding: 17px 18px 15px;
}
.insight-card--primary .insight-headline {
  font-size: 1rem;
}

/* ══════════════════════════════════════════════
   CONFIDENCE BADGE
   Only shown on medium-confidence insights.
   Honest about what the pattern matcher can't guarantee.
══════════════════════════════════════════════ */
.confidence-badge {
  font-size: 0.57rem;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  /* Neutral annotation — not a warning, just honesty about the method's limits */
  color: var(--ink-4);
  flex-shrink: 0;
  margin-right: 6px;
}

/* ══════════════════════════════════════════════
   LANGUAGE WARNING
   Low-confidence detection or unknown language.
══════════════════════════════════════════════ */
.lang-warning {
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--s-orange);
  background: rgba(255, 77, 0, 0.06);
  border: 1px solid rgba(255, 77, 0, 0.18);
  border-radius: 5px;
  padding: 7px 12px;
}

/* ══════════════════════════════════════════════
   ANALYSIS DISCLAIMER
   Honest limitation note at the bottom.
══════════════════════════════════════════════ */
.analysis-disclaimer {
  font-size: 0.62rem;
  font-family: var(--mono);
  color: var(--ink-4);
  letter-spacing: 0.02em;
  flex: 1;
}

/* ══════════════════════════════════════════════
   TRACE MODE
   Line-by-line execution walkthrough.
   Each step: line number | code snippet | description.
══════════════════════════════════════════════ */
.trace-content {
  display: flex;
  flex-direction: column;
}

/* ── Playback controls ── */
.trace-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  flex-shrink: 0;
}
.trace-controls-left { display: flex; align-items: center; gap: 4px; }
.trace-controls-right { display: flex; align-items: center; }

.trace-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
}
.trace-btn:hover { background: var(--bg); color: var(--ink-1); }
.trace-btn.is-playing {
  background: var(--ink-1);
  color: #fff;
  border-color: var(--ink-1);
}
.trace-speed-btn { width: auto; padding: 0 7px; }

.trace-progress {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}

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

/* ── Individual step ── */
.trace-step {
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 3px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: default;
  /* Entry state — revealed by JS */
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.2s ease, transform 0.2s ease,
              box-shadow 0.12s ease, background 0.18s ease,
              border-color 0.18s ease;
}
/* Currently executing step */
.trace-step--active {
  opacity: 1;
  transform: translateY(0);
  background: var(--bg);
  border-color: var(--border-2);
}
/* Already executed — subtly dimmed to show progress */
.trace-step--past {
  opacity: 0.42;
  transform: translateY(0);
}
.trace-step--past:hover { opacity: 0.72; }
/* Playback finished — all steps fully visible */
.trace-step--done {
  opacity: 1;
  transform: translateY(0);
}

/* Hover lift — same as insight cards */
.trace-step:not(.trace-step--pending):hover {
  box-shadow: -3px 4px 18px rgba(0,0,0,0.07);
  transform: translateX(-2px) translateY(-1px);
}

.trace-line-num {
  grid-row: 1 / 3;
  align-self: center;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--ink-4);
  letter-spacing: 0.02em;
}

.trace-code {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trace-desc {
  font-size: 0.79rem;
  color: var(--ink-1);
  line-height: 1.5;
}
.trace-desc code {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: rgba(0,0,0,0.05);
  color: var(--s-blue);
  padding: 1px 4px;
  border-radius: 3px;
}

.trace-empty {
  font-size: 0.8rem;
  color: var(--ink-3);
  padding: 20px 0;
  text-align: center;
  font-style: italic;
}

@media (max-width: 700px) {
  body { overflow: auto; }

  .navbar { flex-direction: column; height: auto; }
  .nav-brand  { width: 100%; min-width: 0; padding: 10px 16px; border-right: none; }
  .nav-actions { width: 100%; border-left: none; padding: 8px 16px; }

  .app-shell {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  .panel-left  { width: 100%; min-width: 0; height: 45vh; }
  .panel-right { height: auto; min-height: 55vh; }
  .output-state { min-height: 40vh; }
}
