/* ============================================================
   Ralph Monitor — Mission Control Dashboard
   Theme: Hacker Terminal / Living Coral
   ============================================================ */

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
  --bg:            #0a0a0a;
  --bg-panel:      rgba(17, 17, 17, 0.75);
  --bg-panel-alt:  rgba(13, 13, 13, 0.60);

  --coral:         #FF6F61;
  --coral-dark:    #CC5850;
  --coral-dim:     rgba(255, 111, 97, 0.15);

  --green:         #00FF41;
  --green-dim:     rgba(0, 255, 65, 0.12);
  --cyan:          #00D4FF;
  --cyan-dim:      rgba(0, 212, 255, 0.12);
  --amber:         #FFB000;
  --amber-dim:     rgba(255, 176, 0, 0.12);
  --red:           #FF3333;
  --red-dim:       rgba(255, 51, 51, 0.12);

  --text:          rgba(255, 255, 255, 0.80);
  --text-dim:      rgba(255, 255, 255, 0.40);
  --text-faint:    rgba(255, 255, 255, 0.20);

  --border:        rgba(255, 255, 255, 0.06);
  --border-coral:  rgba(255, 111, 97, 0.30);

  --font:          'JetBrains Mono', monospace;

  --radius:        4px;
  --gap:           10px;
  --panel-pad:     14px;

  /* Glow intensities */
  --glow-coral:    0 0 8px rgba(255, 111, 97, 0.7), 0 0 20px rgba(255, 111, 97, 0.3);
  --glow-green:    0 0 8px rgba(0, 255, 65, 0.7),  0 0 20px rgba(0, 255, 65, 0.3);
  --glow-cyan:     0 0 8px rgba(0, 212, 255, 0.7), 0 0 20px rgba(0, 212, 255, 0.3);
  --glow-amber:    0 0 8px rgba(255, 176, 0, 0.7), 0 0 20px rgba(255, 176, 0, 0.3);
  --glow-red:      0 0 8px rgba(255, 51, 51, 0.7), 0 0 20px rgba(255, 51, 51, 0.3);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Matrix Canvas ──────────────────────────────────────────── */
#matrix-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}

/* ── Status Dot ─────────────────────────────────────────────── */
.status-dot {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  z-index: 100;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.status-dot.connected {
  background: var(--green);
  box-shadow: var(--glow-green);
  animation: pulse-green 2s ease-in-out infinite;
}

.status-dot.disconnected {
  background: var(--red);
  box-shadow: var(--glow-red);
  animation: pulse-red 2s ease-in-out infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Session Picker ────────────────────────────────────────── */
.session-picker {
  position: fixed;
  top: 10px;
  right: 36px;
  z-index: 100;
}

.session-select {
  background: var(--bg-panel);
  color: var(--coral);
  border: 1px solid var(--border-coral);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  outline: none;
  min-width: 120px;
}

.session-select:focus {
  border-color: var(--coral);
  box-shadow: 0 0 6px rgba(255, 111, 97, 0.3);
}

.session-select option {
  background: var(--bg);
  color: var(--text);
  padding: 4px;
}

.session-select option[value="live"] {
  color: var(--green);
  font-weight: 700;
}

/* ── App Grid ───────────────────────────────────────────────── */
.app-grid {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  padding: var(--gap);
  display: grid;
  grid-template-rows: 1fr auto auto auto;
  gap: var(--gap);
  overflow: hidden;
}

/* ── Top Row ────────────────────────────────────────────────── */
.top-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--gap);
  min-height: 0;
  overflow: hidden;
}

/* ── Metrics Row ────────────────────────────────────────────── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  height: 130px;
  flex-shrink: 0;
}

/* ── Timeline Panel ─────────────────────────────────────────── */
.timeline-panel {
  height: 80px;
  flex-shrink: 0;
}

/* ── Panel Base ─────────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--panel-pad);
  position: relative;
  overflow: hidden;
}

/* Scanline overlay on panels */
.panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  z-index: 0;
  border-radius: var(--radius);
}

.panel > * {
  position: relative;
  z-index: 1;
}

/* ── Panel Header ───────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  color: var(--coral);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-badge {
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.05em;
}

/* ── Cat Panel ──────────────────────────────────────────────── */
.cat-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  background: transparent;
  border-color: transparent;
}

.cat-panel::after {
  display: none;
}

.cat-panel .panel-header {
  width: 100%;
}

.cat-state-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.cat-state-label.state-working  { color: var(--coral); }
.cat-state-label.state-thinking { color: var(--cyan); }
.cat-state-label.state-error    { color: var(--red); }
.cat-state-label.state-complete { color: var(--green); }
.cat-state-label.state-sleeping { color: var(--text-dim); }

