/* Orbtile Away Web & TV Client Stylesheet.
 * Visual parity with Orbtile Phone App & Frosted Keypad:
 * - design/website/assets/tokens.css (dark & light brand tokens)
 * - Sources/OrbtileContracts/Palette.swift & Sources/OrbtilePhoneRender/DetailTile.swift (grid tiles)
 * - apps/ios/OrbtilePhonePad/StagePresentation.swift, StageLayout.swift, NativeFocusView.swift (Stage)
 * - apps/android/app/src/main/java/com/orbtile/phonepad/NativeStageFocus.kt & OrbtileTheme.kt
 */

@font-face {
  font-family: 'Google Sans Flex';
  src: url('/fonts/GoogleSansFlex-latin.woff2') format('woff2');
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Google Sans Code';
  src: url('/fonts/GoogleSansCode-latin.woff2') format('woff2');
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ot-well: #0b0908;
  --ot-bg: #080706;
  --ot-surface: #17130f;
  --ot-surface-2: #211b16;
  --ot-surface-3: #2a231c;
  --ot-tile: #141210;
  --ot-tile-border: rgba(255, 236, 210, 0.08);
  --ot-tile-text: #f2e8dc;
  --ot-hair: #2a2420;
  --ot-hair-strong: #3a322b;
  --ot-tile-edge: #46392e;
  --ot-text: #f2e8dc;
  --ot-text-2: #b9aa94;
  --ot-text-dim: #9c8f80;
  --ot-text-faint: #6b6055;
  --ot-gold: #d9a441;
  --ot-gold-hi: #f0c46a;
  --ot-gold-text: #e2b153;
  --ot-terra-text: #ec8455;
  --ot-on-accent: #1c1208;

  /* Stage tokens (StagePresentation.swift & NativeStageFocus.kt) */
  --ot-allow: #2eb85c;
  --ot-deny: #e5695a;
  --ot-error-text: #e06a58;
  --ot-stage-card-bg: #17130f;
  --ot-stage-card-border: #362922;
  --ot-stage-opt-bg: #211b16;
  --ot-stage-opt-picked: #2a231c;
  --ot-stage-opt-border: #3c2d24;
  --ot-stage-badge-bg: #1b1512;
  --ot-stage-badge-border: #5a4434;
  --ot-stage-key-bg: #211b16;
  --ot-stage-key-title: #f2e8dc;
  --ot-stage-key-hint: #a39482;
  --ot-stage-hero-border: #352821;
  --ot-stage-rail-bg: rgba(224, 122, 74, 0.12);
  --ot-stage-rail-border: #593a26;
  --ot-stage-rail-count: #ffd6b1;
  --ot-stage-rail-next: #a8836a;

  /* Orbtile state colours */
  --ot-state-permission-core: #d9693e;
  --ot-state-permission-label: #f08a5a;
  --ot-state-question-core: #e0703f;
  --ot-state-question-label: #f29a5e;
  --ot-state-error-core: #9e2a22;
  --ot-state-error-label: #e5695a;
  --ot-state-tool-core: #dfa946;
  --ot-state-tool-label: #f0c46a;
  --ot-state-streaming-core: #e0b35a;
  --ot-state-streaming-label: #f0c46a;
  --ot-state-thinking-core: #d9a441;
  --ot-state-thinking-label: #e6b45a;
  --ot-state-compacting-core: #a8966e;
  --ot-state-compacting-label: #cbbd9f;
  --ot-state-done-core: #c9b38e;
  --ot-state-done-label: #efe3cf;
  --ot-state-idle-core: #8a6435;
  --ot-state-idle-label: #a39482;
  --ot-state-offline-core: #4e463d;
  --ot-state-offline-label: #6b5f52;

  --ot-font-sans: 'Google Sans Flex', -apple-system, 'SF Pro Text', system-ui, sans-serif;
  --ot-font-mono: 'Google Sans Code', ui-monospace, 'SF Mono', Menlo, monospace;

  --tv-shift-x: 0px;
  --tv-shift-y: 0px;
}

/* Light theme: matching design/website/assets/tokens.css & popover-mixed-029-light@2x.png.
 * Frosted orb tiles stay dark glass seated cleanly on the warm #f5f1eb parchment canvas. */
