:root {
  --bg: #1c1e21;
  --bg-deep: #090b0f;
  --panel: #272a2f;
  --panel-strong: #34383f;
  --text: #ffffff;
  --text-secondary: #e4e6eb;
  --muted: #b0b3b8;
  --accent: #00d4ff;
  --accent-deep: #007b9d;
  --danger: #ff6b7a;
  --success: #58e6a9;
  --focus: 0 0 0 4px #ffffff, 0 0 24px rgba(0, 212, 255, 0.78);
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html,
body {
  width: 600px;
  height: 600px;
  margin: 0;
  overflow: hidden;
  background: #000000;
  color: var(--text);
  font-size: 16px;
  user-select: none;
}

body {
  position: relative;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#app {
  position: relative;
  width: 600px;
  height: 600px;
  overflow: hidden;
  background:
    radial-gradient(circle at 85% 5%, rgba(0, 212, 255, 0.12), transparent 38%),
    var(--bg);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  width: 600px;
  height: 600px;
  padding: 20px 24px 18px;
  overflow: hidden;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.screen[hidden] {
  display: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.muted {
  color: var(--muted);
}

.lead {
  max-width: 470px;
  margin: 38px 0 24px;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1.35;
}

.hero-header,
.app-header,
.screen-header,
.detail-header {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 0 0 auto;
}

.hero-header {
  min-height: 126px;
  padding-top: 12px;
}

.screen-header {
  min-height: 86px;
}

.screen-header.compact {
  min-height: 72px;
}

.app-header {
  min-height: 72px;
  justify-content: space-between;
}

.brand-mark {
  display: grid;
  width: 92px;
  height: 92px;
  flex: 0 0 auto;
  place-items: center;
  border: 4px solid var(--accent);
  border-radius: 30% 70% 66% 34% / 38% 38% 62% 62%;
  color: var(--text);
  font-size: 52px;
  font-weight: 900;
  text-shadow: 0 0 18px var(--accent);
  transform: rotate(-8deg);
}

.brand-mark.small {
  width: 70px;
  height: 70px;
  border-width: 3px;
  font-size: 39px;
}

.centered-state {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.centered-state.compact {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--bg);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.spinner.small {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.8s; }
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.action-button,
.text-input,
.result-item {
  width: 100%;
  min-height: 76px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: var(--panel);
}

.action-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  font-size: 20px;
  font-weight: 750;
  text-align: left;
}

.action-button.primary,
.player-button.primary {
  background: linear-gradient(135deg, var(--accent-deep), #00556d);
}

.button-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.focusable {
  cursor: default;
  opacity: 0.86;
  transition: opacity 100ms ease, transform 100ms ease, box-shadow 100ms ease;
}

.focusable:focus,
.focusable.focused {
  z-index: 3;
  outline: none;
  box-shadow: var(--focus);
  opacity: 1;
  transform: scale(0.97);
}

.focusable:active {
  transform: scale(0.93);
}

.status-line {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.status-line.error {
  color: var(--danger);
}

.status-line.success {
  color: var(--success);
}

.quick-code-panel {
  display: flex;
  min-height: 350px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 18px;
  border: 2px solid rgba(0, 212, 255, 0.34);
  border-radius: 24px;
  background: rgba(9, 11, 15, 0.72);
  text-align: center;
}

.quick-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 0.14em;
  line-height: 1;
  text-shadow: 0 0 22px rgba(0, 212, 255, 0.58);
}

.text-input {
  padding: 16px 18px;
  color: var(--text);
  font-size: 20px;
  user-select: text;
}

.text-input::placeholder {
  color: #858a91;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.icon-button,
.player-button {
  display: grid;
  width: 60px;
  height: 60px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 18px;
  background: var(--panel);
  font-size: 26px;
  font-weight: 800;
}

.icon-button.large {
  width: 76px;
  height: 76px;
}

.loading-row {
  display: flex;
  min-height: 430px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}

.scroll-region {
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.scroll-region::-webkit-scrollbar {
  display: none;
}

.home-rows {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 5px 32px;
}

.library-grid {
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 16px;
  overflow-y: auto;
  padding: 8px 5px 30px;
}

.library-card {
  min-width: 0;
  height: 206px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 20px;
  background: var(--panel);
  padding: 0;
  text-align: left;
}

.library-art,
.library-art-placeholder {
  display: block;
  width: 100%;
  height: 138px;
  object-fit: cover;
  background: linear-gradient(135deg, #313740, #181b20);
}

.library-art-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 42px;
  font-weight: 900;
}

.library-copy {
  display: block;
  overflow: hidden;
  padding: 12px 14px;
  font-size: 18px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-row + .media-row {
  margin-top: 20px;
}

.media-row h2 {
  margin: 0 0 10px 2px;
}

.media-row-empty {
  min-height: 66px;
  padding: 18px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(9, 11, 15, 0.32);
}

.media-track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 5px 5px 14px;
  scrollbar-width: none;
}

.media-track::-webkit-scrollbar {
  display: none;
}

.media-card {
  position: relative;
  width: 170px;
  min-width: 170px;
  height: 184px;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: var(--panel);
  padding: 0;
  text-align: left;
}

.media-art,
.media-art-placeholder {
  display: block;
  width: 170px;
  height: 104px;
  object-fit: cover;
  background: linear-gradient(135deg, #313740, #181b20);
}

.media-art-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 38px;
  font-weight: 900;
}

.media-copy {
  display: block;
  padding: 10px 12px 8px;
}

.media-title,
.media-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-title {
  font-size: 16px;
  font-weight: 750;
}

.media-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.card-progress {
  position: absolute;
  right: 10px;
  bottom: 6px;
  left: 10px;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
}

.card-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.empty-state {
  display: flex;
  min-height: 410px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  color: var(--muted);
  text-align: center;
}

.guide-window {
  min-height: 26px;
  padding: 0 2px 8px;
  font-size: 13px;
}

.guide-list {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 5px 5px 28px;
}

.channel-row {
  display: grid;
  width: 100%;
  min-height: 112px;
  flex: 0 0 auto;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: var(--panel);
  padding: 12px 14px;
  text-align: left;
}

.channel-logo,
.channel-logo-placeholder {
  width: 76px;
  height: 76px;
  border-radius: 14px;
  object-fit: contain;
  background: var(--panel-strong);
}

.channel-logo-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 22px;
  font-weight: 900;
}

.channel-copy,
.channel-line,
.channel-program,
.channel-next {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-line {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 750;
}

.channel-program {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 800;
}

.channel-next {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.search-form {
  display: flex;
  gap: 12px;
}

.search-form .text-input {
  min-width: 0;
  flex: 1 1 auto;
}

.result-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 5px 5px 28px;
}

#search-results {
  flex: 1 1 auto;
}

.result-item {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  color: var(--text);
  text-align: left;
}

.result-thumb,
.result-placeholder {
  width: 84px;
  height: 60px;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
  background: var(--panel-strong);
}

.result-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 24px;
}

.result-copy {
  min-width: 0;
}

.result-title,
.result-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-title {
  font-size: 18px;
  font-weight: 750;
}

.result-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.detail-screen {
  padding-bottom: 10px;
}

.detail-content {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 5px 60px;
}

.detail-header {
  align-items: flex-start;
}

.detail-image {
  width: 164px;
  height: 110px;
  flex: 0 0 auto;
  border-radius: 18px;
  object-fit: cover;
  background: var(--panel);
}

.detail-heading {
  min-width: 0;
  padding-top: 4px;
}

.detail-heading h1 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.overview {
  margin: 18px 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.4;
}

.detail-actions {
  margin: 12px 0 18px;
}

.detail-actions:empty,
#detail-children:empty {
  display: none;
}

.overlay-status {
  position: absolute;
  right: 24px;
  bottom: 10px;
  left: 24px;
  z-index: 4;
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(9, 11, 15, 0.9);
}

.player-screen {
  padding: 0;
  background: #000000;
}

.player-heading {
  position: absolute;
  top: 16px;
  right: 22px;
  left: 22px;
  z-index: 4;
  text-shadow: 0 2px 8px #000000;
}

.player-heading h1 {
  overflow: hidden;
  font-size: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-video {
  position: absolute;
  inset: 0;
  width: 600px;
  height: 600px;
  background: #000000;
  object-fit: contain;
}

.player-gradient {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.66), transparent 25%, transparent 58%, rgba(0, 0, 0, 0.94));
  pointer-events: none;
}

.player-overlay {
  position: absolute;
  right: 20px;
  bottom: 16px;
  left: 20px;
  z-index: 3;
}

.progress-readout {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 13px;
}

.progress-readout span:last-child {
  text-align: right;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.25);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.player-controls {
  display: flex;
  justify-content: center;
}

.player-button {
  width: 184px;
  height: 88px;
  border-radius: 20px;
  font-size: 22px;
}

.player-button.primary {
  font-size: 22px;
}

.toast {
  position: fixed;
  right: 28px;
  bottom: 24px;
  left: 28px;
  z-index: 20;
  padding: 14px 18px;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: rgba(9, 11, 15, 0.96);
  color: var(--text);
  text-align: center;
}

.toast.error {
  border-color: var(--danger);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}