.cat-meta {
  margin-top: auto;
  width: 100%;
  text-align: center;
}

.cat-session-id {
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
}

/* ── Gate Compliance Bar ────────────────────────────────────── */
.gate-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  width: 100%;
}

.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.3s ease;
}

.gate-icon {
  font-size: 12px;
  color: var(--text-faint);
  transition: color 0.3s ease;
}

.gate-label {
  font-size: 7px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  transition: color 0.3s ease;
}

.gate-sep {
  font-size: 10px;
  color: var(--text-faint);
  opacity: 0.3;
}

.gate.done .gate-icon {
  color: var(--green);
}
.gate.done .gate-label {
  color: var(--green);
}

.gate.active .gate-icon {
  color: var(--cyan);
  animation: gate-pulse 1.5s ease-in-out infinite;
}
.gate.active .gate-label {
  color: var(--cyan);
}

.gate.skipped .gate-icon {
  color: var(--coral);
}
.gate.skipped .gate-label {
  color: var(--coral);
}

@keyframes gate-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Log Panel ──────────────────────────────────────────────── */
.log-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.log-stream {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding-right: 4px;
  min-height: 0;
}

/* Thin coral scrollbar */
.log-stream::-webkit-scrollbar {
  width: 3px;
}
.log-stream::-webkit-scrollbar-track {
  background: transparent;
}
.log-stream::-webkit-scrollbar-thumb {
  background: var(--coral-dark);
  border-radius: 2px;
}
.log-stream::-webkit-scrollbar-thumb:hover {
  background: var(--coral);
}

/* ── Log Entries ────────────────────────────────────────────── */
.log-entry {
  display: grid;
  grid-template-columns: 58px 36px 1fr;
  gap: 6px;
  align-items: baseline;
  padding: 3px 6px 3px 8px;
  margin-bottom: 2px;
  border-radius: 2px;
  border-left: 2px solid var(--border);
  background: var(--bg-panel-alt);
  transition: border-color 0.2s ease;
  animation: log-in 0.2s ease-out forwards;
}

@keyframes log-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.log-entry.log-edit   { border-left-color: var(--cyan); }
.log-entry.log-bash   { border-left-color: var(--amber); }
.log-entry.log-commit { border-left-color: var(--green); }
.log-entry.log-error  { border-left-color: var(--red); background: rgba(255,51,51,0.05); }
.log-entry.log-read   { border-left-color: rgba(255,255,255,0.15); }

.log-time {
  color: var(--text-faint);
  font-size: 10px;
}

.log-type {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: right;
}

.log-entry.log-edit   .log-type { color: var(--cyan); }
.log-entry.log-bash   .log-type { color: var(--amber); }
.log-entry.log-commit .log-type { color: var(--green); }
.log-entry.log-error  .log-type { color: var(--red); }
.log-entry.log-read   .log-type { color: var(--text-dim); }

.log-msg {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Allow SYS summary messages to wrap fully */
.log-entry.log-summary .log-msg {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
}

.log-entry.log-commit .log-msg { color: var(--green); }
.log-entry.log-error  .log-msg { color: var(--red); }

/* ── Metric Cards ───────────────────────────────────────────── */
.metric-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: space-between;
}

.metric-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 1px;
  color: var(--text);
  transition: all 0.4s ease;
}

.metric-value.coral-glow { color: var(--coral); text-shadow: var(--glow-coral); }
.metric-value.green-glow { color: var(--green); text-shadow: var(--glow-green); }
.metric-value.cyan-glow  { color: var(--cyan);  text-shadow: var(--glow-cyan); }
.metric-value.amber-glow { color: var(--amber); text-shadow: var(--glow-amber); }
.metric-value.red-glow   { color: var(--red);   text-shadow: var(--glow-red); }

.metric-sub {
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

/* Progress bar */
.metric-bar-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.metric-bar {
  height: 100%;
  background: var(--coral);
  border-radius: 2px;
  transition: width 0.6s ease;
  box-shadow: 0 0 6px rgba(255, 111, 97, 0.5);
}

.metric-bar.cyan-bar {
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(0, 212, 255, 0.5);
}

/* ── Agent Card (list view) ────────────────────────────────── */
.agent-card {
  justify-content: flex-start;
  gap: 6px;
}

.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-count {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  transition: all 0.4s ease;
}

.agent-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  min-height: 0;
}

.agent-list::-webkit-scrollbar { width: 2px; }
.agent-list::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 2px; }

.agent-empty {
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

.agent-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 2px;
  background: var(--bg-panel-alt);
  animation: log-in 0.2s ease-out forwards;
  min-width: 0;
  overflow: hidden;
}

.agent-entry-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 4px var(--cyan);
  flex-shrink: 0;
  animation: pulse-green 2s ease-in-out infinite;
}