:root[data-theme='light'] {
  color-scheme: light;
  --ot-well: #14110e;
  --ot-bg: #f5f1eb;
  --ot-surface: #fffdf9;
  --ot-surface-2: #ece5dc;
  --ot-surface-3: #e0d6c9;
  --ot-tile: #141210;
  --ot-tile-border: rgba(31, 25, 19, 0.14);
  --ot-hair: #e0d7cb;
  --ot-hair-strong: #cfc3b4;
  --ot-tile-edge: #bfb09c;
  --ot-text: #1f1913;
  --ot-text-2: #4f4439;
  --ot-text-dim: #6a5f53;
  --ot-text-faint: #9a8e81;
  --ot-gold-text: #946414;
  --ot-terra-text: #b4501f;
  --ot-error-text: #b3342a;
  --ot-on-accent: #1c1208;

  --ot-allow: #1e8c45;
  --ot-deny: #c0392b;
  --ot-stage-card-bg: #fffdf9;
  --ot-stage-card-border: #dcd2c5;
  --ot-stage-opt-bg: #fffdf9;
  --ot-stage-opt-picked: #f7ece2;
  --ot-stage-opt-border: #d7ccbe;
  --ot-stage-badge-bg: #ece5dc;
  --ot-stage-badge-border: #c5b6a4;
  --ot-stage-key-bg: #fffdf9;
  --ot-stage-key-title: #1f1913;
  --ot-stage-key-hint: #5d5145;
  --ot-stage-hero-border: rgba(31, 25, 19, 0.16);
  --ot-stage-rail-bg: rgba(180, 80, 31, 0.1);
  --ot-stage-rail-border: rgba(180, 80, 31, 0.34);
  --ot-stage-rail-count: #9c3f14;
  --ot-stage-rail-next: #5d5145;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;
    --ot-well: #14110e;
    --ot-bg: #f5f1eb;
    --ot-surface: #fffdf9;
    --ot-surface-2: #ece5dc;
    --ot-surface-3: #e0d6c9;
    --ot-tile: #141210;
    --ot-tile-border: rgba(31, 25, 19, 0.14);
    --ot-hair: #e0d7cb;
    --ot-hair-strong: #cfc3b4;
    --ot-tile-edge: #bfb09c;
    --ot-text: #1f1913;
    --ot-text-2: #4f4439;
    --ot-text-dim: #6a5f53;
    --ot-text-faint: #9a8e81;
    --ot-gold-text: #946414;
    --ot-terra-text: #b4501f;
    --ot-error-text: #b3342a;
    --ot-on-accent: #1c1208;

    --ot-allow: #1e8c45;
    --ot-deny: #c0392b;
    --ot-stage-card-bg: #fffdf9;
    --ot-stage-card-border: #dcd2c5;
    --ot-stage-opt-bg: #fffdf9;
    --ot-stage-opt-picked: #f7ece2;
    --ot-stage-opt-border: #d7ccbe;
    --ot-stage-badge-bg: #ece5dc;
    --ot-stage-badge-border: #c5b6a4;
    --ot-stage-key-bg: #fffdf9;
    --ot-stage-key-title: #1f1913;
    --ot-stage-key-hint: #5d5145;
    --ot-stage-hero-border: rgba(31, 25, 19, 0.16);
    --ot-stage-rail-bg: rgba(180, 80, 31, 0.1);
    --ot-stage-rail-border: rgba(180, 80, 31, 0.34);
    --ot-stage-rail-count: #9c3f14;
    --ot-stage-rail-next: #5d5145;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--ot-bg);
  background-image: none;
  color: var(--ot-text);
  font-family: var(--ot-font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100%;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

:focus-visible,
[data-dpad-focus='true'] {
  outline: 2px solid var(--ot-gold);
  outline-offset: 2px;
}

.aw-shell {
  min-height: 100vh;
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: translate(var(--tv-shift-x), var(--tv-shift-y));
}

.aw-shell > * {
  min-width: 0;
  max-width: 100%;
}

.aw-stage {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .aw-shell {
    transform: none;
  }
}

/* Top bar */
.aw-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ot-hair);
}

.aw-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.aw-gridlet {
  display: grid;
  grid-template-columns: repeat(3, 4px);
  gap: 2px;
  flex: none;
}

.aw-gridlet b {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: var(--ot-hair-strong);
}

.aw-gridlet b.on {
  background: var(--ot-gold);
  border-radius: 50%;
}

.aw-brand-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.aw-mode-label {
  font-family: var(--ot-font-mono);
  font-size: 12px;
  color: var(--ot-text-dim);
  font-variant-numeric: tabular-nums;
}

.aw-topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.aw-host-select {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--ot-surface);
  border: 1px solid var(--ot-hair-strong);
  color: var(--ot-text);
  font-size: 13.5px;
}

/* Orbtile buttons */
.aw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 15px;
  border-radius: 12px;
  border: 1px solid var(--ot-hair-strong);
  background: var(--ot-surface);
  color: var(--ot-text);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.aw-btn:hover:not(:disabled) {
  background: var(--ot-surface-2);
  border-color: var(--ot-tile-edge);
}

.aw-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.aw-btn-primary {
  background: var(--ot-gold);
  border-color: var(--ot-gold);
  color: var(--ot-on-accent);
  font-weight: 650;
}

.aw-btn-primary:hover:not(:disabled) {
  background: var(--ot-gold-hi);
  border-color: var(--ot-gold-hi);
}

.aw-btn-quiet {
  background: transparent;
  border-color: var(--ot-hair);
  color: var(--ot-text-2);
}

/* Hold Banner */
.aw-hold-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ot-surface-2);
  border: 1px solid var(--ot-state-thinking-core);
  color: var(--ot-text);
  font-size: 14px;
}

.aw-hold-banner-text {
  font-family: var(--ot-font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ot-gold-text);
}

.aw-hold-banner[hidden] {
  display: none;
}

/* Centered panels: Sign-in, Waiting Room, Notice */
.aw-panel-center {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 20px 0;
}

.aw-panel-footnote {
  max-width: 460px;
  text-align: center;
  color: var(--ot-text-dim);
  font-size: 13px;
  line-height: 1.45;
}

.aw-panel-footnote[hidden] {
  display: none;
}

.aw-panel {
  width: 100%;
  max-width: 460px;
  background: var(--ot-surface);
  border: 1px solid var(--ot-hair);
  border-radius: 20px;
  padding: 28px;
  display: grid;
  gap: 18px;
}

.aw-panel h1,
.aw-panel h2 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.aw-panel-copy {
  color: var(--ot-text-2);
  font-size: 15px;
  line-height: 1.55;
}

.aw-field {
  display: grid;
  gap: 8px;
}

