* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { font-size: var(--base-size); }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.45;
  overflow: hidden;
  transition: background 0.6s ease, color 0.6s ease;
}
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--sig); color: var(--bg); }

.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr) var(--tick-h);
  grid-template-areas: "top top" "rail main" "tick tick";
  height: 100vh;
}
[data-view="tv"] .app { padding: 2.5vh 2.5vw; height: 100vh; }

/* Top bar */
.top {
  grid-area: top;
  display: flex; align-items: center; gap: 1.6rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  white-space: nowrap; overflow: hidden;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand b { font-family: var(--font-display); font-weight: 500; font-size: 1.35rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sig); }
.brand span { font-size: 0.72rem; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.readout { display: flex; flex-direction: column; line-height: 1.15; }
.readout label { font-size: 0.68rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; }
.readout span { font-size: 0.95rem; color: var(--ink); }
.top .spacer { flex: 1; }
.warp { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.warp button { background: none; border: 0; padding: 0.3rem 0.6rem; cursor: pointer; color: var(--ink-2); font-size: 0.8rem; border-right: 1px solid var(--line); }
.warp button:last-child { border-right: 0; }
.warp button.on { background: var(--sig); color: var(--bg); }

/* Left rail */
.rail {
  grid-area: rail;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  padding: 0.6rem 0;
  overflow-y: auto;
}
.rail .group { font-size: 0.66rem; color: var(--ink-3); letter-spacing: 0.14em; text-transform: uppercase; padding: 0.9rem 1rem 0.3rem; }
.tab {
  display: flex; align-items: center; gap: 0.7rem;
  background: none; border: 0; border-left: 2px solid transparent;
  padding: 0.42rem 1rem; text-align: left; cursor: pointer; color: var(--ink-2);
}
.tab code { font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.08em; color: var(--ink-3); width: 1.6rem; }
.tab:hover { color: var(--ink); background: var(--panel); }
.tab.on { color: var(--sig); border-left-color: var(--sig); background: var(--panel); }
.tab.on code { color: var(--sig); }
.tab.locked { opacity: 0.45; }
.tab .badge { margin-left: auto; font-size: 0.66rem; color: var(--bg); background: var(--alert); padding: 0 0.35rem; border-radius: var(--radius); }

/* Main */
.main { grid-area: main; overflow: auto; padding: 1rem; position: relative; }
.view { display: none; height: 100%; }
.view.on { display: block; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Bottom ticker */
.tick {
  grid-area: tick;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  display: flex; align-items: center; gap: 2rem;
  padding: 0 1rem; font-size: 0.78rem; color: var(--ink-3);
  overflow: hidden; white-space: nowrap;
}
.tick .entry b { color: var(--ink-2); font-weight: 400; margin-right: 0.5rem; }
.tick .entry.hot { color: var(--sig); }
.tick .entry.bad { color: var(--alert); }

/* Focus for TV D-pad and keyboard */
:focus-visible { outline: 2px solid var(--sig); outline-offset: 2px; }
[data-view="tv"] :focus { outline: 3px solid var(--sig); outline-offset: 3px; }
