:root {
  --bg: #0f0f12;
  --panel: #18181d;
  --line: #26262d;
  --text: #f2f2f5;
  --muted: #9a9aa6;
  --accent: #ff4d5e;
  --yt: #ff3b3b;
  --rt: #2f8cff;
  --vk: #4c8dff;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(24px + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 16px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 8px; }
h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.top p { margin: 0; color: var(--muted); font-size: 13px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line);
}
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.stage {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding-top: var(--safe-t); border-bottom: 1px solid var(--line);
}
.frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.frame .layer { position: absolute; inset: 0; }
.frame iframe, .frame video { display: block; width: 100%; height: 100%; border: 0; background: #000; }
.now { display: flex; gap: 10px; align-items: center; padding: 10px 16px 12px; }
.now-text { flex: 1; min-width: 0; }
.now h2 {
  margin: 2px 0 0; font-size: 14px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ctrls { display: flex; gap: 6px; }

.badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge.youtube { color: var(--yt); }
.badge.rutube { color: #19c3ff; }
.badge.vk { color: var(--vk); }
.srcs { display: flex; gap: 6px; align-items: center; }
.badge.switch {
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel);
}
.badge.switch.on { border-color: currentColor; }
.srcs .ext { font-size: 12px; color: var(--vk); text-decoration: none; margin-left: 4px; }

.tools { padding: 8px 16px 4px; }
input[type=search] {
  width: 100%; padding: 11px 14px; border-radius: 12px; font-size: 16px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); outline: none;
  -webkit-appearance: none; appearance: none;
}
input[type=search]:focus { border-color: #44444f; }
.chips { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.install {
  margin: 10px 16px 0; padding: 10px 12px; border-radius: 12px;
  background: #1f1d2a; border: 1px solid #34304a; font-size: 13px;
  display: flex; align-items: center; gap: 10px;
}
.install span { flex: 1; }
.install #install-btn { background: var(--accent); color: #fff; padding: 6px 12px; border-radius: 8px; font-weight: 600; }
.install .x { font-size: 20px; color: var(--muted); padding: 0 4px; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.item { display: flex; gap: 12px; padding: 8px 16px; align-items: flex-start; cursor: pointer; }
.item:active { background: var(--panel); }
.item.playing { background: #1d1a20; }
.thumb {
  position: relative; flex: none; width: 140px; aspect-ratio: 16 / 9; border-radius: 10px;
  overflow: hidden; background: var(--panel);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dur {
  position: absolute; right: 5px; bottom: 5px; font-size: 11px; padding: 1px 5px;
  border-radius: 4px; background: rgba(0,0,0,.75);
}
.item.seen .thumb::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent);
}
.meta { flex: 1; min-width: 0; padding-top: 1px; }
.meta h3 {
  margin: 0; font-size: 14px; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.item.seen .meta h3 { color: var(--muted); }
.sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 5px; }
.sub .dot { color: #55555f; font-size: 11px; }
.sub .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.del {
  flex: none; width: 36px; height: 36px; margin: 0 -8px 0 -4px; border-radius: 10px;
  display: grid; place-items: center; color: #6c6c78;
}
.del svg { width: 19px; height: 19px; }
.del:active { background: var(--line); color: var(--accent); }

.sortbar { display: flex; gap: 8px; margin-top: 10px; }
.sort {
  flex: 1; min-width: 0; position: relative; display: flex; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding-left: 10px;
}
.sort svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.sort select {
  flex: 1; min-width: 0; appearance: none; -webkit-appearance: none; background: none; border: 0;
  color: var(--text); font: inherit; font-size: 14px; padding: 9px 10px 9px 8px; outline: none;
}
.pill {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); font-size: 14px;
}
.pill svg { width: 18px; height: 18px; }
.pill:active { border-color: var(--accent); color: var(--accent); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + var(--safe-b)); z-index: 20;
  max-width: 480px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px; background: #2a2a33; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  font-size: 14px;
}
.toast span { flex: 1; }
.toast button { color: var(--accent); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.foot { text-align: center; color: #5d5d68; font-size: 12px; padding: 20px 16px 0; }

@media (min-width: 720px) {
  body { max-width: 720px; margin: 0 auto; }
  .thumb { width: 180px; }
}