.aw-label {
  font-size: 13px;
  color: var(--ot-text-2);
  font-weight: 550;
}

.aw-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--ot-surface-2);
  border: 1px solid var(--ot-hair-strong);
  color: var(--ot-text);
}

.aw-check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 8px 0;
  cursor: pointer;
  color: var(--ot-text-2);
  font-size: 14px;
}

.aw-check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--ot-gold);
  flex: none;
}

/* Waiting Room 6-digit code */
.aw-code-box {
  background: var(--ot-surface-2);
  border: 1px solid var(--ot-hair-strong);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
}

.aw-code-digits {
  font-family: var(--ot-font-mono);
  font-size: 36px;
  font-weight: 650;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  color: var(--ot-text);
}

.aw-code-meta {
  font-family: var(--ot-font-mono);
  font-size: 13px;
  color: var(--ot-text-dim);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
 * ORBTILE SESSION GRID (Phone & Keypad Parity — DetailTile.swift)
 * ============================================================ */
.aw-grid-wrap {
  display: grid;
  gap: 12px;
  align-content: start;
}

.aw-grid-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--ot-text-dim);
  font-size: 13px;
}

.aw-meta-host {
  font-weight: 500;
}

.aw-meta-waiting {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ot-stage-rail-count);
  background: var(--ot-stage-rail-bg);
  border: 1px solid var(--ot-stage-rail-border);
}

.aw-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

/* Keep .aw-tile itself flat (no box-shadow / background-image); the frosted orb lives in .aw-tile-orb */
.aw-tile {
  --tile-badge-size: 28px;
  --tile-badge-gap: 12px;
  --tile-pad-top: 16px;
  --tile-pad-x: 18px;
  --tile-pad-bottom: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 224px;
  padding: 0;
  text-align: left;
  background-color: var(--ot-tile);
  background-image: none;
  box-shadow: none;
  border: 1px solid var(--ot-tile-border);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  color: var(--ot-tile-text);
  transition: border-color 140ms ease, transform 140ms ease;
}

.aw-tile:hover {
  border-color: rgba(242, 232, 220, 0.24);
}

.aw-tile[data-state='permission'] {
  border-color: rgba(240, 138, 90, 0.42);
}

.aw-tile[data-state='question'] {
  border-color: rgba(242, 154, 94, 0.42);
}

.aw-tile[data-state='error'] {
  border-color: rgba(229, 105, 90, 0.5);
}

.aw-tile-orb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 0;
}

.aw-tile-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: var(--tile-pad-top) var(--tile-pad-x) var(--tile-pad-bottom);
  min-width: 0;
}

.aw-tile-content[data-has-helpers='true'] {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.aw-tile-title {
  font-size: 22px;
  font-weight: 640;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--ot-tile-text);
  text-shadow: 0 1px 6px rgba(11, 9, 8, 0.9);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
}

.aw-tile-state-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.aw-state-word {
  font-size: 15.5px;
  font-weight: 580;
  line-height: 1.2;
  color: var(--ot-state-idle-label);
  text-shadow: 0 1px 6px rgba(11, 9, 8, 0.92);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aw-state-word[data-state='permission'] { color: var(--ot-state-permission-label); }
.aw-state-word[data-state='question'] { color: var(--ot-state-question-label); }
.aw-state-word[data-state='error'] { color: var(--ot-state-error-label); }
.aw-state-word[data-state='tool'] { color: var(--ot-state-tool-label); }
.aw-state-word[data-state='streaming'] { color: var(--ot-state-streaming-label); }
.aw-state-word[data-state='thinking'] { color: var(--ot-state-thinking-label); }
.aw-state-word[data-state='compacting'] { color: var(--ot-state-compacting-label); }
.aw-state-word[data-state='done'] { color: var(--ot-state-done-label); }
.aw-state-word[data-state='idle'] { color: var(--ot-state-idle-label); }
.aw-state-word[data-state='offline'] { color: var(--ot-state-offline-label); }

.aw-tile-timer {
  font-family: var(--ot-font-sans);
  font-size: 15.5px;
  font-weight: 580;
  font-variant-numeric: tabular-nums;
  color: var(--ot-tile-text);
  text-shadow: 0 1px 6px rgba(11, 9, 8, 0.92);
  flex: none;
}

.aw-tile-body-slot {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  margin-right: calc(var(--tile-badge-size) + var(--tile-badge-gap));
}

.aw-tile-body {
  font-family: var(--ot-font-sans);
  font-size: 13.5px;
  font-weight: 470;
  line-height: 1.32;
  color: rgba(242, 232, 220, 0.92);
  text-shadow: 0 1px 6px rgba(11, 9, 8, 0.95);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  padding-top: 2px;
}

.aw-tile-body .aw-tile-timer {
  font-size: inherit;
  font-weight: 500;
  letter-spacing: normal;
  color: inherit;
}

.aw-tile-body.is-streaming {
  font-family: var(--ot-font-mono);
  font-size: 12.5px;
  line-height: 1.36;
}

.aw-tile-caret {
  display: inline-block;
  width: 6px;
  height: 12px;
  margin-left: 2px;
  vertical-align: -1px;
  border-radius: 1px;
  background: var(--ot-gold-hi);
}

.aw-tile-caret.is-off {
  opacity: 0;
}

.aw-tile-foot {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  min-height: 0;
  padding-right: calc(var(--tile-badge-size) + var(--tile-badge-gap));
}

.aw-tile-helpers {
  font-family: var(--ot-font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(242, 232, 220, 0.85);
  background: rgba(11, 9, 8, 0.56);
  border: 1px solid rgba(242, 232, 220, 0.14);
  padding: 2px 8px;
  border-radius: 999px;
}

.aw-tile-agent {
  position: absolute;
  right: var(--tile-pad-x);
  bottom: var(--tile-pad-bottom);
  z-index: 2;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tile-badge-size);
  height: var(--tile-badge-size);
  flex: none;
  opacity: 0.92;
  filter: drop-shadow(0 1px 4px rgba(11, 9, 8, 0.85));
}

.aw-agent-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================================
 * ORBTILE STAGE FOCUS, QUESTION & APPROVAL
 * (NativeFocusView.swift, StageLayout.swift, NativeStageFocus.kt)
 * ============================================================ */
.aw-focus-wrap {
  display: grid;
  justify-items: center;
  align-content: start;
  width: 100%;
}

.aw-stage-column {
  --stage-accent: var(--ot-state-permission-label);
  --stage-decision-border: var(--ot-state-question-core);
  width: 100%;
  max-width: 540px;
  display: grid;
  gap: 10px;
}

/* Stage Hero */
.aw-stage-hero {
  position: relative;
  border-radius: 30px;
  background: #0b0908;
  border: 1px solid var(--ot-stage-hero-border);
  overflow: hidden;
  color: #f2e8dc;
}

.aw-stage-wash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 0;
}

