/* Themes: each one sets the same 11 colours. Add a theme by copying a block
   and adding its name to THEMES in app.js. */
:root, [data-theme="tokyo-night"] {
  --bg: #1a1b26; --tile: #16161e; --border: #292e42; --focus: #7aa2f7; --fg: #c0caf5; --dim: #737aa2;
  --green: #9ece6a; --purple: #bb9af7; --orange: #ff9e64; --cyan: #7dcfff; --sel: #283457; color-scheme: dark;
}
[data-theme="catppuccin"] {
  --bg: #1e1e2e; --tile: #181825; --border: #313244; --focus: #cba6f7; --fg: #cdd6f4; --dim: #9399b2;
  --green: #a6e3a1; --purple: #cba6f7; --orange: #fab387; --cyan: #89dceb; --sel: #313244; color-scheme: dark;
}
[data-theme="gruvbox"] {
  --bg: #282828; --tile: #1d2021; --border: #3c3836; --focus: #d79921; --fg: #ebdbb2; --dim: #a89984;
  --green: #b8bb26; --purple: #d3869b; --orange: #fe8019; --cyan: #8ec07c; --sel: #3c3836; color-scheme: dark;
}
[data-theme="nord"] {
  --bg: #2e3440; --tile: #272c36; --border: #3b4252; --focus: #88c0d0; --fg: #eceff4; --dim: #9aa5b8;
  --green: #a3be8c; --purple: #b48ead; --orange: #d08770; --cyan: #88c0d0; --sel: #434c5e; color-scheme: dark;
}
[data-theme="everforest"] {
  --bg: #2d353b; --tile: #272e33; --border: #3d484d; --focus: #a7c080; --fg: #d3c6aa; --dim: #9da9a0;
  --green: #a7c080; --purple: #d699b6; --orange: #e69875; --cyan: #83c092; --sel: #3d484d; color-scheme: dark;
}
[data-theme="rose-pine"] {
  --bg: #191724; --tile: #1f1d2e; --border: #26233a; --focus: #c4a7e7; --fg: #e0def4; --dim: #908caa;
  --green: #ebbcba; --purple: #c4a7e7; --orange: #f6c177; --cyan: #9ccfd8; --sel: #403d52; color-scheme: dark;
}
[data-theme="kanagawa"] {
  --bg: #1f1f28; --tile: #16161d; --border: #2a2a37; --focus: #7e9cd8; --fg: #dcd7ba; --dim: #938f84;
  --green: #98bb6c; --purple: #957fb8; --orange: #ffa066; --cyan: #7fb4ca; --sel: #2d4f67; color-scheme: dark;
}
[data-theme="matte-black"] {
  --bg: #121212; --tile: #0b0b0b; --border: #262626; --focus: #e68e0d; --fg: #d4d4d4; --dim: #8a8a8d;
  --green: #c8c8c8; --purple: #e68e0d; --orange: #f5a524; --cyan: #b8b8b8; --sel: #2a2a2a; color-scheme: dark;
}
[data-theme="latte"] {
  --bg: #eff1f5; --tile: #e6e9ef; --border: #ccd0da; --focus: #8839ef; --fg: #4c4f69; --dim: #6c6f85;
  --green: #2f7d1f; --purple: #8839ef; --orange: #c94f00; --cyan: #1e66f5; --sel: #ccd0da; color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.6 "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.desk { max-width: 1100px; margin: 0 auto; padding: 10px max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left)); display: grid; gap: 10px; min-height: 100vh; align-content: start; }
@media (min-width: 900px) { .desk { padding-top: 6vh; } }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 2px 6px; color: var(--dim); }
.ws { display: flex; gap: 10px; }
.ws .on { color: var(--focus); }
.theme-btn { color: var(--dim); border: 1px solid var(--border); border-radius: 4px; padding: 0 8px; }
.theme-btn:hover { color: var(--fg); border-color: var(--focus); }
.theme-btn span { color: var(--focus); }

.tiles { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 10px; }
.tile { background: var(--tile); border: 2px solid var(--border); border-radius: 6px; padding: 14px 16px; min-width: 0; overflow-x: auto; transition: border-color .15s; }
.tile.big { grid-row: span 2; }
.tile.focus, .tile:hover, .tile:focus-within { border-color: var(--focus); }
.tile.radio { grid-column: 1 / -1; }
@media (max-width: 700px) { .tiles { grid-template-columns: minmax(0, 1fr); } .tile.big { grid-row: auto; } }

pre { margin: 0; font: inherit; white-space: pre; }
.ascii { color: var(--focus); font-size: 11px; line-height: 1.15; margin-bottom: 12px; }
.p { color: var(--green); } .c { color: var(--dim); } .k { color: var(--purple); } .o { color: var(--orange); } .cy { color: var(--cyan); }
.small { font-size: 12px; }

.me { display: grid; grid-template-columns: 7ch 1fr; gap: 0 10px; margin: 0; }
.me dt { color: var(--cyan); }
.me dd { margin: 0; }

