:root {
  --bg: #0b0e14;
  --bg-soft: #111621;
  --card: #151b28;
  --card-2: #1b2333;
  --line: #232c3d;
  --text: #e7ecf5;
  --muted: #8b98ae;
  --accent: #4c8dff;
  --accent-2: #2f6fe0;
  --danger: #e0564f;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .35rem; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.sm { font-size: .82rem; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------------- nav ---------------- */
.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .8rem 1.5rem;
  background: rgba(11, 14, 20, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: .5rem; }
.dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 0 12px rgba(76, 141, 255, .6);
}
.nav-links { display: flex; gap: .25rem; margin-right: auto; }
.nav-links a {
  padding: .4rem .75rem; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--card); }
.nav-links a.on { color: var(--text); background: var(--card-2); }
.nav-user { display: flex; align-items: center; gap: .75rem; }
.who { color: var(--muted); font-size: .85rem; }
.who em { font-style: normal; color: var(--accent); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }

.wrap { max-width: 900px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.wrap.wide { max-width: 1240px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head p { margin: 0; }
.sec { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .75rem; }

/* ---------------- controls ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #222c3f; border-color: #2e3a50; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--card); }
.btn.danger { color: var(--danger); border-color: #3a2429; background: transparent; }
.btn.danger:hover { background: rgba(224, 86, 79, .12); }
.btn.sm { padding: .38rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; margin-top: .5rem; padding: .7rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

input, textarea, select {
  width: 100%; padding: .6rem .75rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76, 141, 255, .15); }
label { display: block; margin-bottom: .85rem; font-size: .85rem; color: var(--muted); }
label input, label textarea, label select { margin-top: .3rem; color: var(--text); }
textarea { resize: vertical; }
.search input { width: 240px; }

.err {
  background: rgba(224, 86, 79, .12); border: 1px solid rgba(224, 86, 79, .35);
  color: #ffb4b0; padding: .6rem .8rem; border-radius: 10px; font-size: .88rem;
}

/* ---------------- cards ---------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card.pad { padding: 1.25rem; }
.card.scroll { overflow-x: auto; }
.card + .card { margin-top: 1.25rem; }
.empty { text-align: center; padding: 3rem 1.5rem; }
.empty .btn { margin-top: .75rem; }

/* ---------------- library grid ---------------- */
.grid {
  display: grid; gap: 1.15rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.video-card { display: block; transition: transform .15s, border-color .15s; }
.video-card:hover { transform: translateY(-3px); border-color: #2e3a50; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #05070c; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-fallback {
  width: 100%; height: 100%; display: grid; place-items: center;
  color: #33405a; font-size: 2rem;
}
.thumb-fallback.sm { font-size: 1rem; }
.badge {
  position: absolute; right: .5rem; bottom: .5rem;
  background: rgba(0, 0, 0, .78); color: #fff; font-size: .72rem;
  padding: .12rem .4rem; border-radius: 5px; font-variant-numeric: tabular-nums;
}
.badge.sm { font-size: .65rem; right: .25rem; bottom: .25rem; }
.play {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 2.2rem; color: #fff; opacity: 0;
  background: rgba(5, 7, 12, .35); transition: opacity .15s;
}
.video-card:hover .play { opacity: 1; }
.meta { padding: .8rem .9rem 1rem; }
.meta h3 { font-size: .98rem; }
.meta p { margin: 0; }

/* ---------------- watch ---------------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.75rem; align-items: start; }
@media (max-width: 980px) { .watch { grid-template-columns: 1fr; } }

/* --arn is the source video's width/height, set by player.js once metadata
   loads, so portrait clips get a tall player instead of a letterboxed strip. */
.player-shell {
  background: #000; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  aspect-ratio: var(--arn, 1.7778);
  max-width: calc(76vh * var(--arn, 1.7778));
  margin-inline: auto;
}
#player { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }

.watch-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin: 1.1rem 0 .5rem;
}
.watch-head p { margin: 0; }
.watch-actions { display: flex; gap: .5rem; }
.desc { color: #c3cddd; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem; margin-top: .5rem; white-space: pre-wrap; }

.admin-bar {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  margin-top: 1.1rem; padding: .85rem; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.inline { display: flex; gap: .5rem; align-items: center; margin: 0; }
.inline.grow { flex: 1; min-width: 260px; }
.inline input { min-width: 0; }

.up-next .row {
  display: flex; gap: .7rem; padding: .5rem; border-radius: 10px; margin-bottom: .3rem;
}
.up-next .row:hover { background: var(--card); }
.row-thumb {
  position: relative; width: 120px; flex: 0 0 120px; aspect-ratio: 16 / 9;
  border-radius: 8px; overflow: hidden; background: #05070c;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-meta h4 { font-size: .87rem; margin: 0 0 .2rem; }
.row-meta p { margin: 0; }

/* ---------------- tables ---------------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; padding: .75rem 1rem; color: var(--muted);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--line); font-weight: 600;
}
td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .inline { justify-content: flex-end; display: inline-flex; }
td input { width: 150px; }
.tag {
  display: inline-block; padding: .12rem .5rem; border-radius: 20px;
  font-size: .72rem; background: var(--card-2); color: var(--muted);
}
.tag.admin { background: rgba(76, 141, 255, .15); color: #9dc0ff; }
.add-user { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; align-items: end; }
.add-user .btn { margin-bottom: .85rem; }

/* ---------------- upload ---------------- */
.file input { padding: .8rem; background: var(--bg-soft); border-style: dashed; cursor: pointer; }
.progress { height: 8px; background: var(--bg-soft); border-radius: 20px; overflow: hidden; margin: .5rem 0; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #8b5cf6); transition: width .2s; }

/* ---------------- login ---------------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(1000px 600px at 50% -10%, #1a2340 0%, var(--bg) 60%);
}
.login {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; padding: 2rem;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; margin-bottom: 1.5rem; }
.login h1 { font-size: 1.35rem; }
.login .err { margin: .75rem 0; }
.login form { margin-top: 1.25rem; }

/* ---------------- video wall ---------------- */
.wall-body { margin: 0; height: 100vh; overflow: hidden; background: #000; cursor: none; }
#stage { position: fixed; inset: 0; background: #000; }
#stage video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; opacity: 0; transition: opacity .6s ease;
}
.wall-body.cover #stage video { object-fit: cover; }
#stage video.on { opacity: 1; }
#hint {
  position: fixed; left: 0; right: 0; bottom: 28px; text-align: center;
  color: rgba(255, 255, 255, .45); font-size: .85rem; letter-spacing: .02em;
  transition: opacity .6s ease; pointer-events: none;
}

.copy-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.copy-row input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; }
.copy-row .btn { flex: 0 0 auto; }
table.opts td { border-bottom: 0; padding: .35rem .75rem .35rem 0; vertical-align: top; }
table.opts code {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px;
  padding: .1rem .4rem; font-size: .82rem; white-space: nowrap;
}
