:root {
  --bg: #0d0e11; --panel: #16181d; --line: #262a31; --text: #f3f1ea; --mute: #8d929b;
  --yellow: #febe46; --cyan: #00acc1; --red: #ef4854;
  --r: 14px; --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Devanagari", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 12px; padding: 18px 24px; }
.mark { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.dot { width: 22px; height: 22px; border-radius: 7px; background: var(--yellow); position: relative; }
.dot::after { content: ""; position: absolute; left: 5px; right: 5px; top: 9px; height: 4px; border-radius: 2px; background: #111; }
main { max-width: 980px; margin: 0 auto; padding: 8px 24px 140px; }

.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #2a2d33; color: var(--text); white-space: nowrap; }
.tag.warn { background: rgba(254,190,70,.16); color: var(--yellow); }
.tag.bad { background: rgba(239,72,84,.16); color: #ff8a93; }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 650; background: #24272d; transition: transform .15s var(--ease), background .15s; }
.btn:hover { background: #2c3037; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--yellow); color: #121212; }
.btn.primary:hover { background: #ffc95f; }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.link { background: none; border: 0; color: var(--mute); padding: 8px 4px; font-weight: 600; text-decoration: none; }
.link:hover { color: var(--text); }

.alert { background: rgba(239,72,84,.12); border: 1px solid rgba(239,72,84,.35); color: #ffc2c7; padding: 12px 14px; border-radius: 12px; margin: 14px 0; display: flex; gap: 12px; align-items: center; justify-content: space-between; }

/* Wizard */
.wizard { min-height: 52vh; display: flex; flex-direction: column; justify-content: center; padding-top: 6vh; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; min-height: 34px; margin-bottom: 18px; }
.crumb { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 5px 12px; color: var(--mute); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb:hover { color: var(--text); border-color: #3a3f48; }
.ask { font-size: clamp(30px, 5vw, 52px); font-weight: 750; letter-spacing: -.03em; line-height: 1.08; margin: 0 0 22px; }
.oneline { display: flex; gap: 10px; align-items: stretch; }
.oneline input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; font-size: clamp(18px, 2.4vw, 24px); outline: none; transition: border-color .2s; }
.oneline input:focus { border-color: var(--yellow); }
.oneline .btn { padding: 0 22px; font-size: 22px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-height: 150px; transition: border-color .2s, transform .2s var(--ease), background .2s; animation: rise .35s var(--ease) both; }
.tile:nth-child(2) { animation-delay: .04s; } .tile:nth-child(3) { animation-delay: .08s; }
.tile:hover, .tile:focus-visible { border-color: var(--yellow); transform: translateY(-2px); outline: none; }
.tile:focus { outline: none; }
.tile .name { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.tile .sub { color: var(--mute); font-size: 14px; margin-top: auto; }
.shape { border: 2.5px solid currentColor; border-radius: 6px; color: var(--yellow); }
.shape.v { width: 30px; height: 52px; } .shape.h { width: 62px; height: 36px; margin-top: 8px; }
.glyph { font-size: 34px; font-weight: 750; color: var(--yellow); line-height: 1; }
.mins { display: flex; gap: 6px; }
.mins span { border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 13px; color: var(--mute); }
.mins span.on { border-color: var(--yellow); color: var(--yellow); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.recent { margin-top: 64px; }
.recent h2, .section { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); margin: 0 0 14px; font-weight: 650; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.card { text-decoration: none; display: flex; flex-direction: column; gap: 8px; }
.card .pic { aspect-ratio: 9/12; border-radius: 12px; background: var(--panel) center/cover; border: 1px solid var(--line); position: relative; overflow: hidden; }
.card .pic .tag { position: absolute; left: 8px; top: 8px; }
.card .t { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card:hover .pic { border-color: #3a3f48; }

/* Script */
.head { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.title-in { width: 100%; background: transparent; border: 0; border-bottom: 1px solid transparent; font-size: clamp(24px, 3.4vw, 36px); font-weight: 750; letter-spacing: -.02em; padding: 4px 0; outline: none; }
.title-in:focus { border-bottom-color: var(--line); }
.meta { display: flex; gap: 10px; align-items: center; color: var(--mute); font-size: 14px; margin: 6px 0 22px; flex-wrap: wrap; }
.meta b { color: var(--text); font-weight: 650; }
.scenes { display: flex; flex-direction: column; gap: 10px; }
.scene { display: grid; grid-template-columns: 34px 1fr auto; gap: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 14px 12px; animation: rise .3s var(--ease) both; }
.scene:focus-within { border-color: #3a3f48; }
.scene .n { color: var(--mute); font-variant-numeric: tabular-nums; font-weight: 650; padding-top: 3px; }
.scene textarea { width: 100%; resize: none; overflow: hidden; background: transparent; border: 0; outline: none; padding: 2px 0; line-height: 1.45; }
.scene .say { font-size: 18px; }
.scene .vis { font-size: 13px; color: var(--mute); grid-column: 2; }
.scene .vis:focus { color: var(--text); }
.scene .side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; grid-row: 1 / span 2; grid-column: 3; }
.pill { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.pill button { border: 0; background: transparent; color: var(--mute); padding: 4px 11px; font-size: 13px; font-weight: 600; }
.pill button.on { background: #2d3138; color: var(--text); }
.pill button.on.clip { background: rgba(0,172,193,.2); color: #5fe3f2; }
.x { border: 0; background: transparent; color: #555b65; font-size: 18px; line-height: 1; padding: 2px 4px; opacity: 0; transition: opacity .15s; }
.scene:hover .x, .scene:focus-within .x { opacity: 1; }
.x:hover { color: var(--red); }
.add { margin-top: 10px; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }

/* Real photos */
.scene .ref { grid-column: 2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.scene .add-ref { grid-column: 2; justify-self: start; font-size: 13px; padding: 2px 0; opacity: 0; transition: opacity .15s; }
.scene:hover .add-ref, .scene:focus-within .add-ref, .add-ref:focus-visible { opacity: 1; }
.ref-pic { width: 44px; height: 44px; flex: none; padding: 0; border-radius: 9px; border: 1px solid var(--line); background: #1d2025 center/cover; transition: border-color .15s; }
.ref-pic:hover { border-color: var(--yellow); }
.ref-pic.empty { border-style: dashed; }
.ref-name { font-size: 13px; font-weight: 650; min-width: 0; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene .ref .link { font-size: 13px; padding: 4px 2px; }
.pick { grid-column: 2 / -1; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; padding: 10px; background: #121318; border: 1px solid var(--line); border-radius: 12px; animation: rise .25s var(--ease) both; }
.pick .q { display: flex; gap: 8px; }
.pick .q input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; outline: none; }
.pick .q input:focus { border-color: var(--yellow); }
.pick .strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; min-height: 104px; align-items: center; }
.pick .cand { flex: none; width: 100px; height: 100px; padding: 0; border-radius: 10px; border: 2px solid transparent; background: #1d2025 center/cover; scroll-snap-align: start; font-size: 11px; color: var(--mute); overflow: hidden; transition: border-color .15s, opacity .15s; }
.pick .cand:hover:not(:disabled) { border-color: var(--yellow); }
.pick .cand.busy { opacity: .45; pointer-events: none; }
.pick .cand:disabled { opacity: .2; cursor: default; }
.pick .none { color: var(--mute); font-size: 14px; }
.pick .alert { margin: 0; }
.pick .link { font-size: 14px; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(13,14,17,.86); backdrop-filter: blur(14px); border-top: 1px solid var(--line); z-index: 5; }
.bar .in { max-width: 980px; margin: 0 auto; padding: 14px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.bar .grow { flex: 1; }
.cost { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: #1d2025; border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--mute); padding: 8px 12px; border-radius: 9px; font-weight: 650; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: #30343c; color: var(--text); }
.seg button:disabled { cursor: default; }

/* Skeletons and progress */
.skel { background: linear-gradient(90deg, #17191e 0%, #20232a 50%, #17191e 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r); }
@keyframes shimmer { to { background-position: -200% 0; } }
.writing .skel { height: 74px; margin-bottom: 10px; }
.writing .skel:nth-child(2) { width: 92%; } .writing .skel:nth-child(3) { width: 84%; } .writing .skel:nth-child(4) { width: 88%; }
.steps { display: flex; gap: 22px; margin: 8px 0 14px; color: var(--mute); font-weight: 650; flex-wrap: wrap; }
.steps .on { color: var(--text); }
.steps .done { color: var(--cyan); }
.track { height: 6px; background: #1d2025; border-radius: 99px; overflow: hidden; margin-bottom: 26px; }
.track i { display: block; height: 100%; background: var(--yellow); border-radius: 99px; transition: width .6s var(--ease); }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.grid.long { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid .cell { border-radius: 12px; overflow: hidden; background: var(--panel); position: relative; }
.grid .cell img { width: 100%; height: 100%; object-fit: cover; display: block; animation: pop .5s var(--ease) both; }
.grid .cell .tag { position: absolute; left: 6px; bottom: 6px; }
@keyframes pop { from { opacity: 0; transform: scale(1.06); filter: blur(6px); } }

/* Ready */
.ready { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; margin-top: 10px; }
.ready.short { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); }
.player { width: 100%; border-radius: 16px; background: #000; display: block; }
.fields { display: flex; flex-direction: column; gap: 12px; }
.fields textarea, .fields input { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; resize: vertical; }
.fields input { font-size: 20px; font-weight: 700; }
.fields textarea:focus, .fields input:focus { border-color: #3a3f48; }
.where { display: flex; gap: 10px; flex-wrap: wrap; }
.where button { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px 16px; font-weight: 650; display: inline-flex; gap: 8px; align-items: center; }
.where button.on { border-color: var(--yellow); background: rgba(254,190,70,.08); }
.where button:disabled { opacity: .45; cursor: default; }
.where .ok { color: var(--cyan); }
.where a { text-decoration: none; }
.fields [readonly] { border-color: transparent; background: transparent; padding-left: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.posted a.btn { text-decoration: none; display: inline-block; }

.login { max-width: 380px; margin: 16vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login input { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 18px; outline: none; }

@media (max-width: 720px) {
  main { padding: 4px 16px 160px; }
  .ready, .ready.short { grid-template-columns: 1fr; }
  .ready.short .player { max-width: 320px; margin: 0 auto; }
  .scene { grid-template-columns: 26px 1fr; }
  .scene .side { grid-row: auto; grid-column: 2; flex-direction: row; justify-content: space-between; }
  .x { opacity: 1; }
  .scene .add-ref { opacity: 1; }
  .pick { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
