:root {
  color-scheme: light dark;
  --bg: #eceef2;
  --bg-2: #f7f8fa;
  --surface: #ffffff;
  --line: #d7dae1;
  --text: #191b20;
  --muted: #5d6370;
  --accent: #e2860b;
  --accent-text: #ffffff;
  --accent-soft: #fdf0dc;
  --danger: #c8323a;
  --device: #1b1c20;
  --device-edge: #2c2e34;
  --device-text: #9aa0ab;
  --focus: #2f7bf6;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 24px rgb(0 0 0 / 8%);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1013;
    --bg-2: #15171b;
    --surface: #1a1c21;
    --line: #2c2f36;
    --text: #e8eaee;
    --muted: #9aa0ab;
    --accent: #f5a524;
    --accent-text: #1a1206;
    --accent-soft: #2b2112;
    --danger: #f0616a;
    --device: #08090b;
    --device-edge: #22242a;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 10px 30px rgb(0 0 0 / 35%);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1013;
  --bg-2: #15171b;
  --surface: #1a1c21;
  --line: #2c2f36;
  --text: #e8eaee;
  --muted: #9aa0ab;
  --accent: #f5a524;
  --accent-text: #1a1206;
  --accent-soft: #2b2112;
  --danger: #f0616a;
  --device: #08090b;
  --device-edge: #22242a;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 10px 30px rgb(0 0 0 / 35%);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

code, kbd, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0 0.4em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-2);
  text-align: center;
}

/* Header */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 57px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: 0.01em; }
.brand-word { height: 30px; width: 159px; color: var(--text); flex: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }

.segmented {
  display: inline-flex;
  margin: 0 0 0 auto;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.segmented button {
  padding: 6px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
}

.segmented button small { font-weight: 400; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--surface); box-shadow: var(--shadow); }

.top-actions { display: flex; gap: 6px; }

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
}

.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.icon-button svg path:first-child { fill: currentColor; stroke: none; }
#screenshot svg path:first-child, #fullscreen svg path:first-child { fill: none; stroke: currentColor; }
#sound .cross { display: inline; }
#sound .wave { display: none; }
#sound[aria-pressed="true"] .cross { display: none; }
#sound[aria-pressed="true"] .wave { display: inline; }
#sound[aria-pressed="false"] { color: var(--accent); border-color: var(--accent); }

/* The clock */

.device {
  width: 100%;
  max-width: 900px;
  padding: 18px 18px 12px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--device-edge), var(--device) 40%);
  box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / 6%);
}

.device[data-board="tc001"] { max-width: 760px; }

.bezel {
  padding: 14px;
  border-radius: 12px;
  background: #020203;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 4%), inset 0 6px 18px rgb(0 0 0 / 80%);
}

.screen { position: relative; width: 100%; display: grid; place-items: center; }
.screen canvas { display: block; max-width: 100%; image-rendering: auto; border-radius: 4px; }

.screen-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--device-text);
  font-size: 0.95rem;
  text-align: center;
  background: rgb(0 0 0 / 70%);
  border-radius: 4px;
}

.hardware {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 6px 2px;
}

.clock-buttons, .knob { display: flex; align-items: center; gap: 10px; }
.device[data-board="tc001"] .knob { display: none; }
.device[data-board="tc001"] .hardware { justify-content: center; }

.hw-button, .knob-turn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 30px;
  border: 1px solid #34363d;
  border-radius: 8px;
  background: linear-gradient(#2a2c32, #1c1d22);
  color: var(--device-text);
  cursor: pointer;
  touch-action: manipulation;
}

