:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #eef5ff;
  --text: #172033;
  --muted: #69758a;
  --line: #e3e9f2;
  --accent: #2563eb;
  --accent-soft: #eaf2ff;
  --success: #16845b;
  --focus: #60a5fa;
  --shadow: 0 8px 24px rgba(31, 55, 90, 0.07);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Poppins", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  height: 100dvh;
  padding: 22px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

.app-header h1, .app-header p, h2, p { margin: 0; }
.app-header h1 { font-size: 25px; line-height: 1.15; letter-spacing: 0; font-weight: 800; }
.app-header p { margin-top: 3px; color: var(--muted); font-size: 13px; }

.quick-actions { display: flex; gap: 8px; }
.quick-actions a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(31, 55, 90, 0.03);
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.quick-actions a:hover { border-color: #b9cdf0; background: var(--accent-soft); color: var(--accent); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  min-height: 0;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

.player-section, .guide-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.player-section { display: grid; grid-template-rows: auto minmax(260px, 1fr) auto; min-width: 0; min-height: 0; }
.player-head, .guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}
.eyebrow { display: block; color: var(--accent); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.player-head h2, .guide-head h2 { font-size: 18px; line-height: 1.25; font-weight: 700; }
.guide-title { display: flex; align-items: center; gap: 9px; }
.filter-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}
.filter-button span { color: #e2556d; font-size: 18px; line-height: 1; }
.filter-button:hover, .filter-button.is-active { border-color: #f0a6b4; background: #fff1f3; color: #c43f58; }
.proxy-pill, .count-pill {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid #cfe0fb;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 11px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.video-wrap { position: relative; display: grid; min-height: 0; place-items: center; background: #101827; }
video { width: 100%; height: 100%; min-height: 360px; background: #101827; object-fit: contain; }
.empty-player { position: absolute; inset: 0; display: grid; place-items: center; color: #c8d2e2; font-size: 14px; font-weight: 600; pointer-events: none; }
.empty-player.is-hidden { display: none; }
.status { min-height: 52px; padding: 14px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.guide-section { display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-height: 0; }
.search-box { display: grid; gap: 7px; padding: 15px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; }
.search-box svg { display: none; }
.search-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 13px;
  font-size: 13px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.search-box input::placeholder { color: #9aa6b8; }
.search-box input:focus { border-color: var(--focus); background: var(--surface); box-shadow: 0 0 0 3px rgba(96, 165, 250, .18); }

.channel-list { min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 11px; overscroll-behavior: contain; }
.channel-row { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 7px; margin-bottom: 8px; }
.channel-button {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 11px;
  width: 100%;
  min-height: 62px;
  align-items: center;
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px;
  text-align: left;
  transition: border-color .2s ease, background .2s ease, transform .2s ease, box-shadow .2s ease;
}
.channel-button:hover { border-color: #b9cdf0; background: var(--surface-hover); transform: translateY(-1px); }
.channel-button.is-active { border-color: #8ab4f8; background: var(--accent-soft); box-shadow: 0 3px 10px rgba(37, 99, 235, .08); }
.channel-button:focus-visible, .favorite-button:focus-visible, .filter-button:focus-visible, .quick-actions a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.favorite-button {
  min-width: 40px;
  min-height: 40px;
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #a6b0bf;
  font-size: 22px;
  line-height: 1;
  transition: border-color .2s ease, background .2s ease, color .2s ease, transform .2s ease;
}
.favorite-button:hover { border-color: #f0a6b4; background: #fff1f3; color: #e2556d; transform: scale(1.04); }
.favorite-button.is-favorite { border-color: #f0a6b4; background: #fff1f3; color: #e2556d; }
.channel-logo { display: grid; width: 40px; height: 40px; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #edf2f8; color: #718096; font-size: 11px; font-weight: 800; }
.channel-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; background: #fff; }
.channel-name, .channel-meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-name { font-size: 13px; font-weight: 700; }
.channel-meta { margin-top: 2px; color: var(--muted); font-size: 11px; }
.play-mark { color: var(--success); font-size: 11px; font-weight: 800; }
.empty-list { display: grid; min-height: 120px; place-items: center; color: var(--muted); font-size: 13px; text-align: center; }
.list-progress { padding: 14px 8px 18px; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 900px) {
  .app-shell { height: auto; min-height: 100dvh; }
  .content-grid { grid-template-columns: 1fr; }
  .guide-section { height: min(560px, 68dvh); min-height: 360px; }
  video { min-height: 240px; aspect-ratio: 16 / 9; }
}
@media (max-width: 520px) {
  .app-shell { padding: 12px; gap: 12px; }
  .app-header { align-items: flex-start; flex-direction: column; }
  .quick-actions { width: 100%; }
  .quick-actions a { flex: 1; justify-content: center; }
  .player-head, .guide-head { padding: 14px; }
  .channel-row { grid-template-columns: minmax(0, 1fr) 36px; }
  .channel-button { grid-template-columns: 36px minmax(0, 1fr); }
  .play-mark { display: none; }
  .channel-logo { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
