:root {
  --bg-0: #09131a;
  --bg-1: #102535;
  --bg-2: #1b3e59;
  --card: rgba(8, 18, 26, 0.7);
  --line: rgba(149, 185, 210, 0.25);
  --text: #ecf4fb;
  --muted: #b4c8d9;
  --accent: #ff8c42;
  --accent-2: #ffd166;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 140, 66, 0.25), transparent 42%),
    radial-gradient(circle at 80% 0%, rgba(16, 37, 53, 0.95), transparent 45%),
    linear-gradient(135deg, var(--bg-0), var(--bg-1) 52%, var(--bg-2));
  display: grid;
  place-items: center;
  padding: 1rem;
}

.shell {
  width: min(1100px, 100%);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.panel-setup {
  padding: 1.5rem;
}

.panel-head h1 {
  margin: 0;
  font-family: "Chakra Petch", sans-serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--accent-2);
}

.subtitle {
  margin: 0.5rem 0 1.25rem;
  color: var(--muted);
}

.setup-form {
  display: grid;
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.35rem;
}

label span {
  font-size: 0.86rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

#startSelectedBtn {
  background: rgba(236, 244, 251, 0.14);
  color: var(--text);
  border: 1px solid var(--line);
}

input,
select {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(9, 19, 26, 0.8);
  color: var(--text);
  padding: 0.75rem;
}

.tag-editor {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(9, 19, 26, 0.8);
  min-height: 46px;
  padding: 0.45rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

#themeInput {
  border: 0;
  background: transparent;
  min-width: 180px;
  flex: 1;
  padding: 0.25rem;
}

#themeInput:focus {
  outline: none;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid rgba(255, 209, 102, 0.45);
  background: rgba(255, 140, 66, 0.18);
  color: var(--text);
  border-radius: 999px;
  padding: 0.22rem 0.34rem 0.22rem 0.6rem;
  font-size: 0.82rem;
}

.tag-pill-remove {
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-radius: 999px;
  width: 1.1rem;
  height: 1.1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  font-size: 0.72rem;
}

.tag-pill-remove:hover {
  filter: brightness(1.15);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-weight: 600;
  background: linear-gradient(110deg, var(--accent), var(--accent-2));
  color: #19222c;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

.hint {
  margin: 0;
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.library-panel {
  margin-top: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  background: rgba(9, 19, 26, 0.5);
  display: grid;
  gap: 0.7rem;
}

.library-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.library-title,
.library-sub {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
}

.library-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: transparent;
  overflow: hidden;
}

.library-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.library-badge {
  position: absolute;
  left: 0.35rem;
  top: 0.35rem;
  font-size: 0.7rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.library-card.selected {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

.library-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.library-actions button {
  background: rgba(236, 244, 251, 0.14);
  color: var(--text);
  border: 1px solid var(--line);
}

.row.two-col {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-show {
  padding: 0.8rem;
}

.frame-wrap {
  min-height: 56vh;
  max-height: 72vh;
  border-radius: 14px;
  overflow: hidden;
  background: #050c12;
  border: 1px solid var(--line);
}

#slide-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: reveal 420ms ease;
}

.hud {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
}

.hud p {
  margin: 0;
}

.hud-left {
  color: var(--muted);
  font-size: 0.9rem;
}

.hud-right {
  display: flex;
  gap: 0.5rem;
}

.hud-right button {
  background: rgba(236, 244, 251, 0.14);
  color: var(--text);
  border: 1px solid var(--line);
}

.hidden {
  display: none;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: scale(1.02);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 700px) {
  .row.two-col {
    grid-template-columns: 1fr;
  }

  .library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hud {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-right {
    justify-content: space-between;
  }
}
