:root {
  color-scheme: dark;
  --bg: #0e0f12;
  --panel: #16181d;
  --panel-2: #1f2228;
  --fg: #e7e9ee;
  --muted: #8a8f99;
  --accent: #4f8cff;
  --danger: #ff5d5d;
  --border: #2a2d35;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.4 system-ui, -apple-system, Segoe UI, sans-serif; }
button { font: inherit; color: inherit; background: var(--panel-2); border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
button:hover { background: #262a32; }
button.ghost { background: transparent; }
input[type=text], input[type=password], input[type=search] {
  font: inherit; color: inherit; background: var(--panel-2); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 6px; outline: none; min-width: 0;
}
input:focus { border-color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); }

#app { min-height: 100%; display: flex; flex-direction: column; }
.view { display: none; flex: 1; }
.view.active { display: flex; flex-direction: column; }

/* Login */
#view-login { align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 320px; }
.login-card h1 { margin: 0 0 4px; font-size: 28px; }
.login-card p { margin: 0 0 24px; }
#login-form { display: flex; flex-direction: column; gap: 10px; }
#login-form button { background: var(--accent); border-color: var(--accent); padding: 10px; font-weight: 600; }
#login-form button:hover { background: #3a76e6; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); gap: 20px; flex-wrap: wrap; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; border: 1px solid transparent; padding: 6px 14px; }
.tab.active { border-color: var(--border); background: var(--panel-2); }
.breadcrumb { padding: 10px 20px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.breadcrumb button { background: transparent; border: none; color: var(--accent); padding: 2px 4px; }
.breadcrumb .sep { color: var(--muted); }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; padding: 20px; overflow-y: auto; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; transition: transform 0.1s, border-color 0.1s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .poster { width: 100%; aspect-ratio: 2 / 3; background: #222 center/cover no-repeat; display: block; }
.card .episode-thumb { aspect-ratio: 16 / 9; }
.card .label { padding: 8px 10px; font-size: 13px; }
.card .sub { color: var(--muted); font-size: 12px; }

/* Player */
#view-player { background: #000; }
.player-frame { position: relative; width: 100%; height: 100vh; display: flex; align-items: center; justify-content: center; }
#canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; background: #000; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent 30%, transparent 60%, rgba(0,0,0,0.7)); opacity: 1; transition: opacity 0.25s; }
.overlay.hidden { opacity: 0; pointer-events: none; }
.title-bar { font-size: 18px; font-weight: 600; }
.controls { display: flex; align-items: center; gap: 12px; }
.controls #seek { flex: 1; }
.controls #volume { width: 100px; flex: 0 0 auto; }
.time { font-variant-numeric: tabular-nums; min-width: 50px; }
.status { padding: 4px 8px; font-size: 12px; }
