:root {
  color-scheme: dark;
  --bg0: #0f0f10;
  --bg: #141415;
  --card: #19191b;
  --raised: #232325;
  --raised-hi: #2b2b2e;
  --line: rgb(237 237 237 / .08);
  --text: #ededed;
  --text2: #a1a1a6;
  --muted: #85858b;
  --accent: #f0b44c;
  --led: #e5484d;
  --ease: cubic-bezier(.22, 1, .36, 1); /* the one curve: fast start, long soft landing */
  --sans: 'Archivo', system-ui, sans-serif; /* a sturdy grotesque with a width axis: set narrower, it reads like a broadcast programme guide */
  --guide: 87.5%; /* the narrower width, for channel names and titles */
  --mono: 'Geist Mono', ui-monospace, monospace;
  --panel: 'Doto', 'Geist Mono', ui-monospace, monospace; /* dot-matrix, like a set-top box front panel: channel numbers only */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .7 0 0 0 0 .7 0 0 0 0 .7 0 0 0 2.2 -.7'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: #3a3a3e transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #000;
  color: var(--text);
  font: 400 14px/20px var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
h2 { margin: 0 0 16px; font-size: 20px; line-height: 28px; font-weight: 500; font-stretch: var(--guide); }
.chan__name, .ch__name, .ident__name { font-stretch: var(--guide); }
p { margin: 0; text-wrap: pretty; } /* no lone last word */
a { color: var(--text); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid rgb(237 237 237 / .7); outline-offset: 2px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd { margin-left: auto; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; font: 12px/18px var(--mono); color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; translate: 0 12px; scale: .98; } }

/* the room: the screen's own light, thrown onto everything around it */
.ambient { position: fixed; inset: 0; overflow: hidden; background: #000; transition: opacity .2s var(--ease); }
.ambient canvas { position: absolute; inset: -8%; width: 116%; height: 116%; filter: blur(14px) saturate(1.6) brightness(.85); opacity: 0; transition: opacity .7s var(--ease); }
.ambient canvas.on { opacity: .62; }

/* shell */
.app { position: relative; display: grid; grid-template-columns: 280px minmax(0, 1fr); height: 100dvh; }
.stage { position: relative; overflow: hidden; container-type: inline-size; }

/* guide */
.guide { display: flex; flex-direction: column; min-height: 0; padding: 16px 8px 8px; background: rgb(15 15 16 / .9); border-right: 1px solid var(--line); }
.guide__head { display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 8px; }
.guide__grab { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 500; }
.brand__mark { flex: none; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
/* the title in the same front-panel dots as the channel numbers: "Channel" lit off-white, "34" amber.
   Big enough that the dots still read as letters. */
.brand__name { font: 900 20px/1 var(--panel); white-space: nowrap; word-spacing: -.3em; } /* the dot font's space is a full letter wide */
.brand__n { color: var(--accent); }
.guide .guide__close, .scrim { display: none; }
.label { margin: 24px 8px 8px; font-size: 12px; line-height: 16px; color: var(--muted); }
.guide { overflow-y: auto; scrollbar-width: none; } /* when it's taller than the screen the whole guide scrolls; no part of it gets squeezed away */
.guide__scroll { position: relative; flex: none; }
.guide__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
/* one highlight that glides to the current channel */
.ch-ind { position: absolute; top: 0; left: 0; right: 0; border-radius: 8px; background: rgb(237 237 237 / .09); box-shadow: inset 0 1px 0 rgb(255 255 255 / .06); opacity: 0; pointer-events: none; transition: transform .5s var(--ease), opacity .2s var(--ease); }
.ch-row { position: relative; }
.ch { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 8px; border-radius: 8px; text-align: left; color: var(--text2); transition: background-color .15s var(--ease), color .3s var(--ease); }
.guide__list .ch { height: 48px; }
.ch:hover { background: rgb(237 237 237 / .05); color: var(--text); }
.ch[aria-current] { color: var(--text); }
.ch__n { display: grid; place-items: center; width: 24px; flex: none; font: 500 13px/20px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; transition: color .3s var(--ease); }
.ch[aria-current] .ch__n { color: var(--accent); }
.ch__text { flex: 1; min-width: 0; display: grid; }
.ch__name, .ch__q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch__q { font: 12px/16px var(--mono); color: var(--muted); }
.ch__pic { width: 44px; height: 28px; flex: none; border-radius: 4px; object-fit: cover; background: rgb(237 237 237 / .04); box-shadow: 0 0 0 1px var(--line); opacity: .7; transition: opacity .15s var(--ease); }
.ch:hover .ch__pic, .ch[aria-current] .ch__pic { opacity: 1; }
.ch__x { position: absolute; right: 16px; top: 10px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: rgb(15 15 16 / .86); color: var(--text); opacity: 0; transition: opacity .15s var(--ease); }
.ch-row:hover .ch__x, .ch__x:focus-visible { opacity: 1; }
/* touch screens of any width can't hover, so the remove button shows, beside the thumbnail rather than over it */
@media (hover: none) {
  .ch__x { opacity: 1; right: 2px; top: 50%; translate: 0 -50%; width: 44px; height: 44px; background: none; color: var(--text2); }
  .guide__list .ch { padding-right: 48px; } /* every row keeps the button's room, so the pictures line up */
}
.ch--new { margin-top: 2px; }
.suggested { display: grid; gap: 2px; }
.suggested .ch { height: 44px; }
.guide__foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); display: grid; gap: 2px; }

/* reel */
.reel { height: 100%; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; container-type: inline-size; touch-action: pan-y; }
.reel::-webkit-scrollbar { display: none; }
/* each slide is a size container: its frame is fitted to it, so media never sets its own height */
.slide { position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; container-type: size; }
/* the frame is exactly the picture's box, so it can be moved, scaled and morphed as one object */
.frame { position: relative; overflow: hidden; width: min(100cqw, 100cqh * var(--ar)); aspect-ratio: var(--ar); }
/* while the file loads, its own thumbnail stands in, softened, so the screen is never empty */
.frame::before { content: ''; position: absolute; inset: 0; background: var(--ph, none) center / cover no-repeat; filter: blur(14px); scale: 1.1; transition: opacity .45s var(--ease); }
.frame:has(> .ready)::before { opacity: 0; }
.frame > img, .frame > video, .frame > canvas { position: relative; display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .45s var(--ease); }
.frame > .ready { opacity: 1; }
.ghost { position: absolute; z-index: 1; margin: 0; pointer-events: none; animation: none; }
/* comic strips: the slide is as tall as the strip at reading width, and scrolls freely inside the snap */
.slide--strip { height: calc(min(100cqw, 760px) / var(--ar)); min-height: 100%; }
.slide--strip .frame { max-width: 760px; }
.slide--paused::after, .slide--failed::after { position: absolute; top: calc(max(16px, env(safe-area-inset-top)) + 56px); right: max(16px, env(safe-area-inset-right)); font: 500 13px/20px var(--mono); color: var(--text); text-shadow: 0 1px 2px #000; animation: fade .3s var(--ease); }
.slide--paused::after { content: 'Paused'; }
.slide--failed::after { content: 'No signal'; top: 50%; right: 50%; transform: translate(50%, -50%); color: var(--text2); }
.slide--failed > * { visibility: hidden; }
.slide--strip.slide--failed { height: 100%; } /* one screen with "No signal" in it, not a strip's worth of nothing */

/* scrolling between posts: the one leaving sinks back and dims as the next one rises to full size */
@supports (animation-timeline: view()) {
  .slide { view-timeline: --slide block; }
  .slide:not(.slide--strip) .frame { animation: depth linear both; animation-timeline: --slide; animation-range: entry 0% exit 100%; }
  @keyframes depth {
    entry 0% { scale: .86; opacity: .2; }
    entry 100% { scale: 1; opacity: 1; }
    exit 0% { scale: 1; opacity: 1; }
    exit 100% { scale: .86; opacity: .2; }
  }
}

/* static means what it means on a TV: no picture yet. It snows only while a channel is still loading, and stays faint on "no signal" */
.static { position: absolute; inset: -10%; z-index: 3; pointer-events: none; opacity: 0; background: #0c0c0d var(--noise); transition: opacity .25s var(--ease); }
.searching .static { opacity: .5; transition-delay: .12s; animation: snow .32s steps(1) infinite; }
.nosignal .static { opacity: .16; animation: snow .32s steps(1) infinite; }
@keyframes snow {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-4%, 3%); }
  50% { transform: translate(3%, -5%); }
  75% { transform: translate(-6%, -2%); }
}
.ident { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 4px; pointer-events: none; opacity: 0; text-shadow: 0 2px 24px rgb(0 0 0 / .7); }
.ident__n { font: 900 clamp(128px, 22cqw, 264px)/.9 var(--panel); color: var(--accent); font-variant-numeric: tabular-nums; }
.ident__name { font-size: 20px; line-height: 28px; }
.tuning .ident { animation: ident 1.4s var(--ease); }
.entering .ident { opacity: 1; }
/* while the number is up the picture dims beneath it, a little more at the centre where the number sits,
   and comes back as the number lets go: the same timing and curve, so the two move as one.
   It sits under the controls, which stay readable. */
.tint { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgb(0 0 0 / .72), rgb(0 0 0 / .5) 75%); transition: opacity .2s var(--ease); }
.tuning .tint { animation: tint 1.4s var(--ease); }
.entering .tint { opacity: 1; }
@keyframes tint { 0% { opacity: 0; } 14%, 72% { opacity: 1; } 100% { opacity: 0; } }
/* the number focuses in, holds, and lets go */
@keyframes ident {
  0% { opacity: 0; scale: 1.12; filter: blur(10px); }
  14% { opacity: 1; scale: 1; filter: blur(0); }
  72% { opacity: 1; scale: 1; }
  100% { opacity: 0; scale: .98; }
}

