:root {
  --bg: #0e0f13; --panel: #171920; --panel2: #1f222b; --line: #2c303b; --text: #eceef3; --muted: #9aa1b2;
  --accent: #e8c97a; --accent-ink: #1b1608; --danger: #e5484d; --ok: #46a758; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 28px; margin: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 20px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.warn { color: #f0c36d; margin: 0 0 6px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 50; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 18px; }
.top nav { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 14px; }
.view { max-width: 1100px; margin: 0 auto; padding: 24px 20px 120px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.page-head { display: grid; gap: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #4a5060; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: #6b2a2d; color: #ff8589; }
.btn-big { padding: 12px 22px; font-size: 17px; justify-self: start; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type=text], textarea, select { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; }
textarea { resize: vertical; }
select { appearance: auto; }

/* library */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); text-decoration: none; display: grid; }
.tile:hover { border-color: var(--accent); }
.tile-img { aspect-ratio: 16 / 9; background: #23262f center 25% / cover no-repeat; position: relative; }
.tile-body { padding: 12px 14px; }
.tile-body h3 { margin: 0 0 2px; }
.tile-body .muted { font-size: 14px; }
.badge { position: absolute; left: 10px; bottom: 10px; background: rgba(0, 0, 0, .75); padding: 3px 9px; border-radius: 20px; font-size: 13px; }
.badge.error { color: #ff8589; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px 24px; text-align: center; display: grid; gap: 16px; justify-items: center; }
.empty p { margin: 0; max-width: 520px; color: var(--muted); }

/* form */
.form { display: grid; gap: 18px; max-width: 820px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label { font-weight: 600; }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > select, .inline > input[type=text] { flex: 1 1 180px; width: auto; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { color: #ff8589; margin: 0; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-chip { border: 2px solid var(--line); border-radius: 10px; padding: 12px 10px; min-height: 84px; cursor: pointer; text-align: left; display: grid; gap: 4px; align-content: center; background: var(--t-card, #14151a); color: var(--t-ink, #fff); font-family: var(--t-font, inherit); }
.theme-chip.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.chip-title { font-weight: 700; font-size: 16px; color: var(--t-accent, #fff); }
.chip-hint { font-size: 12px; opacity: .8; font-family: system-ui, sans-serif; }

/* progress */
.progress-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 12px; max-width: 720px; }
.stage-name { font-size: 20px; font-weight: 650; margin: 0; }
.stage-name.bad { color: #ff8589; }
.meter { height: 10px; background: var(--panel2); border-radius: 10px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 10px; transition: width .6s; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); }

/* documentary page */
.settings { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.settings label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.settings select { min-width: 190px; }
.settings .push { margin-left: auto; }
.video-box, .notes, .editor { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 10px; }
.notes:empty { display: none; }
.notes details ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.notes summary { cursor: pointer; }
.editable { cursor: text; }
.editor { gap: 18px; }
.chapter { display: grid; gap: 12px; }
.chapter h3 { color: var(--accent); margin: 0; }
.scene { display: grid; grid-template-columns: 240px 1fr; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); }
.scene.cur { border-color: var(--accent); }
.scene-media { display: grid; gap: 6px; align-content: start; min-width: 0; }
.thumb { aspect-ratio: 16 / 9; border: 0; border-radius: 8px; background: #0b0c10 center / contain no-repeat; cursor: pointer; position: relative; width: 100%; }
.vid-tag, .no-media { position: absolute; left: 6px; top: 6px; background: rgba(0, 0, 0, .75); color: #fff; padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.pager .btn { padding: 2px 10px; }
.find { display: flex; gap: 6px; }
.find input { padding: 6px 8px; font-size: 14px; }
.find .btn { padding: 6px 10px; }
.credit { font-size: 12px; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.scene-text { display: grid; gap: 8px; align-content: start; min-width: 0; }
.scene-text .yr-in { flex: 0 0 90px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #23262f; border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; z-index: 4000; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); max-width: 90vw; }
.toast.bad { border-color: #6b2a2d; color: #ff8589; }

/* login + consent */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login { padding: 24px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; max-width: 420px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.login-card h1 { font-size: 24px; }
.login-status { margin: 0; color: var(--muted); }
.login-status.error { color: var(--danger); }
.gsi { min-height: 44px; }
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 3000; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); max-width: 900px; margin: 0 auto; }
.consent p { margin: 0; font-size: 14px; color: var(--muted); flex: 1 1 380px; }
.consent-actions { display: flex; gap: 8px; }

@media (max-width: 720px) {
  .cols { grid-template-columns: 1fr; }
  .scene { grid-template-columns: 1fr; }
  .who { display: none; }
  .brand span { display: none; }
  .view { padding: 16px 16px 120px; }
  .settings .push { margin-left: 0; }
}
