:root {
  --bg: #0b0b10;
  --card: #15151d;
  --line: #262632;
  --text: #f2f2f7;
  --muted: #9a9aab;
  --accent: #7c5cff;
  --accent-2: #a28bff;
  --danger: #ff5a6a;
  --ok: #34d399;
  --r: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.err { color: var(--danger); margin: 0; font-size: 14px; }

.logo { font-weight: 800; letter-spacing: .3px; font-size: 18px; }

.btn {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 10px 16px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:active { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.big { width: 100%; padding: 18px; font-size: 19px; border-radius: 16px; margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Login */
#view-login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login .logo { font-size: 22px; text-align: center; }
.login p { margin: 0; text-align: center; }
input[type=password] {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #0f0f15; color: var(--text); outline: none;
}
input[type=password]:focus { border-color: var(--accent); }

/* Config */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 11, 16, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card h2 { margin: 0; font-size: 17px; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; }
.hint { margin: 4px 0 10px; }

.drop {
  display: grid; justify-items: center; gap: 4px; text-align: center;
  padding: 26px 16px; border: 2px dashed #3a3a4a; border-radius: var(--r);
  background: #111118; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over, .drop:hover { border-color: var(--accent); background: #15131f; }
.drop input { display: none; }
.drop-icon { font-size: 26px; color: var(--accent-2); }

.up { display: grid; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.up-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 6px; background: #262632; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.up.done .bar > i { background: var(--ok); }
.up.fail .bar > i { background: var(--danger); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: grid; grid-template-columns: auto 52px 1fr auto; align-items: center; gap: 10px;
  padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #101017;
}
.item.off { opacity: .5; }
.item .num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: var(--accent); color: #fff;
}
.item.off .num { background: #33333f; color: var(--muted); }
.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: #000; pointer-events: none; }
.meta { min-width: 0; }
.meta .name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .size { font-size: 12px; color: var(--muted); }
.tools { display: flex; gap: 4px; }
.ic {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #181822; display: grid; place-items: center; font-size: 15px; padding: 0;
}
.ic:disabled { opacity: .3; cursor: default; }
.ic.del { color: var(--danger); }
.empty { text-align: center; margin: 10px 0 2px; }
@media (max-width: 480px) {
  .item { grid-template-columns: auto 48px 1fr; row-gap: 6px; }
  .thumb { width: 48px; height: 48px; grid-row: span 2; }
  .chk { grid-row: span 2; }
  .tools { grid-column: 3; }
}

.settings { display: grid; gap: 14px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #0f0f15; border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; color: var(--muted); font-size: 14px; }
.seg button small { font-size: 11px; opacity: .8; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }

.tip { background: #14141c; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #22222e; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; z-index: 50; max-width: calc(100% - 32px);
}

/* Player */
body.playing { overflow: hidden; }
body.playing > .view { display: none !important; }
#stage {
  position: fixed; inset: 0; z-index: 100; background: #000;
  display: flex; align-items: center; justify-content: center;
  cursor: none; touch-action: none; user-select: none; -webkit-user-select: none;
}
#frame {
  position: relative; overflow: hidden; background: #000;
  aspect-ratio: 9 / 16;
  width: min(100vw, calc(100dvh * 9 / 16));
}
#stage.r169 #frame {
  aspect-ratio: 16 / 9;
  width: min(100vw, calc(100dvh * 16 / 9));
}
#frame video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; pointer-events: none; background: #000;
}
#stage.contain #frame video { object-fit: contain; }
#frame video.on { opacity: 1; }
#stage-msg {
  position: absolute; inset: auto 0 40px; text-align: center; color: #fff;
  font-size: 15px; text-shadow: 0 1px 4px #000; pointer-events: none;
}
