:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-2: #1b1f26;
  --line: #262b33;
  --text: #eef0f3;
  --muted: #8b939f;
  --accent: #f5a524;
  --accent-ink: #1c1303;
  --danger: #ff7a6b;
  --radius: 16px;
  --tap: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 20px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h2 { font-size: 22px; font-weight: 650; margin: 28px 0 14px; letter-spacing: .01em; }

/* ------------------------------------------------------------ buttons -- */
.btn {
  min-height: 56px; padding: 0 26px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 650; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 44px; padding: 0 18px; font-size: 17px; }
.btn.wide { width: 100%; }
.btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.2;
           stroke-linecap: round; stroke-linejoin: round; }
.btn svg .fill { fill: currentColor; stroke: none; }

/* -------------------------------------------------------------- brand -- */
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 22px; letter-spacing: .02em; }
.brand.big { font-size: 34px; justify-content: center; }
.mark {
  width: 30px; height: 14px; border-radius: 999px; background: var(--accent);
  box-shadow: 0 0 18px rgba(245, 165, 36, .55);
}
.brand.big .mark { width: 40px; height: 18px; }

/* -------------------------------------------------------------- login -- */
.screen { min-height: 100%; }
#login { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 24px; padding: 40px 32px; display: grid; gap: 18px; text-align: center;
}
.login-card p { margin: 0 0 6px; }
input[type=password], input[type=search] {
  width: 100%; height: var(--tap); padding: 0 22px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); outline: none;
}
input:focus { border-color: var(--accent); }
.err { color: var(--danger); min-height: 1.4em; font-size: 18px; }

/* ------------------------------------------------------------- topbar -- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px;
  padding: 14px 28px; background: rgba(11, 13, 16, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin: 0 auto; }
.tab { min-height: 52px; min-width: 150px; padding: 0 26px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; }
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.quality { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.quality select {
  height: 48px; padding: 0 14px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line);
}

.panel { padding: 24px 28px 60px; max-width: 1600px; margin: 0 auto; }

/* ------------------------------------------------------------- search -- */
.search { display: flex; gap: 14px; }
.search input { flex: 1; }
.status { color: var(--muted); margin: 18px 4px; min-height: 1.2em; }
.status.err { color: var(--danger); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000 center / cover no-repeat; cursor: pointer; }
.thumb .dur {
  position: absolute; right: 10px; bottom: 10px; padding: 2px 9px; border-radius: 8px;
  background: rgba(0, 0, 0, .78); font-size: 16px; font-variant-numeric: tabular-nums;
}
.thumb .dur.live { background: #c4302b; }
.card-body { padding: 14px 16px 16px; display: flex; gap: 12px; align-items: flex-start; flex: 1; }
.card-text { flex: 1; min-width: 0; cursor: pointer; }
.card-title { font-weight: 600; font-size: 18px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--muted); font-size: 16px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save { min-height: 48px; padding: 0 16px; font-size: 16px; flex-shrink: 0; }
.save svg { width: 22px; height: 22px; }
.save.done { color: var(--accent); border-color: rgba(245, 165, 36, .4); }

/* -------------------------------------------------------------- lists -- */
.list { display: grid; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 18px; min-height: 76px; padding: 12px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.row.clickable { cursor: pointer; }
.row.clickable:active { background: var(--panel-2); }
.row .play-dot {
  width: 48px; height: 48px; border-radius: 50%; background: var(--panel-2); flex-shrink: 0;
  display: grid; place-items: center; color: var(--accent);
}
.row .play-dot svg { width: 22px; height: 22px; fill: currentColor; margin-left: 3px; }
.row-text { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-label { color: var(--muted); font-size: 16px; text-transform: uppercase; letter-spacing: .08em; margin: 22px 4px 8px; }
.lib-head { display: flex; align-items: center; justify-content: space-between; }
.empty { color: var(--muted); padding: 30px 4px; }
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--accent); }

.rail { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 300px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; cursor: pointer;
}
.chip .row-title { font-size: 18px; }
.chip-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.chip-x { border: 0; background: none; color: var(--muted); font-size: 15px; padding: 6px 0 6px 12px; cursor: pointer; }

/* ------------------------------------------------------------- player -- */
.player { position: fixed; inset: 0; background: #000; z-index: 20; overflow: hidden; }
.stage { position: absolute; inset: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage canvas.incoming { visibility: hidden; }

.controls { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; transition: opacity .25s ease; }
.controls.faded { opacity: 0; }
.controls.faded * { pointer-events: none; }
.ctl-top, .ctl-bottom { padding: 18px 26px; }
.ctl-top { display: flex; align-items: center; gap: 18px; background: linear-gradient(rgba(0,0,0,.75), transparent); }
.ctl-bottom { background: linear-gradient(transparent, rgba(0,0,0,.85)); padding-top: 50px; }
.p-title { flex: 1; font-weight: 600; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 6px #000; }
.btn.icon { padding: 0; width: 56px; }

.seek { display: flex; align-items: center; gap: 18px; }
.time { font-variant-numeric: tabular-nums; font-size: 18px; min-width: 70px; text-align: center; }
.bar { flex: 1; height: 48px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.bar-track { position: relative; width: 100%; height: 8px; background: rgba(255,255,255,.22); border-radius: 999px; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); border-radius: 999px; }
.bar-knob { position: absolute; top: 50%; left: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.bar.disabled { opacity: .35; pointer-events: none; }

.buttons { display: flex; justify-content: center; align-items: center; gap: 44px; margin-top: 10px; }
.btn.round { width: 76px; height: 76px; min-height: 0; padding: 0; border-radius: 50%; background: rgba(255,255,255,.12); border-color: transparent; position: relative; }
.btn.round b { position: absolute; font-size: 12px; font-weight: 700; top: 50%; left: 50%; transform: translate(-50%, -38%); }
.btn.round svg { width: 40px; height: 40px; }
.btn.round.big { width: 96px; height: 96px; background: var(--accent); color: var(--accent-ink); }
.btn.round.big svg { width: 44px; height: 44px; }

.overlay-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  display: grid; justify-items: center; gap: 18px; text-align: center; max-width: 80%;
  padding: 28px 34px; border-radius: 20px; background: rgba(11, 13, 16, .82);
}
.overlay-msg.error .spinner { display: none; }
.overlay-msg.error #overlayText { color: var(--danger); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,.18); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  body { font-size: 18px; }
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; min-width: 0; }
  .quality { margin-left: auto; }
  .panel { padding: 16px 16px 50px; }
  .grid { grid-template-columns: 1fr; }
  .buttons { gap: 26px; }
}