.aw-stage-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 38px;
}

.aw-stage-column[data-stage-phase='mid'] .aw-stage-hero-inner {
  padding: 12px 16px 32px;
  gap: 8px;
}

.aw-stage-column[data-stage-phase='band'] .aw-stage-hero-inner {
  padding: 10px 14px 28px;
  gap: 8px;
}

.aw-stage-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.aw-stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.aw-stage-chip-back {
  background: rgba(24, 18, 14, 0.72);
  border: 1px solid #3a2c22;
  color: #d9bb9f;
}

.aw-stage-chip-back:hover {
  background: rgba(38, 28, 22, 0.86);
}

.aw-stage-chip-waiting {
  background: rgba(224, 122, 74, 0.14);
  border: 1px solid #5a3924;
  color: #ffd6b1;
}

.aw-stage-chip-waiting:disabled {
  cursor: default;
  opacity: 0.9;
}

.aw-stage-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.aw-stage-identity.is-band {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  gap: 10px;
}

.aw-stage-identity-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.aw-stage-orb {
  width: 108px;
  height: 108px;
  flex: none;
  display: block;
}

.aw-stage-column[data-stage-phase='mid'] .aw-stage-orb {
  width: 68px;
  height: 68px;
}

.aw-stage-column[data-stage-phase='band'] .aw-stage-orb {
  width: 44px;
  height: 44px;
}

.aw-stage-labels {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.aw-focus-title {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.18;
  color: #f2e8dc;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aw-stage-column[data-stage-phase='band'] .aw-focus-title {
  font-size: 16.5px;
}

.aw-stage-subtitle {
  font-size: 12px;
  font-weight: 470;
  color: #a39482;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Stage State Pill */
.aw-stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--stage-accent) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--stage-accent) 38%, transparent);
  margin-top: 2px;
  flex: none;
}

.aw-stage-pill .aw-state-word {
  font-size: 12px;
  font-weight: 550;
  text-shadow: none;
}

.aw-stage-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 8px var(--stage-accent);
}

.aw-stage-pill-sep {
  width: 1px;
  height: 12px;
  background: color-mix(in srgb, var(--stage-accent) 26%, transparent);
}

.aw-stage-pill-sep[hidden] {
  display: none;
}

.aw-stage-pill-timer {
  font-size: 11.5px;
  font-weight: 450;
  color: #b9aa94;
  text-shadow: none;
}

/* Stage Request / Output Card (overlaps hero edge) */
.aw-stage-card {
  position: relative;
  z-index: 2;
  margin-top: -26px;
  background: var(--ot-stage-card-bg);
  border: 1px solid var(--ot-stage-card-border);
  border-radius: 26px;
  padding: 16px 18px 18px;
  display: grid;
  gap: 10px;
}

.aw-stage-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.aw-stage-card-tag {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
  color: var(--stage-decision-border);
  white-space: nowrap;
}

:root[data-theme='light'] .aw-stage-card-tag {
  color: var(--ot-terra-text);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) .aw-stage-card-tag {
    color: var(--ot-terra-text);
  }
}

