:root {
  --bg: #0f0f0d;
  --surface: #1a1916;
  --surface-2: #24221e;
  --ink: #efede6;
  --muted: #9b978c;
  --accent: #e8a72a;
  --accent-ink: #1a1305;
  --error: #ff8a7a;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input, select, .button {
  font: inherit;
  color: inherit;
}

input, select {
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 12px;
  min-width: 0;
}

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
}

.ghost:hover { color: var(--ink); border-color: var(--muted); }

.logo {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.logo span { color: var(--accent); }

.error { color: var(--error); margin: 0; min-height: 1.5em; font-size: 14px; }

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

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card .logo { font-size: 34px; margin-bottom: 18px; }
.login-card label { color: var(--muted); font-size: 14px; }

/* ---------- library ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgb(15 15 13 / 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--surface);
}

.topbar .logo { margin-right: auto; }
.topbar #search { width: min(260px, 40vw); }

.library { padding: 18px clamp(16px, 4vw, 40px) 60px; }

.count { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

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

.card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius);
}

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 6px;
  transition: transform 160ms ease-out;
}

.card:hover .poster { transform: translateY(-3px); }

.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }

.poster.placeholder {
  display: grid;
  place-items: center;
  font-size: 54px;
  font-weight: 800;
  color: var(--accent);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgb(0 0 0 / 0.6);
}

.progress::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--progress);
  background: var(--accent);
}

.title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 13px; }

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

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

.player {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #000;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(16px, 4vw, 40px);
}

.player-bar h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player video {
  flex: 1;
  width: 100%;
  max-height: calc(100vh - 64px);
  background: #000;
}

.player-error { text-align: center; padding: 16px; }

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .topbar #search { order: 3; width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 18px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .poster { transition: none; }
  .card:hover .poster { transform: none; }
}