/* on-screen display: slides a few pixels off its edge as it fades */
.osd { position: absolute; left: 0; right: 0; z-index: 2; display: flex; gap: 12px; padding: 16px; transition: opacity .3s var(--ease), translate .3s var(--ease); }
.osd--top { top: 0; align-items: center; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: 32px; background: linear-gradient(rgb(0 0 0 / .6), transparent); }
.osd--bottom { bottom: 0; align-items: flex-end; padding-top: 64px; padding-bottom: max(20px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgb(0 0 0 / .7)); }
/* the display's empty areas let taps through to the picture; only its controls take them */
.osd, .meta, .tags, .acts, .osd__acts { pointer-events: none; }
.osd button, .osd a, .progress { pointer-events: auto; }
.idle .osd { opacity: 0; }
.idle .osd--top { translate: 0 -8px; }
.idle .osd--bottom { translate: 0 8px; }
.idle .osd * { pointer-events: none; }
.idle .stage { cursor: none; }
.osd__acts { margin-left: auto; display: flex; gap: 8px; }

.chan { display: flex; align-items: center; gap: 12px; height: 36px; min-width: 0; text-shadow: 0 1px 2px rgb(0 0 0 / .6); }
.chan__n { flex: none; white-space: nowrap; font: 900 32px/1 var(--panel); color: var(--accent); font-variant-numeric: tabular-nums; }
#save-ch { flex: none; }
.chan__name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan__down { display: none; color: var(--text2); }

