:root {
  color-scheme: dark;
  --bg: #10110f;
  --wall: #1b1c18;
  --wood: #442a19;
  --wood-2: #26170f;
  --metal: #767b78;
  --metal-dark: #262a2b;
  --glass: #050706;
  --panel: #171815;
  --panel-2: #242620;
  --button: #0c0d0c;
  --text: #f5f2e8;
  --muted: #b7b1a3;
  --line: rgba(255, 255, 255, 0.16);
  --green: #65f08c;
  --amber: #ffc857;
  --red: #ec5b4d;
  --cyan: #68d8cf;
  --blue: #6ca8ff;
  --shadow: rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(255, 200, 87, 0.13), transparent 30%),
    radial-gradient(circle at 86% 18%, rgba(104, 216, 207, 0.1), transparent 28%),
    linear-gradient(155deg, #202119 0%, #11120f 48%, #090a09 100%);
  background-size: 48px 48px, 48px 48px, auto, auto, auto;
  color: var(--text);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.tv-console {
  min-height: calc(100vh - 48px);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 18px;
  padding: clamp(18px, 2vw, 30px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.01)),
    linear-gradient(135deg, rgba(68, 42, 25, 0.42), rgba(16, 17, 15, 0.42) 44%, rgba(7, 8, 7, 0.9));
  box-shadow: 0 28px 90px var(--shadow);
}

.console-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.console-label {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2.4rem, 4.6vw, 5.2rem);
  line-height: 0.95;
}

.header-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-status span {
  min-width: 62px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.file-notice {
  margin: 0 0 16px;
  border: 1px solid rgba(255, 200, 87, 0.56);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 200, 87, 0.12);
}

.file-notice a {
  color: var(--amber);
  font-weight: 800;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: 24px;
  align-items: start;
}

.tv-set {
  min-width: 0;
  filter: drop-shadow(0 34px 42px rgba(0, 0, 0, 0.46));
}

.tv-frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 12px;
  padding: clamp(12px, 1.6vw, 20px);
  border: 8px solid #121412;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), transparent 18%),
    linear-gradient(180deg, #8a8d85, #363a39 42%, #171918 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    inset 0 -18px 38px rgba(0, 0, 0, 0.44);
}

.tv-glass {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.08), transparent 58%),
    #030504;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.82),
    inset 0 0 70px rgba(0, 0, 0, 0.72);
}

.tv-glass::before,
.tv-glass::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.tv-glass::before {
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0.18), transparent 25%),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.32));
  mix-blend-mode: screen;
}

.tv-glass::after {
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.045) 1px, transparent 1px, transparent 8px);
  opacity: 0.65;
}

.tv-glass iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.screen-overlay {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  min-height: 92px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.35));
  backdrop-filter: blur(8px);
}

.screen-overlay strong,
.channel-number,
.remote-display span,
.clock {
  font-family: Consolas, "Courier New", monospace;
}

.screen-overlay strong {
  color: var(--green);
  font-size: clamp(2.8rem, 6vw, 5.4rem);
  line-height: 0.9;
  text-shadow: 0 0 16px rgba(101, 240, 140, 0.38);
}

.screen-overlay h2 {
  margin-bottom: 5px;
  font-size: clamp(1.5rem, 3vw, 2.7rem);
  line-height: 1.05;
}

.screen-overlay p {
  margin-bottom: 0;
  color: var(--muted);
}

.screen-off {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  place-items: center;
  background: #030504;
  color: #383d38;
  font-family: Consolas, "Courier New", monospace;
  font-size: 5rem;
  font-weight: 800;
}

.tv-set.off .screen-off {
  display: grid;
}

.tv-side-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  min-height: 100%;
  border-radius: 10px;
  padding: 14px 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent),
    linear-gradient(180deg, #222620, #0d0f0d);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.clock {
  width: 100%;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(101, 240, 140, 0.32);
  border-radius: 6px;
  background: #050806;
  color: var(--green);
  font-weight: 800;
}

.signal-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  box-shadow: 0 0 16px currentColor;
}

.signal-dot.red {
  background: var(--red);
  color: var(--red);
}

.signal-dot.amber {
  background: var(--amber);
  color: var(--amber);
}

.speaker-lines {
  width: 48px;
  flex: 1;
  min-height: 160px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(to bottom, transparent, transparent 9px, rgba(255, 255, 255, 0.18) 10px, rgba(255, 255, 255, 0.18) 12px);
}

.tv-base {
  width: min(34%, 310px);
  height: 22px;
  margin: 0 auto;
  border-radius: 0 0 30px 30px;
  background: linear-gradient(180deg, #4c514d, #171a18);
}

.remote-panel {
  position: sticky;
  top: 18px;
}

.remote {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 24px;
  padding: 18px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.1), transparent 22%),
    linear-gradient(180deg, #32342f, #12130f 72%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 22px 48px rgba(0, 0, 0, 0.42);
}

.remote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--amber);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.remote-round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.power {
  background: #0b0c0b;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 1.4rem;
}

