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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: system-ui, -apple-system, sans-serif;
  color: #fff;
}

/* ── Progress bar (inset pill fill) ────────────────────────── */
#progress-bar {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(to right, rgba(255,255,255,0.22), rgba(255,255,255,0.06));
  border-radius: 999px;
  transition: width linear;
  pointer-events: none;
  z-index: 0;
}

/* ── Stage / iframes ───────────────────────────────────────── */
#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  background: #111;
  pointer-events: none;
}

#stage iframe.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── HUD ───────────────────────────────────────────────────── */
#hud {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#hud.hidden {
  display: none;
}

#hud-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 15px;
}

#hud-url {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#hud:hover #hud-url,
#hud:focus-within #hud-url {
  opacity: 1;
}

#hud-collapsed {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  cursor: default;
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

#hud-collapsed:hover {
  opacity: 1;
}

#slide-counter {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
  white-space: nowrap;
  min-width: 32px;
  text-align: right;
}

#hud-expanded {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 6px;
  margin-right: 15px;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#hud:hover #hud-expanded,
#hud:focus-within #hud-expanded {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── HUD buttons ───────────────────────────────────────────── */
.hud-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  padding: 0;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.hud-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Play button uses filled polygon */
#btn-play-pause .icon-play {
  fill: currentColor;
  stroke: none;
}

/* ── Management panel ──────────────────────────────────────── */
#panel {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  pointer-events: none;
}

#panel.hidden {
  display: none;
}

#panel-inner {
  width: 380px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(18, 18, 20, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

#panel:not(.hidden) #panel-inner {
  transform: translateX(0);
}

#panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#panel-header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#panel-header h1 span {
  color: #f59e0b;
  font-weight: 400;
}

/* ── Add slide form ────────────────────────────────────────── */
#add-slide-form {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#url-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

#url-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

#url-input:focus {
  border-color: rgba(255, 255, 255, 0.35);
}

#btn-add-slide {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

#btn-add-slide:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── Slide list ────────────────────────────────────────────── */
#slide-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

#slide-list::-webkit-scrollbar {
  width: 6px;
}

#slide-list::-webkit-scrollbar-track {
  background: transparent;
}

#slide-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}

.slide-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  transition: background 0.12s;
  cursor: default;
  border-radius: 6px;
  margin: 0 8px;
}

.slide-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.slide-item.drag-over {
  background: rgba(255, 255, 255, 0.1);
  outline: 2px dashed rgba(255, 255, 255, 0.3);
  outline-offset: -2px;
}

.slide-item.dragging {
  opacity: 0.4;
}

.drag-handle {
  cursor: grab;
  opacity: 0.35;
  flex-shrink: 0;
  padding: 4px;
  color: #fff;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.slide-url {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

.slide-url.active-slide {
  opacity: 1;
  font-weight: 500;
}

.slide-url.active-slide::before {
  content: '▶ ';
  font-size: 10px;
  opacity: 0.6;
}

.duration-input {
  width: 52px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px 6px;
  color: #fff;
  font-size: 13px;
  text-align: center;
  outline: none;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.duration-input:focus {
  border-color: rgba(255, 255, 255, 0.35);
}

.duration-label {
  font-size: 11px;
  opacity: 0.4;
  flex-shrink: 0;
}

.btn-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.4);
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.btn-delete:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.12);
}

.btn-delete svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Empty state */
#empty-state {
  padding: 32px 24px;
  text-align: center;
  opacity: 0.45;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Panel footer ──────────────────────────────────────────── */
#panel-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#btn-done {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  padding: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

#btn-done:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── Utilities ─────────────────────────────────────────────── */
.hidden {
  display: none !important;
}
