/* ==========================================================
   TOONCAST — Retro VHS Anime Theme
   Palette: Magenta + Cyan + Yellow on dark CRT
   ========================================================== */

:root {
  --bg: #0c0c14;
  --card: #14141f;
  --magenta: #ff2d95;
  --cyan: #00f0ff;
  --yellow: #ffe156;
  --green: #39ff8f;
  --text: #d0d0e0;
  --muted: #6060a0;
  --border: #252540;
  --scanline: rgba(0,0,0,0.12);
}

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

body {
  font-family: 'IBM Plex Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Panel background collage */
.panel-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.panel-bg-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  width: 100%;
  min-height: 100vh;
  opacity: 0.20;
  filter: grayscale(30%) contrast(1.1);
  animation: bg-drift 60s linear infinite;
}

.panel-bg-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 1;
}

/* Dark vignette overlay on top of panels */
.panel-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(12,12,20,0.3) 0%,
    rgba(12,12,20,0.7) 60%,
    rgba(12,12,20,0.95) 100%
  );
  pointer-events: none;
}

@keyframes bg-drift {
  0% { transform: translateY(0); }
  100% { transform: translateY(-30px); }
}

/* CRT scanlines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    var(--scanline) 0px, var(--scanline) 1px,
    transparent 1px, transparent 3px
  );
  pointer-events: none;
  z-index: 100;
}

/* VHS tracking line */
.vhs-noise {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent 40%, var(--cyan) 45%, var(--magenta) 55%, transparent 60%);
  opacity: 0.35;
  animation: vhs-track 5s linear infinite;
  z-index: 99;
}

@keyframes vhs-track {
  0% { transform: translateY(0); }
  100% { transform: translateY(100vh); }
}

/* App */
.app {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
.header { text-align: center; padding: 1.5rem 0 1.5rem; }

h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 2.2rem;
  color: var(--cyan);
  text-shadow:
    3px 3px 0 var(--magenta),
    0 0 20px rgba(0,240,255,0.3);
  animation: glitch 4s infinite;
}

@keyframes glitch {
  0%, 92%, 100% { transform: translate(0); }
  93% { transform: translate(-2px, 1px); }
  95% { transform: translate(2px, -1px); }
  97% { transform: translate(-1px, 2px); }
}

.rec-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  font-size: 0.7rem;
  color: var(--magenta);
  letter-spacing: 0.1em;
}

.rec-dot {
  width: 8px; height: 8px;
  background: var(--magenta);
  border-radius: 50%;
  animation: rec-blink 1s infinite;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.tagline {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  position: relative;
}

.card-header {
  font-size: 0.7rem;
  color: var(--cyan);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}

.timestamp {
  position: absolute;
  top: 8px; right: 12px;
  font-size: 0.6rem;
  color: var(--muted);
}

/* Input */
.input-row { display: flex; gap: 0.5rem; }

input[type="url"] {
  flex: 1;
  padding: 0.75rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus { border-color: var(--cyan); box-shadow: 0 0 10px rgba(0,240,255,0.08); }
input::placeholder { color: var(--muted); }
input.input-error { border-color: var(--magenta); }

/* Buttons */
.btn {
  padding: 0.75rem 1.3rem;
  border: 1px solid var(--cyan);
  background: transparent;
  color: var(--cyan);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.btn:hover {
  background: var(--cyan);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(0,240,255,0.25);
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; color: var(--cyan); box-shadow: none; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.5rem; }

.blink { animation: rec-blink 0.8s infinite; }

/* Toggle buttons (compare view) */
.toggle-active {
  background: var(--cyan) !important;
  color: var(--bg) !important;
}

/* Jobs list */
.jobs-list { display: flex; flex-direction: column; gap: 0.4rem; }

.job-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  font-size: 0.75rem;
}

.job-url { flex: 1; color: var(--text); }
.job-panels { color: var(--muted); font-size: 0.65rem; }

/* Badges */
.badge {
  padding: 0.1rem 0.5rem;
  font-size: 0.55rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-done { color: var(--green); border: 1px solid var(--green); }
.status-fail { color: var(--magenta); border: 1px solid var(--magenta); }
.status-active { color: var(--cyan); border: 1px solid var(--cyan); }

/* Steps */
.steps {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.75rem;
}

.step { display: flex; align-items: center; gap: 0.4rem; }

.step-marker {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  color: var(--muted);
}

.step-label { color: var(--muted); }

.step-done .step-marker { color: var(--green); }
.step-done .step-label { color: var(--green); }

.step-active .step-marker { color: var(--cyan); animation: rec-blink 0.8s infinite; }
.step-active .step-label { color: var(--cyan); }

/* Loading bar */
.loading-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.7rem;
}

.loading-label span:first-child { color: var(--cyan); }
.loading-label span:last-child { color: var(--yellow); }

.loading-bar {
  height: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px;
  display: flex;
  gap: 2px;
}

.loading-block {
  flex: 1;
  height: 100%;
  background: var(--border);
  transition: background 0.2s;
}

.loading-block.filled {
  background: var(--cyan);
  box-shadow: 0 0 4px var(--cyan);
}

.loading-block.current {
  background: var(--magenta);
  box-shadow: 0 0 5px var(--magenta);
  animation: rec-blink 0.5s infinite;
}

.status {
  text-align: center;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.7rem;
}

/* Live panel strip */
.live-strip {
  margin-top: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.6rem;
}

.live-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.65rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--magenta);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  letter-spacing: 0.08em;
}

.live-badge .rec-dot {
  width: 6px;
  height: 6px;
}

.live-count {
  color: var(--muted);
}

.live-strip-scroll {
  overflow-x: auto;
  scroll-behavior: smooth;
}