.remote-display {
  min-height: 86px;
  margin-bottom: 14px;
  border: 1px solid rgba(101, 240, 140, 0.25);
  border-radius: 8px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(101, 240, 140, 0.08), transparent),
    #030705;
  color: var(--green);
  text-align: center;
}

.remote-display span {
  display: block;
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1;
}

.remote-display small {
  display: block;
  margin-top: 8px;
  color: #93c99f;
}

.remote button,
.category-tab,
.channel-actions a,
.page-actions a,
.page-actions button {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--button);
  color: var(--text);
  font-weight: 800;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.remote button:hover,
.category-tab:hover,
.channel-card:hover,
.channel-actions a:hover,
.page-actions a:hover,
.page-actions button:hover {
  border-color: var(--amber);
  transform: translateY(-1px);
}

.remote-row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.remote-row.three {
  grid-template-columns: repeat(3, 1fr);
}

.remote-row.two {
  grid-template-columns: repeat(2, 1fr);
}

.remote-row button,
.remote-wide,
.keypad button {
  min-height: 44px;
  border-radius: 8px;
}

.dpad {
  width: 186px;
  margin: 0 auto 14px;
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
}

.dpad button {
  border-radius: 8px;
}

.dpad button[data-action="up"] {
  grid-column: 2;
}

.dpad button[data-action="left"] {
  grid-column: 1;
  grid-row: 2;
}

.dpad .ok {
  grid-column: 2;
  grid-row: 2;
  background: var(--amber);
  color: #16120a;
}

.dpad button[data-action="right"] {
  grid-column: 3;
  grid-row: 2;
}

.dpad button[data-action="down"] {
  grid-column: 2;
  grid-row: 3;
}

.remote-wide {
  width: 100%;
  margin-bottom: 12px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.keypad button {
  font-size: 1.15rem;
}

.category-dock {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent),
    linear-gradient(180deg, rgba(68, 42, 25, 0.7), rgba(38, 23, 15, 0.86));
}

.category-tab {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  min-height: 86px;
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent),
    #141510;
}

.category-tab.active {
  border-color: rgba(101, 240, 140, 0.76);
  background:
    linear-gradient(180deg, rgba(101, 240, 140, 0.18), transparent),
    #151a13;
}

.category-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 200, 87, 0.14);
  color: var(--amber);
  font-size: 1.35rem;
}

.category-tab strong {
  align-self: end;
  font-size: 1.35rem;
}

.category-tab small {
  align-self: start;
  color: var(--muted);
  font-size: 0.88rem;
}

.channel-page {
  min-height: 100vh;
  padding-top: 28px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.page-head h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.page-actions a,
.page-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  text-decoration: none;
}

.page-actions a {
  background: rgba(101, 240, 140, 0.13);
}

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

.channel-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent),
    #151713;
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.26);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.channel-card.active {
  border-color: rgba(101, 240, 140, 0.76);
  background:
    linear-gradient(180deg, rgba(101, 240, 140, 0.12), transparent),
    #151a13;
}

.preview-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--glass);
}

.preview-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.preview-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.12), transparent 26%),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 8px);
}

.preview-frame span {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.66);
  color: var(--text);
  font-size: 0.82rem;
}

.channel-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.channel-number {
  color: var(--green);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  font-weight: 800;
  line-height: 0.95;
  text-shadow: 0 0 12px rgba(101, 240, 140, 0.28);
}

.channel-copy h3 {
  margin: 2px 0 7px;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.16;
}

.channel-copy p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.45;
}

.channel-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.channel-actions button,
.channel-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  text-decoration: none;
}

.channel-actions button {
  background: var(--amber);
  color: #17120a;
}

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

  .remote-panel {
    position: static;
  }

  .remote {
    max-width: 430px;
    margin: 0 auto;
  }
}

@media (max-width: 840px) {
  .app-shell {
    padding: 14px;
  }

  .tv-console {
    min-height: calc(100vh - 28px);
    padding: 16px;
  }

  .console-header,
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .header-status,
  .page-actions {
    justify-content: flex-start;
  }

  .tv-frame {
    grid-template-columns: 1fr;
  }

  .tv-side-panel {
    display: none;
  }

  .screen-overlay {
    left: 10px;
    right: 10px;
    bottom: 10px;
    min-height: 76px;
    padding: 10px;
  }

  .category-dock,
  .channel-grid {
    grid-template-columns: 1fr;
  }

  .category-tab {
    min-height: 72px;
  }

  .channel-page {
    min-height: auto;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 2.35rem;
  }

  .screen-overlay strong {
    font-size: 2.5rem;
  }

  .screen-overlay h2 {
    font-size: 1.2rem;
    overflow-wrap: anywhere;
  }

  .remote {
    padding: 14px;
  }

  .dpad {
    width: 168px;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 48px);
  }

  .channel-body {
    grid-template-columns: 1fr;
  }

  .channel-actions {
    grid-template-columns: 1fr;
  }
}