.aw-stage-card-tail {
  font-family: var(--ot-font-mono);
  font-size: 11.5px;
  color: var(--ot-text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aw-stage-card-kicker {
  font-size: 17px;
  font-weight: 600;
  color: var(--ot-text);
}

.aw-stage-card-title {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.38;
  color: var(--ot-text);
}

.aw-stage-context {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ot-text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.aw-stage-selection {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--stage-accent);
}

:root[data-theme='light'] .aw-stage-selection {
  color: var(--ot-terra-text);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) .aw-stage-selection {
    color: var(--ot-terra-text);
  }
}

.aw-stage-selection[hidden] {
  display: none;
}

.aw-stage-status:empty {
  display: none;
}

.aw-stage-display-note {
  font-size: 13.5px;
  color: var(--ot-terra-text);
}

.aw-request-text {
  background: var(--ot-surface-2);
  border: 1px solid var(--ot-hair);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--ot-font-mono);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ot-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.aw-stream-box {
  font-family: var(--ot-font-mono);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ot-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 88px;
}

.aw-caret {
  display: inline-block;
  width: 8px;
  height: 14px;
  margin-left: 2px;
  vertical-align: middle;
  background: var(--ot-gold);
}

.aw-caret.is-off {
  opacity: 0;
}

/* Stage Question Wrapper & Option Chips (focus-q-sel1-loop.jpg) */
.aw-stage-question-wrap {
  display: grid;
  gap: 10px;
}

.aw-question-group {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 20px;
  background: var(--ot-stage-card-bg);
  border: 1px solid var(--ot-stage-card-border);
}

.aw-question-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.aw-question-header {
  font-family: var(--ot-font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ot-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.aw-question-mode {
  font-size: 11.5px;
  color: var(--ot-text-dim);
}

.aw-question-text {
  font-size: 15.5px;
  font-weight: 550;
  color: var(--ot-text);
}

.aw-opt-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.aw-opt-grid.is-two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.aw-opt-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 60px;
  padding: 10px 14px;
  border-radius: 20px;
  background: var(--ot-stage-opt-bg);
  border: 1px solid var(--ot-stage-opt-border);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.aw-opt-grid.is-two-col .aw-opt-row {
  min-height: 70px;
  border-radius: 22px;
}

.aw-opt-row:hover {
  border-color: color-mix(in srgb, var(--stage-accent) 55%, var(--ot-stage-opt-border));
}

.aw-opt-row[data-picked='true'] {
  background: color-mix(in srgb, var(--stage-accent) 16%, var(--ot-stage-opt-picked));
  border-color: color-mix(in srgb, var(--stage-accent) 90%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--stage-accent) 24%, transparent);
}

.aw-opt-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.aw-opt-row:has(.aw-opt-input:focus-visible) {
  outline: 2px solid var(--ot-gold);
  outline-offset: 2px;
}

.aw-opt-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  background: var(--ot-stage-badge-bg);
  border: 1px solid var(--ot-stage-badge-border);
  color: var(--ot-text-dim);
}

.aw-opt-num.is-multi {
  border-radius: 7px;
}

.aw-opt-row[data-picked='true'] .aw-opt-num {
  background: var(--stage-accent);
  border-color: var(--stage-accent);
  color: #0b0908;
}

.aw-opt-copy {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.aw-opt-label {
  font-size: 15.5px;
  font-weight: 550;
  line-height: 1.25;
  color: var(--ot-text);
}

.aw-opt-row[data-picked='true'] .aw-opt-label {
  font-weight: 620;
}

.aw-opt-desc {
  font-size: 12px;
  line-height: 1.3;
  color: var(--ot-text-dim);
}

.aw-opt-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--ot-text);
  opacity: 0;
}

.aw-opt-row[data-picked='true'] .aw-opt-check {
  opacity: 1;
}

.aw-opt-check.is-multi {
  opacity: 1;
  border-radius: 6px;
  background: var(--ot-stage-badge-bg);
  border: 1.5px solid var(--ot-stage-badge-border);
  color: transparent;
}

.aw-opt-row[data-picked='true'] .aw-opt-check.is-multi {
  background: var(--stage-accent);
  border-color: var(--stage-accent);
  color: #0b0908;
}

/* Stage Thumb-Zone Action Deck (Deny / Allow / Allow for session / Send) */
.aw-stage-deck {
  display: grid;
  gap: 10px;
}

.aw-stage-deck-pair {
  display: grid;
  grid-template-columns: minmax(112px, 0.32fr) minmax(0, 0.68fr);
  gap: 10px;
}

.aw-stage-key {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 80px;
  padding: 12px 14px;
  border-radius: 24px;
  text-align: left;
  cursor: pointer;
  background: var(--ot-stage-key-bg);
  border: 1px solid var(--ot-hair-strong);
  transition: opacity 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.aw-stage-key:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.aw-stage-key-deny {
  min-height: 100px;
  background: color-mix(in srgb, var(--ot-deny) 7%, var(--ot-stage-key-bg));
  border-color: color-mix(in srgb, var(--ot-deny) 46%, transparent);
  color: var(--ot-deny);
}

.aw-stage-key-deny:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ot-deny) 14%, var(--ot-stage-key-bg));
}

.aw-stage-key-allow {
  min-height: 100px;
  background: color-mix(in srgb, var(--ot-allow) 16%, var(--ot-stage-key-bg));
  border-color: color-mix(in srgb, var(--ot-allow) 55%, transparent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--ot-allow) 22%, transparent);
  color: var(--ot-allow);
}

.aw-stage-key-allow:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ot-allow) 24%, var(--ot-stage-key-bg));
}

.aw-stage-key-allow-session {
  min-height: 58px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--ot-allow) 10%, var(--ot-stage-key-bg));
  border-color: color-mix(in srgb, var(--ot-allow) 38%, transparent);
  color: var(--ot-allow);
}

.aw-stage-key-allow-session:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ot-allow) 18%, var(--ot-stage-key-bg));
}

.aw-stage-key-send {
  min-height: 78px;
  background: color-mix(in srgb, var(--ot-allow) 16%, var(--ot-stage-key-bg));
  border-color: color-mix(in srgb, var(--ot-allow) 55%, transparent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--ot-allow) 22%, transparent);
  color: var(--ot-allow);
}

.aw-stage-key-send:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ot-allow) 24%, var(--ot-stage-key-bg));
}

