/* Brand colours, sampled from the YK Tv Network logo */
:root {
  --yellow: #f2c102; --red: #ee2125; --ink: #262626;
  color-scheme: light;
  --bg: #f6f5f1; --card: #fff; --sunken: #faf8f2; --text: #262626; --muted: #67635a; --line: #e6e2d6;
  --accent: var(--yellow); --accent-hover: #dcae00; --accent-ink: #1c1c1c; --danger: #c4161a; --link: #c4161a; --focus: #262626; --chip: #efece2;
  --videos: #5c4800; --videos-bg: #fdeeb0; --shorts: #fff; --shorts-bg: #3a3a3a; --live: #b81317; --live-bg: #fde3e3;
  --shadow: 0 1px 2px rgb(38 38 38 / .05), 0 6px 20px rgb(38 38 38 / .05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #131312; --card: #1e1d1b; --sunken: #262522; --text: #f3f1ea; --muted: #aaa598; --line: #37342e;
    --danger: #ff8a8c; --link: var(--yellow); --focus: var(--yellow); --chip: #33302a;
    --videos: #ffd84a; --videos-bg: #423600; --shorts: #262626; --shorts-bg: #dedbd2; --live: #ff9495; --live-bg: #4d1a1b;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--text); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
a { color: inherit; }
h2, h3 { text-wrap: balance; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Controls */
input, select { font: inherit; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--text); }
button { font: inherit; height: 38px; cursor: pointer; border: 0; border-radius: 9px; padding: 0 16px; background: var(--accent); color: var(--accent-ink); font-weight: 600; transition: background .15s; }
button:hover:not(:disabled) { background: var(--accent-hover); }
button.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.secondary:hover:not(:disabled) { background: var(--chip); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* Status messages */
.status { margin: 0; color: var(--muted); }
.status:empty { display: none; }
.status.error { color: var(--danger); font-weight: 500; }
/* While loading, the message shows in the loader; kept here for screen readers */
.status.busy { position: absolute; width: 1px; height: 1px; padding: 0 !important; margin: -1px !important; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes spin { to { transform: rotate(1turn); } }

/* Header */
.top { position: sticky; top: 0; z-index: 5; background: var(--ink); color: #fff; border-bottom: 3px solid var(--yellow); margin-bottom: 20px; }
.top-row { display: flex; align-items: center; gap: 28px; padding-block: 10px; }
.brand { text-decoration: none; border-radius: 9px; display: flex; align-items: center; gap: 10px; flex: none; }
.brand img { width: 42px; height: 42px; display: block; border-radius: 50%; border: 2px solid #fff; background: #fff; }
h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.search { display: flex; gap: 8px; flex: 1; max-width: 680px; margin-left: auto; }
.search input { flex: 1; min-width: 0; background: #3a3a3a; border-color: #555; color: #fff; }
.search input::placeholder { color: #bdb9ae; }
.search { position: relative; }
.suggest { position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; right: 0; max-height: min(460px, 65vh); overflow-y: auto; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgb(0 0 0 / .28); padding: 6px; }
.suggest-row { display: flex; gap: 12px; align-items: center; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.suggest-row:hover { background: var(--chip); }
.suggest-row[aria-selected="true"] { background: var(--yellow); color: #1c1c1c; }
.suggest-row[aria-selected="true"] small { color: inherit; }
.suggest-row img { width: 36px; height: 36px; border-radius: 50%; background: var(--chip); flex: none; }
.suggest-row span { min-width: 0; }
.suggest-row b { display: block; font-weight: 600; line-height: 1.3; }
.suggest-row small { color: var(--muted); font-size: 12.5px; }
.suggest-search:not(:first-child) { border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 4px; padding-block: 10px; }
.suggest-search span { overflow-wrap: anywhere; }
.top :focus-visible { outline-color: var(--yellow); }
.top .status { color: #dcd8cc; }
.top .status.error { color: #ff9c9d; }
.top .status { padding-bottom: 12px; }

/* Welcome */
.welcome { padding: 28px 0 16px; display: grid; gap: 36px; }
.home-hero { text-align: center; padding: 28px 16px 4px; }
.welcome h2 { margin: 0 0 10px; font-size: 34px; line-height: 1.15; letter-spacing: -.02em; }
.home-hero p { margin: 0 auto 22px; max-width: 62ch; color: var(--muted); font-size: 15.5px; }
.home-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.home-actions button, .home-btn { height: 42px; padding: 0 20px; font-size: 15px; }
.home-btn { display: inline-flex; align-items: center; border-radius: 9px; background: var(--ink); color: #fff; font-weight: 600; text-decoration: none; }
.home-btn:hover { background: #3a3a3a; }
.home-popular h3 { margin: 0 0 12px; font-size: 15px; padding-left: 10px; border-left: 4px solid var(--red); line-height: 1.25; }
.home-channels { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.home-ch { height: auto; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 10px 12px; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; font-weight: 400; box-shadow: var(--shadow); }
.home-ch:hover:not(:disabled) { background: var(--card); border-color: var(--yellow); }
.home-ch img { grid-row: span 2; width: 40px; height: 40px; border-radius: 50%; background: var(--chip); }
.home-ch b { font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-ch small { color: var(--muted); font-size: 12px; }
.home-features { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.home-card { display: block; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
a.home-card:hover { border-color: var(--yellow); }
.home-card h3 { margin: 12px 0 6px; font-size: 16px; }
.home-card p { margin: 0; color: var(--muted); }
.home-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--yellow); color: #1c1c1c; }
.home-features .home-card:nth-child(2) .home-ico { background: var(--red); color: #fff; }
.home-features .home-card:nth-child(3) .home-ico { background: var(--ink); color: #fff; }
.home-ico svg { width: 22px; height: 22px; }

/* Channel choices */
.candidates { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); margin-bottom: 20px; }
.cand { height: auto; display: flex; gap: 12px; align-items: center; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--line); padding: 12px; font-weight: 400; }
.cand:hover:not(:disabled) { border-color: var(--accent); background: var(--card); }
.cand img { width: 46px; height: 46px; border-radius: 50%; flex: none; }
.cand b { display: block; }

/* Channel profile */
.channel-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.cover { aspect-ratio: 6 / 1; min-height: 110px; width: 100%; background:
  linear-gradient(115deg, transparent 62%, var(--red) 62% 65%, transparent 65%),
  linear-gradient(115deg, var(--ink) 66%, var(--yellow) 66%); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile { display: flex; align-items: center; gap: 20px; padding: 16px 28px 20px; }
.profile > img { width: 112px; height: 112px; margin-top: -60px; border-radius: 50%; flex: none; align-self: flex-start; position: relative; background: var(--card); border: 5px solid var(--card); box-shadow: 0 0 0 3px var(--yellow); }
.ch-info { min-width: 0; flex: 1; }
.ch-info h2 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; overflow-wrap: anywhere; }
.ch-info p { margin: 3px 0 0; }
.ch-info a { font-weight: 600; text-decoration-color: var(--yellow); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.ch-info a:hover { color: var(--link); }
.ch-figures { display: flex; gap: 32px; flex: none; }
.ch-figures .val { display: block; font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
.ch-figures .label { color: var(--muted); font-size: 12.5px; }

/* Panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; padding-left: 10px; border-left: 4px solid var(--red); line-height: 1.25; }
.day-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.day-form label { color: var(--muted); }
.day-to { display: inline-flex; gap: 10px; align-items: center; }
.day-form .day-check { display: inline-flex; gap: 6px; align-items: center; color: var(--text); cursor: pointer; margin-right: 4px; }
.day-check input { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--accent); }
.day-hint, .day-panel > .status { padding: 18px 20px; margin: 0; }
#dayResult { padding: 16px 20px 18px; }
.day-panel h3 { margin: 0; font-size: 15px; }
.day-head { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--sunken); }
.metric .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.metric .ico svg { width: 22px; height: 22px; }
.metric.views .ico { background: var(--yellow); color: #1c1c1c; }
.metric.likes .ico { background: var(--red); color: #fff; }
.metric.comments .ico { background: var(--shorts-bg); color: var(--shorts); }
.metric .label, .metric .val { display: block; }
.metric .label { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.metric .val { font-size: 24px; line-height: 1.25; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.day-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat { display: inline-flex; gap: 7px; align-items: baseline; border-radius: 9px; padding: 5px 12px; background: var(--chip); }
.stat .val { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 12.5px; }
.stat.videos { background: var(--videos-bg); color: var(--videos); }
.stat.shorts { background: var(--shorts-bg); color: var(--shorts); }
.stat.live { background: var(--live-bg); color: var(--live); }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.day-table { width: 100%; border-collapse: collapse; }
.day-table th, .day-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.day-table th { background: var(--sunken); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.day-table tbody tr:hover { background: var(--sunken); }
.day-table td:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.day-table .title { white-space: normal; min-width: 300px; }
.day-table .title-btn { display: flex; gap: 12px; align-items: center; width: 100%; height: auto; padding: 0; background: none; color: inherit; text-align: left; font-weight: 500; line-height: 1.4; border-radius: 6px; }
.day-table .title-btn:hover:not(:disabled) { background: none; }
.day-table .title-btn:hover span { text-decoration: underline; color: var(--link); }
.day-table .title img { width: 72px; height: 41px; object-fit: cover; border-radius: 6px; background: var(--chip); flex: none; }
.day-table .n, .day-table td:last-child { font-variant-numeric: tabular-nums; }
.day-table .n { text-align: right; }
.day-table tfoot td { font-weight: 700; border-bottom: 0; background: var(--sunken); }
.badge { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.badge.videos { background: var(--videos-bg); color: var(--videos); }
.badge.shorts { background: var(--shorts-bg); color: var(--shorts); }
.badge.live { background: var(--live-bg); color: var(--live); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 12px; }
.pager select { height: 32px; padding: 0 8px; margin-left: 6px; }
.pager-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pager button { height: 32px; padding: 0 12px; }
#dayResult > p:last-child { margin: 12px 0 0; }

.th-btn { height: auto; padding: 2px 0; background: none; color: inherit; font-weight: 600; border-radius: 4px; white-space: nowrap; }
.th-btn:hover:not(:disabled) { background: none; color: var(--text); }
.th-btn span { display: inline-block; width: 1.2em; margin-left: 4px; text-align: center; opacity: .6; font-size: 11px; }
.th-btn.on { color: var(--text); }
.th-btn.on span { opacity: 1; color: var(--red); }
.th-select { height: 30px; padding: 0 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.th-select.on { background: var(--yellow); border-color: var(--yellow); color: #1c1c1c; }
.th-select option { background: var(--card); color: var(--text); }

@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .top { position: relative; }
  .top-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .search { max-width: none; width: 100%; margin: 0; }
  .welcome { padding-top: 8px; gap: 28px; }
  .welcome h2 { font-size: 26px; }
  .home-channels { grid-template-columns: 1fr 1fr; }
  .profile { flex-wrap: wrap; gap: 10px 14px; padding: 12px 16px 16px; }
  .profile > img { width: 80px; height: 80px; margin-top: -44px; }
  .ch-info { flex-basis: 100%; }
  .ch-info h2 { font-size: 21px; }
  .ch-figures { gap: 24px; }
  .ch-figures .val { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Footer: stays at the bottom of the window on short pages */
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; width: 100%; }
.footer { background: var(--ink); color: #fff; border-top: 3px solid var(--yellow); margin-top: 16px; }
.footer .wrap { display: flex; flex-wrap: wrap; gap: 4px 20px; justify-content: space-between; padding-block: 18px; }
.footer a { color: var(--yellow); font-weight: 700; text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer :focus-visible { outline-color: var(--yellow); }
.footer-note { color: #bdb9ae; font-size: 12.5px; }

/* Play buttons */
.play { display: grid; place-items: center; width: 32px; height: 32px; margin: 0 auto; border-radius: 50%; background: var(--red); color: #fff; transition: background .15s; }
.play:hover { background: #c4161a; }
.play svg { width: 17px; height: 17px; }
.play-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px 0 11px; border-radius: 9px; background: #d3171b; color: #fff; font-weight: 600; text-decoration: none; }
.play-btn:hover { background: #b81317; }
.play-btn svg { width: 18px; height: 18px; }

/* Details popup */
dialog { width: min(860px, 94vw); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-top: 5px solid var(--yellow); border-radius: var(--radius); background: var(--card); color: var(--text); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgb(20 20 18 / .65); }
.dlg-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 4px 0 0; font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
button.icon { background: transparent; color: var(--muted); padding: 0 10px; font-size: 16px; flex: none; }
button.icon:hover:not(:disabled) { background: var(--chip); }
#dBody { padding: 18px 20px; overflow-y: auto; min-height: 0; }
.dlg-foot { display: flex; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--sunken); }
.d-top { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
.d-top img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: var(--chip); display: block; }
.d-figures { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 10px; }
.d-figures .val { display: block; font-size: 21px; line-height: 1.2; font-weight: 700; }
.d-figures .label { color: var(--muted); font-size: 12.5px; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 16px 4px 0; white-space: nowrap; vertical-align: top; width: 1%; }
.kv td { padding: 4px 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chip); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--sunken); border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
#dBody h4 { margin: 18px 0 8px; font-size: 14px; }
#dBody p { margin: 0; }
@media (max-width: 760px) { .d-top { grid-template-columns: 1fr; } }

/* Loader: covers the page below the header */
.loader { position: fixed; inset: 0; z-index: 4; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(3px); }
.loader-box { display: grid; justify-items: center; gap: 16px; padding: 70px 20px 20px; text-align: center; }
.loader-ring { position: relative; width: 116px; height: 116px; display: grid; place-items: center; }
.loader-ring::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 6px solid color-mix(in srgb, var(--yellow) 28%, transparent); border-top-color: var(--yellow); border-right-color: var(--red); animation: spin .9s linear infinite; }
.loader-ring img { border-radius: 50%; animation: breathe 1.8s ease-in-out infinite; }
.loader p { margin: 0; font-weight: 600; max-width: 42ch; min-height: 1.5em; }
@keyframes breathe { 50% { transform: scale(.93); } }
@media (prefers-reduced-motion: reduce) { .loader-ring::before { animation-duration: 3s; } .loader-ring img { animation: none; } }
