:root {
  --glass: rgba(28, 24, 20, 0.42);
  --glass-strong: rgba(24, 20, 16, 0.62);
  --stroke: rgba(255, 248, 236, 0.16);
  --text: rgba(255, 250, 240, 0.94);
  --muted: rgba(255, 250, 240, 0.6);
  --accent: rgba(255, 214, 150, 0.95);
  --radius: 16px;
  --blur: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: #1b1712;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Scene ---------- */
#scene { position: fixed; inset: 0; z-index: 0; }

#bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: background-image 0.6s ease, filter 0.8s ease;
}

#capyLayer { position: absolute; inset: 0; pointer-events: none; }

.capy {
  position: absolute;
  bottom: 0;
  transform-origin: bottom center;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35));
  will-change: transform, opacity;
}
.capy.flip { transform: scaleX(-1); }

@keyframes capyIn {
  0%   { opacity: 0; transform: translateY(18px) scale(var(--s, 1)); }
  100% { opacity: 1; transform: translateY(0)    scale(var(--s, 1)); }
}
.capy.enter { animation: capyIn 0.9s cubic-bezier(.2,.8,.2,1) both; }
.capy.flip.enter { animation: capyInFlip 0.9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes capyInFlip {
  0%   { opacity: 0; transform: translateY(18px) scaleX(-1) scale(var(--s, 1)); }
  100% { opacity: 1; transform: translateY(0)    scaleX(-1) scale(var(--s, 1)); }
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 35%, transparent 55%, rgba(0,0,0,0.35) 100%),
    linear-gradient(to bottom, rgba(0,0,0,0.18), transparent 22%, transparent 70%, rgba(0,0,0,0.32));
}

/* ---------- Clock ---------- */
#clock {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  z-index: 2;
  text-align: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
  user-select: none;
}
#time {
  font-size: clamp(48px, 11vw, 132px);
  font-weight: 300;
  letter-spacing: 2px;
  line-height: 1;
}
#status {
  margin-top: 14px;
  font-size: clamp(13px, 1.6vw, 17px);
  color: var(--muted);
  letter-spacing: 1px;
}

/* ---------- Glass helpers ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
}

/* ---------- Controls ---------- */
#controls {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.ctrl {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}
.ctrl:hover { background: rgba(255, 255, 255, 0.18); }
.ctrl:active { transform: scale(0.94); }
#playBtn.playing { background: var(--accent); color: #2a1d0c; }

#controls.hidden { display: none; }

/* Collapsed-player launcher pill */
#playerShow {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: background 0.2s ease, transform 0.1s ease;
}
#playerShow:hover { background: var(--glass-strong); }
#playerShow:active { transform: translateX(-50%) scale(0.94); }

#volume {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  outline: none;
}
#volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
#volume::-moz-range-thumb {
  width: 14px; height: 14px; border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}

/* ---------- Settings popover ---------- */
#settingsPanel {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: min(360px, 90vw);
  padding: 16px;
  border-radius: var(--radius);
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
#settingsPanel label { display: block; font-size: 13px; margin-bottom: 8px; color: var(--muted); }
#streamUrl {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 14px;
}
#streamUrl:focus { outline: none; border-color: var(--accent); }

#settingsPanel .divider {
  height: 1px;
  margin: 16px 0;
  background: var(--stroke);
}
#localFile {
  width: 100%;
  font-size: 13px;
  color: var(--muted);
}
#localFile::file-selector-button {
  margin-right: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
#localFile::file-selector-button:hover { background: rgba(255, 255, 255, 0.16); }

.debug-row { display: flex; gap: 8px; margin-bottom: 8px; }
.debug-row input[type="number"] {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 14px;
}
.debug-row input[type="number"]:focus { outline: none; border-color: var(--accent); }
.debug-row button {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.debug-row button:hover { background: rgba(255, 255, 255, 0.16); }
.debug-row input[type="number"] + button { flex: 0 0 auto; }

/* ---------- Todo panel ---------- */
#todoToggle {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 5;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
#todoToggle:hover { background: var(--glass-strong); }

#todoPanel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 6;
  width: min(340px, 86vw);
  height: 100%;
  padding: 28px 22px;
  background: var(--glass-strong);
  border-left: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(calc(var(--blur) + 6px));
  backdrop-filter: blur(calc(var(--blur) + 6px));
  box-shadow: -16px 0 50px rgba(0, 0, 0, 0.4);
  transition: transform 0.32s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto;
}
#todoPanel.hidden { transform: translateX(100%); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 18px;
}
#todoPanel h2 {
  margin: 0;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 2px;
}
.panel-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.panel-close:hover { background: rgba(255, 255, 255, 0.16); color: var(--text); }

#todoForm { display: flex; gap: 8px; margin-bottom: 18px; }
#todoInput {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 14px;
}
#todoInput:focus { outline: none; border-color: var(--accent); }
#todoForm button {
  width: 42px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #2a1d0c;
  font-size: 20px;
  cursor: pointer;
}

#todoList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  transition: background 0.15s ease;
}
.todo-item:hover { background: rgba(255, 255, 255, 0.1); }
.todo-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 6px;
  border: 2px solid var(--muted);
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
}
.todo-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.todo-item input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #2a1d0c;
  font-size: 12px;
  font-weight: 700;
}
.todo-item .text { flex: 1; font-size: 14px; word-break: break-word; }
.todo-item.done .text { text-decoration: line-through; color: var(--muted); }
.todo-item .del {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.todo-item:hover .del { opacity: 1; }
.todo-item .del:hover { color: #ff9b8a; }

.muted { color: var(--muted); font-size: 13px; }
#todoEmpty { margin-top: 4px; }

.hidden { display: none; }
#todoPanel.hidden { display: block; } /* keep for slide animation */
