:root {
  color-scheme: light;
  --room: #d9d0bf;
  --room-bright: #efe8dc;
  --ink: #17130e;
  --muted: rgba(23, 19, 14, 0.62);
  --soft: rgba(23, 19, 14, 0.10);
  --line: rgba(57, 42, 27, 0.20);
  --cream: #f6efe1;
  --glass: rgba(255, 252, 242, 0.70);
  --glass-strong: rgba(255, 250, 237, 0.86);
  --metal: #bfc1ba;
  --metal-dark: #6f726c;
  --wood: #8b5d36;
  --wood-dark: #4f311f;
  --blue: #3c7b8f;
  --red: #be513c;
  --green: #477b52;
  --shadow: rgba(57, 37, 18, 0.22);
  --hard-shadow: rgba(26, 18, 10, 0.36);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 251, 240, 0.80), rgba(217, 208, 191, 0.74)),
    radial-gradient(circle at 18% 10%, #fff9eb 0, rgba(255, 249, 235, 0) 34%),
    linear-gradient(115deg, #e6dccb 0%, #cfc4b0 58%, #b9b0a3 100%);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: url("assets/tv-control-material.png");
  background-size: cover;
  background-position: center bottom;
  opacity: 0.12;
  filter: saturate(0.8) brightness(1.55);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(255, 252, 240, 0.82), rgba(255, 252, 240, 0.30) 52%, rgba(96, 76, 55, 0.18)),
    repeating-linear-gradient(90deg, rgba(68, 46, 28, 0.035) 0 1px, transparent 1px 10px);
  pointer-events: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.watchSurface {
  width: min(1440px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  padding: 18px 0 22px;
}

.topbar {
  min-height: 64px;
  display: grid;
  grid-template-columns: auto minmax(180px, 420px) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(237, 228, 211, 0.62)),
    rgba(252, 246, 232, 0.72);
  box-shadow:
    0 18px 44px rgba(95, 73, 44, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
}

.brandLens {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, #ffffff 0 10%, #9ec1ca 12% 26%, #1f3f49 48%, #0c171b 72%),
    #244752;
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 -3px 8px rgba(0, 0, 0, 0.42),
    0 6px 14px rgba(25, 46, 52, 0.22);
}

.quickTune {
  min-height: 44px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 5px 8px 5px 14px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(226, 220, 207, 0.58)),
    rgba(255, 250, 239, 0.88);
  border: 1px solid rgba(65, 48, 30, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.quickTuneLabel {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.quickTuneInput {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  font-weight: 800;
}

.primaryButton,
.secondaryButton,
.roundButton,
.modeButton,
.toolButton,
.transportButton,
.liveTune,
.miniScreen {
  cursor: pointer;
}

.primaryButton,
.secondaryButton,
.toolButton,
.modeButton {
  min-height: 42px;
  border-radius: 9px;
  border: 1px solid rgba(74, 51, 30, 0.22);
  background:
    linear-gradient(180deg, #fffaf0, #d6c6ad),
    var(--cream);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    inset 0 -2px 0 rgba(84, 57, 32, 0.12),
    0 8px 18px rgba(71, 48, 27, 0.14);
  color: #27180e;
  font-size: 13px;
  font-weight: 900;
}

.primaryButton {
  min-width: 94px;
  color: #fffaf0;
  background:
    linear-gradient(180deg, #4e8796, #275769),
    var(--blue);
  border-color: rgba(20, 68, 82, 0.45);
}

.roundButton,
.transportButton {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(74, 51, 30, 0.24);
  border-radius: 50%;
  background:
    linear-gradient(180deg, #fff8ea, #c7beb0),
    var(--metal);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    inset 0 -3px 0 rgba(71, 48, 27, 0.12),
    0 8px 20px rgba(55, 39, 22, 0.14);
  display: grid;
  place-items: center;
}

.scanIcon {
  width: 18px;
  height: 18px;
  border: 3px solid #325765;
  border-radius: 50%;
  border-left-color: transparent;
  display: block;
}

.stageGrid {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 382px);
  gap: 18px;
  align-items: start;
}

.playerStack {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.television {
  min-width: 0;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(104, 66, 35, 0.94), rgba(151, 103, 59, 0.92) 12%, rgba(236, 221, 196, 0.72) 13%, rgba(185, 154, 112, 0.84) 88%, rgba(78, 49, 29, 0.94)),
    linear-gradient(180deg, #9b6a3d, #4f311f);
  border: 1px solid rgba(60, 39, 23, 0.38);
  box-shadow:
    0 28px 70px var(--shadow),
    inset 0 1px 0 rgba(255, 242, 220, 0.48);
}

.mount {
  position: relative;
  width: calc(100% - 28px);
  aspect-ratio: 16 / 9;
  margin: 14px;
  overflow: hidden;
  border-radius: 12px;
  background: #050606;
  border: 8px solid #20201d;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    inset 0 20px 60px rgba(255, 255, 255, 0.06),
    0 12px 26px rgba(44, 25, 13, 0.34);
}

.mount > moq-watch {
  width: 100%;
  height: 100%;
  display: block;
}

.idleScreen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 250, 235, 0.94);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.50)),
    url("assets/live-preview-mosaic.png");
  background-size: cover;
  background-position: center;
}

.idleScreen::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.10), transparent 32%, rgba(255, 255, 255, 0.08) 62%, transparent),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px);
  pointer-events: none;
}