.aw-stage-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
  border: 2px solid color-mix(in srgb, currentColor 32%, transparent);
  color: currentColor;
}

.aw-stage-key-deny .aw-stage-ring {
  width: 30px;
  height: 30px;
}

.aw-stage-key-allow-session .aw-stage-ring {
  width: 30px;
  height: 30px;
}

.aw-stage-key-labels {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.aw-stage-key-title {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ot-stage-key-title);
}

.aw-stage-key-deny .aw-stage-key-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--ot-deny);
}

.aw-stage-key-allow-session .aw-stage-key-title {
  font-size: 15.5px;
  font-weight: 650;
}

.aw-stage-key-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--ot-stage-key-hint);
}

.aw-stage-key-num {
  position: absolute;
  top: 9px;
  right: 12px;
  font-size: 11px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  color: var(--ot-stage-key-hint);
  opacity: 0.6;
}

/* Subagents & Follow-up Composer */
.aw-subagents,
.aw-stage-composer {
  background: var(--ot-stage-card-bg);
  border: 1px solid var(--ot-stage-card-border);
  border-radius: 20px;
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}

.aw-subagent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--ot-hair);
  font-size: 13.5px;
}

.aw-subagent-row .aw-state-word,
.aw-subagent-row .aw-tile-timer {
  font-size: 13px;
  text-shadow: none;
  color: var(--ot-text-dim);
}

.aw-subagent-row:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.aw-instr-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.aw-instr-form .aw-input {
  flex: 1 1 220px;
}

.aw-msg {
  font-size: 13.5px;
  color: var(--ot-text-2);
}

.aw-msg.is-error {
  color: var(--ot-error-text);
}

/* Stage Rail (footer dots + next waiting chip) */
.aw-stage-rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding-top: 2px;
}

.aw-stage-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.aw-stage-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.72;
}

.aw-stage-dot.is-current {
  opacity: 1;
  outline: 2px solid rgba(242, 232, 220, 0.45);
  outline-offset: 2px;
}

.aw-stage-dots-more {
  font-size: 11px;
  color: var(--ot-text-dim);
  font-variant-numeric: tabular-nums;
}

.aw-stage-rail-waiting {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--ot-stage-rail-bg);
  border: 1px solid var(--ot-stage-rail-border);
  font-size: 12px;
  cursor: pointer;
  max-width: 72%;
}

.aw-stage-rail-waiting:disabled {
  cursor: default;
}

.aw-stage-rail-count {
  font-weight: 650;
  color: var(--ot-stage-rail-count);
  white-space: nowrap;
}

