/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f12;
  --bg2:       #1a1a22;
  --bg3:       #232330;
  --border:    #2e2e3e;
  --accent:    #f97316;   /* orange */
  --accent2:   #fb923c;
  --text:      #e8e8f0;
  --text-muted:#888899;
  --radius:    8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.logo:hover { color: var(--accent); }
nav { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-muted); font-size: 0.9rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; }

/* ── Main / footer ───────────────────────────────────────────────────────── */
main { flex: 1; max-width: 1100px; margin: 0 auto; padding: 32px 20px; width: 100%; }
footer { text-align: center; padding: 20px; color: var(--text-muted); font-size: 0.8rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: var(--font);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--border); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg3); }
.btn-danger { background: #7f1d1d; border-color: #991b1b; color: #fca5a5; }
.btn-danger:hover { background: #991b1b; }

/* ── Landing ─────────────────────────────────────────────────────────────── */
.landing {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}
.landing-card {
  text-align: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
}
.landing-card h1 { font-size: 2rem; margin-bottom: 12px; }
.landing-card p { color: var(--text-muted); margin-bottom: 8px; }
.landing-card .sub { margin-bottom: 28px; }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h2 { font-size: 1.5rem; }

/* ── Run dropdowns ───────────────────────────────────────────────────────── */
.run-dropdown {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  overflow: hidden;
}
.run-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  gap: 12px;
}
.run-summary::-webkit-details-marker { display: none; }
.run-summary::before {
  content: "▶";
  font-size: 0.65em;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.run-dropdown[open] > .run-summary::before { transform: rotate(90deg); }
.run-summary:hover { background: var(--bg3); }
.run-label { font-size: 1rem; font-weight: 600; color: var(--accent); flex: 1; }
.run-count { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.run-body { padding: 4px 20px 20px; border-top: 1px solid var(--border); }

.clip-group { margin-bottom: 20px; margin-top: 16px; }
.clip-group h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em;
                  color: var(--text-muted); margin-bottom: 10px; }

/* ── Clip grid ───────────────────────────────────────────────────────────── */
.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.clip-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}
.clip-card:hover { border-color: var(--accent); }
.clip-card > a:first-child { display: block; flex: 1; }
.clip-thumb {
  background: #1c1c28;
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
}
.clip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.clip-thumb .play-icon {
  position: absolute;
  font-size: 2rem;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.clip-card:hover .play-icon { opacity: 1; }
.reel-thumb { font-size: 0.9rem; font-weight: 600; color: var(--accent); }
.clip-info { padding: 8px 10px; }
.clip-name { display: block; font-size: 0.8rem; color: var(--text); white-space: nowrap;
              overflow: hidden; text-overflow: ellipsis; }
.clip-size { font-size: 0.72rem; color: var(--text-muted); }
.clip-card .btn { margin: 0 10px 10px; }

/* ── Transcode pending state ─────────────────────────────────────────────── */
.transcode-pending {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}
.transcode-pending .hint { font-size: 0.82rem; }
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Watch page ──────────────────────────────────────────────────────────── */
.watch-page { max-width: 900px; margin: 0 auto; }
.watch-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.watch-header h2 { flex: 1; font-size: 1.1rem; word-break: break-all; }
.video-container { background: #000; border-radius: 10px; overflow: hidden; }
.video-container video { width: 100%; display: block; max-height: 70vh; }
.watch-meta { margin-top: 12px; color: var(--text-muted); font-size: 0.82rem; }
.watch-meta code { background: var(--bg3); padding: 2px 6px; border-radius: 4px; }

/* ── Admin ───────────────────────────────────────────────────────────────── */
.admin-section { margin-bottom: 32px; }
.admin-section h3 { font-size: 1rem; margin-bottom: 14px; }
.add-form { display: flex; gap: 10px; flex-wrap: wrap; }
.input {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  flex: 1;
  min-width: 180px;
}
.input:focus { outline: none; border-color: var(--accent); }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.875rem;
}
.user-table th { color: var(--text-muted); font-weight: 500; font-size: 0.78rem;
                   text-transform: uppercase; letter-spacing: 0.04em; }
.text-muted { color: var(--text-muted); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
