/* lofi.fm — layout D. Tokens mirror the Figma "lofi tokens" collection and design/build.mjs. */
:root {
  --color-glass: #0E0B1A; --color-text: #FFFFFF; --color-accent: #FFD27A; --accent-rgb: 255, 210, 122; --color-ink: #1B1430; --color-live: #FF5A6A;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 24px; --radius-full: 999px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --glass-bg: rgba(14, 11, 26, .34); --tip-bg: rgba(14, 11, 26, .82);

  /* layout grid: one 440px column. toolbar (56 + 2×8 = 72) + gutter 12 + panel 356 = 440 */
  --edge: 40px; --card-w: 440px; --gutter: 12px; --tool: 56px; --bar-w: 72px;
  --panel-w: calc(var(--card-w) - var(--bar-w) - var(--gutter));
  --bar-h: 312px; /* 2×8 padding + 5×56 buttons + 4×4 gaps */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; } /* fixed interface: never scrolls */
body { background: #0B0912; color: #fff; font-family: 'Pixelify Sans', system-ui, sans-serif; -webkit-font-smoothing: antialiased; user-select: none; }
button, a { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-decoration: none; }
[hidden] { display: none !important; }
.pxi { display: block; flex: none; }
[data-ic] { display: inline-flex; }

/* text styles */
.t-clock { font: 400 72px/1 'Pixelify Sans'; font-variant-numeric: tabular-nums; }
.t-start { font: 500 48px/48px 'Pixelify Sans'; white-space: nowrap; }
.t-track { font: 500 24px/32px 'Pixelify Sans'; white-space: nowrap; }
.t-item { font: 500 20px/24px 'Pixelify Sans'; letter-spacing: .02em; }
.t-label-m { font: 400 13px/20px 'Silkscreen'; letter-spacing: .04em; }
.t-label-s { font: 400 12px/16px 'Silkscreen'; letter-spacing: .04em; }
.o85 { opacity: .85; } .o75 { opacity: .75; } .grow { flex: 1; min-width: 0; } .accent { color: var(--color-accent); }
kbd { font: 400 12px/1 'Silkscreen'; padding: 4px 8px; background: rgba(255,255,255,.14); border-radius: var(--radius-sm); opacity: .9; }

/* focus ring: pixel-ish, keyboard only */
/* no outlines anywhere; keyboard focus = a soft highlight instead */
:focus { outline: none; }
.ctl:focus-visible, .tool:focus-visible, .picker:focus-visible, .station:focus-visible, .thumb:focus-visible,
.chip:not(.is-on):focus-visible, .btn-ghost:focus-visible, .volume:focus-visible, .pslider:focus-visible { background-color: rgba(255,255,255,.14); border-radius: var(--radius-md); }
.play:focus-visible, .btn:focus-visible, .chip.is-on:focus-visible, .btn-outline:focus-visible { filter: brightness(1.12); }

/* glass */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 12px 40px -12px rgba(0,0,0,.4);
}

/* ---------- stage ---------- */
.stage { position: fixed; inset: 0; background: #1A1428; }
/* bg.jpg is painterly pixel art at 1376×768 (not an integer pixel grid) — scale it smoothly */
.scene { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s ease, filter .6s ease; }
.scene.is-on { opacity: 1; }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(760px 900px at 0 0, rgba(10,8,20,.62), transparent 72%); }

/* ---------- layout ---------- */
.ui { position: fixed; inset: 0; pointer-events: none; }
.ui > * { pointer-events: auto; }
.column { position: absolute; left: var(--edge); top: var(--edge); display: flex; flex-direction: column; align-items: flex-start; gap: var(--gutter); }
.card-wrap { position: relative; z-index: 2; }
.dock { position: relative; display: flex; align-items: flex-start; gap: var(--gutter); }
.ui[data-open="stations"] .dock { display: none; } /* toolbar disappears while stations are open */

