:root {
  --bg: #0d0f13;
  --bg2: #14171d;
  --bg3: #1b1f27;
  --line: #262b35;
  --fg: #eaeef5;
  --dim: #98a2b3;
  --acc: #ff3d5a;
  --acc2: #ff7a45;
  --ok: #35c48a;
  --warn: #e2a33c;
  --bad: #ef4b5c;
  --r: 14px;
  --shadow: 0 18px 40px -20px rgba(0,0,0,.75);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a1f29 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--fg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
p { margin: 0; }

/* ---------- header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(13, 15, 19, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.brand .mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--acc), var(--acc2));
  box-shadow: 0 6px 18px -6px rgba(255, 61, 90, .8);
}
.brand .dim { color: var(--dim); font-weight: 500; }
.nav { display: flex; align-items: center; gap: 10px; }
.nav form { margin: 0; }

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 36px) clamp(16px, 4vw, 40px) 60px;
  flex: 1;
}
.foot {
  padding: 18px clamp(16px, 4vw, 40px) 26px;
  color: #6b7484;
  font-size: 12.5px;
  text-align: center;
  border-top: 1px solid var(--line);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: linear-gradient(180deg, #ff4a63, #f0324c);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, background .12s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: var(--bg3);
  border-color: var(--line);
  color: var(--fg);
  font-weight: 500;
}
.btn.ghost:hover { background: #222834; }
.btn.tiny { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { background: transparent; border-color: #522530; color: #ff8a9a; }
.btn.danger:hover { background: #2a1620; }

/* ---------- home grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: clamp(18px, 2.4vw, 28px);
}
.card {
  display: block;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--line);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: #38404f;
  box-shadow: var(--shadow);
}
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #1d232e, #12151b);
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dur {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .78);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cardmeta { padding: 12px 14px 14px; }
.cardmeta h3 { font-size: 15px; line-height: 1.35; }
.cardmeta p { margin-top: 4px; color: var(--dim); font-size: 12.5px; }

/* ---------- empty / notice ---------- */
.empty {
  text-align: center;
  padding: clamp(40px, 9vw, 90px) 20px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(20, 23, 29, .5);
}
.empty h1 { font-size: clamp(22px, 3vw, 30px); }
.empty p { margin: 12px auto 0; max-width: 520px; color: var(--dim); }
.empty .btn, .empty a.btn { margin-top: 22px; }

.notice {
  margin-bottom: 22px;
  padding: 11px 15px;
  border: 1px solid #2c3442;
  border-left: 3px solid var(--acc2);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--dim);
  font-size: 13.5px;
}
.notice a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- player ---------- */
.player-page { max-width: 980px; margin: 0 auto; }
.player {
  background: #000;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
}
.player video { width: 100%; height: 100%; display: block; background: #000; }
.state { text-align: center; padding: 28px; color: var(--dim); }
.state p + p { margin-top: 6px; }
.state .alert { color: #ff9aa7; }
.state pre.err {
  margin: 14px auto 0;
  max-width: 700px;
  max-height: 180px;
  overflow: auto;
  text-align: left;
  font-size: 12px;
  color: #ffb3bd;
  background: #17090d;
  border: 1px solid #3a1520;
  border-radius: 10px;
  padding: 12px;
  white-space: pre-wrap;
}
.spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid #2a3140;
  border-top-color: var(--acc);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.vtitle { margin-top: 20px; font-size: clamp(19px, 2.6vw, 26px); line-height: 1.3; }
.vmeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 10px;
  color: var(--dim);
  font-size: 13px;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.desc {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: #c8d0dc;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--dim);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.pill.ok { color: #8ff0c4; border-color: #1f4a3a; background: #11241d; }
.pill.warn { color: #f3cd86; border-color: #4a3a1c; background: #241d10; }
.pill.bad { color: #ff9aa7; border-color: #4a2029; background: #241014; }

/* ---------- admin ---------- */
.panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(16px, 2.4vw, 24px);
  margin-bottom: 22px;
}
.panel h2 { font-size: 17px; margin-bottom: 14px; }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; }

.upload { display: grid; gap: 12px; }
.drop {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 26px 18px;
  border: 1.5px dashed #333c4b;
  border-radius: 12px;
  background: #10131a;
  color: var(--dim);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.drop:hover, .drop.over { border-color: var(--acc); background: #161a22; }
.drop input[type=file] { display: none; }
.drop.has-file { border-color: #2a5a46; background: #101b17; color: #a9e9cb; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.grow { flex: 1 1 260px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--acc); width: 16px; height: 16px; }

input[type=text], input[type=password], textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1218;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type=text]:focus, input[type=password]:focus, textarea:focus {
  border-color: #3c4557;
  box-shadow: 0 0 0 3px rgba(255, 61, 90, .1);
}
textarea { resize: vertical; min-height: 74px; }
progress { width: min(320px, 100%); height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: #222834; }
progress::-webkit-progress-bar { background: #222834; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--acc), var(--acc2)); }
progress::-moz-progress-bar { background: var(--acc); }

.hint { color: var(--dim); font-size: 12.5px; }
.alert {
  color: #ffb3bd;
  background: #1d0f13;
  border: 1px solid #3d1a23;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13.5px;
}

.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left;
  padding: 8px 10px;
  color: var(--dim);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 10px; border-bottom: 1px solid #1e232c; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.tbl .right { text-align: right; white-space: nowrap; }
.thumbcell { width: 76px; }
.thumbcell img, .thumbcell .dot {
  width: 62px;
  height: 35px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  background: #1a1f28;
}
.thumbcell .dot { display: grid; place-items: center; }
.thumbcell .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #3a4353; }

.switch {
  width: 38px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #20262f;
  cursor: pointer;
  position: relative;
  transition: background .15s ease, border-color .15s ease;
}
.switch span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #8b95a5;
  transition: transform .15s ease, background .15s ease;
}
.switch.on { background: #1c3a2e; border-color: #2a5a46; }
.switch.on span { transform: translateX(16px); background: #57d9a3; }

/* ---------- login ---------- */
.login {
  max-width: 420px;
  margin: clamp(20px, 6vw, 70px) auto;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
}
.login h1 { font-size: 21px; margin-bottom: 6px; }
.login form { display: grid; gap: 12px; margin-top: 18px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #1e2530;
  border: 1px solid #333c4b;
  color: var(--fg);
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .cardmeta { padding: 9px 10px 11px; }
  .cardmeta h3 { font-size: 13px; }
  .cardmeta p { font-size: 11px; }
  .top { padding: 12px 16px; }
  .tbl { font-size: 12.5px; }
  .thumbcell { width: 56px; }
  .thumbcell img, .thumbcell .dot { width: 48px; height: 27px; }
}
