/* 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; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.6 ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Roboto Mono", "DejaVu Sans Mono", monospace; /* the device's own code font: nothing to download */
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  padding: 6px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); gap: 6px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; text-align: inherit; }
: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; }
[hidden] { display: none !important; }

/* Top bar, like a status bar: menu on the left, radio, theme and clock on the right. */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 6px 16px; flex-wrap: wrap; padding: 0 4px; color: var(--dim); }
.menu { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.menu button { padding: 0 8px; border-radius: 3px; white-space: nowrap; }
.menu button:hover { color: var(--fg); background: var(--sel); }
.menu button[aria-current="true"] { color: var(--tile); background: var(--focus); }
.bar-right { display: flex; align-items: center; gap: 14px; }
.mini { display: flex; gap: 6px; }
.mini button:hover { color: var(--focus); }
.mini.playing #mini-name { color: var(--green); }
.theme-btn { color: var(--dim); border: 1px solid var(--border); border-radius: 4px; padding: 0 8px; white-space: nowrap; }
.theme-btn:hover { color: var(--fg); border-color: var(--focus); }
.theme-btn span { color: var(--focus); }
@media (max-width: 640px) { .clock { display: none; } .bar { justify-content: flex-start; } }

/* The terminal window: fills the page. */
.term { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--tile); border: 2px solid var(--focus); border-radius: 6px; }
.screen { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 18px; cursor: text; }
@media (max-width: 640px) { .screen { padding: 10px 12px 14px; } }
#out > *:not(.panel) { white-space: pre-wrap; overflow-wrap: anywhere; }
#out > div { min-height: 1.6em; }
.line { display: flex; align-items: baseline; }
.line label { white-space: nowrap; }
.line input { flex: 1; min-width: 0; padding: 0; font: inherit; color: inherit; background: none; border: 0; outline: 0; caret-color: var(--focus); }
@media (pointer: coarse) { .line input { font-size: 16px; } } /* no zoom on iPhone */
.hints { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 4px 18px; border-top: 1px solid var(--border); color: var(--dim); font-size: 12px; }
.hints button:hover kbd { border-color: var(--focus); color: var(--focus); }
@media (max-width: 640px) { .hints span:nth-child(2), .hints span:nth-child(3) { display: none; } }

pre { margin: 0; font: inherit; white-space: pre; }
.p { color: var(--green); } .c { color: var(--dim); } .k { color: var(--purple); } .o { color: var(--orange); } .cy { color: var(--cyan); }
.small { font-size: 12px; }
kbd { font: inherit; color: var(--fg); border: 1px solid var(--border); border-radius: 3px; padding: 0 5px; }

/* Clickable things in the output: commands, folders, links. */
.run { color: var(--cyan); border-bottom: 1px dotted currentColor; }
.run:hover, .run:focus-visible { color: var(--focus); background: var(--sel); outline: none; }
.dir { color: var(--focus); font-weight: 700; border-bottom: 0; }
.file { color: var(--fg); border-bottom: 0; }
.row-list { display: flex; flex-wrap: wrap; gap: 0 3ch; }

.ascii { color: var(--focus); font-size: 11px; line-height: 1.15; margin: 4px 0 12px; cursor: pointer; user-select: none; white-space: pre !important; overflow-wrap: normal !important; }
.ascii .r { display: block; }
@media (min-width: 700px) { .ascii { font-size: 15px; line-height: 1.1; } }
.ascii .r.off { visibility: hidden; }
.ascii span span { display: inline-block; }
.ascii.wave span span { animation: wave .8s ease-in-out calc(var(--col) * 35ms) 2; }
@keyframes wave { 35% { transform: translateY(-7px); color: var(--c); } 70% { transform: translateY(2px); color: var(--c); } }
@keyframes wave-colour { 50% { color: var(--c); } }

.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; max-width: 70ch; }
.ls a { display: grid; grid-template-columns: 2ch 12ch minmax(0, 1fr); gap: 8px; padding: 1px 4px; margin-left: -4px; border-radius: 3px; }
.ls a span:nth-child(2) { color: var(--cyan); }
.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); }

.help { display: grid; grid-template-columns: 15ch 1fr; gap: 0 10px; max-width: 70ch; }
.help .head { grid-column: 1 / -1; color: var(--purple); margin-top: 6px; }
.help .head:first-child { margin-top: 0; }
.help > span:not(.head) { color: var(--dim); }
.help > .run, .help > .cmd { justify-self: start; margin-left: 2ch; }

/* The radio panel, printed inside the terminal. */
.panel { border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; margin: 4px 0 6px; max-width: 760px; text-transform: lowercase; cursor: default; } /* fip sends Track Names In Capitals */
.panel:focus-within, .panel.playing { border-color: var(--focus); }
.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; text-align: center; }
.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 { flex: 1; min-width: 0; }
.np dd { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np dd[hidden], .np dt[hidden] { display: none; }
.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); }

/* Volume bar in the radio panel: 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); } }

/* Easter eggs: notes window, toast, exit blackout, party mode, screensaver. */
.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 { 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); }
.win-keys button:hover kbd, .win-keys button:focus-visible kbd { border-color: var(--focus); color: var(--focus); }

.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); }
.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 #out > * { animation: bob .45s ease-in-out infinite alternate; }
.party #out > *:nth-child(2n) { animation-delay: -.22s; }
.party .term { animation: bob .9s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-4px) rotate(-.3deg); } }

.saver { position: fixed; inset: 0; z-index: 30; background: var(--bg); cursor: none; }
.saver canvas { display: block; width: 100%; height: 100%; }
.saver-np { text-transform: lowercase; 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) {
  .playing .eq span { animation: none; transform: scaleY(.6); }
  .vol.bump .vol-bar, .party #out > *, .party .term { animation: none; }
  .blackout { transition: none; }
  .ascii.wave span span { animation-name: wave-colour; }
}