/* ---------- player ---------- */
.card { width: var(--card-w); padding: var(--space-5); border-radius: var(--radius-xl); display: flex; flex-direction: column; gap: var(--space-3); }
.card__station { display: flex; align-items: center; gap: var(--space-2); }
.picker { display: flex; align-items: center; gap: var(--space-2); margin: -4px -8px; padding: 4px 8px; border-radius: var(--radius-sm); opacity: .9; transition: background .15s; }
.picker:hover { background: rgba(255,255,255,.08); opacity: 1; }
.picker__chev { opacity: .75; margin: -8px -6px; } /* 30px glyph box; keep row height */
.ui[data-open="stations"] .picker { background: rgba(255,255,255,.14); color: var(--color-accent); opacity: 1; }
.live { width: 8px; height: 8px; background: var(--color-live); display: inline-block; flex: none; }
.live--wait { background: #fff; opacity: .5; animation: blink 1s steps(2) infinite; }
.dot { width: 8px; height: 8px; background: #fff; opacity: .4; display: inline-block; }
@keyframes blink { 50% { opacity: .15; } }

.marquee { position: relative; height: 32px; overflow: hidden; }
.marquee.is-overflow { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.marquee__track { display: inline-flex; gap: 48px; padding-top: 2px; white-space: nowrap; }
.marquee.is-overflow .marquee__track { animation: marquee var(--dur, 12s) linear infinite; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(calc(-50% - 24px)); } }
.loader { position: absolute; inset: 0; display: flex; align-items: center; gap: var(--space-3); }
.segs { display: flex; gap: var(--space-1); }
.segs i { width: 8px; height: 8px; background: rgba(255,255,255,.2); }
.segs i.on { background: var(--color-accent); }
.segs--run i { animation: segrun 1s steps(1) infinite; }
.segs--run i:nth-child(1) { animation-delay: 0s; } .segs--run i:nth-child(2) { animation-delay: .1s; } .segs--run i:nth-child(3) { animation-delay: .2s; }
.segs--run i:nth-child(4) { animation-delay: .3s; } .segs--run i:nth-child(5) { animation-delay: .4s; } .segs--run i:nth-child(6) { animation-delay: .5s; }
.segs--run i:nth-child(7) { animation-delay: .6s; } .segs--run i:nth-child(8) { animation-delay: .7s; } .segs--run i:nth-child(9) { animation-delay: .8s; }
.segs--run i:nth-child(10) { animation-delay: .9s; }
@keyframes segrun { 0% { background: var(--color-accent); } 30% { background: rgba(255,255,255,.2); } }

.card__controls { display: flex; align-items: center; gap: var(--space-4); min-height: 40px; }
.play { width: 56px; height: 56px; border-radius: var(--radius-full); background: var(--color-accent); color: var(--color-ink); display: grid; place-items: center; flex: none;
  box-shadow: 0 6px 24px -4px rgba(var(--accent-rgb), .45), inset 0 -4px 0 rgba(0,0,0,.15); transition: transform .1s, box-shadow .2s; }
.play:hover { transform: translateY(-2px); }
.play:active { transform: translateY(1px); box-shadow: 0 2px 8px -4px rgba(var(--accent-rgb), .45), inset 0 -2px 0 rgba(0,0,0,.15); }
.play--wait { opacity: .5; box-shadow: none; }
.play--xl { width: 96px; height: 96px; margin: var(--space-2) 0; }
.ctl { color: #fff; opacity: .8; display: grid; place-items: center; transition: opacity .15s, transform .1s; }
.ctl:hover { opacity: 1; }
.ctl:active { transform: translateY(1px); }
/* play/pause: no plate, just the accent-coloured icon between prev and next */
.ctl--play { color: var(--color-accent); opacity: 1; padding: 4px; }
.ctl--like[aria-pressed="true"] { color: var(--color-accent); opacity: 1; }
.ctl:disabled { opacity: .25; cursor: default; }
.ctl--play:hover { transform: translateY(-1px); }
.ctl--play.is-wait { opacity: .45; animation: blink 1s steps(2) infinite; }
.ctl--sm { opacity: .75; margin: -4px; }
.volume { display: flex; gap: var(--space-1); padding: 6px 0; cursor: pointer; }
.volume i { width: 8px; height: 16px; background: rgba(255,255,255,.25); transition: background .1s; }
.volume i.on { background: #fff; }
.volume:hover i.on { background: var(--color-accent); }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: var(--radius-lg); }
.tool { position: relative; width: var(--tool); height: var(--tool); border-radius: var(--radius-md); display: grid; place-items: center; color: #fff; transition: background .15s, transform .1s; }
.tool > [data-ic] { opacity: .9; }
.tool:hover { background: rgba(255,255,255,.08); }
.tool:active { transform: translateY(1px); }
.tool.is-active { background: rgba(255,255,255,.14); color: var(--color-accent); }
.tool.is-on { color: var(--color-accent); }
.tool__dot { position: absolute; right: 6px; top: 6px; width: 8px; height: 8px; background: var(--color-accent); display: none; }
.tool.is-on .tool__dot { display: block; }

/* tooltip: to the right of the button, hidden while its panel is open */
.tip { position: absolute; left: calc(100% + 8px + 1px + 12px); top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); background: var(--tip-bg); border-radius: var(--radius-sm); white-space: nowrap; color: #fff;
  opacity: 0; pointer-events: none; transition: opacity .12s; }
.tip::before { content: ''; position: absolute; left: -8px; top: 50%; margin-top: -6px; width: 8px; height: 12px;
  background: linear-gradient(90deg, transparent 4px, var(--tip-bg) 4px), linear-gradient(transparent 4px, var(--tip-bg) 4px 8px, transparent 8px); }
.tool:hover .tip, .tool:focus-visible .tip { opacity: 1; transition-delay: .35s; }
.tool.is-active .tip, .ui[data-open]:not([data-open=""]) .tool .tip { opacity: 0 !important; }

/* ---------- panels ---------- */
.panel { position: relative; padding: var(--space-4); border-radius: var(--radius-xl); display: flex; flex-direction: column; gap: var(--space-3); }
.panel--cell { width: var(--panel-w); min-height: var(--bar-h); max-height: calc(100vh - 260px); overflow: auto; scrollbar-width: none; }
.panel--corner { min-height: 0; max-height: none; }
.dropdown { position: absolute; left: 0; top: calc(100% + var(--gutter)); width: var(--card-w); max-height: calc(100vh - 300px); overflow: auto; scrollbar-width: none; }
.dropdown::-webkit-scrollbar, .panel--cell::-webkit-scrollbar { display: none; }
.panel[hidden] { display: none; }
.panel:not([hidden]) { animation: panelIn .16s ease-out; }
@keyframes panelIn { from { opacity: 0; transform: translateY(-4px); } }
.panel__head { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-1); }
.tail-u { position: absolute; top: -9px; left: 40px; width: 16px; height: 8px;
  background: linear-gradient(transparent 4px, var(--glass-bg) 4px), linear-gradient(90deg, transparent 4px, var(--glass-bg) 4px 12px, transparent 12px); }
.list { display: flex; flex-direction: column; gap: var(--space-1); margin: 0 calc(-1 * var(--space-1)); }
.list--rows { gap: var(--space-2); }
.row-line { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-1) 0; }
.note { padding: 0 var(--space-1); }

/* stations */
.station { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4) var(--space-3) var(--space-3); border-radius: var(--radius-lg); text-align: left; transition: background .15s; }
.station:hover { background: rgba(255,255,255,.07); }
.station > [data-ic] { opacity: .75; }
.station.is-active { background: rgba(255,255,255,.12); }
.station.is-active > [data-ic], .station.is-active .t-item { color: var(--color-accent); opacity: 1; }
.station__text { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; min-width: 0; }
.station__on { display: flex; align-items: center; gap: var(--space-2); }