.live-strip-track {
  display: flex;
  gap: 6px;
  padding-bottom: 4px;
}

.live-thumb-slot {
  flex-shrink: 0;
  width: 64px;
  height: 90px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.live-thumb-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.live-thumb-num {
  font-size: 0.55rem;
  color: var(--border);
  font-family: 'IBM Plex Mono', monospace;
}

/* Pending — dim dashed border */
.live-thumb-pending {
  border: 1px dashed var(--border);
  opacity: 0.4;
}

/* Loaded — solid cyan border */
.live-thumb-loaded {
  border: 1px solid var(--cyan);
  opacity: 1;
  animation: thumbAppear 0.3s ease;
}

/* Latest — glowing magenta pulse */
.live-thumb-latest {
  border: 2px solid var(--magenta);
  box-shadow: 0 0 12px rgba(255,45,149,0.5);
  opacity: 1;
  animation: thumbPulse 0.6s ease;
}

/* Rendered — green border flash */
.live-thumb-rendered {
  border: 1px solid var(--green);
  box-shadow: 0 0 8px rgba(57,255,143,0.25);
  opacity: 1;
}

@keyframes thumbAppear {
  0% { opacity: 0; transform: scale(0.8); }
  50% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes thumbPulse {
  0% { opacity: 0; transform: scale(0.7); }
  40% { transform: scale(1.1); box-shadow: 0 0 20px rgba(255,45,149,0.7); }
  100% { opacity: 1; transform: scale(1); box-shadow: 0 0 12px rgba(255,45,149,0.5); }
}

/* Terminal log */
.terminal {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.6rem;
  margin-top: 0.75rem;
  font-size: 0.65rem;
  line-height: 1.7;
  max-height: 150px;
  overflow-y: auto;
}

.terminal .line { color: var(--muted); }
.terminal .cmd { color: var(--cyan); }
.terminal .ok { color: var(--yellow); }
.terminal .err { color: var(--magenta); }

.terminal::-webkit-scrollbar { width: 4px; }
.terminal::-webkit-scrollbar-track { background: var(--bg); }
.terminal::-webkit-scrollbar-thumb { background: var(--border); }

/* Tabs */
.tab-bar {
  display: flex;
  gap: 0;
  margin: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  color: var(--muted);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  text-transform: uppercase;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }

/* Panel comparison */
.panel-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-counter {
  font-size: 0.7rem;
  color: var(--yellow);
  font-family: 'Press Start 2P', monospace;
}

.toggle-row {
  text-align: center;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.panel-display {
  text-align: center;
}

.panel-display img {
  max-width: 100%;
  max-height: 80vh;
  border: 1px solid var(--border);
}

/* Scroll view */
.stitched-panel {
  margin-bottom: 1.5rem;
  text-align: center;
}

.stitched-panel img {
  max-width: 100%;
  border: 1px solid var(--border);
}

/* Panel grid */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.4rem;
}

.panel-grid-img {
  width: 100%;
  display: block;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.panel-grid-img:hover { border-color: var(--cyan); }

/* Audio controls */
.audio-controls {
  text-align: center;
  margin-bottom: 0.75rem;
}

.btn-audio {
  border-color: var(--yellow);
  color: var(--yellow);
}

.btn-audio:hover {
  background: var(--yellow);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(255,225,86,0.25);
}

.audio-player-bar {
  text-align: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Error */
.error-text { color: var(--magenta); font-size: 0.7rem; display: block; margin-top: 0.4rem; }

.error-box {
  background: rgba(255,45,149,0.05);
  border: 1px solid rgba(255,45,149,0.3);
  padding: 1rem;
  margin-top: 0.75rem;
  text-align: center;
}

.error-box p { color: var(--magenta); margin-bottom: 0.6rem; font-size: 0.75rem; }

/* Robot mascot */
.robot {
  position: fixed;
  left: 15px;
  bottom: 15px;
  z-index: 50;
}

.robot-head {
  width: 40px; height: 35px;
  background: var(--cyan);
  border: 2px solid var(--text);
  border-radius: 6px 6px 2px 2px;
  position: relative;
  margin: 0 auto;
}

.robot-antenna {
  width: 2px; height: 12px;
  background: var(--text);
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
}

.robot-antenna::after {
  content: '';
  width: 6px; height: 6px;
  background: var(--magenta);
  border-radius: 50%;
  position: absolute;
  top: -4px; left: -2px;
  animation: rec-blink 1.5s infinite;
}

.robot-eye {
  width: 8px; height: 8px;
  background: var(--bg);
  position: absolute;
  top: 10px;
}

.robot-eye.left { left: 7px; }
.robot-eye.right { right: 7px; }

.robot-eye::after {
  content: '';
  width: 4px; height: 4px;
  background: var(--magenta);
  position: absolute;
  top: 2px; left: 2px;
  animation: rec-blink 2s infinite;
}

.robot-mouth {
  position: absolute;
  bottom: 5px; left: 50%;
  transform: translateX(-50%);
  width: 16px; height: 3px;
  background: var(--bg);
}

.robot-body {
  width: 35px; height: 28px;
  background: var(--card);
  border: 2px solid var(--text);
  border-radius: 2px;
  margin: 2px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.robot-screen {
  width: 16px; height: 12px;
  background: var(--bg);
  border: 1px solid var(--cyan);
  font-size: 6px;
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.65rem;
}

/* Animations */
.fade-in { animation: fadeIn 0.3s ease; }

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

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }

/* Responsive */
@media (max-width: 600px) {
  .app { padding: 1rem; }
  h1 { font-size: 1.4rem; }
  .input-row { flex-direction: column; }
  .steps { flex-direction: column; gap: 0.5rem; }
  .toggle-row { flex-direction: column; align-items: center; }
}
