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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

/* ── Header ── */
header {
  text-align: center;
  margin-bottom: 1rem;
}

header h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #94a3b8;
  margin-top: 0.3rem;
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 2px 12px;
  font-size: 0.7rem;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.1);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

/* ── Input Row ── */
.input-row {
  display: flex;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto 0.6rem;
}

.input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.counter-wrapper {
    display: flex;
    justify-content: center; /* Centers horizontally */
    align-items: center;     /* Centers vertically, if container has height */
    width: 100%;             /* Ensures it takes full width */
}

.input-wrapper input {
  width: 100%;
  padding: 10px 44px 10px 16px;
  border: 2px solid #334155;
  border-radius: 10px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-wrapper input:focus {
  border-color: #818cf8;
}

.voice-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}

.voice-btn:hover { color: #818cf8; }
.voice-btn.recording { color: #f87171; animation: pulse 1s infinite; }

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

.ask-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.ask-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.ask-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Voice Selector Row ── */
.voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto 1rem;
  justify-content: center;
}

.voice-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 500;
}

.voice-select {
  padding: 5px 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
  min-width: 200px;
  transition: border-color 0.2s;
}

.voice-select:focus {
  border-color: #818cf8;
}

/* ── Status / Progress ── */
.status-section {
  max-width: 800px;
  margin: 0 auto 1rem;
  text-align: center;
  padding: 1rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #334155;
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 0.6rem;
}

.spinner.small { width: 22px; height: 22px; border-width: 2px; }

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

.status-text { color: #94a3b8; font-size: 0.85rem; }

.progress-bar-track {
  height: 4px;
  background: #1e293b;
  border-radius: 4px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #38bdf8);
  border-radius: 4px;
  transition: width 0.3s;
}

.hidden { display: none !important; }

/* ── Content Section: side by side ── */
.content-section {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

/* ── Answer Panel (left) ── */
.answer-panel {
  width: 340px;
  flex-shrink: 0;
  background: #1e293b;
  border-radius: 12px;
  overflow: hidden;
}

.answer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.answer-header:hover { background: #253349; }

.answer-header h3 {
  color: #818cf8;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.collapse-icon {
  transition: transform 0.3s;
  color: #64748b;
}

.collapse-icon.collapsed { transform: rotate(-90deg); }

.answer-body {
  padding: 0 1rem 0.8rem;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  max-height: 800px;
  opacity: 1;
}

.answer-body.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.answer-body p {
  color: #cbd5e1;
  line-height: 1.6;
  font-size: 0.9rem;
  text-align: left;
}

.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 0.6rem;
  padding: 4px 12px;
  background: none;
  border: 1px solid #334155;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.2s, color 0.2s;
}

.speak-btn:hover { background: #334155; color: #e2e8f0; }

/* ── Animation Panel (right) ── */
.video-panel {
  flex: 1;
  min-width: 0;
}

.video-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  background: #1e293b;
  border-radius: 12px;
  color: #64748b;
  font-size: 0.85rem;
}

/* Canvas Container — wraps the canvas for fullscreen */
.canvas-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}

.canvas-container:fullscreen {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
}

.canvas-container:fullscreen .canvas-wrapper {
  width: 100%;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

.canvas-wrapper {
  border-radius: 12px;
  overflow: hidden;
  background: #0f172a;
  aspect-ratio: 16 / 9;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Timeline ── */
.timeline {
  height: 5px;
  background: #1e293b;
  border-radius: 5px;
  margin-top: 6px;
  overflow: hidden;
}

.timeline-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #38bdf8);
  border-radius: 5px;
  transition: width 0.1s linear;
}

/* ── Animation Controls ── */
.anim-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: #1e293b;
  border-radius: 10px;
}

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

.ctrl-btn {
  padding: 4px 12px;
  border: 1px solid #334155;
  background: transparent;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.ctrl-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

.scene-label {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
}

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

.speed-label {
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-select {
  padding: 3px 6px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  outline: none;
}

.speed-select:focus { border-color: #818cf8; }

/* ── Error ── */
.error-section {
  max-width: 800px;
  margin: 1rem auto 0;
  padding: 0.8rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
}

.error-section p {
  color: #f87171;
  font-size: 0.85rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .content-section {
    flex-direction: column;
  }

  .answer-panel {
    flex: none;
    width: 100%;
  }

  .input-row {
    flex-direction: column;
  }

  .ask-btn {
    width: 100%;
  }

  .voice-row {
    flex-direction: column;
    gap: 4px;
  }

  .voice-select {
    width: 100%;
  }

  .anim-controls {
    flex-direction: column;
    gap: 6px;
  }

  .controls-left,
  .controls-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
}