/* scenes */
.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.thumb { display: flex; flex-direction: column; gap: var(--space-2); text-align: left; }
.thumb__img { display: block; aspect-ratio: 16/10; border-radius: var(--radius-md); overflow: hidden; opacity: .55; transition: opacity .15s; }
.thumb:hover .thumb__img { opacity: .85; }
.thumb__img img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; display: block; }
.thumb.is-active .thumb__img { opacity: 1; }
.thumb.is-active .t-label-s { color: var(--color-accent); opacity: 1; }

/* ambience mixer */
.mix { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-1); }
.mix > [data-ic] { color: var(--color-accent); }
.mix__name { width: 52px; }
.mix__val { width: 36px; text-align: right; }
.mix.is-off > [data-ic], .mix.is-off .mix__name { color: #fff; opacity: .5; }
.pslider { display: flex; gap: 3px; cursor: pointer; padding: 4px 0; touch-action: none; }
.pslider i { width: 8px; height: 16px; background: rgba(255,255,255,.2); }
.pslider i.on { background: var(--color-accent); }

/* focus */
.focus { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); padding: 0 var(--space-1) var(--space-2); }
.segs--wide { flex-wrap: wrap; }
.btns { display: flex; gap: var(--space-2); }
.btn { display: flex; align-items: center; justify-content: center; gap: var(--space-2); height: 40px; padding: 0 var(--space-4); background: var(--color-accent); color: var(--color-ink); border-radius: var(--radius-md); transition: transform .1s; }
.btn:active, .btn-outline:active, .chip:active { transform: translateY(1px); }
.btn--wide { width: 100%; }
.btn-outline { display: flex; align-items: center; gap: var(--space-2); height: 40px; padding: 0 var(--space-4); background: rgba(var(--accent-rgb), .16); color: var(--color-accent); border-radius: var(--radius-md); }
.btn-outline:hover { background: rgba(var(--accent-rgb), .24); }
.btn-ghost { opacity: .75; padding: 4px 8px; border-radius: var(--radius-sm); background: rgba(255,255,255,.08); }
.btn-ghost:hover { opacity: 1; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.chips--2 { grid-template-columns: 1fr 1fr; }
.chip { height: 36px; white-space: nowrap; background: rgba(255,255,255,.1); border-radius: var(--radius-md); opacity: .9; transition: background .15s; }
.chip:hover { background: rgba(255,255,255,.18); opacity: 1; }
.chip.is-on { background: var(--color-accent); color: var(--color-ink); opacity: 1; }

/* custom focus preset */
.custom { display: flex; align-items: flex-end; gap: var(--space-2); }
.custom label { flex: 1; display: flex; flex-direction: column; gap: var(--space-1); }
.custom input { height: 40px; width: 100%; padding: 0 var(--space-3); border-radius: var(--radius-md); border: 0;
  background: rgba(255,255,255,.1); color: #fff; font: 500 20px 'Pixelify Sans'; user-select: text; }
.custom input:focus { outline: none; background: rgba(255,255,255,.18); }

/* toggle */
.toggle { width: 40px; height: 24px; padding: 4px; border-radius: var(--radius-sm); background: rgba(255,255,255,.18); display: flex; flex: none; transition: background .15s; }
.toggle i { width: 16px; height: 16px; border-radius: 4px; background: #fff; transition: transform .15s; }
.toggle[aria-checked="true"] { background: var(--color-accent); }
.toggle[aria-checked="true"] i { background: var(--color-ink); transform: translateX(16px); }

/* coffee */
.coffee { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; padding: var(--space-2) var(--space-1) 0; }
.coffee__icon { color: var(--color-accent); }
.coffee .chips { width: 100%; }

/* toast */
.toast { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5); border-radius: var(--radius-lg); }
.toast__icon { color: var(--color-live); }
.toast__text { display: flex; flex-direction: column; }

/* ---------- start screen ---------- */
.start-screen { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; transition: opacity .6s ease; }
.start-screen.is-leaving { opacity: 0; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(10,8,20,.55); }
.start { position: relative; width: 480px; padding: var(--space-10) var(--space-8); border-radius: var(--radius-xl); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; }
.start__brand { display: flex; align-items: center; gap: var(--space-4); }
.hint { display: flex; align-items: center; gap: var(--space-2); }
.ui.is-locked { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* toolbar separator (before coffee) */
.toolbar__sep { width: 32px; height: 1px; margin: 4px 0; background: rgba(255,255,255,.18); }

/* night mode: same season, darker scene */
.stage .scene { filter: none; }
.stage.is-night .scene { filter: brightness(.5) saturate(.8) hue-rotate(-6deg); }
.stage.is-night .vignette { background: radial-gradient(760px 900px at 0 0, rgba(10,8,20,.5), transparent 72%), rgba(6,6,20,.25); }

/* minimal pomodoro */
.pomo { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-1) 0; }
.pomo__time { flex: 1; display: flex; justify-content: center; }
.pxd { display: block; }
.pomo__step { width: 40px; height: 40px; border-radius: var(--radius-md); background: rgba(255,255,255,.08); opacity: 1; }
.pomo__step:hover:not(:disabled) { background: rgba(255,255,255,.16); }
.pomo__bar { height: 8px; background: rgba(255,255,255,.12); margin: var(--space-2) 0 var(--space-3); }
.pomo__bar i { display: block; height: 100%; width: 0; background: var(--color-accent); transition: width 1s linear; }
#panel-focus { justify-content: space-between; }

/* accent colour button: the drop is painted in the current accent */
#accent > [data-ic] { color: var(--color-accent); opacity: 1; }

/* track title opens the track list */
.marquee { cursor: pointer; margin: 0 -8px; padding: 0 8px; border-radius: var(--radius-sm); transition: background .15s; }
.marquee:hover, .ui[data-open="tracks"] .marquee { background: rgba(255,255,255,.08); }
.marquee:focus-visible { background: rgba(255,255,255,.14); }
.ui[data-open="tracks"] .dock { display: none; }

/* tracks dropdown */
.tabs2 { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: rgba(255,255,255,.08); }
.tabs2 button { padding: 5px 9px; border-radius: 9px; opacity: .7; }
.tabs2 button:hover { opacity: 1; }
.tabs2 button.is-on { background: rgba(255,255,255,.16); color: var(--color-accent); opacity: 1; }
.trow { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); border-radius: var(--radius-lg); cursor: pointer; transition: background .15s; }
.trow:hover { background: rgba(255,255,255,.07); }
.trow.is-current { background: rgba(255,255,255,.12); }
.trow.is-current .trow__name { color: var(--color-accent); }
.trow__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trow__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .eq { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.trow .eq i { width: 3px; background: var(--color-accent); animation: eq 1s steps(3) infinite; }
.trow .eq i:nth-child(2) { animation-delay: -.3s; } .trow .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0% { height: 4px; } 33% { height: 12px; } 66% { height: 7px; } }
.trow .ctl--like { opacity: .55; } .trow:hover .ctl--like { opacity: .9; }
.trow .ctl--like[aria-pressed="true"] { opacity: 1; }
.empty { padding: var(--space-4); text-align: center; line-height: 1.6; }

/* tracks dropdown: header stays put, only the list scrolls */
#panel-tracks { overflow: hidden; }
#trackList { flex: 1; min-height: 0; overflow: auto; scrollbar-width: none; }
#trackList::-webkit-scrollbar { display: none; }

/* player rows: station picker spans the row (chevron at the right edge); heart sits at the end of the title row */
.picker--wide { flex: 1; }
.picker--wide .picker__chev { margin-left: auto; }
.card__title { display: flex; align-items: center; gap: var(--space-2); }
.card__title .marquee { flex: 1; min-width: 0; }
.card__title .ctl--like { flex: none; margin-right: -4px; }

/* scenes: four portrait previews in one row */
.thumbs { grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.thumb__img { aspect-ratio: 3 / 5; }
.thumb { align-items: center; }

/* focus timer: pixel segments (like volume), they switch off one by one as time runs out */
.segbar { display: flex; gap: 4px; margin: var(--space-2) 0 var(--space-3); }
.segbar i { flex: 1; height: 16px; background: rgba(255,255,255,.2); transition: background .3s; }
.segbar i.on { background: var(--color-accent); }

/* ---------- grid lock: every row has a fixed height on the 4px grid ---------- */
.card__station { height: 20px; }                 /* player: 20 + 12 + 32 + 12 + 40 + 2×20 padding = 156 */
.marquee__track { padding-top: 0; }
.panel__head { min-height: 32px; }
.mix { height: 40px; padding-top: 0; padding-bottom: 0; }
.row-line { min-height: 32px; padding-top: 0; }
.station { min-height: 64px; padding-top: 8px; padding-bottom: 8px; }
.trow { min-height: 48px; padding-top: 4px; padding-bottom: 4px; }