.idlePlate {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(16, 20, 21, 0.54);
  border: 1px solid rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(12px);
}

.playGlyph,
.backGlyph,
.forwardGlyph {
  display: block;
  width: 0;
  height: 0;
}

.playGlyph {
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-left: 23px solid #fff6e4;
}

.backGlyph {
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 16px solid #5d4c3c;
}

.forwardGlyph {
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid #5d4c3c;
}

.canvas,
.archiveVideo {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.controlShelf {
  display: grid;
  gap: 12px;
  padding: 13px 16px 16px;
  background:
    linear-gradient(180deg, rgba(248, 241, 226, 0.84), rgba(206, 189, 166, 0.72)),
    rgba(237, 225, 206, 0.82);
  border-top: 1px solid rgba(255, 255, 255, 0.40);
}

.nowLine {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.kicker {
  color: rgba(77, 55, 36, 0.64);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nowTitle {
  margin-top: 2px;
  font-size: 22px;
  line-height: 1.05;
  font-weight: 950;
}

.hint,
.listHint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.hint[data-kind="ok"],
.listHint[data-kind="ok"] {
  color: var(--green);
}

.hint[data-kind="warn"],
.listHint[data-kind="warn"] {
  color: #855524;
}

.scrubDeck {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.scrubberWrap {
  position: relative;
  min-height: 42px;
  display: grid;
  align-items: center;
}

.scrubber {
  width: 100%;
  accent-color: var(--blue);
}

.chapterMarks {
  position: absolute;
  inset: auto 10px 4px;
  height: 6px;
  border-radius: 999px;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(39, 32, 24, 0.34) 12% 13%, transparent 13% 31%, rgba(39, 32, 24, 0.34) 31% 32%, transparent 32% 52%, rgba(39, 32, 24, 0.34) 52% 53%, transparent 53% 77%, rgba(39, 32, 24, 0.34) 77% 78%, transparent 78%);
}

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

.toolButton.pressed,
.modeButton.pressed {
  color: #fff9e8;
  background:
    linear-gradient(180deg, #6e93a0, #315c6c),
    var(--blue);
}

.multiview {
  border-radius: 16px;
  padding: 11px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.70), rgba(230, 219, 201, 0.62)),
    rgba(247, 239, 223, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.54);
  box-shadow: 0 18px 42px rgba(79, 60, 37, 0.14);
}

.multiViewGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.miniScreen {
  min-height: 84px;
  display: flex;
  align-items: end;
  justify-content: start;
  padding: 9px;
  border-radius: 10px;
  border: 2px solid rgba(34, 28, 22, 0.20);
  color: #fffaf0;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  background-image:
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.54)),
    url("assets/live-preview-mosaic.png");
  background-size: 200% 200%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.tileA { background-position: 0 0; }
.tileB { background-position: 100% 0; }
.tileC { background-position: 0 100%; }
.tileD { background-position: 100% 100%; }

.channelRail {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 252, 243, 0.84), rgba(222, 207, 183, 0.70)),
    rgba(250, 242, 226, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow:
    0 24px 62px rgba(73, 52, 30, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

.railHead {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.modeSwitch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(98, 73, 44, 0.10);
}

.modeButton {
  min-height: 34px;
  padding: 0 10px;
  box-shadow: none;
  font-size: 12px;
}

.liveList {
  display: grid;
  gap: 10px;
}

.liveItem {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  min-height: 74px;
}

.liveTune {
  min-width: 0;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid rgba(61, 45, 28, 0.18);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(231, 219, 199, 0.70)),
    rgba(255, 250, 239, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 10px 22px rgba(75, 52, 28, 0.10);
  text-align: left;
}

.liveTune::before {
  content: "";
  width: 54px;
  height: 54px;
  border-radius: 9px;
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.36)),
    url("assets/live-preview-mosaic.png");
  background-size: 210% 210%;
  background-position: var(--thumb-x, 0) var(--thumb-y, 0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.liveTitle {
  color: #20140b;
  font-size: 14px;
  line-height: 1.18;
  font-weight: 950;
}

.liveMeta {
  margin-top: 4px;
  overflow: hidden;
  color: rgba(49, 35, 22, 0.60);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.liveActions {
  display: grid;
}

.watchBadge,
.emptyState .secondaryButton {
  align-self: center;
}

.watchBadge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 999px;
  color: #fffaf0;
  background: linear-gradient(180deg, #588c9a, #2d5b69);
  font-size: 12px;
  font-weight: 950;
}

.emptyState {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 74px;
  padding: 10px;
  border: 1px dashed rgba(68, 49, 29, 0.30);
  border-radius: 12px;
  background: rgba(255, 252, 242, 0.58);
}

.emptyTitle {
  color: rgba(42, 30, 19, 0.72);
  font-size: 14px;
  font-weight: 950;
}

.signalDrawer {
  border-top: 1px solid rgba(67, 47, 29, 0.16);
  padding-top: 10px;
}

.signalDrawer summary {
  cursor: pointer;
  color: rgba(38, 28, 18, 0.70);
  font-size: 13px;
  font-weight: 950;
}

.signalGrid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.field {
  display: grid;
  gap: 6px;
  color: rgba(38, 28, 18, 0.68);
  font-size: 12px;
  font-weight: 850;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  color: var(--ink);
  border: 1px solid rgba(66, 47, 29, 0.22);
  border-radius: 9px;
  background: rgba(255, 252, 243, 0.72);
  outline: none;
}

.checkField {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid rgba(66, 47, 29, 0.18);
  border-radius: 9px;
  background: rgba(255, 252, 243, 0.62);
  font-size: 13px;
  font-weight: 850;
}

.checkField input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.shareLink {
  min-width: 0;
  overflow: hidden;
  color: rgba(35, 26, 18, 0.56);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primaryButton:hover,
.secondaryButton:hover,
.toolButton:hover,
.modeButton:hover,
.roundButton:hover,
.transportButton:hover,
.liveTune:hover,
.miniScreen:hover {
  transform: translateY(-1px);
}

.primaryButton:active,
.secondaryButton:active,
.toolButton:active,
.modeButton:active,
.roundButton:active,
.transportButton:active,
.liveTune:active,
.miniScreen:active {
  transform: translateY(0);
}

.primaryButton:focus-visible,
.secondaryButton:focus-visible,
.toolButton:focus-visible,
.modeButton:focus-visible,
.roundButton:focus-visible,
.transportButton:focus-visible,
.liveTune:focus-visible,
.miniScreen:focus-visible,
.signalDrawer summary:focus-visible,
.quickTuneInput:focus-visible,
.input:focus-visible,
.scrubber:focus-visible {
  outline: 3px solid rgba(60, 123, 143, 0.48);
  outline-offset: 3px;
}

@media (max-width: 1080px) {
  .stageGrid {
    grid-template-columns: 1fr;
  }

  .channelRail {
    order: 2;
  }
}

@media (max-width: 720px) {
  .watchSurface {
    width: min(calc(100% - 20px), 560px);
    gap: 12px;
    padding-top: 10px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .brand {
    font-size: 21px;
  }

  .quickTune {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .mount {
    width: calc(100% - 18px);
    margin: 9px;
    border-width: 6px;
  }

  .controlShelf {
    padding: 11px;
  }

  .nowLine {
    align-items: start;
    flex-direction: column;
  }

  .nowTitle {
    font-size: 19px;
  }

  .scrubDeck {
    grid-template-columns: minmax(0, 1fr);
  }

  .transportButton {
    display: none;
  }

  .toolRow,
  .multiViewGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .miniScreen {
    min-height: 92px;
  }
}

@media (max-width: 440px) {
  html,
  body {
    overflow-x: hidden;
  }

  .watchSurface {
    width: min(calc(100% - 16px), 420px);
    max-width: calc(100% - 16px);
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr);
    padding: 8px;
  }

  .topbar,
  .stageGrid,
  .playerStack,
  .television,
  .multiview,
  .channelRail {
    width: 100%;
    max-width: 100%;
  }

  .brand {
    max-width: 100%;
  }

  .brand span:last-child,
  .quickTuneInput {
    min-width: 0;
  }

  .brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .primaryButton {
    width: 100%;
    min-width: 78px;
    padding: 0 14px;
  }

  .roundButton {
    display: none;
  }

  .quickTune {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
  }

  .toolRow,
  .multiViewGrid {
    grid-template-columns: minmax(0, 1fr);
  }

  .toolButton {
    width: 100%;
  }

  .liveTune {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .liveTune::before {
    width: 48px;
    height: 48px;
  }

  .watchBadge {
    padding: 0 10px;
  }

  .roundButton {
    width: 42px;
    height: 42px;
  }

  .channelRail {
    padding: 10px;
  }

  .railHead {
    align-items: stretch;
    flex-direction: column;
  }

  .liveItem,
  .emptyState {
    grid-template-columns: 1fr;
  }

  .liveActions {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
