:root {
  --glass: rgba(20, 17, 36, 0.58);
  --glass-2: rgba(255, 255, 255, 0.07);
  --glass-3: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f6f0ea;
  --muted: rgba(246, 240, 234, 0.62);
  --accent: #ffb38a;
  --accent-ink: #2b1a13;
  --break: #93d6c4;
  --radius: 18px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
body[data-mode='short'], body[data-mode='long'] { --accent: var(--break); --accent-ink: #11302a; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0c18; color: var(--text); }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }

#scene {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  object-fit: cover;
  image-rendering: pixelated;
}

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

.card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

.icon {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; background: var(--glass-2);
  transition: background .15s;
}
.icon:hover { background: var(--glass-3); }
.icon.round { border-radius: 50%; }
.icon.big { width: 48px; height: 48px; background: var(--accent); color: var(--accent-ink); }
.icon.big:hover { filter: brightness(1.07); background: var(--accent); }

/* ---------- Timer ---------- */
.timer {
  position: absolute; top: 24px; left: 24px; width: 320px;
  padding: 16px 18px;
  transition: opacity .8s var(--ease);
}
.modes { display: flex; gap: 4px; background: var(--glass-2); border-radius: 12px; padding: 4px; }
.modes button { flex: 1; padding: 6px 2px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--muted); transition: background .15s, color .15s; }
.modes button:hover { color: var(--text); }
.modes button.active { background: var(--glass-3); color: var(--text); }
.time {
  font-size: 78px; font-weight: 800; line-height: 1; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
  margin: 18px 0 14px; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.3);
}
.progress { height: 4px; border-radius: 4px; background: var(--glass-3); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .3s linear, background .3s; }
.controls { display: flex; gap: 10px; justify-content: center; align-items: center; margin: 16px 0 12px; }
.primary {
  min-width: 128px; padding: 11px 26px; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 16px; letter-spacing: .4px;
  transition: filter .15s, transform .1s, background .3s;
}
.primary:hover { filter: brightness(1.07); }
.primary:active { transform: scale(.97); }
#task {
  width: 100%; padding: 9px 12px;
  background: var(--glass-2); border: 1px solid transparent; border-radius: 10px;
  font-size: 14px; outline: none; text-align: center;
}
#task:focus { border-color: var(--line); }
#task::placeholder { color: var(--muted); }
.stats { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--glass-3); }
.dots i.on { background: var(--accent); }

/* ---------- Dock ---------- */
.dock {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 6px;
  transition: opacity .8s var(--ease);
  max-width: calc(100vw - 24px);
}
.dock-btn {
  position: relative; width: 44px; height: 44px; flex: none;
  display: grid; place-items: center; border-radius: 13px;
  color: var(--muted); transition: background .15s, color .15s;
}
.dock-btn svg { width: 20px; height: 20px; }
.dock-btn:hover, .dock-btn.active { background: var(--glass-3); color: var(--text); }
.badge {
  position: absolute; top: 6px; right: 6px; min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 800; line-height: 15px; text-align: center;
}
.badge:empty { display: none; }
.sep { width: 1px; height: 26px; background: var(--line); margin: 0 6px; flex: none; }
.now-playing { display: flex; align-items: center; gap: 8px; min-width: 0; }
.now-playing .icon { width: 36px; height: 36px; background: var(--accent); color: var(--accent-ink); }
.np-text {
  max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 13px; font-weight: 600; color: var(--muted); text-align: left; padding: 4px 4px 4px 0;
}
.np-text:hover { color: var(--text); }

/* ---------- Panels ---------- */
.panel {
  position: absolute; bottom: 88px; left: 50%;
  width: min(390px, calc(100vw - 24px)); max-height: calc(100vh - 124px); overflow-y: auto;
  padding: 14px 18px 18px;
  opacity: 0; visibility: hidden; transform: translate(-50%, 10px);
  transition: opacity .2s var(--ease), transform .2s var(--ease), visibility 0s .2s;
  scrollbar-width: thin; scrollbar-color: var(--glass-3) transparent;
}
.panel.open { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .2s var(--ease), transform .2s var(--ease); }
.panel header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel h2 { font-size: 17px; margin: 0; font-weight: 800; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 18px 0 8px; font-weight: 800; }
.panel h3 small { text-transform: none; letter-spacing: 0; font-weight: 600; }
.close { width: 32px; height: 32px; background: transparent; }
.hint { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; line-height: 1.5; }
.link { text-decoration: underline; color: var(--text); font-size: inherit; }