.hw-button svg, .knob-turn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; }
.hw-button.select svg { fill: currentColor; stroke: none; }
.hw-button:active, .hw-button.down, .knob-turn:active { background: #15161a; color: var(--accent); }

.knob-press {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #3a3c43;
  background: radial-gradient(circle at 35% 30%, #4a4d55, #1d1e23 70%);
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.knob-press span { width: 3px; height: 12px; border-radius: 2px; background: var(--device-text);
  transform: translateY(-8px); transition: transform 0.15s; }
.knob-press.down { filter: brightness(0.75); }

.now { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; justify-content: center; color: var(--muted); }
.now strong { color: var(--text); }
.now-label { text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.08em; }

.alert {
  width: 100%;
  max-width: 900px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--text);
  white-space: pre-wrap;
}

.alert b { color: var(--danger); }

/* Touch gamepad */

.touchpad {
  width: 100%;
  max-width: 620px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.touchpad button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  font-weight: 650;
  touch-action: none;
}

.touchpad button.down { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.tp-shoulders { display: flex; justify-content: space-between; margin-bottom: 8px; }
.tp-shoulders button { width: 30%; height: 38px; }
.tp-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }

.tp-dpad, .tp-face { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); gap: 4px; }
.tp-dpad button::before { content: ""; display: block; margin: auto; width: 0; height: 0;
  border: 8px solid transparent; }
.tp-dpad [data-dir="up"]::before { border-bottom-color: currentColor; margin-top: 4px; }
.tp-dpad [data-dir="down"]::before { border-top-color: currentColor; margin-bottom: 4px; }
.tp-dpad [data-dir="left"]::before { border-right-color: currentColor; margin-left: 4px; }
.tp-dpad [data-dir="right"]::before { border-left-color: currentColor; margin-right: 4px; }
.tp-dpad [data-dir="up"] { grid-area: 1 / 2; }
.tp-dpad [data-dir="left"] { grid-area: 2 / 1; }
.tp-dpad [data-dir="right"] { grid-area: 2 / 3; }
.tp-dpad [data-dir="down"] { grid-area: 3 / 2; }
.tp-face { justify-self: end; }
.tp-face button { border-radius: 50%; }
.tp-face [data-pad="Y"] { grid-area: 1 / 2; }
.tp-face [data-pad="X"] { grid-area: 2 / 1; }
.tp-face [data-pad="B"] { grid-area: 2 / 3; }
.tp-face [data-pad="A"] { grid-area: 3 / 2; }
.tp-middle { display: flex; flex-direction: column; gap: 8px; }
.tp-middle button { font-size: 0.7rem; padding: 8px 10px; }

.hint { margin: 6px 0 10px; color: var(--muted); font-size: 0.88rem; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.two > label { flex: 1; }
.row > label.button { display: inline-flex; margin: 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-2);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

.button:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.danger { color: var(--danger); }
.button.small { padding: 4px 9px; font-size: 0.85rem; }

label { display: block; margin: 10px 0; font-weight: 550; font-size: 0.92rem; }

input:not([type="checkbox"], [type="range"], [type="file"], [type="color"]), select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  font-weight: 400;
}

textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
output { float: right; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

/* Games */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
}

.card img { width: 96px; height: 60px; object-fit: cover; border-radius: 6px; background: #000; image-rendering: pixelated; }
.card h3 { margin: 0; font-size: 1rem; }
.card p { margin: 2px 0 8px; color: var(--muted); font-size: 0.85rem; }
.badge { display: inline-block; padding: 0 6px; border-radius: 5px; background: var(--accent-soft); font-size: 0.75rem; font-weight: 650; }

.drop {
  padding: 16px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  text-align: center;
}

.drop p { margin: 0 0 10px; color: var(--muted); }
.drop .row { justify-content: center; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

/* Apps */

.apps { list-style: none; margin: 0; padding: 0; }

.apps li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.apps li .app-pick {
  flex: 1; min-width: 0; margin: -4px 0 -4px -8px; padding: 4px 8px; border-radius: 8px;
  color: inherit; text-decoration: none;
}
.apps li .app-pick:hover { background: var(--bg-2); }
.apps li.picked .app-pick { background: var(--accent-soft); }
.apps li .app-name { min-width: 0; }
.apps li .app-name small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apps li.current .app-name strong::before { content: "● "; color: var(--accent); }
.apps li .err { color: var(--danger); }

/* Files */

.files { margin-top: 6px; }
.files h3 { margin: 12px 0 2px; font-size: 0.85rem; }
.files ul { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.files li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files li small { color: var(--muted); }

/* API console */

.request select { width: auto; flex: none; }
.request input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.request input, .request select { margin-top: 0; }

/* Clock settings */

.days { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.config .row label.check { margin: 0; }

/* Colors: a round swatch and its hex value in a pill, the switch for a color of its own beside. */
.color-field { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.color-field label.check { margin: 0; font-weight: 500; }
.swatch {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2);
}
.swatch input[type="color"] {
  -webkit-appearance: none; appearance: none; display: block; flex: none;
  width: 28px; height: 28px; padding: 0; margin: 0;
  border: 0; border-radius: 50%; background: none; cursor: pointer;
}
.swatch input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.swatch input[type="color"]::-webkit-color-swatch { border: 1px solid rgb(127 127 127 / 35%); border-radius: 50%; }
.swatch input[type="color"]::-moz-color-swatch { border: 1px solid rgb(127 127 127 / 35%); border-radius: 50%; }
.swatch code { min-width: 4.6em; font-size: 0.85rem; font-weight: 500; color: var(--text); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Unset: a crossed-out circle in place of the color. */
.swatch.off input[type="color"] { display: none; }
.swatch.off::before {
  content: ""; flex: none; width: 28px; height: 28px; box-sizing: border-box; border-radius: 50%;
  border: 1.5px dashed var(--muted);
  background: linear-gradient(135deg, transparent 45%, var(--muted) 45% 55%, transparent 55%);
  opacity: 0.7;
}
.swatch.off code { color: var(--muted); }
.config label.check { flex-wrap: wrap; }
.config label.check > .hint { flex-basis: 100%; margin: 0 0 0 46px; }
.config label > .hint { display: block; margin: 2px 0 0; font-weight: 400; }
.days label.check { margin: 0; font-weight: 500; }

/* Controls and log */

.keys { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.keys th { text-align: left; padding: 12px 0 4px; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.keys td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.keys td:last-child { text-align: right; }

.log {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  -webkit-user-select: text;
  user-select: text;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-2);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  z-index: 10;
}

/* Script sign-in */

.signin { margin: 4px 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); }
.signin h3 { margin: 0 0 4px; font-size: 0.95rem; }
.signin code { word-break: break-all; }
.config-group { margin: 18px 0 2px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.config-group:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.callback { max-width: 520px; margin: 15vh auto; padding: 0 16px; text-align: center; }

/* The phone page's code in Controls. */
.phone-code { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-top: 8px; }
.phone-code > div:last-child { flex: 1; min-width: 200px; }
.qr { width: 176px; height: 176px; padding: 8px; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.qr svg { display: block; width: 100%; height: 100%; }
#phones li button { flex: none; }

/* ---- The app: sections in a rail, the clock on top, pages of cards ------------------------- */

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.mobile-only { display: none; }
.page-title { margin: 0; font-size: 1.1rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.rail .brand { padding: 6px 8px 2px; }

.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 9px;
  color: var(--text); text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--bg-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); }
.nav a[aria-current="page"] svg { color: var(--accent); }
.nav svg, .tabbar svg, .find svg {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.nav svg { color: var(--muted); }
.rail .about { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; }
.rail .about p { margin: 4px 0; }

/* Find a setting. */
.find { position: relative; }
.find svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.find input { margin: 0; padding-left: 34px; border-radius: 9px; }
.find-results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 340px; overflow-y: auto;
}
.find-results button {
  display: block; width: 100%; padding: 7px 9px; border: 0; border-radius: 7px;
  background: none; text-align: left; cursor: pointer;
}
.find-results button:hover, .find-results button:focus-visible { background: var(--accent-soft); }
.find-results small { display: block; color: var(--muted); }
.find-results .none { padding: 7px 9px; color: var(--muted); font-size: 0.9rem; }
.found { animation: found 1.6s ease-out; border-radius: 8px; }
@keyframes found { 0%, 40% { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); } 100% { background: transparent; box-shadow: none; } }

/* The clock: large on Play; compact and pinned under the header elsewhere. */
.stage { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px 24px 4px; min-width: 0; }
.stage-side { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; max-width: 900px; min-width: 0; }
.stage.compact {
  position: sticky; top: 57px; z-index: 4;
  flex-direction: row; justify-content: center; gap: 18px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
}
.stage.compact .device { max-width: 470px; padding: 9px 9px 7px; border-radius: 15px; }
.stage.compact .device[data-board="tc001"] { max-width: 400px; }
.stage.compact .bezel { padding: 6px; border-radius: 8px; }
.stage.compact .hardware { padding: 7px 2px 0; }
.stage.compact .hw-button, .stage.compact .knob-turn { width: 36px; height: 24px; }
.stage.compact .knob-press { width: 32px; height: 32px; }
.stage.compact .stage-side { align-items: flex-start; width: auto; max-width: 300px; }
.stage.compact .now { justify-content: flex-start; }
.stage.compact .touchpad { display: none !important; }

/* Pages: a grid of cards. */
.pages { padding: 18px 24px 56px; }
/* Cards flow down two columns (one where there is no room), so short ones leave no holes. */
.page { columns: 2 340px; column-gap: 16px; max-width: 1180px; margin: 0 auto; }
.page > .box, .boxes > .box { break-inside: avoid; margin: 0 0 16px; }
.page > .wide, .page > .page-hint, .page > .boxes { column-span: all; }
.page > .page-hint { margin: 0 0 14px; }
.page.split { columns: auto; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.page.split > .box { margin: 0; }
.page-hint { color: var(--muted); }
.boxes { columns: 2 340px; column-gap: 16px; }
.box {
  min-width: 0; padding: 16px 18px 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.box h2 { margin: 0 0 6px; font-size: 1rem; font-weight: 650; }
.box > .hint:first-of-type { margin-top: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.log.tall { max-height: 70vh; min-height: 320px; }
.config > label:first-child, .config > .signin:first-child { margin-top: 4px; }

/* On and off as switches (the weekday pickers stay check boxes). */
label.check > input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none; width: 38px; height: 22px; margin: 0;
  border-radius: 999px; background: var(--line); cursor: pointer; transition: background 0.15s;
}
label.check > input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 30%); transition: transform 0.15s;
}
label.check > input[type="checkbox"]:checked { background: var(--accent); }
label.check > input[type="checkbox"]:checked::after { transform: translateX(16px); }
.days label.check > input[type="checkbox"] { appearance: auto; -webkit-appearance: checkbox; width: 16px; height: 16px; background: none; }
.days label.check > input[type="checkbox"]::after { content: none; }

/* Full screen: only the clock. */
body.fullscreen .rail, body.fullscreen .top, body.fullscreen .pages, body.fullscreen .tabbar,
body.fullscreen .stage-side, body.fullscreen .sheet { display: none !important; }
body.fullscreen .app { grid-template-columns: 1fr; }
body.fullscreen .stage, body.fullscreen .stage.compact {
  position: static; min-height: 100vh; justify-content: center; border: 0; background: var(--bg); flex-direction: column;
}
body.fullscreen .device, body.fullscreen .stage.compact .device { max-width: none; }

/* Phones and narrow windows: the sections move to a bar at the bottom. */
.tabbar, .sheet { display: none; }
@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .mobile-only { display: flex; }
  .top { gap: 10px; padding: 8px 16px; }
  .page-title { flex: 1; min-width: 0; }
  .segmented { margin: 0; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 2px 7px; border: 0; background: none; color: var(--muted);
    font-size: 0.72rem; font-weight: 600; text-decoration: none; cursor: pointer;
  }
  .tabbar [aria-current="page"], .tabbar #more[aria-expanded="true"], .tabbar #more.current { color: var(--accent); }
  .sheet { display: block; position: fixed; inset: 0; z-index: 8; background: rgb(0 0 0 / 35%); }
  .sheet-panel {
    position: absolute; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom));
    display: grid; gap: 4px; padding: 12px 16px 16px;
    border-radius: 16px 16px 0 0; background: var(--surface); box-shadow: var(--shadow);
  }
  .sheet-panel > a { padding: 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; }
  .sheet-panel > a[aria-current="page"] { background: var(--accent-soft); }
  .sheet-panel .find { margin-top: 6px; }
  .sheet-panel .find input { padding-left: 12px; }
  .sheet-panel .find-results { top: auto; bottom: calc(100% + 4px); }
  .stage { padding: 12px 16px 4px; }
  .stage.compact { padding: 8px 16px; gap: 12px; top: 53px; }
  .pages { padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); }
  .page.split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 599px) {
  .page, .boxes { columns: 1; }
  /* The page's name above its cards: the header has no room for it. */
  .page-title { display: none; }
  .pages::before { content: attr(data-title); display: block; margin: 2px 0 12px; font-size: 1.25rem; font-weight: 650; }
  .top { justify-content: space-between; }
  .stage.compact .hardware { display: none; }
  .stage.compact .bezel { padding: 5px; }
  .stage.compact .device { padding: 7px; border-radius: 12px; }
  .segmented button { padding: 6px 10px; }
  .segmented button small { display: none; }
  .top-actions { gap: 4px; }
  .icon-button { width: 34px; height: 34px; }
  .device { padding: 10px 10px 8px; border-radius: 16px; }
  .bezel { padding: 8px; }
  .stage.compact { flex-direction: column; align-items: stretch; }
  .stage.compact .device { max-width: none; }
  .stage.compact .stage-side { max-width: none; }
  .stage.compact .now { font-size: 0.85rem; }
  .box { padding: 14px 14px 16px; }
  .tp-main { gap: 6px; }
  .tp-dpad, .tp-face { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); gap: 3px; }
  .tp-middle button { padding: 6px 6px; font-size: 0.65rem; }
}