.agent-entry-type {
  color: var(--cyan);
  font-weight: 700;
  font-size: 9px;
  flex-shrink: 0;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-entry-task {
  color: var(--text-dim);
  font-size: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.agent-entry.done {
  opacity: 0.4;
  transition: opacity 0.5s ease;
}

.agent-entry.done .agent-entry-dot {
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
  animation: none;
}

/* ── Skills Card (tag list) ─────────────────────────────────── */
.skill-card {
  justify-content: flex-start;
  gap: 6px;
}

.skill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.skill-count {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  transition: all 0.4s ease;
}

.skill-list {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
  overflow-y: auto;
  min-height: 0;
}

.skill-list::-webkit-scrollbar { width: 2px; }
.skill-list::-webkit-scrollbar-thumb { background: var(--amber-dim); border-radius: 2px; }

.skill-empty {
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

.skill-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(255, 176, 0, 0.2);
  white-space: nowrap;
  animation: log-in 0.2s ease-out forwards;
}

.metric-bar.red-bar {
  background: var(--red);
  box-shadow: 0 0 6px rgba(255, 51, 51, 0.5);
}

/* Circuit breaker lights */
.circuit-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}

.circuit-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--border);
  opacity: 0.25;
  transition: opacity 0.3s, box-shadow 0.3s;
}

.circuit-light.closed    { background: var(--green); }
.circuit-light.open      { background: var(--red); }
.circuit-light.half-open { background: var(--amber); }

.circuit-light.active.closed    { opacity: 1; box-shadow: var(--glow-green); }
.circuit-light.active.open      { opacity: 1; box-shadow: var(--glow-red); }
.circuit-light.active.half-open { opacity: 1; box-shadow: var(--glow-amber); }

/* Git detail row */
.git-detail {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}

.git-adds  { color: var(--green);  font-size: 10px; font-weight: 700; }
.git-dels  { color: var(--red);    font-size: 10px; font-weight: 700; }
.git-files { color: var(--text-dim); font-size: 10px; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline-panel {
  display: flex;
  flex-direction: column;
}

.timeline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px;
  min-height: 0;
}

.timeline::-webkit-scrollbar {
  height: 3px;
}
.timeline::-webkit-scrollbar-track {
  background: transparent;
}
.timeline::-webkit-scrollbar-thumb {
  background: var(--coral-dark);
  border-radius: 2px;
}

.timeline-empty {
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 0 4px;
}

/* Timeline event chips */
.timeline-event {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  cursor: default;
}

.timeline-event-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.timeline-event:hover .timeline-event-dot {
  transform: scale(1.4);
}

.timeline-event-dot.type-edit   { background: var(--cyan); box-shadow: 0 0 5px var(--cyan); }
.timeline-event-dot.type-bash   { background: var(--amber); box-shadow: 0 0 5px var(--amber); }
.timeline-event-dot.type-commit { background: var(--green); box-shadow: 0 0 5px var(--green); }
.timeline-event-dot.type-error  { background: var(--red); box-shadow: 0 0 5px var(--red); }
.timeline-event-dot.type-read   { background: var(--text-faint); }

.timeline-event-label {
  font-size: 8px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Connector line between events */
.timeline-connector {
  flex: 1;
  height: 1px;
  min-width: 16px;
  max-width: 48px;
  background: var(--border);
  flex-shrink: 0;
  align-self: center;
  margin-bottom: 13px; /* offset for label */
}

/* ── Token Budget Gauge (Donut Ring) ───────────────────────── */
.token-gauge-card {
  align-items: stretch;
}

.token-layout {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.token-gauge-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  flex-shrink: 0;
}

.token-side {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.token-total-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-top: 4px;
}

.token-total-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  line-height: 1;
}

.token-gauge {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.token-gauge-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}

.token-gauge-fill {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease, stroke 0.4s ease;
  filter: drop-shadow(0 0 4px var(--cyan));
}

.token-gauge-fill.gauge-amber {
  stroke: var(--amber);
  filter: drop-shadow(0 0 4px var(--amber));
}

.token-gauge-fill.gauge-red {
  stroke: var(--red);
  filter: drop-shadow(0 0 6px var(--red));
}

.token-gauge-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.token-gauge-value {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

.token-gauge-pct {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-top: 2px;
}


/* ── Log Separators (loop_start / loop_end) ─────────────────── */
.log-separator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  margin: 3px 0;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.log-sep-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.log-sep-label {
  color: var(--text-faint);
  white-space: nowrap;
  font-weight: 700;
}

.log-sep-time {
  color: var(--text-faint);
  white-space: nowrap;
}

/* ── Embedded Diff Block ────────────────────────────────────── */
.diff-block {
  font-family: var(--font);
  font-size: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.diff-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--border);
}

