:root {
  --bg: #0b0b10;
  --surface: #16161f;
  --surface-2: #20202c;
  --text: #f4f4f7;
  --muted: #a3a3b5;
  --accent: #ff5a3c;
  --accent-2: #e0237f;
  --danger: #ff6b6b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: linear-gradient(var(--bg) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; text-decoration: none; letter-spacing: -0.02em; }
.brand img { border-radius: 8px; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar nav a:not(.btn) { text-decoration: none; color: var(--muted); }
.topbar nav a:not(.btn):hover { color: var(--text); }

.banner { margin: 0 20px 12px; padding: 10px 14px; border-radius: 10px; background: #3a2a00; color: #ffd98a; font-size: 14px; }
.banner a { color: #fff; font-weight: 700; }

main { padding: 0 20px 48px; max-width: 1400px; margin: 0 auto; outline: none; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; text-decoration: none;
  background: var(--surface-2); color: var(--text);
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 14px; }
.btn-ghost { background: transparent; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #fff; outline-offset: 2px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 14px; font-weight: 400; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid #2c2c3a;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
.field { margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ---------- Home ---------- */
.hero {
  position: relative; border-radius: var(--radius); overflow: hidden;
  min-height: min(62vh, 560px); display: flex; align-items: flex-end;
  background: var(--surface) center / cover no-repeat;
  margin-bottom: 32px;
}
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(11,11,16,.95) 0%, rgba(11,11,16,.35) 55%, transparent 100%); }
.hero-body { position: relative; z-index: 1; padding: 32px; max-width: 720px; }
.hero h1 { font-size: clamp(28px, 5vw, 52px); line-height: 1.05; margin: 0 0 10px; letter-spacing: -0.03em; }
.hero p { color: #d6d6e0; margin: 0 0 20px; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 8px; }

.row h2 { font-size: 20px; margin: 0 0 12px; }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 280px); gap: 14px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x mandatory; }
.card { scroll-snap-align: start; text-decoration: none; border-radius: 12px; overflow: hidden; background: var(--surface); transition: transform .2s; }
.card:hover, .card:focus-visible { transform: scale(1.03); }
.card .thumb { aspect-ratio: 16 / 9; background: var(--surface-2) center / cover no-repeat; }
.card .meta { padding: 10px 12px 12px; }
.card .meta strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta span { color: var(--muted); font-size: 13px; }

.empty { text-align: center; padding: 80px 20px; }
.empty h1 { font-size: 32px; margin-bottom: 8px; }
.empty p { color: var(--muted); margin-bottom: 24px; }

/* ---------- Create ---------- */
.create { max-width: 760px; margin: 0 auto; }
.create h1 { font-size: 32px; margin: 8px 0 4px; letter-spacing: -0.02em; }
.create > p { color: var(--muted); margin-top: 0; margin-bottom: 24px; }
.progress { margin-top: 24px; background: var(--surface); border-radius: var(--radius); padding: 20px; }
.progress .status { font-weight: 700; margin-bottom: 4px; }
.progress .error { color: var(--danger); margin: 8px 0; }
.bar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin: 10px 0 16px; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumbs figure { margin: 0; }
.thumbs .ph { aspect-ratio: 16 / 9; border-radius: 8px; background: var(--surface-2) center / cover no-repeat; }
.thumbs .ph.busy { animation: pulse 1.2s ease-in-out infinite; }
.thumbs figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@keyframes pulse { 50% { opacity: .45; } }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

/* ---------- Player ---------- */
.watch { max-width: 1200px; margin: 0 auto; }
.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; }
.player:fullscreen { border-radius: 0; display: flex; flex-direction: column; justify-content: center; }
.stage { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #000; }
.player:fullscreen .stage { aspect-ratio: auto; height: 100%; }
.layer {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 1.2s ease; transform-origin: center;
}
.layer.on { opacity: 1; }
.kb-zoom-in  { animation: kbZoomIn  var(--dur, 8s) ease-in-out forwards; }
.kb-zoom-out { animation: kbZoomOut var(--dur, 8s) ease-in-out forwards; }
.kb-pan-left { animation: kbPanLeft var(--dur, 8s) ease-in-out forwards; }
.kb-pan-right{ animation: kbPanRight var(--dur, 8s) ease-in-out forwards; }
@keyframes kbZoomIn  { from { transform: scale(1); }    to { transform: scale(1.18); } }
@keyframes kbZoomOut { from { transform: scale(1.2); }  to { transform: scale(1); } }
@keyframes kbPanLeft { from { transform: scale(1.2) translateX(4%); }  to { transform: scale(1.2) translateX(-4%); } }
@keyframes kbPanRight{ from { transform: scale(1.2) translateX(-4%); } to { transform: scale(1.2) translateX(4%); } }
.stage.paused .layer { animation-play-state: paused; }
.stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 160px rgba(0,0,0,.65); }

.subtitle {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); z-index: 2;
  width: min(86%, 900px); text-align: center;
  font-size: clamp(15px, 2.3vw, 26px); line-height: 1.4; font-weight: 600;
  text-shadow: 0 2px 8px #000, 0 0 2px #000;
}
.subtitle:empty { display: none; }
.subtitle span { background: rgba(0,0,0,.45); padding: 2px 10px; border-radius: 6px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

.overlay {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 20px;
  background: radial-gradient(circle, rgba(0,0,0,.35), rgba(0,0,0,.8));
}
.overlay h1 { margin: 0; font-size: clamp(24px, 4.5vw, 48px); letter-spacing: -0.02em; }
.overlay p { margin: 0; color: #d0d0dc; max-width: 640px; }
.big-play { width: 84px; height: 84px; border-radius: 50%; font-size: 30px; padding: 0; }

.controls { display: flex; align-items: center; gap: 6px; padding: 10px 12px; background: #0f0f16; flex-wrap: wrap; }
.controls .btn { padding: 8px 12px; font-size: 15px; }
.controls .count { color: var(--muted); font-size: 14px; margin: 0 8px; font-variant-numeric: tabular-nums; }
.controls .spacer { flex: 1; }
.controls .btn.off { opacity: 0.4; text-decoration: line-through; }
.timeline { display: flex; gap: 4px; padding: 0 12px 12px; background: #0f0f16; }
.timeline button { flex: 1; height: 6px; border: 0; padding: 0; border-radius: 4px; background: #2d2d3b; cursor: pointer; }
.timeline button.done { background: #6d6d85; }
.timeline button.now { background: var(--accent); }

.story-info { padding: 20px 4px; }
.story-info h1 { margin: 0 0 6px; font-size: 28px; }
.story-info p { color: var(--muted); margin: 0 0 6px; }
.export-status { color: var(--muted); font-size: 14px; }
.export-preview { display: block; width: min(360px, 100%); aspect-ratio: 16 / 9; margin-top: 12px; border-radius: 10px; background: #000; }

@media (max-width: 600px) {
  main { padding: 0 12px 40px; }
  .hero-body { padding: 20px; }
  .controls .btn { padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .layer { animation: none !important; transition: none; }
}

/* ---------- Accounts, plans, admin ---------- */
.btn-block { width: 100%; }
.small { font-size: 13px; }
.topbar nav { flex-wrap: wrap; justify-content: flex-end; }
.auth { max-width: 420px; margin: 24px auto; background: var(--surface); padding: 28px; border-radius: var(--radius); }
.auth h1 { margin: 0 0 4px; font-size: 26px; }
.auth > .hint { margin: 0 0 20px; }
.auth-switch { text-align: center; color: var(--muted); margin: 18px 0 0; font-size: 14px; }
.form-error { color: var(--danger); margin: 0 0 12px; }
.form-ok { color: #7ee2a8; margin: 0 0 12px; }

.plans { max-width: 1040px; margin: 0 auto; text-align: center; }
.plans h1 { font-size: 34px; margin: 8px 0 6px; letter-spacing: -0.02em; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin: 24px 0 12px; text-align: left; }
.plans-single .plan-grid { grid-template-columns: minmax(0, 400px); justify-content: center; }
.plan { background: var(--surface); border: 1px solid #2c2c3a; border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; }
.plan.best { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2), 0 20px 60px -30px var(--accent-2); }
.plan.used { opacity: .6; }
.plan h2 { font-size: 44px; margin: 4px 0 0; letter-spacing: -0.03em; }
.plan .per { color: var(--muted); margin: 0 0 12px; }
.plan ul { margin: 0 0 20px; padding-left: 18px; color: #d6d6e0; flex: 1; }
.plan li { margin: 4px 0; }
.pass-status { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; display: inline-block; }
.pass-status.ok, .ok { color: #7ee2a8; }
.pay-status { min-height: 1.5em; font-weight: 600; }
.pay-status.ok { color: #7ee2a8; }
.pay-status.error { color: var(--danger); }

.account { max-width: 900px; margin: 0 auto; }
.account h1 { font-size: 30px; margin: 8px 0 16px; }
.account h2 { font-size: 20px; margin: 28px 0 10px; }
.account-card, .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.account-card > div, .tile { background: var(--surface); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile strong { font-size: 22px; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #262634; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
@media (max-width: 600px) {
  .topbar nav a[href="#/plans"], .topbar nav a[href="#/"]:not(.brand) { display: none; }
}

.footer { border-top: 1px solid #1f1f2b; margin-top: 40px; padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }
.footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-bottom: 6px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }
.policy { max-width: 760px; margin: 0 auto; line-height: 1.65; }
.policy h1 { font-size: 30px; margin: 8px 0 6px; }
.policy h2 { font-size: 19px; margin: 24px 0 6px; }
.policy a { color: #ff8a70; }
.plan h2 small { font-size: 18px; font-weight: 600; color: var(--muted); margin-left: 4px; }
