:root {
  --ink: #1b1410;
  --paper: #f3e6d4;
  --cream: #f7edd9;
  --amber: #e8b86d;
  --lamp: #ffc37a;
  --wood: #3a2a1f;
  --moss: #7d9a6f;
  --glass: rgba(18, 12, 9, 0.62);
  --glass-2: rgba(28, 18, 12, 0.78);
  --line: rgba(243, 230, 212, 0.14);
  --soft: rgba(243, 230, 212, 0.55);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --radius: 22px;
}

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

html, body {
  min-height: 100%;
  background: #0c0907;
  color: var(--paper);
  font-family: "Figtree", system-ui, sans-serif;
  overflow: hidden;
}

body {
  height: 100dvh;
}

.scene {
  position: relative;
  height: 100dvh;
  background:
    linear-gradient(180deg, rgba(8,5,3,.28), rgba(8,5,3,.55) 55%, rgba(8,5,3,.78)),
    url("lounge.jpg") center / cover no-repeat;
  isolation: isolate;
}

.grain, .vignette, .rain {
  pointer-events: none;
  position: absolute;
  inset: 0;
}

.grain {
  opacity: .18;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  background: radial-gradient(120% 80% at 50% 30%, transparent 30%, rgba(0,0,0,.55) 100%);
}

.rain {
  overflow: hidden;
  opacity: .35;
}
.rain span {
  position: absolute;
  top: -12%;
  width: 1px;
  height: 14vh;
  background: linear-gradient(transparent, rgba(255,255,255,.35));
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(120vh); }
}

.app {
  position: relative;
  z-index: 2;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 22px 24px 18px;
  gap: 16px;
}

.topbar, .dock, .panel {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 12px 18px;
  border-radius: 999px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}
.mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #fff3, transparent 40%),
    conic-gradient(from 210deg, #2b2118, #6b4a2c, #d7a15a, #2b2118);
  box-shadow: 0 0 0 3px rgba(232,184,109,.18);
  animation: spin 18s linear infinite paused;
}
.mark.on { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand h1 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -.02em;
}
.brand p {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--soft);
}

.clock-wrap {
  text-align: center;
}
.clock {
  font-family: "Fraunces", serif;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.clock-sub {
  font-size: 11px;
  color: var(--soft);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

button, .file-btn {
  font: inherit;
  color: inherit;
  background: rgba(243,230,212,.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: .2s ease;
}
button:hover, .file-btn:hover {
  background: rgba(243,230,212,.16);
  transform: translateY(-1px);
}
button.primary {
  background: linear-gradient(180deg, #f0c48a, #c98945);
  color: #2a1b10;
  border-color: transparent;
  font-weight: 600;
}
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.stage {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr minmax(280px, 360px);
  gap: 16px;
  min-height: 0;
}

.panel {
  border-radius: var(--radius);
  padding: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel h2 {
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 4px;
}
.hint {
  color: var(--soft);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.tabs button {
  padding: 6px 11px;
  font-size: 12px;
}
.tabs button.active {
  background: var(--paper);
  color: var(--ink);
}

#spotifyPane, #localPane, #setupPane {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  min-height: 0;
  flex: 1;
}
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb {
  background: rgba(243,230,212,.2);
  border-radius: 99px;
}

.card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid transparent;
  cursor: pointer;
}
.card:hover, .card.active {
  border-color: rgba(232,184,109,.35);
  background: rgba(232,184,109,.08);
}
.card img, .cover-fallback {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
  background: #2a1f18;
  flex: none;
}
.card .meta { min-width: 0; }
.card .meta b {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .meta span {
  display: block;
  font-size: 11px;
  color: var(--soft);
}

.center {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 0;
  position: relative;
}

.now {
  text-align: center;
  max-width: 520px;
  margin-bottom: 18px;
}
.now .kicker {
  letter-spacing: .2em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--amber);
  margin-bottom: 8px;
}
.now h3 {
  font-family: "Fraunces", serif;
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 500;
  line-height: 1.05;
  text-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.now p {
  margin-top: 8px;
  color: var(--soft);
}

.timer-card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 16px 20px 14px;
  backdrop-filter: blur(18px);
  min-width: min(420px, 92%);
  text-align: center;
}
.timer {
  font-family: "Fraunces", serif;
  font-size: 54px;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.timer-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.mode-pill {
  font-size: 12px;
  color: var(--amber);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.mixer label, .vol-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin: 8px 0 4px;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: rgba(243,230,212,.18);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--lamp);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(232,184,109,.15);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.field input[type="text"] {
  background: rgba(0,0,0,.28);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.embed-wrap {
  width: min(560px, 94%);
  min-height: 152px;
  margin-bottom: 14px;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(8,5,3,.45);
  border: 1px solid var(--line);
}
.embed-wrap iframe {
  display: block;
  width: 100%;
  border: 0;
}
.dock-slim {
  display: block;
  text-align: center;
}
.dock {
  display: grid;
  grid-template-columns: 1.1fr .9fr .9fr;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 28px;
}

.transport {
  display: flex;
  align-items: center;
  gap: 14px;
}
.art {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #241910;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
.track-copy { min-width: 0; }
.track-copy b, .track-copy span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-copy span { color: var(--soft); font-size: 12px; }
.controls {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.controls button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
}
.controls .play {
  width: 42px;
  height: 42px;
  background: var(--paper);
  color: var(--ink);
}
.controls button.on {
  background: rgba(232,184,109,.22);
  color: var(--lamp);
  border-color: rgba(232,184,109,.45);
}
.ghost-link {
  align-self: flex-start;
  margin-bottom: 8px;
  font-size: 12px;
}
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}
.presets button, #focusPresets button {
  font-size: 12px;
  padding: 6px 10px;
}
.presets button.on, #focusPresets button.on {
  background: var(--paper);
  color: var(--ink);
}
#atmosAdvanced {
  margin-top: 6px;
}
#atmosAdvanced summary {
  cursor: pointer;
  color: var(--soft);
  font-size: 13px;
  margin-bottom: 8px;
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--soft);
}
.progress input { flex: 1; }

.lofi-note {
  font-size: 12px;
  color: var(--soft);
  line-height: 1.4;
}

.bubbles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
.bubble {
  position: absolute;
  max-width: 240px;
  padding: 12px 16px;
  background: #f4e7d3;
  color: #3a2a1c;
  border-radius: 18px 18px 18px 6px;
  font-family: "Fraunces", serif;
  font-size: 15px;
  line-height: 1.3;
  box-shadow: 0 14px 30px rgba(0,0,0,.28);
  animation: floatUp 8s ease-in forwards;
  transform-origin: bottom left;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(16px) scale(.92); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-48px) scale(.98); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: var(--glass-2);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 999px;
  z-index: 20;
  font-size: 13px;
  display: none;
}

.hidden { display: none !important; }

@media (max-width: 980px) {
  body { overflow: auto; }
  .scene, .app { height: auto; min-height: 100dvh; }
  .stage, .dock { grid-template-columns: 1fr; }
  .topbar { border-radius: 24px; flex-wrap: wrap; }
}
