:root {
  --bg: #FFFFFF; --ink: #0F0F0F; --muted: #606060; --chip: #F2F2F2; --chip-hover: #E5E5E5; --line: #E5E5E5;
  --red: #E5322D; --red-ink: #FFFFFF; --fresh: #0A8A4F; --focus: #065FD4; --overlay: rgb(0 0 0 / .8);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F0F0F; --ink: #F1F1F1; --muted: #AAAAAA; --chip: #272727; --chip-hover: #3F3F3F; --line: #303030;
    --red: #FF4E45; --red-ink: #0F0F0F; --fresh: #3FCF8E; --focus: #3EA6FF;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.45 Roboto, Arial, sans-serif; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ico { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 16px; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 8px; flex: none; text-decoration: none; font-size: 18px; font-weight: 500; letter-spacing: -.02em; padding: 0 8px 0 4px; }
.logo { width: 32px; height: 24px; display: block; }
.searchbox { position: relative; flex: 0 1 600px; margin: 0 auto; }
.searchbox input { width: 100%; height: 40px; padding: 0 44px 0 18px; font: inherit; font-size: 16px; color: var(--ink);
                   background: var(--bg); border: 1px solid var(--line); border-radius: 40px; box-shadow: inset 0 1px 2px rgb(0 0 0 / .06); }
.searchbox input:focus { outline: none; border-color: var(--focus); }
.kbd { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; display: grid; place-items: center;
       border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 12px; pointer-events: none; }
.searchbox input:focus + .kbd { display: none; }
.top-link { margin-left: auto; flex: none; padding: 8px 14px; border-radius: 18px; text-decoration: none; font-weight: 500; color: var(--muted); }
.searchbox + .top-link { margin-left: 0; }
.top-link:hover { background: var(--chip); color: var(--ink); }

/* layout + guide */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.side { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; padding: 4px 12px 24px; scrollbar-width: thin; }
.side h2 { margin: 0; padding: 16px 12px 6px; font-size: 16px; font-weight: 500; border-top: 1px solid var(--line); }
.side .home { margin-bottom: 12px; }
.side ul { list-style: none; margin: 0 0 12px; padding: 0; }
.side .item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px; text-decoration: none; }
.side .item:hover { background: var(--chip); }
.side .item[aria-current] { background: var(--chip); font-weight: 500; }
.side .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; font-weight: 500; color: var(--fresh); font-variant-numeric: tabular-nums; }
.mnav { display: none; }

.main { padding: 16px 24px 64px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; margin: 8px 0 16px; }
h1 { margin: 0; font-size: 32px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.lang { display: inline-block; vertical-align: middle; margin-left: 10px; padding: 3px 8px; border-radius: 6px; background: var(--chip);
        font-size: 13px; font-weight: 500; color: var(--muted); position: relative; top: -3px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* buttons */
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border: 0; border-radius: 18px;
       background: var(--chip); color: var(--ink); font: 500 14px/1 Roboto, Arial, sans-serif; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--chip-hover); }
.btn.rss { background: var(--red); color: var(--red-ink); }
.btn.rss:hover { filter: brightness(1.08); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 16px; }
.btn.small .ico { width: 18px; height: 18px; }

