/* Студия — редактор сцены в игре (public/js/studio*.js). Раскладка как в Unity: сверху — вкладки и кнопки, слева —
   объекты, справа — свойства, снизу — библиотека или таймлайн, в середине — сцена игры. Пока студия открыта, интерфейс
   игры спрятан (body.studio-on). */
:root {
  --stu-bg: rgba(24, 22, 20, .96); --stu-bg2: #1c1a18; --stu-line: #3b3429; --stu-text: #e9e2d3; --stu-mute: #9a907f;
  --stu-gold: #d8ad44; --stu-sel: #2c5a96; --stu-hov: #2c2822; --stu-red: #c8483e; --stu-top: 44px; --stu-left: 270px;
  --stu-right: 330px; --stu-bot: 200px; --stu-stat: 24px;
}
body.studio-on #map-wrap > :not(#map):not(#map3d):not(#cut-veil):not(#cut-play),
body.studio-on #actionbar, body.studio-on #hud-chat, body.studio-on #hud-menu, body.studio-on .side,
body.studio-on #tutor, body.studio-on #tooltip, body.studio-on .talent-win, body.studio-on #cheat-panel, body.studio-on #intro,
body.studio-on #ow-bigmap, body.studio-on #trade-win, body.studio-on #whisper { display: none !important; }
#studio { position: fixed; inset: 0; z-index: 60; pointer-events: none; color: var(--stu-text); font: 13px/1.35 system-ui, 'Segoe UI', sans-serif; }
#studio > * { pointer-events: auto; }
#studio button { font: inherit; color: inherit; cursor: pointer; }
#studio .muted { color: var(--stu-mute); }
#studio .hidden { display: none !important; }

