:root {
  --bg: #0b0d13;
  --bg-soft: #12151d;
  --surface: #171b24;
  --surface-2: #1e2330;
  --border: #262c39;
  --border-strong: #333b4d;
  --text: #e9ecf3;
  --muted: #98a1b3;
  --accent: #5b74ea;
  --accent-soft: rgba(91, 116, 234, 0.14);
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  --ring: 0 0 0 3px rgba(91, 116, 234, 0.35);

  /* Plyr theming */
  --plyr-color-main: #5b74ea;
  --plyr-video-background: #000;
  --plyr-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(91, 116, 234, 0.16), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

.muted { color: var(--muted); }

/* ------------------------------------------------------------------ top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 4vw, 2rem);
  background: rgba(11, 13, 19, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), #7d5bea);
  color: #fff;
  box-shadow: 0 6px 16px rgba(91, 116, 234, 0.4);
}
.brand-mark svg { width: 15px; height: 15px; }

.topbar nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.89rem;
  font-weight: 600;
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--text); background: var(--accent-soft); }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.35rem;
  padding: 0.28rem 0.75rem 0.28rem 0.28rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.84rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
}

.topbar form { margin: 0; }

/* ------------------------------------------------------------------ layout */

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.25rem) clamp(1rem, 4vw, 2rem) 3rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  letter-spacing: -0.02em;
}

.subtitle { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.94rem; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #4a5fd0);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(91, 116, 234, 0.28);
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(91, 116, 234, 0.36); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: none;
}
.btn.secondary:hover { background: var(--surface-2); box-shadow: none; }
.btn.block { width: 100%; }
.btn svg { width: 1.05rem; height: 1.05rem; flex: none; }

.link {
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.link:hover { color: var(--text); }

/* ------------------------------------------------------------- grid + cards */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 1.15rem;
}

.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.thumb { position: relative; overflow: hidden; }
.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.card:hover .thumb img { transform: scale(1.05); }

.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6, 8, 12, 0.72), transparent 55%);
  pointer-events: none;
}

.play-badge {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(11, 13, 19, 0.68);
  color: #fff;
  backdrop-filter: blur(6px);
}
.play-badge svg { width: 13px; height: 13px; margin-left: 1px; }

.thumb-placeholder {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: linear-gradient(145deg, #232a3a, #171b24);
  color: var(--accent);
  font-size: 1.9rem;
  font-weight: 750;
}

.card-body { padding: 0.85rem 0.95rem 1rem; }
.card-body h2 {
  margin: 0 0 0.3rem;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }

/* ------------------------------------------------------------- empty state */

.empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  gap: 0.3rem;
  padding: 3.5rem 1.5rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty svg { color: var(--accent); opacity: 0.85; }
.empty h2 { margin: 0.7rem 0 0; font-size: 1.05rem; color: var(--text); }
.empty p { margin: 0; font-size: 0.9rem; }
.empty .btn { margin-top: 1.1rem; }

/* ------------------------------------------------------------------ player */

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.breadcrumb:hover { color: var(--text); }

.player-wrap {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}
.player-wrap video { display: block; width: 100%; background: #000; }

.details {
  margin-top: 1.5rem;
  padding: clamp(1.1rem, 3vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.details h1 { margin-bottom: 0.7rem; }
.details .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.15rem;
}
.details .description {
  margin: 1rem 0 0;
  color: var(--muted);
  white-space: pre-line;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.usage { margin-top: 0.7rem; }
.chip {
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ------------------------------------------------------------------- forms */

.form-card {
  max-width: 680px;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field { margin-bottom: 1.15rem; }
.field label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}
.field .help {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
}
.optional { color: var(--muted); font-weight: 500; }

.capture {
  margin-top: 0.7rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.thumb-preview {
  display: block;
  width: 100%;
  max-width: 320px;
  margin-bottom: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #000;
}
.thumb-preview[hidden] { display: none; }
.capture-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.field .capture-label {
  display: inline;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.input.shot-time { width: 6.5rem; }

.input,
input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus,
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
textarea { resize: vertical; }

input[type="file"] {
  width: 100%;
  padding: 0.9rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
input[type="file"]:hover { border-color: var(--accent); }
input[type="file"]::file-selector-button {
  margin-right: 0.8rem;
  padding: 0.42rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.error { margin-top: 0.4rem; color: var(--danger); font-size: 0.82rem; }

.alert {
  margin-bottom: 1.1rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
}
.alert.error {
  border: 1px solid rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.12);
  color: #ffb3b3;
}

/* ------------------------------------------------------- upload progress */

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.15rem 0 1.25rem;
}
.progress-track {
  flex: 1;
  height: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7d5bea);
  transition: width 0.2s ease;
}
.progress-status {
  min-width: 8.5rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ------------------------------------------------------------------- login */

.login-card {
  width: min(400px, 100%);
  margin: clamp(1.5rem, 8vh, 5rem) auto;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-card .brand-mark {
  width: 42px;
  height: 42px;
  margin-bottom: 1.1rem;
  border-radius: 12px;
}
.login-card .brand-mark svg { width: 20px; height: 20px; }
.login-card h1 { font-size: 1.4rem; }
.login-card .subtitle { margin-bottom: 1.5rem; }

/* ------------------------------------------------------------------ footer */

.footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

@media (max-width: 560px) {
  .page-head { align-items: flex-start; }
  .nav-label { display: none; }
  .progress-wrap { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .progress-status { min-width: 0; text-align: left; }
}