.ib { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: rgb(20 20 21 / .72); border: 1px solid var(--line); color: var(--text); transition: background-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease); }
.ib:hover { background: var(--raised); }
.ib:active { transform: scale(.97); }
.ib--flat { background: none; border-color: transparent; color: var(--text2); }
.ib[aria-pressed=true] { background: var(--text); color: var(--bg); }
.ib--keep[aria-pressed=true] { background: rgb(20 20 21 / .72); color: var(--accent); }
.ib--keep .icon { transition: fill .2s var(--ease); }
.ib--keep[aria-pressed=true] .icon { fill: currentColor; }

.meta { flex: 1; min-width: 0; display: grid; gap: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; max-height: 60px; overflow: hidden; }
/* one chip everywhere: no sign is unused, + is included, − is excluded */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 8px; border-radius: 6px; background: rgb(20 20 21 / .72); border: 1px solid var(--line); font-size: 13px; color: var(--text); white-space: nowrap; transition: background-color .15s var(--ease), transform .15s var(--ease); }
.tag:hover { background: var(--raised); }
.tag:active { transform: scale(.97); }
.tag__sign { font: 500 13px/1 var(--mono); }
.tag__sign:empty { display: none; }
.tag[data-state] { background: var(--raised); }
.tag[data-state]:hover { background: var(--raised-hi); }
.tag:focus-visible { outline-offset: -2px; } /* inside the chip: the rows around it clip anything outside */
.tag[data-state=in] .tag__sign { color: var(--accent); }
.tag[data-state=out] .tag__sign { color: #f07a7d; }
.tag[data-state=out] .tag__name { color: var(--muted); text-decoration: line-through; }
.tag__count { font: 12px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.tag--more { background: none; border-color: rgb(237 237 237 / .24); text-shadow: 0 1px 2px rgb(0 0 0 / .6); } /* an action, not a tag: outlined, not filled */
/* a chip that just arrived grows in; one that changed state stamps its new sign */
.tag--enter { animation: chip-in .3s var(--ease) both; }
.tag--flip .tag__sign { animation: sign-in .35s var(--ease); }
@keyframes chip-in { from { opacity: 0; scale: .86; } }
@keyframes sign-in { from { opacity: 0; scale: 1.8; } }
.meta__line { font: 12px/16px var(--mono); color: var(--text2); font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgb(0 0 0 / .6); }
.acts { display: flex; gap: 8px; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 12px; cursor: pointer; display: flex; align-items: flex-end; }
.progress::before { content: ''; position: absolute; inset: auto 0 0; height: 2px; background: rgb(237 237 237 / .16); }
.progress i { position: relative; display: block; width: 100%; height: 2px; background: var(--text); transform: scaleX(0); transform-origin: left; transition: height .15s var(--ease); }
.progress { touch-action: none; }
.progress::before { transition: height .15s var(--ease); }
/* held: the bar thickens under the finger and the time shows above it */
.progress.held::before, .progress.held i { height: 6px; }
.progress__time { position: absolute; bottom: 16px; translate: -50% 0; padding: 2px 6px; border-radius: 4px; background: rgb(20 20 21 / .86); font: 12px/16px var(--mono); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s var(--ease); }
.progress.held .progress__time { opacity: 1; }

/* zoomed in: the picture may spill past its frame, the feed holds still, and the controls step aside */
.zoomed .reel { overflow: hidden; touch-action: none; }
.zoomed .frame { overflow: visible; z-index: 1; }
.zoomed .frame::before { opacity: 0; }
.zoomed .osd { opacity: 0; }
.zoomed .osd * { pointer-events: none; }

.ib[aria-busy=true] { opacity: .5; } /* still takes the tap, which does nothing, rather than letting it through to the post */

/* holding a post opens this app's menu, not the browser's own image menu */
.reel { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* a message with one optional action, above the controls */
/* under the channel bar, the one strip of screen that's always clear */
.toast { position: fixed; left: 50%; top: max(72px, calc(env(safe-area-inset-top) + 64px)); z-index: 40; translate: -50% 0; display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px); min-height: 44px; padding: 0 8px 0 16px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); box-shadow: 0 8px 24px rgb(0 0 0 / .4); font: 900 16px/1.25 var(--panel); word-spacing: -.3em; animation: toast-in .32s var(--ease); } /* front-panel dots, like the channel number */
@keyframes toast-in { from { opacity: 0; translate: -50% -8px; } } /* keeps the centring that `rise` would overwrite */
.toast span { padding: 12px 0; } /* every dot letter is a full cell wide, so longer messages wrap rather than get cut off */
.toast button { flex: none; height: 32px; padding: 0 10px; border-radius: 8px; color: var(--accent); transition: background-color .15s var(--ease); }
.toast button:hover { background: rgb(237 237 237 / .06); }
.toast:has(button[hidden]) { padding-right: 16px; }

/* first visit: how to drive it, once */
.hints { position: absolute; left: 50%; top: 50%; z-index: 3; translate: -50% -50%; display: grid; gap: 8px; padding: 16px 20px; border-radius: 16px; background: rgb(20 20 21 / .94); border: 1px solid var(--line); pointer-events: none; font: 900 16px/1.25 var(--panel); word-spacing: -.3em; animation: hints-in .5s var(--ease) both; }
@keyframes hints-in { from { opacity: 0; translate: -50% calc(-50% + 12px); } }
.hints p { display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--text2); white-space: nowrap; }
.hints b { font-weight: inherit; color: var(--text); }
.hints kbd { margin: 0; font: inherit; line-height: 1.5; color: var(--text); }