/* верх */
.stu-top { position: absolute; left: 0; right: 0; top: 0; height: var(--stu-top); display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: linear-gradient(#2a2622, #201d1a); border-bottom: 1px solid var(--stu-line); box-shadow: 0 2px 10px rgba(0, 0, 0, .4); }
.stu-logo { color: var(--stu-gold); font-size: 15px; letter-spacing: .3px; white-space: nowrap; }
.stu-camp { color: var(--stu-mute); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.stu-tabs { display: flex; gap: 2px; margin-left: 8px; }
.stu-tabs button { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px 10px; white-space: nowrap; }
.stu-tabs button:hover { background: var(--stu-hov); }
.stu-tabs button.on { background: #3a3226; border-color: #5a4a30; color: #ffe6a8; }
.stu-place select { background: var(--stu-bg2); color: var(--stu-text); border: 1px solid var(--stu-line); border-radius: 5px; padding: 4px 6px; max-width: 220px; }
.stu-sp { flex: 1; }
.stu-ic { background: var(--stu-bg2); border: 1px solid var(--stu-line); border-radius: 6px; width: 30px; height: 30px; font-size: 16px; }
.stu-ic:hover:not(:disabled) { background: var(--stu-hov); }
.stu-ic:disabled { opacity: .35; cursor: default !important; }
.stu-btn { background: #2f2a24; border: 1px solid #4a4134; border-radius: 6px; padding: 6px 12px; white-space: nowrap; }
.stu-btn:hover:not(:disabled) { background: #3a332b; border-color: #66573f; }
.stu-btn.gold { background: linear-gradient(#6b5320, #4e3c16); border-color: #a07e34; color: #ffeebb; }
.stu-btn.gold:hover { background: linear-gradient(#7d6126, #5c4719); }
.stu-btn.danger { background: #4a2420; border-color: #7a3a32; color: #ffd6d0; }
.stu-btn.wide { display: block; width: 100%; text-align: center; margin: 6px 0; }
#stu-save.dirty { box-shadow: 0 0 0 2px rgba(216, 173, 68, .45); }
.stu-mini { background: #2b2722; border: 1px solid #463d31; border-radius: 4px; padding: 2px 7px; font-size: 12px !important; }
.stu-mini:hover { background: #3a332b; }

/* панели */
.stu-left, .stu-right, .stu-bottom { position: absolute; background: var(--stu-bg); border: 1px solid var(--stu-line); display: flex; flex-direction: column; overflow: hidden; }
.stu-left { left: 0; top: var(--stu-top); bottom: var(--stu-stat); width: var(--stu-left); border-left: 0; }
.stu-right { right: 0; top: var(--stu-top); bottom: var(--stu-stat); width: var(--stu-right); border-right: 0; }
.stu-bottom { left: var(--stu-left); right: var(--stu-right); bottom: var(--stu-stat); height: var(--stu-bot); border-bottom: 0; }
.stu-left.empty, .stu-right.empty, .stu-bottom.empty { display: none; }
/* таймлайн кат-сцен — во всю ширину под боковыми панелями, как в Unity */
#studio[data-tab='cut'] .stu-bottom { height: 250px; left: 0; right: 0; }
#studio[data-tab='cut'] .stu-left, #studio[data-tab='cut'] .stu-right { bottom: calc(250px + var(--stu-stat)); }
.stu-ph { padding: 8px 10px; font-weight: 600; color: #f2e4c0; border-bottom: 1px solid var(--stu-line); background: rgba(255, 255, 255, .02); flex: none; }
.stu-pad { padding: 8px 10px; }
.stu-in { width: 100%; box-sizing: border-box; background: #15130f; color: var(--stu-text); border: 1px solid var(--stu-line); border-radius: 5px; padding: 5px 7px; font: inherit; }
.stu-in:focus { outline: none; border-color: #8a7140; }
.stu-empty { color: var(--stu-mute); padding: 14px 10px; text-align: center; }
.stu-err { color: #ff9a8a; }
.stu-tip p { margin: 0 0 10px; padding: 0 10px; }
.stu-tip { padding-top: 10px; overflow: auto; }

/* список объектов */
.stu-own { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 10px 6px; color: var(--stu-mute); font-size: 12px; flex: none; }
.stu-hlist { flex: 1; overflow: auto; padding-bottom: 8px; }
.stu-hg { padding: 4px 10px; cursor: pointer; color: #d9cdb4; user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stu-hg:hover { background: var(--stu-hov); }
.stu-hg i { display: inline-block; width: 12px; font-style: normal; color: var(--stu-mute); }
.stu-hg small, .stu-hr small { color: var(--stu-mute); }
.stu-hr { padding: 3px 10px 3px 30px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stu-hr:hover { background: var(--stu-hov); }
.stu-hr.sel { background: var(--stu-sel); color: #fff; }

.stu-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; box-shadow: 0 0 6px currentColor; vertical-align: 0; }

/* свойства */
.stu-ins { flex: 1; overflow: auto; padding: 6px 10px 14px; }
.stu-sec { margin: 12px 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--stu-line); color: var(--stu-gold); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.stu-f { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 6px; margin: 4px 0; }
.stu-f > span:first-child { color: #cbbfa8; font-size: 12px; }
.stu-xy { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stu-xy .stu-f { grid-template-columns: 16px 1fr; }
.stu-rng { display: flex; gap: 6px; align-items: center; min-width: 0; }
.stu-rng input[type=range] { flex: 1; min-width: 0; accent-color: var(--stu-gold); }
.stu-rng input[type=number] { width: 56px; background: #15130f; color: var(--stu-text); border: 1px solid var(--stu-line); border-radius: 4px; padding: 3px 4px; font: inherit; }
.stu-f input[type=color] { width: 48px; height: 26px; padding: 0; border: 1px solid var(--stu-line); background: none; border-radius: 4px; }
.stu-btns { display: flex; gap: 4px; margin-left: 4px; }
.stu-chk { display: flex; align-items: center; gap: 7px; margin: 5px 0; cursor: pointer; }
.stu-chk input { accent-color: var(--stu-gold); width: auto !important; flex: none; margin: 0; }
#studio input[type=range] { width: auto; padding: 0; }
#studio input[type=color] { flex: none; }
.stu-model { display: flex; gap: 8px; align-items: center; background: #15130f; border: 1px solid var(--stu-line); border-radius: 6px; padding: 6px; margin: 6px 0; }
.stu-model img { width: 52px; height: 52px; border-radius: 4px; background: #24201b; object-fit: contain; }
.stu-model div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stu-model small { color: var(--stu-mute); }
.stu-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }

/* библиотека */
.stu-libh { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--stu-line); flex: none; flex-wrap: wrap; }
.stu-libh .stu-in { width: 180px; }
.stu-chips { display: flex; gap: 3px; flex-wrap: wrap; }
.stu-chips button { background: #221f1b; border: 1px solid #3a3328; border-radius: 12px; padding: 2px 9px; font-size: 12px !important; }
.stu-chips button.on { background: #4a3c22; border-color: #8a6f3a; color: #ffe8b0; }
.stu-lib { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; padding: 8px 10px; align-content: start; }
.stu-card { background: #1a1815; border: 1px solid #332d24; border-radius: 6px; padding: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; user-select: none; }
.stu-card:hover { border-color: #7a6440; background: #221f1a; }
.stu-card.on { border-color: var(--stu-gold); box-shadow: 0 0 0 1px var(--stu-gold) inset; background: #2b2518; }
.stu-card span { font-size: 11px; text-align: center; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.stu-thumb { width: 74px; height: 74px; display: flex; align-items: center; justify-content: center; font-size: 34px; background: radial-gradient(#2e2a24, #181613); border-radius: 4px; }
.stu-thumb img { width: 100%; height: 100%; object-fit: contain; }
.stu-thumb img.none { display: none; }

/* инструменты и подсказка поверх сцены */
.stu-tools { position: absolute; left: calc(var(--stu-left) + 10px); top: calc(var(--stu-top) + 10px); display: flex; gap: 4px; background: var(--stu-bg); border: 1px solid var(--stu-line); border-radius: 8px; padding: 4px; }
.stu-tools button { width: 32px; height: 32px; border-radius: 6px; border: 1px solid transparent; background: transparent; font-size: 17px; }
.stu-tools button:hover { background: var(--stu-hov); }
.stu-tools button.on { background: #3a3226; border-color: #6a5636; color: #ffe2a0; }
.stu-tsep { width: 1px; background: var(--stu-line); margin: 3px 2px; }
#studio:not([data-tab='scene']) .stu-tools [data-tool] { display: none; }
#studio:not([data-tab='scene']) .stu-tsep { display: none; }
.stu-hint { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--stu-top) + 10px); max-width: 560px; background: rgba(40, 32, 18, .94); border: 1px solid #8a6f3a; color: #ffeec4;
  border-radius: 8px; padding: 7px 14px; text-align: center; pointer-events: none !important; }

/* строка состояния */
.stu-status { position: absolute; left: 0; right: 0; bottom: 0; height: var(--stu-stat); display: flex; gap: 16px; align-items: center; padding: 0 10px; background: #161412; border-top: 1px solid var(--stu-line);
  color: var(--stu-mute); font-size: 12px; white-space: nowrap; overflow: hidden; }
.stu-status b { color: #ffe2a0; font-weight: 600; }
.stu-status .stu-keys { margin-left: auto; overflow: hidden; text-overflow: ellipsis; }

/* окно с вопросом */
.stu-modal { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; z-index: 5; }
.stu-mbox { background: #221f1b; border: 1px solid #6a5636; border-radius: 10px; padding: 16px 20px; max-width: 440px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
.stu-mbox h3 { margin: 0 0 8px; color: #ffe2a0; font-size: 16px; }
.stu-mbox p { margin: 0 0 14px; }
.stu-mrow { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* таймлайн кат-сцен */
.stc-bar { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-bottom: 1px solid var(--stu-line); flex: none; flex-wrap: wrap; }
.stc-time { font: 12px ui-monospace, Consolas, monospace; color: #ffe2a0; min-width: 92px; }
.stc-evs { display: flex; gap: 3px; flex-wrap: wrap; }
.stc-zoom { display: flex; gap: 2px; }
.stc-tl { flex: 1; display: flex; min-height: 0; }
.stc-heads { width: 110px; flex: none; border-right: 1px solid var(--stu-line); }
.stc-rh { height: 26px; line-height: 26px; padding: 0 8px; font-size: 12px; color: #cbbfa8; border-bottom: 1px solid #2a251f; white-space: nowrap; }
.stc-rh:first-child { height: 22px; }
.stc-scroll { flex: 1; overflow: auto; position: relative; }
.stc-inner { position: relative; min-height: 100%; }
.stc-ruler { height: 22px; position: relative; border-bottom: 1px solid var(--stu-line); background: #191714; cursor: pointer; }
.stc-ruler i { position: absolute; top: 0; bottom: 0; border-left: 1px solid #3a3328; }
.stc-ruler b { position: absolute; left: 3px; top: 3px; font: 10px ui-monospace, monospace; color: var(--stu-mute); font-weight: 400; }
.stc-row { height: 26px; position: relative; border-bottom: 1px solid #2a251f; }
.stc-row:nth-child(odd) { background: rgba(255, 255, 255, .015); }
.stc-key { position: absolute; top: 6px; width: 12px; height: 12px; margin-left: -6px; transform: rotate(45deg); background: #e8a83a; border: 1px solid #ffde98; cursor: ew-resize; }
.stc-key.e-linear { background: #6aa0e8; border-color: #b8d4ff; }
.stc-key.e-cut { background: #d85a5a; border-color: #ffb0a8; }
.stc-key.sel { box-shadow: 0 0 0 2px #fff; }
.stc-ev { position: absolute; top: 3px; height: 19px; border-radius: 4px; background: #3a4a62; border: 1px solid #5a7090; font-size: 11px; font-weight: 400; line-height: 17px; padding: 0 5px; color: #e6eefc;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: ew-resize; box-sizing: border-box; min-width: 16px; }
.stc-ev.k-text { background: #4a3f2a; border-color: #8a7340; color: #ffeec4; }
.stc-ev.k-fade, .stc-ev.k-white, .stc-ev.k-bars, .stc-ev.k-shake { background: #3c3048; border-color: #6a5486; }
.stc-ev.k-light { background: #4a3c1c; border-color: #a08030; }
.stc-ev.k-npc { background: #2a4a3a; border-color: #4a8a6a; }
.stc-ev.sel { box-shadow: 0 0 0 2px #fff; }
.stc-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ff5a4a; pointer-events: none; }
.stc-head::before { content: ''; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: #ff5a4a; }
.stc-end { position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: rgba(216, 173, 68, .35); cursor: col-resize; }
.stu-ins textarea.stu-in { resize: vertical; min-height: 60px; }
/* вступление «На повозках»: реплики по звеньям в списке кат-сцен, подсказка на дорожке камеры */
.stc-road { padding-left: 10px; }
.stc-grp { padding: 8px 10px 2px 18px; color: var(--stu-gold); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.stc-ln { padding: 2px 10px 2px 22px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: #d9cdb4; }
.stc-ln b { font-weight: 600; color: #ffe2a0; margin-right: 3px; }
.stc-ln:hover { background: var(--stu-hov); }
.stc-ln.sel { background: var(--stu-sel); color: #fff; }
.stc-note { position: absolute; left: 8px; top: 5px; font-size: 11px; color: var(--stu-mute); white-space: nowrap; pointer-events: none; }
.stu-ins code { background: #15130f; padding: 1px 4px; border-radius: 3px; font-size: 11px; }

/* триггеры */
.stt-half { flex: 1 1 40%; min-height: 80px; }
.stu-left .small { font-size: 12px; padding-top: 4px; }
.stu-left .stu-f { grid-template-columns: 70px 1fr; }
.stt-do { display: grid; grid-template-columns: 20px 1fr auto; gap: 4px 6px; align-items: center; background: #15130f; border: 1px solid var(--stu-line); border-radius: 6px; padding: 6px; margin-bottom: 6px; }
.stt-do > :last-child { grid-column: 2 / 4; }
.stt-n { color: var(--stu-gold); font-weight: 600; text-align: center; }
.stt-mv { display: flex; gap: 3px; }

/* рельеф */
.str-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 4px; margin-bottom: 8px; }
.str-tools .stu-btn { overflow: hidden; text-overflow: ellipsis; padding: 6px 8px; }
.str-tools .stu-btn.on { background: #4a3c22; border-color: #a07e34; color: #ffeebb; }
.str-layers { display: flex; flex-direction: column; gap: 3px; }
.str-layer { display: flex; align-items: center; gap: 8px; background: #1a1815; border: 1px solid #332d24; border-radius: 5px; padding: 4px 8px; text-align: left; }
.str-layer i { width: 18px; height: 18px; border-radius: 3px; display: inline-block; }
.str-layer.on { border-color: var(--stu-gold); background: #2b2518; }

/* кампания */
.stu-camp p { margin: 0 0 10px; }
.stu-file { position: relative; cursor: pointer; }
.stu-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.stu-card-sum { background: #15130f; border: 1px solid var(--stu-line); border-radius: 8px; padding: 10px; margin-top: 10px; }
.stu-card-sum ul { margin: 8px 0; padding-left: 18px; color: #cbbfa8; }
.stu-card-sum .stu-mrow { justify-content: flex-start; }

@media (max-width: 1200px) { :root { --stu-left: 220px; --stu-right: 290px; } .stu-tabs button { padding: 6px 7px; } .stu-camp { display: none; } }

/* кат-сцена студии (r3d-studio.js cutVeil): затемнение, белый экран, полосы кадра, реплика — у всех игроков и в просмотре */
#cut-play { position: absolute; inset: 0; pointer-events: none; z-index: 40; display: none; --bars: 0; }
#cut-play.on { display: block; }
#cut-play i { position: absolute; left: 0; right: 0; display: block; }
#cut-play .cp-black, #cut-play .cp-white { inset: 0; opacity: 0; }
#cut-play .cp-black { background: #000; }
#cut-play .cp-white { background: #fff; }
#cut-play .cp-bar { height: calc(11% * var(--bars)); background: #000; }
#cut-play .cp-bar.top { top: 0; }
#cut-play .cp-bar.bot { bottom: 0; }
#cut-play .cp-text { position: absolute; left: 50%; bottom: calc(4% + 11% * var(--bars)); transform: translateX(-50%); max-width: min(900px, 80%); text-align: center;
  color: #f4ecd8; font: 20px/1.4 var(--bg3-serif, Georgia, serif); text-shadow: 0 2px 6px #000, 0 0 2px #000; opacity: 0; transition: opacity .3s; }
#cut-play .cp-text.on { opacity: 1; }
#cut-play .cp-text b { color: #e8c37a; margin-right: 6px; }
#cut-play .cp-skip { position: absolute; right: 24px; bottom: calc(3% + 11% * var(--bars)); pointer-events: auto; background: rgba(20, 16, 12, .7); color: #eadfc6; border: 1px solid #6a5636; border-radius: 6px; padding: 6px 14px; cursor: pointer; font: 14px system-ui, sans-serif; }
#cut-play .cp-skip.sent { opacity: .5; }
#cut-play .cp-skip.hidden { display: none; }
body.stu-cut #actionbar, body.stu-cut #hud-chat, body.stu-cut #hud-menu, body.stu-cut #hud-tr, body.stu-cut #party-cards, body.stu-cut #initiative,
body.stu-cut #tooltip, body.stu-cut #target-hud { opacity: 0 !important; pointer-events: none !important; transition: opacity .4s ease; }
body.studio-on #cut-play { left: var(--stu-left); right: var(--stu-right); top: var(--stu-top); bottom: calc(var(--stu-bot) + var(--stu-stat)); }
body.studio-on[data-stu-tab='cut'] #cut-play { bottom: calc(250px + var(--stu-stat)); }

/* ── Студия → «💬 Разговоры» (studio-talk.js): список сцен и редактор сцен поверх мира ── */
.stk-top { display: flex; flex-direction: column; gap: 6px; }
.stk-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.stk-h { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.stk-about { line-height: 1.45; color: #d8cdb8; border-left: 3px solid #6b5320; padding-left: 8px; }
#stk-ed { position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column; background: #14110d; }
.stk-ed-top { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid #3a3226; color: #f2e4c0; font: 13px system-ui, 'Segoe UI', sans-serif; }
.stk-ed-top .stu-ic { background: #2f2a24; border: 1px solid #4a4134; color: inherit; border-radius: 6px; padding: 3px 9px; cursor: pointer; }
#stk-ed iframe { flex: 1; width: 100%; border: 0; background: #14110d; }