.diff-icon {
  color: var(--cyan);
  font-size: 8px;
}

.diff-filepath {
  color: var(--cyan);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diff-stats {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.diff-stat-add { color: var(--green); font-weight: 700; }
.diff-stat-del { color: var(--red);   font-weight: 700; }

.diff-lines {
  font-size: 10px;
  line-height: 1.4;
}

.diff-line {
  display: flex;
  gap: 4px;
  padding: 1px 6px;
}

.diff-line-add { background: rgba(0, 255, 65,   0.08); }
.diff-line-del { background: rgba(255, 111, 97, 0.08); }
.diff-line-ctx { background: transparent; }

.diff-ln {
  color: var(--text-faint);
  width: 24px;
  flex-shrink: 0;
  text-align: right;
  user-select: none;
}

.diff-prefix {
  flex-shrink: 0;
  width: 10px;
}

.diff-line-add .diff-prefix { color: var(--green); }
.diff-line-del .diff-prefix { color: var(--red); }
.diff-line-ctx .diff-prefix { color: var(--text-faint); }

.diff-content {
  color: var(--text);
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.diff-line-add .diff-content { color: var(--green); }
.diff-line-del .diff-content { color: var(--coral); }

.diff-truncated {
  padding: 2px 8px;
  color: var(--text-faint);
  font-style: italic;
  font-size: 9px;
  border-top: 1px solid var(--border);
}

.diff-empty {
  padding: 4px 8px;
  color: var(--text-faint);
  font-size: 10px;
}

.log-diff-embed {
  margin-top: 4px;
}

.log-commit-hash {
  color: var(--text-dim);
  font-size: 9px;
  margin-left: 4px;
}

.log-commit-icon {
  color: var(--green);
}

.log-tool-input {
  color: var(--text-dim);
  font-size: 10px;
}

/* ── Timeline Loop Blocks ───────────────────────────────────── */
.timeline-loop-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  cursor: pointer;
  min-width: 20px;
}

.timeline-loop-block:hover .timeline-block {
  filter: brightness(1.3);
  transform: scaleY(1.15);
}

.timeline-block {
  height: 24px;
  border-radius: 2px;
  min-width: 20px;
  transition: transform 0.15s ease, filter 0.15s ease, width 0.4s ease;
  flex-shrink: 0;
}

.timeline-block-pulse {
  animation: block-pulse 1.4s ease-in-out infinite;
}

@keyframes block-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.timeline-block-label {
  font-size: 8px;
  color: var(--text-faint);
  white-space: nowrap;
  letter-spacing: 0.04em;
}

/* ── Metric value update flash ──────────────────────────────── */
@keyframes value-flash {
  0%   { opacity: 1; }
  20%  { opacity: 0.4; }
  100% { opacity: 1; }
}

.metric-value.updated {
  animation: value-flash 0.4s ease-out;
}

/* ── Number update pulse ────────────────────────────────────── */
@keyframes count-up-flash {
  from { transform: scale(1.15); }
  to   { transform: scale(1); }
}

.metric-value.bump {
  animation: count-up-flash 0.3s ease-out;
}

/* ── CRT Flicker (very subtle) ──────────────────────────────── */
@keyframes crt-flicker {
  0%, 98%, 100% { opacity: 1; }
  99%            { opacity: 0.96; }
}

.app-grid {
  animation: crt-flicker 8s infinite;
}

/* ── Responsive: Mobile (<768px) ────────────────────────────── */
@media (max-width: 768px) {
  html, body {
    overflow-y: auto;
    height: auto;
  }

  .app-grid {
    height: auto;
    overflow: visible;
    grid-template-rows: auto auto auto;
    padding: 8px;
    gap: 8px;
  }

  .top-row {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
  }

  .cat-panel {
    padding: 10px;
  }

  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
    height: auto;
    grid-template-rows: repeat(2, 110px);
  }

  .timeline-panel {
    height: 90px;
  }

  .metric-value {
    font-size: 22px;
  }

  .log-stream {
    max-height: 200px;
  }
}

/* ── Narrator Bar (below cat) ──────────────────────────────── */
.narrator-bar {
  background: rgba(0, 255, 65, 0.05);
  border-left: 3px solid #00ff41;
  padding: 6px 12px;
  font-size: 12px;
  color: #00ff41;
  font-family: var(--font);
  transition: opacity 0.5s ease;
  margin: 4px 8px 0;
  border-radius: var(--radius);
  opacity: 0.6;
  line-height: 1.4;
}

.narrator-bar .narrator-time {
  color: var(--text-dim);
  margin-right: 6px;
  font-size: 10px;
}

@media (max-width: 480px) {
  .metrics-row {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 100px);
  }

  .top-row {
    grid-template-columns: 1fr;
  }
}
