:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-2: #1f2b47;
  --border: #2a3a5c;
  --text: #e0e0e0;
  --text-muted: #8892a4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #ed4245;
  --success: #57f287;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
}

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent);
  text-decoration: none;
}
.logo:hover { color: var(--accent-hover); }
.logo h1 { font-size: 2rem; font-weight: 700; color: var(--text); }
.logo-sm h2 { font-size: 1.1rem; font-weight: 600; color: var(--text); }

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-name { color: var(--text-muted); font-size: 14px; }
.inline { display: inline; }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  min-height: 100vh;
  width: min(420px, calc(100% - 32px));
  margin: 0 auto;
  gap: 16px;
}
.login-card .logo {
  justify-content: center;
  margin-bottom: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--border); color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-block { width: 100%; padding: 14px 28px; font-size: 16px; border-radius: 12px; }

.stack { display: grid; gap: 14px; width: 100%; }

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
input:focus {
  outline: none;
  border-color: var(--accent);
}
input.code {
  font-size: 1.4rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-family: ui-monospace, monospace;
}

.auth-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.banner.bad { color: #fca5a5; border-color: rgba(237, 66, 69, 0.4); }
.banner.ok { color: var(--success); border-color: rgba(87, 242, 135, 0.35); }
.banner.fade-out { opacity: 0; transition: opacity 0.4s; }

#live-flash {
  max-width: 1100px;
  width: calc(100% - 48px);
  margin: 12px auto 0;
}

.header-upload {
  cursor: pointer;
}

.upload-status {
  padding: 8px 24px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.upload-status p {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.upload-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
}
.filters select {
  padding: 6px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}
.filters select:focus {
  outline: none;
  border-color: var(--accent);
}

.star-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
}
.star-btn:hover { color: var(--accent); }
.star-btn svg {
  fill: none;
  stroke: currentColor;
}
.star-btn.on {
  color: var(--accent);
}
.star-btn.on svg {
  fill: currentColor;
}

.thumb-wrap {
  position: relative;
}
.thumb-star {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
}
.thumb-star:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.9);
}
.thumb-star.on {
  color: var(--accent);
}

.card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.card-title h1,
.card-title h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.upload {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.drop {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 110px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  padding: 16px;
}
.drop:hover { border-color: var(--accent); }
.drop small { color: var(--text-muted); font-size: 12px; }
.drop input { position: absolute; opacity: 0; width: 0; height: 0; }

body.drag-over::after {
  content: 'Drop to upload';
  position: fixed;
  inset: 12px;
  z-index: 80;
  display: grid;
  place-items: center;
  pointer-events: none;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 16%, rgba(26, 26, 46, 0.78));
  color: #fff;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.progress { height: auto; }
.bar {
  height: 4px;
  width: 0;
  border-radius: 4px;
  background: var(--accent);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(88, 101, 242, 0.15);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  overflow: hidden;
  display: block;
}
.thumb img, .ph {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ph {
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 12px, var(--bg) 12px 24px);
}

.dur {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-body { padding: 12px 14px 14px; }
.card-body h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card-body h2 a { color: var(--text); }
.card-body h2 a:hover { color: var(--accent); }
.meta { margin: 0 0 10px; font-size: 12px; color: var(--text-muted); }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.page-title { font-size: 1.25rem; font-weight: 600; }
.muted { color: var(--text-muted); }
.invite-form {
  display: flex;
  gap: 8px;
  margin: 8px 0 20px;
  max-width: 440px;
}
.invite-form input { flex: 1; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.admin-table th {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.watch video {
  width: 100%;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.watch-meta { margin-top: 16px; }
.watch-meta h1 { font-size: 1.4rem; font-weight: 600; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  header { padding: 10px 16px; }
  .page { padding: 16px; }
  .nav-name { display: none; }
  .upload-status { padding-left: 16px; padding-right: 16px; }
  #live-flash { width: calc(100% - 32px); }
}