/* the post menu: a sheet from the bottom on a phone, a small panel elsewhere */
#post-menu { width: min(400px, calc(100vw - 32px)); padding: 0; }
.pm { padding: 20px; }
.pm__meta { font: 12px/16px var(--mono); color: var(--muted); }
.pm__acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.pm__act { display: grid; justify-items: center; gap: 6px; padding: 12px 4px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); color: var(--text); font-size: 13px; text-decoration: none; transition: background-color .15s var(--ease), transform .15s var(--ease); }
.pm__act:hover { background: var(--raised-hi); }
.pm__act:active { transform: scale(.97); }
.pm__act.on { color: var(--accent); }
.pm__act.on .icon { fill: currentColor; }
#post-menu .label { margin: 20px 0 8px; }
#post-menu .suggest { margin-bottom: 8px; max-height: 176px; }
#post-menu .hint { padding: 0; }

/* double-tap to keep: the mark lands where you tapped and lifts away */
.burst { position: fixed; z-index: 30; width: 88px; height: 88px; margin: -44px 0 0 -44px; fill: var(--accent); pointer-events: none; filter: drop-shadow(0 6px 20px rgb(0 0 0 / .5)); animation: burst .8s var(--ease) forwards; }
@keyframes burst {
  0% { opacity: 0; scale: .3; }
  22% { opacity: 1; scale: 1.08; }
  40% { opacity: 1; scale: 1; translate: 0 0; }
  100% { opacity: 0; scale: .9; translate: 0 -48px; }
}