.ls { display: grid; margin-top: 2px; }
.ls a { display: grid; grid-template-columns: 2ch 11ch minmax(0, 1fr); gap: 8px; padding: 1px 4px; border-radius: 3px; }
.ls a span:last-child { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls a:hover, .ls a:focus-visible { background: var(--sel); outline: none; }
.ls a:hover span:nth-child(2), .ls a:focus-visible span:nth-child(2) { color: var(--focus); }

.cursor { display: inline-block; width: .6em; height: 1.1em; background: var(--fg); vertical-align: text-bottom; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.radio-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.radio-head a:hover { color: var(--focus); }
.player { display: flex; align-items: center; gap: 14px; margin: 10px 0; flex-wrap: wrap; }
.play { border: 1px solid var(--focus); color: var(--focus); border-radius: 4px; padding: 2px 12px; min-width: 10ch; }
.play:hover, .play[aria-pressed="true"] { background: var(--focus); color: var(--tile); }
.eq { display: flex; align-items: flex-end; gap: 3px; height: 22px; width: 120px; }
.eq span { flex: 1; height: 100%; background: linear-gradient(var(--orange), var(--purple)); transform-origin: bottom; transform: scaleY(.12); border-radius: 1px; }
.playing .eq span { animation: eq 1s ease-in-out infinite alternate; }
@keyframes eq { from { transform: scaleY(.15); } to { transform: scaleY(1); } }
.status { color: var(--dim); }
.status b { color: var(--green); font-weight: 400; }
.now { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; min-width: 0; }
.now .cover { width: 56px; height: 56px; flex: none; border-radius: 4px; border: 1px solid var(--border); object-fit: cover; }
.np-text { min-width: 0; }
.np-text > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stations { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.stations button { color: var(--dim); padding: 0 6px; border-radius: 3px; }
.stations button:hover { color: var(--fg); background: var(--sel); }
.stations button[aria-pressed="true"] { color: var(--tile); background: var(--cyan); }

.keys { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--dim); padding: 2px 6px; font-size: 12px; }
kbd { font: inherit; color: var(--fg); border: 1px solid var(--border); border-radius: 3px; padding: 0 5px; }

@media (prefers-reduced-motion: reduce) { .cursor, .playing .eq span { animation: none; } .playing .eq span { transform: scaleY(.6); } }

[hidden] { display: none !important; }

/* Easter eggs: notes and shell window, ^C toast, exit blackout, party mode, screensaver. */
.secrets { font-size: inherit; color: inherit; }
.secrets:hover kbd { border-color: var(--focus); color: var(--focus); }
.win { width: min(680px, calc(100vw - 32px)); max-height: min(72vh, 560px); padding: 0; background: var(--tile); color: var(--fg); border: 2px solid var(--focus); border-radius: 6px; box-shadow: 0 20px 60px rgb(0 0 0 / .45); }
.win[open] { display: flex; flex-direction: column; }
.win::backdrop { background: rgb(0 0 0 / .5); }
.win-bar { display: flex; justify-content: space-between; gap: 12px; padding: 2px 4px 2px 12px; background: var(--focus); color: var(--tile); }
.win-bar button { padding: 0 8px; border-radius: 3px; }
.win-bar button:hover { background: var(--tile); color: var(--focus); }
.win-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.win textarea, .win input { font: inherit; color: inherit; background: none; border: 0; outline: 0; caret-color: var(--focus); }
#nano-text { flex: 1; min-height: 40vh; resize: none; padding: 12px 14px; }
#nano-text::placeholder { color: var(--dim); }
.win-msg { min-height: 1.6em; text-align: center; color: var(--orange); }
.win-keys { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 6px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--dim); }
.sh { overflow-y: auto; padding: 10px 14px; min-height: 40vh; }
#sh-out > div { white-space: pre-wrap; overflow-wrap: anywhere; }
.sh-line { display: flex; }
.sh-line input { flex: 1; min-width: 0; padding: 0 0 0 1ch; }

.toast { position: fixed; right: 16px; bottom: 16px; max-width: calc(100vw - 32px); z-index: 10; background: var(--tile); border: 1px solid var(--focus); border-radius: 4px; padding: 6px 12px; box-shadow: 0 8px 30px rgb(0 0 0 / .35); }
.toast b { color: var(--orange); font-weight: 400; }

.blackout { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #000; color: #c0caf5; font-size: 20px; opacity: 0; transition: opacity .8s; }
.blackout.on { opacity: 1; }

.party .tile { animation: bob .45s ease-in-out infinite alternate; }
.party .tile:nth-child(2n) { animation-delay: -.22s; }
@keyframes bob { to { transform: translateY(-6px) rotate(-.4deg); } }

.saver { position: fixed; inset: 0; z-index: 30; background: var(--bg); cursor: none; }
.saver canvas { display: block; width: 100%; height: 100%; }
.saver-np { position: absolute; left: 20px; right: 20px; bottom: 16px; color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) { .party .tile { animation: none; } .blackout { transition: none; } }

/* Volume bar in the radio tile: green, then orange when it gets loud. */
.vol { display: flex; align-items: center; gap: 8px; margin-left: auto; border-radius: 3px; }
.vol-bar { display: flex; align-items: flex-end; gap: 3px; height: 20px; }
.vol-bar span { width: 7px; background: var(--border); border-radius: 1px; cursor: pointer; transition: background .15s; }
.vol-bar span.on { background: var(--green); }
.vol-bar span.on:nth-child(n+7) { background: var(--orange); }
.vol-pct { min-width: 6ch; color: var(--dim); }
.vol.bump .vol-bar { animation: vol-bump .3s ease-out; }
.vol.bump .vol-pct { color: var(--fg); }
@keyframes vol-bump { 40% { transform: scaleY(1.2); } }
@media (prefers-reduced-motion: reduce) { .vol.bump .vol-bar { animation: none; } }
