body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: linear-gradient(135deg, #0f172a, #020617);
  color: #e5e7eb;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === HEADER === */
header {
  padding: 1rem;
  padding-left: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-left img {
  width: 1.25rem;
  height: 1.25rem;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
}

select {
  background: #020617;
  color: #e5e7eb;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
}

/* === MAIN === */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  overflow: hidden;
}

.right-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.panel {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel.audio-panel {
  height: fit-content;
  flex-shrink: 0;
}

.panel.gradient-panel {
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

/* === PANEL TITLES (shared) === */
.panel-title {
  margin: 0 0 0.75rem 0;
  font-size: 1.1rem;
  color: #c7d2fe;
}

/* === STORY HEADER ROW === */
.story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

/* === FONT CONTROLS === */
.font-controls {
  display: flex;
  gap: 0.25rem;
}

.font-controls button {
  background: #020617;
  border: 1px solid #334155;
  color: #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.font-controls button:hover {
  background: #334155;
}

/* === TEXT === */
.text-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  line-height: 1.6;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

/* === AUDIO === */
canvas {
  width: 100%;
  height: 220px;
  border-radius: 0.75rem;
  background: #020617;
  margin-bottom: 0.75rem;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#timeDisplay {
  font-size: 0.85rem;
  min-width: 5rem;
  text-align: center;
}

.player-controls button {
  background: #1e293b;
  color: #e5e7eb;
  border: none;
  border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}

.player-controls button:hover {
  background: #334155;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    #c7d2fe 0%,
    #c7d2fe var(--progress, 0%),
    #334155 var(--progress, 0%),
    #334155 100%
  );
  cursor: pointer;
  flex: 1;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c7d2fe;
}

.speed-control-container {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  padding: 0.25rem 0.4rem;
}

.speed-btn {
  background: transparent;
  color: #e5e7eb;
  border: none;
  font-size: 1rem;
  width: 1.75rem;
  cursor: pointer;
}

.speed-display {
  font-size: 0.85rem;
  min-width: 2.5rem;
  text-align: center;
}

/* === GRADIENT SECTION === */
.gradient-section {
  width: 100%;
  height: 100%;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #9333ea 0%, #ec4899 50%, #f97316 100%);
  background-size: 200% 200%;
  box-shadow: 0 8px 20px rgba(147, 51, 234, 0.3);
  position: relative;
  overflow: hidden;
  animation: gradientShift 8s ease infinite;
}

.gradient-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.75;
  mix-blend-mode: overlay;
  pointer-events: none;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

footer {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  padding: 0.5rem 0;
}

@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
  }

  .right-column {
    display: contents;
  }
}