/* contact sheet: frames keep their shape and carry a frame number, like a strip of negatives */
.sheet { position: absolute; inset: 0; z-index: 1; overflow-y: auto; padding: 80px 16px 16px; background: var(--bg); display: none; }
.sheet-on .sheet { display: block; }
.sheet-on .osd--top { background: var(--bg); border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.sheet-on .osd--bottom { display: none; }
.sheet-on.idle .osd { opacity: 1; translate: none; }
.sheet-on.idle .osd button { pointer-events: auto; }
.sheet-on.idle .stage { cursor: auto; }
.sheet__grid { --row: 176px; display: flex; flex-wrap: wrap; gap: 16px 8px; }
.sheet__grid::after { content: ''; flex-grow: 999; }
.thumb { flex: var(--r) 1 calc(var(--r) * var(--row)); min-width: 0; display: grid; gap: 4px; text-align: left; }
.thumb img { width: 100%; height: var(--row); object-fit: cover; display: block; border-radius: 6px; background: var(--card); transition: opacity .15s var(--ease); }
.thumb:hover img { opacity: .8; }
.thumb[aria-current] img { outline: 2px solid var(--text); outline-offset: 2px; }
.thumb__cap { display: flex; justify-content: space-between; gap: 8px; padding: 0 2px; font: 12px/16px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.thumb__cap span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* on a narrow frame the number stays and the kind gives way */
.thumb[aria-current] .thumb__cap { color: var(--text); }

/* the morph between a post and its frame */
::view-transition-group(hero) { animation-duration: .5s; animation-timing-function: var(--ease); }
::view-transition-old(hero), ::view-transition-new(hero) { height: 100%; object-fit: cover; animation-duration: .3s; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }

/* notice */
.notice { position: absolute; inset: 0; z-index: 4; display: grid; align-content: center; justify-items: start; gap: 8px; padding: 24px; max-width: 408px; margin: auto; animation: rise .5s var(--ease) both; }
/* the notice is a full-height layer: touches pass through to the swipe surface and the top bar, except on its own buttons */
.notice { pointer-events: none; }
.notice button { pointer-events: auto; }
.notice h2 { margin: 0; }
.notice p { color: var(--text2); }
.notice__acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* controls */
.btn { display: inline-grid; place-items: center; height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 500; white-space: nowrap; text-decoration: none; transition: background-color .15s var(--ease), transform .15s var(--ease); }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--text); color: var(--bg); }
.btn--primary:hover { background: #fff; }
.btn--plain { background: var(--raised); border: 1px solid var(--line); color: var(--text); }
.btn--plain:hover { background: var(--raised-hi); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }

input:not([type=checkbox]), select { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); min-width: 0; transition: border-color .15s var(--ease); }
input:not([type=checkbox]):focus-visible, select:focus-visible { outline-width: 1px; outline-offset: 0; }
input::placeholder { color: var(--muted); }
input[type=checkbox] { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--text); } /* never squeezed by a long label */

dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .64); }
dialog[open] { animation: rise .32s var(--ease); }
dialog[open]::backdrop { animation: fade .32s var(--ease); }
/* and back out again, where the browser can keep a closing dialog on screen */
@supports (overlay: auto) {
  dialog, dialog::backdrop { transition: opacity .2s var(--ease), translate .2s var(--ease), overlay .2s allow-discrete, display .2s allow-discrete; }
  dialog:not([open]), dialog:not([open])::backdrop { opacity: 0; }
  dialog:not([open]) { translate: 0 8px; }
  #gate, #gate::backdrop { transition-duration: .6s; }
  #gate:not([open]) { translate: none; }
}
dialog p { color: var(--text2); }
dialog .label { margin: 24px 0 8px; }
.field { display: grid; gap: 8px; margin-bottom: 16px; color: var(--text2); font-size: 13px; }
.field input, .field select { color: var(--text); font-size: 14px; }
.field em, .row em { display: block; font-style: normal; color: var(--muted); font-size: 12px; line-height: 16px; }
.field > span { display: flex; justify-content: space-between; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; border-top: 1px solid var(--line); }
#settings .label { margin-top: 20px; }
#settings .field { margin-bottom: 0; }
.row input:not([type=checkbox]), .row select { width: 168px; height: 36px; }
.row + .field { padding-top: 12px; border-top: 1px solid var(--line); }
.row__btns { display: flex; gap: 8px; }
.hint { padding: 8px 0 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.hint a { color: var(--text2); }
.dialog__acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.field .hint { padding: 0; }
.tokens { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 40px; padding: 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); cursor: text; }
.tokens:focus-within { outline: 1px solid rgb(237 237 237 / .7); }
.tokens__chips { display: contents; }
.tokens .tag { background: var(--card); }
.tokens .tag:hover { background: var(--bg); }
.tokens input:not([type=checkbox]) { flex: 1; min-width: 96px; height: 28px; padding: 0 8px; border: 0; background: none; }
.tokens input:not([type=checkbox]):focus-visible { outline: 0; }
dialog .label:has(+ .suggest) { margin-top: 0; }
.suggest { display: flex; flex-wrap: wrap; gap: 4px; max-height: 136px; overflow-y: auto; margin-bottom: 16px; }
.suggest:empty { display: none; }
.textbtn { display: block; margin: -4px 0 16px; font-size: 13px; color: var(--text2); text-decoration: underline; text-underline-offset: 3px; transition: color .15s var(--ease); }
.textbtn:hover { color: var(--text); }

/* the gate is the station ident: a dark screen and the number */
#gate { width: 100vw; max-width: none; height: 100dvh; max-height: none; padding: 24px; border: 0; border-radius: 0; background: #000; }
#gate[open] { display: grid; place-items: center; animation: none; }
#gate[open]::backdrop { animation: none; }
#gate::backdrop { background: #000; }
.gate__in { width: min(400px, 100%); }
.gate__no { margin: 0 0 32px -8px; font: 900 clamp(160px, 44vw, 240px)/.8 var(--panel); color: var(--accent); }
#gate .dialog__acts { justify-content: flex-start; }
#gate h2 { font: 900 24px/1.2 var(--panel); word-spacing: -.3em; } /* the gate's title in the same dots as the 34 above it */