input[type='range'] { accent-color: var(--accent); width: 100%; min-width: 0; cursor: pointer; }
input[type='text'], input[type='number'], select {
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 14px; outline: none; min-width: 0;
}
select option { background: #1f1b33; }
.pill { padding: 8px 16px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 14px; flex: none; }
.pill.small { padding: 4px 10px; font-size: 12px; }

/* music */
.player { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: rgba(0, 0, 0, 0.35); }
.yt-box, .radio-art { position: absolute; inset: 0; }
.yt-box iframe { width: 100%; height: 100%; border: 0; display: block; }
.radio-art { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-weight: 700; color: var(--muted); padding: 0 16px; text-align: center; }
.player.radio .radio-art { display: flex; }
.player.radio .yt-box { visibility: hidden; }
.player.empty .yt-box { visibility: hidden; }
.player.empty .radio-art { display: flex; }
.eq { display: flex; gap: 4px; align-items: flex-end; height: 34px; }
.eq i { width: 6px; height: 8px; border-radius: 3px; background: var(--accent); }
.player.live .eq i { animation: eq 1s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-delay: -.3s !important; }
.eq i:nth-child(3) { animation-delay: -.6s !important; }
.eq i:nth-child(4) { animation-delay: -.15s !important; }
.eq i:nth-child(5) { animation-delay: -.45s !important; }
@keyframes eq { from { height: 6px; } to { height: 34px; } }

.transport { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; }
.vol { display: flex; align-items: center; gap: 8px; flex: 1; margin-left: 8px; color: var(--muted); }
.stations { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stations li { display: flex; align-items: center; border-radius: 10px; }
.stations li:hover { background: var(--glass-2); }
.stations li.active { background: var(--glass-3); }
.stations .st-play { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px 10px; text-align: left; font-size: 14px; }
.stations .st-play span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stations .kind { flex: none; font-size: 10px; font-weight: 800; letter-spacing: .6px; padding: 2px 6px; border-radius: 6px; background: var(--glass-2); color: var(--muted); }
.stations li.active .kind { background: var(--accent); color: var(--accent-ink); }
.stations .st-del { width: 30px; height: 30px; opacity: 0; color: var(--muted); display: grid; place-items: center; border-radius: 8px; }
.stations li:hover .st-del, .stations .st-del:focus-visible { opacity: 1; }
.stations .st-del:hover { color: var(--text); background: var(--glass-2); }
.stations .st-del svg { width: 14px; height: 14px; }
.add-station { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.add-station .row { display: flex; gap: 6px; }
.add-station .row input { flex: 1; }

/* sounds */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.presets button { padding: 6px 11px; border-radius: 999px; background: var(--glass-2); font-size: 12.5px; font-weight: 700; border: 1px solid var(--line); }
.presets button:hover { background: var(--glass-3); }
.sound-list { display: flex; flex-direction: column; gap: 2px; }
.sound-row { display: grid; grid-template-columns: 26px 110px 1fr; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; }
.sound-row .s-icon { font-size: 17px; text-align: center; filter: grayscale(1) opacity(.6); transition: filter .2s; }
.sound-row .s-name { font-size: 14px; font-weight: 600; color: var(--muted); transition: color .2s; }
.sound-row.on .s-icon { filter: none; }
.sound-row.on .s-name { color: var(--text); }
.sound-row.master { margin-top: 8px; border-top: 1px solid var(--line); border-radius: 0; padding-top: 12px; }
.sound-row.master .s-icon { filter: none; }

/* scenes */
.scene-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scene-card { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; font-weight: 700; color: var(--muted); }
.scene-card canvas { width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; image-rendering: pixelated; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.scene-card:hover canvas { transform: translateY(-2px); }
.scene-card.active { color: var(--text); }
.scene-card.active canvas { border-color: var(--accent); }

/* settings */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid3 label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 700; }
.field { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 10px 0; }
.field input[type='number'] { width: 60px; }
.field input[type='range'] { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 10px 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; flex: none; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.keys dt { font-weight: 800; font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--glass-3); justify-self: start; }
.keys dd { margin: 0; color: var(--muted); }

/* toast */
.toast {
  position: absolute; left: 50%; bottom: 92px; transform: translate(-50%, 8px);
  max-width: min(440px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 12px;
  background: rgba(20, 17, 36, 0.9); border: 1px solid var(--line);
  font-size: 14px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Idle + zen ---------- */
body.idle { cursor: none; }
body.idle .dock { opacity: 0; pointer-events: none; }
body.idle .timer { opacity: .4; }

.zen-exit { position: absolute; top: 16px; right: 16px; display: none; background: var(--glass); }
body.zen .zen-exit { display: grid; transition: opacity .8s; }
body.zen.idle .zen-exit { opacity: 0; }
body.zen .dock, body.zen .panel { display: none; }
body.zen .timer {
  left: 50%; top: 24px; transform: translateX(-50%); width: auto;
  padding: 10px 26px; background: rgba(20, 17, 36, 0.3);
}
body.zen .timer > :not(.time) { display: none; }
body.zen .time { font-size: 44px; margin: 0; }
body.zen.idle .timer { opacity: .55; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .timer { top: 12px; left: 12px; right: 12px; width: auto; padding: 12px 14px; }
  .time { font-size: 58px; margin: 12px 0 10px; }
  .dock { bottom: 12px; overflow-x: auto; }
  .np-text { display: none; }
  .panel { bottom: 76px; max-height: calc(100vh - 290px); }
  .sound-row { grid-template-columns: 24px 92px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .toast, .timer, .dock { transition: none; }
}