.aw-stage-rail-next {
  color: var(--ot-stage-rail-next);
  padding-left: 8px;
  border-left: 1px solid var(--ot-stage-rail-border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aw-stage-rail-chev {
  color: var(--ot-stage-rail-count);
  font-weight: 650;
}

/* ============================================================
 * RESPONSIVE TABLET & PHONE (390px mirrors iPhone 2-column grid)
 * ============================================================ */
@media (max-width: 1099px) {
  .aw-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 719px) {
  .aw-shell {
    padding: 10px 6px 18px;
    gap: 10px;
  }

  .aw-topbar {
    padding: 0 4px 8px;
    gap: 8px;
  }

  .aw-grid-meta {
    padding: 0 4px;
  }

  .aw-topbar-right {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    gap: 6px;
  }

  .aw-btn,
  .aw-host-select {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 10px;
    flex: 0 1 auto;
  }

  .aw-grid-wrap,
  .aw-grid,
  .aw-focus-wrap,
  .aw-stage-column {
    min-width: 0;
    width: 100%;
  }

  .aw-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .aw-tile {
    --tile-badge-size: 26px;
    --tile-badge-gap: 10px;
    --tile-pad-top: 10px;
    --tile-pad-x: 9px;
    --tile-pad-bottom: 9px;
    aspect-ratio: 210 / 199;
    min-height: 174px;
    border-radius: 18px;
  }

  .aw-tile-content {
    gap: 3px;
  }

  .aw-tile-title {
    font-size: 20px;
    line-height: 1.08;
  }

  .aw-tile-state-row {
    gap: 4px;
  }

  .aw-state-word,
  .aw-tile-timer {
    font-size: 14.5px;
    letter-spacing: -0.015em;
  }

  .aw-tile-body {
    font-size: 12.5px;
    -webkit-line-clamp: 3;
  }

  .aw-tile-helpers {
    font-size: 10.5px;
    padding: 1px 6px;
  }

  .aw-stage-column {
    max-width: none;
  }

  .aw-stage-deck-pair {
    grid-template-columns: minmax(104px, 0.34fr) minmax(0, 0.66fr);
  }

  .aw-panel {
    padding: 20px;
  }

  .aw-code-digits {
    font-size: 30px;
  }
}

/* ============================================================
 * TV 10-FOOT FULL-BLEED LAYOUT (1920x1080 & 3840x2160, 3m legible)
 * ============================================================ */
html[data-layout='tv'] body {
  font-size: clamp(20px, 2vh, 42px);
}

html[data-layout='tv'] .aw-shell {
  max-width: none;
  min-height: 100vh;
  padding: 2.8vh 3.2vw;
  gap: 1.8vh;
}

html[data-layout='tv'] .aw-shell[data-stage-kind='grid'] {
  height: 100vh;
  overflow: hidden;
}

html[data-layout='tv'] .aw-shell[data-stage-kind='grid'] .aw-stage,
html[data-layout='tv'] .aw-shell[data-stage-kind='grid'] .aw-grid-wrap {
  height: 100%;
  min-height: 0;
  display: grid;
}

html[data-layout='tv'] .aw-shell[data-stage-kind='grid'] .aw-grid-wrap {
  grid-template-rows: auto 1fr;
  align-content: stretch;
  gap: 1.4vh;
}

html[data-layout='tv'] .aw-topbar {
  padding-bottom: 1.2vh;
}

html[data-layout='tv'] .aw-brand-title {
  font-size: clamp(26px, 2.6vh, 56px);
}

html[data-layout='tv'] .aw-mode-label,
html[data-layout='tv'] .aw-meta-host,
html[data-layout='tv'] .aw-meta-waiting,
html[data-layout='tv'] .aw-hold-banner {
  font-size: clamp(20px, 2vh, 42px);
}

html[data-layout='tv'] .aw-btn,
html[data-layout='tv'] .aw-host-select {
  min-height: clamp(46px, 4.6vh, 88px);
  padding: 0.7vh 1.2vw;
  font-size: clamp(18px, 1.8vh, 36px);
  border-radius: clamp(12px, 1.2vh, 24px);
}

/* Full-bleed TV session-count-fitting grid (no empty half-screen) */
html[data-layout='tv'] .aw-grid {
  height: 100%;
  min-height: 0;
  gap: clamp(16px, 1.8vh, 36px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

html[data-layout='tv'] .aw-grid[data-tv-mode='1x1'] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

html[data-layout='tv'] .aw-grid[data-tv-mode='2x1'] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x1'] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

html[data-layout='tv'] .aw-grid[data-tv-mode='2x2'] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

html[data-layout='tv'] .aw-grid[data-tv-mode='spot-3'] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

html[data-layout='tv'] .aw-grid[data-tv-mode='spot-3'] .aw-tile[data-tv-spotlight='true'] {
  grid-column: span 2;
}

/* 4 sessions with spotlight: Row 1 = 4+2 cols (2/3 + 1/3), Row 2 = 3+3 cols (1/2 + 1/2) -> 100% full! */
html[data-layout='tv'] .aw-grid[data-tv-mode='spot-4'] {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

html[data-layout='tv'] .aw-grid[data-tv-mode='spot-4'] .aw-tile:nth-child(1) {
  grid-column: span 4;
}

html[data-layout='tv'] .aw-grid[data-tv-mode='spot-4'] .aw-tile:nth-child(2) {
  grid-column: span 2;
}

html[data-layout='tv'] .aw-grid[data-tv-mode='spot-4'] .aw-tile:nth-child(3),
html[data-layout='tv'] .aw-grid[data-tv-mode='spot-4'] .aw-tile:nth-child(4) {
  grid-column: span 3;
}

html[data-layout='tv'] .aw-grid[data-tv-mode='spot-5'] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

html[data-layout='tv'] .aw-grid[data-tv-mode='spot-5'] .aw-tile[data-tv-spotlight='true'] {
  grid-column: span 2;
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x2'] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(var(--tv-rows, 3), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}

html[data-layout='tv'] .aw-grid[data-tv-dense='true'] {
  gap: clamp(10px, 1.2vh, 24px);
}

html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile {
  --tile-badge-size: clamp(32px, 3.2vh, 64px);
  --tile-badge-gap: clamp(12px, 1vw, 24px);
  --tile-pad-top: clamp(12px, 1.3vh, 28px);
  --tile-pad-x: clamp(18px, 1.6vw, 38px);
  --tile-pad-bottom: clamp(12px, 1.3vh, 28px);
}

html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile-content {
  gap: clamp(4px, 0.5vh, 12px);
}

html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile-title {
  font-size: clamp(26px, 2.7vh, 56px);
  -webkit-line-clamp: 1;
}

html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-state-word,
html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile-timer {
  font-size: clamp(20px, 2.0vh, 42px);
}

html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile-body {
  font-size: clamp(16px, 1.6vh, 34px);
  -webkit-line-clamp: 2;
}

html[data-layout='tv'] .aw-tile {
  --tile-badge-size: clamp(44px, 4.4vh, 88px);
  --tile-badge-gap: clamp(14px, 1.2vw, 28px);
  --tile-pad-top: clamp(24px, 2.6vh, 52px);
  --tile-pad-x: clamp(26px, 2vw, 56px);
  --tile-pad-bottom: clamp(24px, 2.6vh, 52px);
  aspect-ratio: auto;
  height: 100%;
  min-height: 0;
  border-radius: clamp(24px, 2.4vh, 48px);
}

html[data-layout='tv'] .aw-tile-content {
  gap: clamp(10px, 1.2vh, 24px);
}

/* Title >= 42px at 1080p, scaling cleanly to ~88px at 4K (3840x2160) */
html[data-layout='tv'] .aw-tile-title,
html[data-layout='tv'] .aw-focus-title {
  font-size: clamp(42px, 4.1vh, 92px);
  line-height: 1.08;
}

html[data-layout='tv'] .aw-state-word,
html[data-layout='tv'] .aw-tile-timer {
  font-size: clamp(28px, 2.8vh, 62px);
}

html[data-layout='tv'] .aw-tile-body {
  font-size: clamp(23px, 2.3vh, 50px);
  line-height: 1.3;
  -webkit-line-clamp: 3;
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile {
  --tile-pad-top: clamp(16px, 1.6vh, 36px);
  --tile-pad-x: clamp(22px, 1.8vw, 48px);
  --tile-pad-bottom: clamp(16px, 1.6vh, 36px);
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-content {
  gap: clamp(5px, 0.7vh, 16px);
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-title {
  font-size: clamp(32px, 3.2vh, 72px);
  line-height: 1.08;
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-state-word,
html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-timer {
  font-size: clamp(22px, 2.2vh, 48px);
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-body {
  font-size: clamp(19px, 1.9vh, 42px);
  line-height: 1.3;
  -webkit-line-clamp: 2;
}

html[data-layout='tv'] .aw-tile-body.is-streaming {
  font-size: clamp(21px, 2.1vh, 44px);
}

html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-body.is-streaming {
  font-size: clamp(18px, 1.8vh, 40px);
  line-height: 1.32;
}

html[data-layout='tv'] .aw-tile-helpers {
  font-size: clamp(18px, 1.8vh, 36px);
  padding: 0.4vh 1vw;
}

html[data-layout='tv'] .aw-stage-column {
  max-width: clamp(760px, 60vw, 1500px);
  gap: 2vh;
}

html[data-layout='tv'] .aw-stage-orb {
  width: clamp(110px, 12vh, 220px);
  height: clamp(110px, 12vh, 220px);
}

html[data-layout='tv'] .aw-stage-card-title,
html[data-layout='tv'] .aw-stream-box,
html[data-layout='tv'] .aw-request-text {
  font-size: clamp(24px, 2.4vh, 48px);
}

html[data-layout='tv'] :focus-visible,
html[data-layout='tv'] [data-dpad-focus='true'] {
  outline: 4px solid var(--ot-gold);
  outline-offset: 4px;
}

@media (max-height: 920px) and (min-width: 681px) {
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile {
    --tile-badge-size: 32px;
    --tile-badge-gap: 12px;
    --tile-pad-top: 14px;
    --tile-pad-x: 18px;
    --tile-pad-bottom: 14px;
    border-radius: 18px;
  }

  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-content {
    gap: 5px;
  }

  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-title {
    font-size: clamp(22px, 3vh, 30px);
    line-height: 1.08;
  }

  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-state-word,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-timer {
    font-size: clamp(16px, 2.2vh, 22px);
  }

  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-body {
    font-size: clamp(13px, 1.8vh, 17px);
    line-height: 1.28;
    -webkit-line-clamp: 2;
  }

  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-body.is-streaming {
    font-size: clamp(12px, 1.6vh, 15px);
  }

  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-helpers {
    font-size: 13px;
    padding: 2px 8px;
  }
}

@media (max-width: 680px) {
  html[data-layout='tv'] .aw-shell {
    padding: 12px 10px 24px;
    gap: 10px;
  }

  html[data-layout='tv'] .aw-shell[data-stage-kind='grid'] {
    height: auto;
    overflow: visible;
  }

  html[data-layout='tv'] .aw-brand-title {
    font-size: 16px;
  }

  html[data-layout='tv'] .aw-mode-label,
  html[data-layout='tv'] .aw-meta-host,
  html[data-layout='tv'] .aw-meta-waiting,
  html[data-layout='tv'] .aw-hold-banner {
    font-size: 13px;
  }

  html[data-layout='tv'] .aw-btn,
  html[data-layout='tv'] .aw-host-select {
    min-height: 44px;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 10px;
  }

  html[data-layout='tv'] .aw-grid,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x2'],
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'],
  html[data-layout='tv'] .aw-grid[data-tv-mode='spot-3'],
  html[data-layout='tv'] .aw-grid[data-tv-mode='spot-4'],
  html[data-layout='tv'] .aw-grid[data-tv-mode='spot-5'] {
    height: auto;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }

  html[data-layout='tv'] .aw-grid[data-tv-mode='spot-4'] .aw-tile:nth-child(n),
  html[data-layout='tv'] .aw-grid .aw-tile[data-tv-spotlight='true'] {
    grid-column: span 2;
  }

  html[data-layout='tv'] .aw-tile,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile,
  html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile {
    --tile-badge-size: 24px;
    --tile-badge-gap: 10px;
    --tile-pad-top: 10px;
    --tile-pad-x: 10px;
    --tile-pad-bottom: 10px;
    aspect-ratio: 210 / 199;
    height: auto;
    min-height: 174px;
    border-radius: 16px;
  }

  html[data-layout='tv'] .aw-tile-content,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-content,
  html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile-content {
    gap: 4px;
  }

  html[data-layout='tv'] .aw-tile-title,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-title,
  html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile-title {
    font-size: 18px;
    line-height: 1.1;
  }

  html[data-layout='tv'] .aw-state-word,
  html[data-layout='tv'] .aw-tile-timer,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-state-word,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-timer,
  html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-state-word,
  html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile-timer {
    font-size: 14px;
  }

  html[data-layout='tv'] .aw-tile-body,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-body,
  html[data-layout='tv'] .aw-grid[data-tv-dense='true'] .aw-tile-body {
    font-size: 12.5px;
    line-height: 1.3;
    -webkit-line-clamp: 3;
  }

  html[data-layout='tv'] .aw-tile-body.is-streaming,
  html[data-layout='tv'] .aw-grid[data-tv-mode='3x3'] .aw-tile-body.is-streaming {
    font-size: 11.5px;
    line-height: 1.34;
  }

  html[data-layout='tv'] .aw-tile-helpers {
    font-size: 10.5px;
    padding: 1px 6px;
  }
}
