:root {
  --bg: #0b0910; --panel: #15121d; --panel2: #1d1928; --line: #2c2640; --text: #ece8f6; --dim: #9a93b0;
  --accent: #b36bff; --accent2: #ff5fc8; --ok: #3ddc97; --warn: #ffb547; --bad: #ff5b6e;
  --radius: 10px; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; color: #fff; font-weight: 600; }
button.danger { border-color: #5a2430; color: #ffb3bd; }
button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .45; cursor: default; }
input[type=text], input[type=url], input[type=number], select, textarea {
  background: #0f0d15; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
textarea { resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 38px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: none; padding: 1px; }
input[type=checkbox] { accent-color: var(--accent); }
label { color: var(--dim); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--dim); }
.tiny { font-size: 11px; }
.warn { color: var(--warn); }
.hidden { display: none !important; }

/* ---------------- engine (shared by viewer + preview) */
.engine { position: relative; overflow: hidden; background: #000; isolation: isolate; }
.engine .layer { position: absolute; inset: 0; opacity: 0; background: #000; }
.engine canvas.vis { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.engine .media { position: absolute; inset: 0; pointer-events: none; }
.engine .media .m { position: absolute; inset: 0; width: 100%; height: 100%; transition: opacity .6s ease; }
.engine .media iframe.m { border: 0; }
.engine .words, .engine .messages, .engine .caption { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.engine .blackout { position: absolute; inset: 0; background: #000; z-index: 9; opacity: 0; pointer-events: none; transition: opacity .3s; }
.engine .blackout.on { opacity: 1; }
.word, .msg, .ticker, .caption { text-shadow: 0 0 .25em var(--glow, #fff), 0 0 .08em #000, 0 0 .5em rgba(0,0,0,.6);
  font-weight: 700; letter-spacing: .02em; text-align: center; white-space: pre-wrap;
  -webkit-text-stroke: .045em rgba(0,0,0,.85); paint-order: stroke fill; }
.words .word { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 90%;
  animation: wfade linear forwards; }
.words.d-flash .word { animation: none; }
.words.d-zoom .word { animation-name: wzoom; }
.words.d-random .word { animation-name: wfade; }
.words.d-pulse .word { animation-name: wpulse; }
.words.d-drift .word { animation-name: wdrift; }
.words .word.out { opacity: 0 !important; transition: opacity .4s; }
@keyframes wfade { 0% { opacity: 0 } 15% { opacity: 1 } 80% { opacity: 1 } 100% { opacity: 0 } }
@keyframes wzoom { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.2) } 30% { opacity: 1 }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(2.2) } }
@keyframes wpulse { 0%,100% { opacity: 0; transform: translate(-50%,-50%) scale(.9) } 25%,75% { opacity: 1; transform: translate(-50%,-50%) scale(1.08) } 50% { transform: translate(-50%,-50%) scale(.98) } }
@keyframes wdrift { 0% { opacity: 0; transform: translate(-50%,-10%) } 20% { opacity: .9 } 80% { opacity: .9 } 100% { opacity: 0; transform: translate(-50%,-90%) } }
.words .ticker { position: absolute; bottom: 8%; left: 0; white-space: nowrap; animation: tick linear infinite; }
@keyframes tick { from { transform: translateX(0) } to { transform: translateX(-50%) } }
.caption { display: flex; justify-content: center; padding: 4vmin; color: #fff; font-weight: 600; }
.caption.pos-bottom { align-items: flex-end; } .caption.pos-top { align-items: flex-start; } .caption.pos-center { align-items: center; }
.messages .msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); max-width: 88%; color: #fff;
  animation: mfade ease forwards; }
.messages .msg.st-top { top: 14%; }
.messages .msg.st-whisper { opacity: .75; font-weight: 400; font-style: italic; }
.messages .msg.st-flash { animation: none; }
.messages .msg.out { opacity: 0 !important; transition: opacity .4s; }
@keyframes mfade { 0% { opacity: 0; filter: blur(8px) } 8% { opacity: 1; filter: blur(0) } 85% { opacity: 1 } 100% { opacity: 0 } }


.engine { container-type: size; }
.ptexts { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.ptext { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); max-width: 88%; color: #fff; font-weight: 800;
  text-align: center; white-space: pre-wrap; text-shadow: 0 0 .25em #fff8, 0 0 .5em #0009; -webkit-text-stroke: .045em rgba(0,0,0,.85); paint-order: stroke fill; }
.ptext.st-top { top: 14%; } .ptext.st-bottom { top: 80%; } .ptext.st-whisper { opacity: .75; font-weight: 400; font-style: italic; }

/* ---------------- site chrome */
.nav { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: rgba(11,9,16,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.nav .logo { font-weight: 900; font-size: 20px; letter-spacing: .06em; text-decoration: none;
  background: linear-gradient(90deg, #d9b8ff, #ff8fd8); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav a.l { color: var(--text); text-decoration: none; opacity: .85; }
.nav a.l:hover { opacity: 1; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 18px 16px 60px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card { display: block; text-decoration: none; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: transform .15s, border-color .15s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .th { position: relative; aspect-ratio: 16/9; background: #000; }
.card .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .th .d { position: absolute; right: 6px; bottom: 6px; background: #000c; font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.card .th .rec { position: absolute; left: 6px; top: 6px; background: #a0153ecc; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.card .bd { padding: 10px 12px; }
.card .t { font-weight: 650; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .m { color: var(--dim); font-size: 12px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #2a2340; color: #d9c8ff; margin: 2px 4px 0 0; }
.hero { padding: 30px 0 14px; }
.hero h1 { font-size: clamp(26px, 4vw, 40px); margin: 0 0 6px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: .03em; text-transform: uppercase; color: #cbbef0; }
.panel h4 { margin: 14px 0 6px; font-size: 13px; color: #cbbef0; }
.agegate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(5,3,10,.96); padding: 16px; }
.agegate .box { max-width: 460px; text-align: center; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #2a2340; border: 1px solid var(--accent); padding: 8px 16px; border-radius: 20px; z-index: 200; }
.err { color: var(--bad); }
.form { display: grid; gap: 10px; max-width: 420px; }
.slider label { display: flex; justify-content: space-between; } .slider label b { color: var(--text); font-weight: 500; }
.sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; }
.pal { display: flex; gap: 6px; flex-wrap: wrap; }
.pal button { padding: 0; width: 46px; height: 26px; border-radius: 6px; overflow: hidden; display: flex; border: 2px solid transparent; }
.pal button.sel { border-color: #fff; }
.pal button i { flex: 1; }
.catname { margin: 12px 0 6px; font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.grid-vis { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.vtile { position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: #000; aspect-ratio: 16/10; padding: 0; }
.vtile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vtile span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; padding: 3px 5px; background: linear-gradient(transparent, #000c); text-align: left; }
.vtile.sel { border-color: var(--accent2); box-shadow: 0 0 0 2px #ff5fc855; }
.vtile .fl { position: absolute; top: 3px; right: 3px; font-size: 10px; background: #a32; color: #fff; padding: 0 4px; border-radius: 4px; }
.catname { margin: 12px 0 6px; font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.pal { display: flex; gap: 6px; flex-wrap: wrap; }
.pal button { padding: 0; width: 46px; height: 26px; border-radius: 6px; overflow: hidden; display: flex; border: 2px solid transparent; }
.pal button.sel { border-color: #fff; }
.pal button i { flex: 1; }
.sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; }
.slider label { display: flex; justify-content: space-between; }
.slider label b { color: var(--text); font-weight: 500; }

/* ---------------- player chrome */
.pwrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; }
.pwrap .stage { aspect-ratio: 16/9; width: 100%; }
.pwrap:fullscreen .stage { aspect-ratio: auto; height: 100%; }
.pctl { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; flex-wrap: wrap; }
.pctl input[type=range].seek { flex: 1; min-width: 120px; }
.pctl .time { font: 12px ui-monospace, monospace; color: var(--dim); white-space: nowrap; }
.bigplay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 20; background: rgba(0,0,0,.35); cursor: pointer; }
.bigplay span { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 0 40px #b36bff88; }
.recdot { display: inline-flex; align-items: center; gap: 6px; color: #ff9db5; font-size: 12px; }
.recdot::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #ff3b6b; animation: recb 1.4s infinite; }
@keyframes recb { 50% { opacity: .3 } }
.selfcam { position: absolute; right: 10px; bottom: 10px; width: 22%; border-radius: 8px; z-index: 25; transform: scaleX(-1); border: 1px solid #fff4; }
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(5,3,10,.85); padding: 16px; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: 520px; width: 100%; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.tbl { width: 100%; border-collapse: collapse; }
.tbl td, .tbl th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }

.pimgs { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.pimg { position: absolute; inset: 4%; width: 92%; height: 92%; object-fit: contain; opacity: 0; transition: opacity .45s ease; filter: drop-shadow(0 0 24px #0008); }

/* ---------------- player box + fullscreen OSD */
.pbox { position: relative; }
.pctl .vol { width: 90px; }
.pbox.fakefs { position: fixed; inset: 0; z-index: 1000; }
.pbox.isfs { background: #000; width: 100%; height: 100%; }
.pbox.isfs .pwrap { position: absolute; inset: 0; border-radius: 0; }
.pbox.isfs .stage { aspect-ratio: auto; width: 100%; height: 100%; }
.pbox.isfs .pctl { position: absolute; left: 0; right: 0; bottom: 0; z-index: 30; border: 0; border-radius: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  padding: 26px max(16px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  transition: opacity .3s ease; }
.pbox.isfs .pctl button { font-size: 16px; padding: 8px 14px; }
.pbox.isfs .pctl .time { color: #ddd; }
.pbox.isfs.idle .pctl { opacity: 0; pointer-events: none; }
.pbox.isfs.idle { cursor: none; }
.pflash { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 64px; color: #fff; opacity: 0;
  pointer-events: none; z-index: 25; text-shadow: 0 0 24px #000; }
.pflash.go { animation: pflash .7s ease-out; }
@keyframes pflash { 0% { opacity: .9; transform: translate(-50%, -50%) scale(.8); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); } }
body.noscroll { overflow: hidden; }
@media (max-width: 600px) { .pctl .vol { display: none; } }

/* ---------------- create menu + video actions */
.navmenu { position: relative; }
.navmenu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 250px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px; display: grid; gap: 2px; box-shadow: 0 12px 32px #0008; }
.navmenu .menu button { text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.navmenu .menu button:hover, .navmenu .menu button:focus-visible { background: var(--panel2); }
.navmenu .menu small { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }
.vitem { display: grid; gap: 8px; align-content: start; }
.vacts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.vacts select { width: auto; padding: 4px 8px; font-size: 12px; }