/* standby: the tube collapses to a line, then a dot, and only the LED stays lit */
.standby { position: fixed; inset: 0; z-index: 100; cursor: none; }
.standby.dark { background: #000; }
.standby span { position: absolute; right: calc(36px + env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); font: 12px/16px var(--mono); color: #4a4a4f; animation: fade .6s var(--ease) .5s both; }
.standby i { position: absolute; right: calc(20px + env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 5px); width: 6px; height: 6px; border-radius: 50%; background: var(--led); animation: fade .4s var(--ease) .3s both; }
.off .app { animation: crt-off .36s cubic-bezier(.5, 0, .9, .3) forwards; }
.off .ambient { opacity: 0; }
.on .app { animation: crt-on .5s var(--ease); }
@keyframes crt-off {
  55% { transform: scale(1, .004); filter: brightness(6); }
  100% { transform: scale(0, .004); filter: brightness(10); opacity: 0; }
}
@keyframes crt-on {
  0% { transform: scale(1, .004); filter: brightness(6); opacity: 0; }
  30% { opacity: 1; }
}

/* phone, upright or on its side (big phones are wider than 859px in landscape but still short) */
@media (max-width: 859px), (max-height: 500px) and (orientation: landscape) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .guide { position: fixed; inset: auto 0 0; z-index: 20; max-height: 76dvh; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--bg0); border-right: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; transform: translateY(100%); visibility: hidden; transition: transform .45s var(--ease), visibility 0s .45s; }
  .guide-open .guide { transform: none; visibility: visible; transition-delay: 0s; }
  .guide .guide__close { display: grid; }
  .guide__grab { display: block; position: absolute; top: 6px; left: 50%; translate: -50% 0; width: 36px; height: 4px; border-radius: 2px; background: rgb(237 237 237 / .2); }
  .guide__head, .guide__grab { touch-action: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 19; background: rgb(0 0 0 / .64); opacity: 0; pointer-events: none; transition: opacity .35s var(--ease); }
  .guide-open .scrim { opacity: 1; pointer-events: auto; }
  .ch { height: 44px; }
  .guide__list .ch { height: 52px; }
  .ch__x { opacity: 1; right: 2px; top: 50%; translate: 0 -50%; width: 44px; height: 44px; background: none; color: var(--text2); }
  .guide__list .ch { padding-right: 48px; } /* every row keeps the delete button's room, so the pictures line up */
  .guide kbd { display: none; }
  .chan { height: 44px; }
  .toast button { height: 44px; }
  .btn--sm { position: relative; }
  .btn--sm::after { content: ''; position: absolute; inset: -6px 0; } /* a 44px target around a 32px button */
  .chan__down { display: block; margin-left: -4px; }
  .ib { width: 44px; height: 44px; border-radius: 12px; }
  .tag { height: 32px; }
  .tags { max-height: 68px; }
  .acts { flex-direction: column; }
  /* a thumb-sized strip to scrub along, above the home bar: dragging sideways along the bar switches apps on an iPhone */
  .osd--bottom { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
  .progress { bottom: env(safe-area-inset-bottom); height: 24px; }
  .sheet { padding: calc(max(16px, env(safe-area-inset-top)) + 68px) 8px max(8px, env(safe-area-inset-bottom)); } /* clear of the top bar, notch included */
  .sheet__grid { --row: 112px; gap: 12px 8px; } /* room between captions, so "strip" and the next frame's number don't run together */
  .pm::before { content: ''; display: block; width: 36px; height: 4px; margin: -8px auto 12px; border-radius: 2px; background: rgb(237 237 237 / .2); } /* reads as a sheet you can put away */
  #post-menu { width: 100vw; max-width: none; margin: auto 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; }
  #post-menu[open] { animation: sheet-up .4s var(--ease); }
  .pm { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  @keyframes sheet-up { from { translate: 0 100%; } }
}

/* a phone on its side: one row of controls, the guide as a side panel, clear of the notch */
@media (max-height: 500px) and (orientation: landscape) {
  .osd { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .osd--top { padding-top: 8px; padding-bottom: 24px; }
  .osd--bottom { padding-top: 40px; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
  .acts { flex-direction: row; }
  .tags { max-height: 32px; }
  .guide { inset: 0 auto 0 0; width: min(340px, 60vw); max-height: none; border-top: 0; border-right: 1px solid var(--line); border-radius: 0 16px 16px 0; padding-left: max(8px, env(safe-area-inset-left)); transform: translateX(-100%); }
  .guide__grab { display: none; }
  .toast { top: 56px; }
  .hints { gap: 4px; padding: 12px 16px; }
  .sheet { padding: 76px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)); }
  #post-menu { margin: auto; width: min(480px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 16px; }
  #post-menu[open] { animation: rise .32s var(--ease); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop { animation: none !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .off .app { opacity: 0; }
}
