/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Toolbar ─────────────────────────────────────────── */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

.toolbar h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #e94560;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-actions label {
  font-size: 0.85rem;
  color: #aaa;
}

.toolbar-actions input {
  width: 52px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #0f3460;
  background: #1a1a2e;
  color: #fff;
  text-align: center;
  font-size: 0.85rem;
}

.toolbar-actions button {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

#generateBtn {
  background: linear-gradient(135deg, #e94560, #c2185b);
  color: white;
}

#generateBtn:hover {
  background: linear-gradient(135deg, #ff6b81, #e94560);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
}

#fullscreenBtn {
  background: #0f3460;
  color: #e0e0e0;
}

#fullscreenBtn:hover {
  background: #1a4a8a;
}

/* ── Chaos Toggle ────────────────────────────────────── */
.chaos-toggle {
  background: #263238;
  color: #888;
  position: relative;
  overflow: hidden;
}

.chaos-toggle.active {
  background: linear-gradient(135deg, #ff6d00, #e94560);
  color: #fff;
  animation: chaosPulse 2s ease-in-out infinite;
}

.chaos-toggle:hover {
  transform: translateY(-1px);
}

.chaos-toggle.active:hover {
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.5);
}

@keyframes chaosPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(233, 69, 96, 0); }
  50% { box-shadow: 0 0 12px rgba(233, 69, 96, 0.35); }
}

/* ── Slide Viewport ──────────────────────────────────── */
#slideViewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  min-height: 0;
}

#slideContainer {
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 200px);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* ── Slide ────────────────────────────────────────────── */
.slide {
  width: 100%;
  height: 100%;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.slide-header {
  margin-bottom: 24px;
  flex-shrink: 0;
}

.slide-header h2 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.slide-header .subtitle {
  font-size: 0.95rem;
  opacity: 0.7;
  font-style: italic;
}

.slide-body {
  flex: 1;
  display: flex;
  gap: 32px;
  min-height: 0;
}

.slide-body.center-content {
  align-items: center;
  justify-content: center;
}

.slide-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.slide-text ul {
  list-style: none;
  padding: 0;
}

.slide-text ul li {
  padding: 6px 0 6px 24px;
  position: relative;
  font-size: 1rem;
  line-height: 1.5;
}

.slide-text ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  font-weight: bold;
}

.slide-figure {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 50%;
}

.slide-figure svg {
  width: 100%;
  height: 100%;
  max-height: 320px;
}

.slide-footer {
  font-size: 0.7rem;
  opacity: 0.4;
  text-align: right;
  margin-top: auto;
  padding-top: 8px;
  flex-shrink: 0;
}

/* ── Title slide ─────────────────────────────────────── */
.slide.title-slide {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.slide.title-slide .slide-header {
  margin-bottom: 0;
}

.slide.title-slide h2 {
  font-size: 2.8rem;
}

.slide.title-slide .subtitle {
  font-size: 1.1rem;
  margin-top: 12px;
}

.slide.title-slide .author {
  margin-top: 32px;
  font-size: 0.95rem;
  opacity: 0.6;
}

/* ── Section slide ───────────────────────────────────── */
.slide.section-slide {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.slide.section-slide h2 {
  font-size: 2.4rem;
  border-bottom: 3px solid;
  padding-bottom: 12px;
}

/* ── Full-figure slide ───────────────────────────────── */
.slide.full-figure-slide .slide-body {
  flex-direction: column;
  align-items: center;
}

.slide.full-figure-slide .slide-figure {
  max-width: 80%;
  flex: 1;
}

.slide.full-figure-slide .caption {
  font-size: 0.8rem;
  opacity: 0.6;
  text-align: center;
}

/* ── Navigation ──────────────────────────────────────── */
.slide-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.slide-nav button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #0f3460;
  background: #16213e;
  color: #e0e0e0;
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide-nav button:hover {
  background: #0f3460;
  border-color: #e94560;
  color: #e94560;
}

#slideIndicator {
  font-size: 0.9rem;
  color: #aaa;
  min-width: 60px;
  text-align: center;
}

/* ── Thumbnails ──────────────────────────────────────── */
#thumbnailStrip {
  display: flex;
  gap: 8px;
  padding: 10px 24px;
  background: #16213e;
  border-top: 1px solid #0f3460;
  overflow-x: auto;
  flex-shrink: 0;
}

#thumbnailStrip::-webkit-scrollbar { height: 4px; }
#thumbnailStrip::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 4px; }

.thumbnail {
  width: 100px;
  aspect-ratio: 16/9;
  border-radius: 6px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  position: relative;
}

.thumbnail canvas {
  width: 100%;
  height: 100%;
}

.thumbnail.active {
  border-color: #e94560;
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.4);
}

.thumbnail:hover:not(.active) {
  border-color: #555;
}

.thumbnail .thumb-num {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.6);
  text-shadow: 0 1px 2px #000;
}

/* ── Fullscreen ──────────────────────────────────────── */
body.fullscreen .toolbar,
body.fullscreen #thumbnailStrip { display: none; }

body.fullscreen #slideViewport { padding: 0; }

body.fullscreen #slideContainer {
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  width: 100vw;
  height: 100vh;
  aspect-ratio: unset;
}

body.fullscreen .slide-nav {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(22, 33, 62, 0.85);
  padding: 8px 16px;
  border-radius: 28px;
  backdrop-filter: blur(8px);
}

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide > * {
  animation: fadeSlideIn 0.4s ease both;
}
.slide > :nth-child(1) { animation-delay: 0s; }
.slide > :nth-child(2) { animation-delay: 0.1s; }
.slide > :nth-child(3) { animation-delay: 0.2s; }
.slide > :nth-child(4) { animation-delay: 0.3s; }
