:root {
  --bg: #0e0f11;
  --surface: #1a1c20;
  --surface-2: #26292f;
  --text: #f1f2f4;
  --muted: #9aa0a8;
  --accent: #e5a00d;
  --danger: #e5484d;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 20px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

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

button {
  min-height: 64px;
  padding: 0 28px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
}
button:active { filter: brightness(1.3); }
button.primary { background: var(--accent); color: #111; font-weight: 600; }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login form {
  width: min(480px, 100%);
  display: grid;
  gap: 20px;
  padding: 36px;
  background: var(--surface);
  border-radius: 20px;
}
.login h1 { margin: 0; font-size: 32px; }
.login input {
  min-height: 72px;
  padding: 0 20px;
  border: 2px solid var(--surface-2);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 26px;
}
.login input:focus { outline: none; border-color: var(--accent); }
.login .error { margin: 0; color: var(--danger); }

/* ---------- Library ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px 24px;
  background: rgba(14, 15, 17, 0.94);
  backdrop-filter: blur(8px);
}
header h1 { margin: 0 12px 0 0; font-size: 28px; white-space: nowrap; }
header input {
  flex: 1;
  min-width: 0;
  min-height: 64px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 22px;
}
header input:focus { outline: 2px solid var(--accent); }
header .mode { white-space: nowrap; }
header .mode[aria-pressed="true"] { background: var(--accent); color: #111; font-weight: 600; }

.status { padding: 48px 24px; color: var(--muted); text-align: center; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 24px;
  padding: 8px 24px 40px;
}

.card {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  background: none;
  text-align: left;
}
.card .poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 18px;
  text-align: center;
}
.card .poster.text { padding: 12px; }
.card .poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card .title {
  margin-top: 10px;
  font-size: 19px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .meta { color: var(--muted); font-size: 16px; }

/* ---------- Player ---------- */

.player {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: #000;
}
.player[hidden] { display: none; }
.player video {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
}
.player .stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  background: #000;
}
.player .stage[hidden] { display: none; }
.player .stage canvas {
  max-width: 100%;
  max-height: 100%;
}
.player video[hidden] { display: none; }
.player .seek {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 14px 24px 4px;
  background: var(--surface);
}
.player .seek input {
  flex: 1;
  min-width: 0;
  height: 48px;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.player .seek input::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 5px;
  background: var(--surface-2);
}
.player .seek input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 36px;
  height: 36px;
  margin-top: -13px;
  border-radius: 50%;
  background: var(--accent);
}
.player .seek input::-moz-range-track {
  height: 10px;
  border-radius: 5px;
  background: var(--surface-2);
}
.player .seek input::-moz-range-thumb {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}
.player .bar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  background: var(--surface);
}
.player .bar .now {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.player .seek .time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.player .bar button { min-width: 96px; }
.player .error {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 24px;
  border-radius: var(--radius);
  background: var(--danger);
}