/* tabs, like a channel page */
.tabs { display: flex; gap: 8px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.tabs button { font: 500 16px/1 Roboto, Arial, sans-serif; padding: 14px 12px 12px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent;
               background: none; color: var(--muted); cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button span { margin-left: 4px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }

/* filter chips */
.chips { position: sticky; top: 56px; z-index: 5; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 8px 0 12px; background: var(--bg); }
.chip { height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--chip); color: var(--ink); font: 500 14px/32px Roboto, Arial, sans-serif; cursor: pointer; }
.chip:hover { background: var(--chip-hover); }
select.chip { max-width: 260px; padding-right: 8px; }
.toggle { display: inline-flex; align-items: center; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle:has(input:checked) { background: var(--ink); color: var(--bg); }
.toggle:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.count { margin-left: auto; color: var(--muted); }

/* video grid */
.day { margin: 24px 0 12px; font-size: 20px; font-weight: 700; }
#list > section:first-child .day { margin-top: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 40px 16px; }
.video { display: block; text-decoration: none; border-radius: 12px; }
.video[hidden], section[hidden] { display: none; }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--chip); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img { transition: filter .15s ease; }
.video:hover .thumb img { filter: brightness(1.08); }
.tag { position: absolute; right: 8px; bottom: 8px; padding: 1px 5px; border-radius: 4px; background: rgb(0 0 0 / .8); color: #fff; font-size: 12px; font-weight: 500; }
.tag.new { left: 8px; right: auto; background: var(--fresh); }
.video h3 { margin: 12px 0 4px; font-size: 16px; font-weight: 500; line-height: 22px;
            display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video p { margin: 0; color: var(--muted); font-size: 14px; line-height: 20px; }
.video p b { display: block; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video:hover p b { color: var(--ink); }
.empty { padding: 64px 16px; text-align: center; color: var(--muted); font-size: 16px; }
.empty p { margin: 0 0 16px; }

/* index rows + channel list */
.howto { margin: 0 0 8px; color: var(--muted); font-size: 14px; max-width: 760px; }
.howto p { margin: 0 0 4px; }
.howto b { color: var(--ink); font-weight: 500; }
.lang-block h2 { margin: 28px 0 8px; font-size: 20px; font-weight: 700; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 20px; padding: 10px 12px; margin: 0 -12px; border-radius: 12px; }
.row:hover { background: var(--chip); }
.row .title { display: flex; flex-direction: column; min-width: 0; }
.row .title > a { text-decoration: none; }
.row .title strong { font-size: 16px; font-weight: 500; }
.row .title span { font-size: 13px; color: var(--muted); }
.quiet { color: inherit; text-decoration: none; }
.quiet:hover { color: var(--ink); text-decoration: underline; }
.strip { display: flex; gap: 6px; }
.strip img { width: 104px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--chip); display: block; }
.row .actions { justify-content: flex-end; }
.row:hover .btn:not(.rss) { background: var(--chip-hover); }
#panel-channels > .sub { margin: 0 0 8px; }
.sources .row { grid-template-columns: minmax(0, 1fr) auto 190px auto; }
.stat { color: var(--muted); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* player */
dialog { padding: 0; border: 0; border-radius: 12px; background: var(--bg); color: var(--ink); width: min(1100px, 94vw); overflow: hidden; }
dialog::backdrop { background: var(--overlay); }
.frame { aspect-ratio: 16 / 9; background: #000; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.dialog-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.dialog-bar div { flex: 1; min-width: 0; }
.dialog-bar strong { display: block; font-size: 18px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-bar span { font-size: 14px; color: var(--muted); }

.toast { position: fixed; left: 24px; bottom: 24px; transform: translateY(20px); opacity: 0; pointer-events: none; z-index: 20;
         padding: 14px 20px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 14px; transition: .2s ease; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1100px) { .strip img:nth-child(n+3) { display: none; } }
@media (max-width: 820px) {
  .app { display: block; }
  .side { display: none; }
  .top { gap: 8px; padding: 0 12px; }
  .brand span { display: none; }
  .searchbox input { font-size: 15px; }
  .kbd { display: none; }
  .mnav { display: block; padding: 4px 16px 8px; }
  .mnav select { width: 100%; height: 40px; font: inherit; font-size: 15px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--chip); color: var(--ink); }
  .main { padding: 8px 16px 48px; }
  h1 { font-size: 26px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .strip { display: none; }
  .row .actions { justify-content: flex-start; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 28px 12px; }
  .sources .row { grid-template-columns: auto auto minmax(0, 1fr); gap: 6px 12px; }
  .sources .row .title { grid-column: 1 / -1; }
  .sources .row .btn { grid-column: 1 / -1; justify-self: start; }
  .stat { text-align: left; }
  .toast { left: 16px; right: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.subscribe { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.subscribe .actions[hidden] { display: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 18px; background: var(--chip); }
.seg label { position: relative; padding: 0 12px; height: 30px; line-height: 30px; border-radius: 15px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .15); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.howto a.quiet { text-decoration: underline; }
.langline { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.opml { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; scroll-margin-top: 72px; }
.opml span { color: var(--muted); margin-right: 4px; }
.star { width: 18px; height: 18px; flex: none; fill: #F2B200; }
h1 .star { width: 28px; height: 28px; margin-right: 8px; vertical-align: -2px; }
.row .title > a { display: flex; align-items: center; gap: 6px; }
.empty b { color: var(--ink); font-weight: 500; }
