:root {
  --icevn-bg:#0e0710; --icevn-panel:#1a0a12; --icevn-panel-2:#26111b;
  --icevn-border:#3a1f2c; --icevn-ink:#f0e4e8; --icevn-muted:#b89aa6;
  --icevn-accent:#ae2448; --icevn-accent-2:#72baa9; --icevn-frost:#d5e7b5;
  --icevn-radius:12px; --icevn-radius-lg:20px;
  --icevn-shadow:0 20px 45px -22px rgba(0,0,0,.65);
  --icevn-mono:ui-monospace,'JetBrains Mono',Consolas,monospace;
}
* { box-sizing:border-box; }
/* ВАЖНО: атрибут hidden не работает на элементах, у которых в CSS задан
   display:flex/grid/block — авторский display перебивает UA-стиль [hidden].
   Приходится явно закрывать это правило с !important. */
[hidden] { display: none !important; }
html,body { margin:0; padding:0; font-family:'Inter',system-ui,-apple-system,'Segoe UI',sans-serif; }

.icevn-player { width:100%; height:100vh; background:#000; color:var(--icevn-ink); overflow:hidden; }
.icevn-player--embed { height:100%; }

.icevn-stage {
  position:relative; width:100%; height:100%; overflow:hidden;
  cursor:pointer; user-select:none; background:#000;
  perspective:1200px;
}
.icevn-world { position:absolute; inset:0; transform-origin:center center; will-change:transform; }
.icevn-bg {
  position:absolute; inset:0; background-size:cover; background-position:center;
  background-repeat:no-repeat; transition:opacity .4s ease;
}
.icevn-layers { position:absolute; inset:0; }
.icevn-layers .icevn-layer {
  position:absolute; inset:-5%; background-size:cover; background-position:center;
  will-change:transform; pointer-events:none;
}
.icevn-tint { position:absolute; inset:0; pointer-events:none; transition:background .4s ease; }
.icevn-actors { position:absolute; inset:0; pointer-events:none; }
.icevn-actor {
  position:absolute; bottom:0; height:88%; z-index:5;
  transition:transform .3s ease, opacity .3s ease, left .3s ease, right .3s ease;
  will-change:transform, opacity;
}
.icevn-actor img { height:100%; width:auto; display:block; filter:drop-shadow(0 18px 40px rgba(0,0,0,.6)); }
.icevn-actor[data-pos="left"]         { left:6%; }
.icevn-actor[data-pos="center-left"]  { left:25%; }
.icevn-actor[data-pos="center"]       { left:50%; transform:translateX(-50%); }
.icevn-actor[data-pos="center-right"] { left:60%; }
.icevn-actor[data-pos="right"]        { right:6%; }
.icevn-actor[data-flip="1"] img { transform:scaleX(-1); }
.icevn-actor-placeholder {
  padding:24px 42px; background:linear-gradient(135deg,var(--icevn-accent),var(--icevn-accent-2));
  border-radius:14px; font-weight:700; font-size:1.5rem; color:#fff;
}
.icevn-actor.is-hidden { opacity:0; }
.icevn-actor.is-entering { opacity:0; transform:translateY(20px) translateX(-50%); }
.icevn-actor[data-pos="left"].is-entering,
.icevn-actor[data-pos="right"].is-entering,
.icevn-actor[data-pos="center-left"].is-entering,
.icevn-actor[data-pos="center-right"].is-entering { transform:translateY(20px); }

.icevn-fx-canvas { position:absolute; inset:0; width:100%; height:100%; display:block; pointer-events:none; z-index:6; }

.icevn-triggers { position:absolute; inset:0; z-index:8; pointer-events:none; }
.icevn-trigger {
  position:absolute; pointer-events:auto; cursor:pointer;
  border:2px dashed transparent; border-radius:8px;
  transition:border-color .25s, background .25s;
}
.icevn-trigger:hover { border-color:rgba(114,186,169,.6); background:rgba(114,186,169,.08); }
.icevn-trigger.hint::after {
  content:attr(data-hint); position:absolute; left:50%; bottom:-26px;
  transform:translateX(-50%); background:rgba(14,7,16,.9); color:var(--icevn-frost);
  padding:3px 10px; border-radius:10px; font-size:.72rem; white-space:nowrap;
  opacity:0; transition:opacity .2s; pointer-events:none;
}
.icevn-trigger:hover.hint::after { opacity:1; }

.icevn-video { position:absolute; inset:0; background:#000; z-index:9;
  display:flex; align-items:center; justify-content:center; }
.icevn-video video { width:100%; height:100%; object-fit:contain; }

.icevn-statusbar { position:absolute; top:14px; left:14px; display:flex; gap:8px; align-items:center; z-index:20; }
.icevn-time {
  padding:6px 14px; background:rgba(14,7,16,.72); border:1px solid rgba(114,186,169,.3);
  border-radius:30px; font-family:var(--icevn-mono); font-size:.8rem; color:var(--icevn-frost);
  display:flex; gap:8px; align-items:center;
}
.icevn-time .ph { color:var(--icevn-accent-2); text-transform:capitalize; }
.icevn-inv-toggle {
  padding:6px 14px; background:rgba(14,7,16,.72); border:1px solid rgba(114,186,169,.3);
  border-radius:30px; cursor:pointer; font-size:.8rem; color:var(--icevn-frost);
  transition:.15s; user-select:none;
}
.icevn-inv-toggle:hover { background:var(--icevn-accent-2); color:#0e0710; }

.icevn-inv {
  position:absolute; top:60px; left:14px; width:280px; max-height:70vh;
  background:var(--icevn-panel-2); border:1px solid var(--icevn-border);
  border-radius:var(--icevn-radius-lg); overflow:hidden; z-index:22;
  box-shadow:var(--icevn-shadow); display:flex; flex-direction:column;
}
.icevn-inv header {
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 16px; border-bottom:1px solid var(--icevn-border);
  font-weight:700; color:var(--icevn-frost); font-family:'Cormorant Unicase',serif;
}
.icevn-inv header button { background:none; border:none; color:var(--icevn-muted); font-size:1.3rem; cursor:pointer; }
.icevn-inv-list { padding:10px 12px; overflow-y:auto; }
.icevn-inv-item { display:flex; gap:10px; align-items:center; padding:8px; border-radius:10px; transition:.15s; }
.icevn-inv-item:hover { background:rgba(114,186,169,.08); }
.icevn-inv-icon {
  width:36px; height:36px; border-radius:8px; background:rgba(114,186,169,.15);
  display:flex; align-items:center; justify-content:center; font-size:1.2rem; flex-shrink:0;
}
.icevn-inv-name { font-weight:600; font-size:.9rem; }
.icevn-inv-desc { font-size:.75rem; color:var(--icevn-muted); }
.icevn-inv-count {
  margin-left:auto; font-family:var(--icevn-mono); font-size:.8rem;
  background:rgba(174,36,72,.2); color:var(--icevn-frost); padding:2px 8px; border-radius:10px;
}

.icevn-hud { position:absolute; top:14px; right:14px; display:flex; gap:6px; z-index:20; }
.icevn-hud-btn {
  width:40px; height:40px; border-radius:50%;
  border:1px solid rgba(114,186,169,.32); background:rgba(14,7,16,.72); color:var(--icevn-ink);
  cursor:pointer; font-size:1rem; display:flex; align-items:center; justify-content:center;
  transition:.18s; font-family:var(--icevn-mono);
}
.icevn-hud-btn:hover { background:var(--icevn-accent-2); color:#0e0710; }
.icevn-hud-btn.active { background:var(--icevn-accent); color:#fff; border-color:var(--icevn-accent); }
.icevn-i { font-style:normal; }

.icevn-dialogue {
  position:absolute; left:5%; right:5%; bottom:30px;
  background:rgba(14,7,16,.86); border:1px solid rgba(114,186,169,.32);
  border-radius:var(--icevn-radius-lg); padding:22px 30px 26px;
  backdrop-filter:blur(10px); box-shadow:var(--icevn-shadow); z-index:10;
  animation:icevn-dialogue-in .25s ease-out;
}
@keyframes icevn-dialogue-in { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }
.icevn-speaker {
  font-weight:700; color:var(--icevn-accent-2); margin-bottom:10px;
  font-size:.95rem; letter-spacing:.06em; text-transform:uppercase;
}
.icevn-text { font-size:1.15rem; line-height:1.6; min-height:2.6em; }
.icevn-text.is-thought {
    font-style: italic;
    color: var(--icevn-muted);
    opacity: .92;
}
.icevn-text .caret { display:inline-block; width:.55em; margin-left:2px; animation:icevn-caret .9s steps(2) infinite; color:var(--icevn-accent-2); }
@keyframes icevn-caret { 50% { opacity:0; } }
.icevn-next { position:absolute; right:22px; bottom:12px; color:var(--icevn-accent-2); animation:icevn-bounce 1.2s infinite; }
@keyframes icevn-bounce { 0%,100% { transform:translateY(0); } 50% { transform:translateY(4px); } }

/* ===== Варианты оформления диалога (ui.dialogue_style) ===== */

/* minimal — без рамки и фона, только текст поверх сцены */
.icevn-ui--dialogue-minimal .icevn-dialogue {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 18px 26px 28px;
}
.icevn-ui--dialogue-minimal .icevn-speaker {
    background: rgba(14,7,16,.78);
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
}

/* boxed — акцентная левая полоса, чуть строже */
.icevn-ui--dialogue-boxed .icevn-dialogue {
    border-left: 4px solid var(--icevn-accent-2);
    border-radius: 8px;
    padding-left: 34px;
}
.icevn-ui--dialogue-boxed .icevn-speaker {
    color: var(--icevn-accent-2);
    border-bottom: 1px dashed rgba(114,186,169,.35);
    padding-bottom: 8px;
}

.icevn-choices {
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  display:flex; flex-direction:column; gap:12px; min-width:340px; max-width:82%; z-index:15;
}
.icevn-choice {
  padding:15px 26px; border-radius:60px; border:1.5px solid var(--icevn-accent-2);
  background:rgba(14,7,16,.82); color:var(--icevn-ink);
  font-size:1rem; font-weight:600; cursor:pointer; text-align:center;
  transition:.18s; font-family:inherit; animation:icevn-choice-in .3s ease-out both;
}
.icevn-choice:nth-child(1) { animation-delay:.02s; }
.icevn-choice:nth-child(2) { animation-delay:.08s; }
.icevn-choice:nth-child(3) { animation-delay:.14s; }
.icevn-choice:nth-child(4) { animation-delay:.20s; }
@keyframes icevn-choice-in { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }
.icevn-choice:hover { background:var(--icevn-accent-2); color:#0e0710; transform:translateY(-2px); }

.icevn-input {
  position:absolute; left:50%; bottom:22%; transform:translateX(-50%);
  background:rgba(14,7,16,.9); border:1px solid var(--icevn-accent-2);
  border-radius:var(--icevn-radius-lg); padding:22px 26px; z-index:16;
  min-width:320px; max-width:80%; box-shadow:var(--icevn-shadow);
}
.icevn-input-prompt { font-size:1rem; margin-bottom:12px; color:var(--icevn-frost); }
.icevn-input form { display:flex; gap:8px; }
.icevn-input input {
  flex:1; padding:12px 16px; border-radius:12px; border:1.5px solid var(--icevn-border);
  background:#1a0a12; color:var(--icevn-ink); font-size:1rem; font-family:inherit; outline:none;
}
.icevn-input input:focus { border-color:var(--icevn-accent-2); }
.icevn-input button {
  padding:12px 22px; border-radius:12px; background:var(--icevn-accent-2);
  border:none; color:#0e0710; font-weight:700; cursor:pointer;
}

.icevn-waitclick {
  position:absolute; inset:0; z-index:14; display:flex; align-items:flex-end; justify-content:center;
  padding-bottom:15%; pointer-events:none;
}
.icevn-waitclick-hint {
  background:rgba(14,7,16,.85); border:1px solid var(--icevn-accent-2);
  padding:10px 22px; border-radius:30px; color:var(--icevn-frost); font-weight:600;
  animation:icevn-bounce 1.4s infinite;
}

.icevn-toast {
  position:absolute; top:60px; left:50%; transform:translateX(-50%);
}

.icevn-debug {
  position: absolute; top: 60px; right: 14px;
  width: 320px; max-height: calc(100vh - 90px);
  background: rgba(14,7,16,.95); border: 1px solid var(--icevn-accent-2);
  border-radius: 14px; z-index: 40; overflow: hidden;
  display: flex; flex-direction: column;
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  font-size: .8rem; color: #f0e4e8;
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.7);
}
.icevn-debug[hidden] { display: none; }
.icevn-debug__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: rgba(114,186,169,.14);
  border-bottom: 1px solid rgba(114,186,169,.3);
  font-weight: 700; color: var(--icevn-accent-2);
}
.icevn-debug__close { background: none; border: none; color: var(--icevn-muted); font-size: 1.1rem; cursor: pointer; }
.icevn-debug__body { padding: 10px 14px; overflow-y: auto; flex: 1; }
.icevn-debug__row { display: flex; justify-content: space-between; padding: 4px 0; }
.icevn-debug__row b { color: var(--icevn-muted); font-weight: 600; }
.icevn-debug__details { margin-top: 10px; border-top: 1px dashed rgba(114,186,169,.25); padding-top: 8px; }
.icevn-debug__details summary { cursor: pointer; color: var(--icevn-accent-2); font-weight: 600; padding: 4px 0; }
.icevn-debug__vars { padding: 6px 0; }
.icevn-debug__var { display: flex; justify-content: space-between; padding: 3px 0; gap: 8px; }
.icevn-debug__var span { color: var(--icevn-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icevn-debug__var b { color: #f0e4e8; font-weight: 700; }
.icevn-debug__val.is-true  { color: #8bd0bf; }
.icevn-debug__val.is-false { color: #d63864; }
.icevn-debug__val.is-num   { color: #d5e7b5; }
.icevn-debug__empty { color: var(--icevn-muted); font-style: italic; font-size: .75rem; }
.icevn-debug__foot {
  padding: 10px 14px; border-top: 1px solid rgba(114,186,169,.3);
  display: flex; gap: 8px;
}
.icevn-debug__btn {
  flex: 1; padding: 6px 10px; border-radius: 8px;
  background: rgba(114,186,169,.14); border: 1px solid rgba(114,186,169,.35);
  color: var(--icevn-frost); font-weight: 600; cursor: pointer;
  font-family: inherit; font-size: .78rem;
}
.icevn-debug__btn:hover { background: var(--icevn-accent-2); color: #0e0710; }

.icevn-toast {
  position:absolute; top:60px; left:50%; transform:translateX(-50%);
  background:rgba(14,7,16,.94); color:var(--icevn-frost);
  border:1px solid var(--icevn-accent-2); padding:10px 20px; border-radius:30px;
  font-weight:600; z-index:60; box-shadow:0 12px 32px -10px rgba(114,186,169,.6);
  animation:icevn-toast 3s ease-out both;
  max-width:80%;
}
@keyframes icevn-toast {
  0% { opacity:0; transform:translate(-50%,-10px); }
  10%,85% { opacity:1; transform:translate(-50%,0); }
  100% { opacity:0; transform:translate(-50%,-10px); }
}

/* ============== РЕЖИССЁРСКИЕ ПЛАШКИ ============== */
.icevn-letterbox {
  position: absolute; inset: 0; pointer-events: none; z-index: 40;
}
.icevn-letterbox-top,
.icevn-letterbox-bottom {
  position: absolute; left: 0; right: 0; height: 12%;
  background: #000;
  animation: icevn-letterbox-in .5s ease-out both;
}
.icevn-letterbox-top { top: 0; }
.icevn-letterbox-bottom { bottom: 0; }
@keyframes icevn-letterbox-in { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.icevn-letterbox-top { transform-origin: top; }
.icevn-letterbox-bottom { transform-origin: bottom; }

.icevn-card {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: 45; pointer-events: none;
  background: rgba(14,7,16,.72);
  backdrop-filter: blur(6px);
  animation: icevn-card-in .7s ease-out both;
}
.icevn-card--out { animation: icevn-card-out .6s ease-in both; }
@keyframes icevn-card-in  { from { opacity:0; } to { opacity:1; } }
@keyframes icevn-card-out { from { opacity:1; } to { opacity:0; } }
.icevn-card-inner {
  text-align: center; max-width: 720px; padding: 0 30px;
  animation: icevn-card-rise 1s cubic-bezier(.16,1,.3,1) both;
}
@keyframes icevn-card-rise {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.icevn-card-number {
  font-family: var(--icevn-mono); font-size: .9rem; letter-spacing: .35em;
  text-transform: uppercase; color: var(--icevn-accent-2); margin-bottom: 14px;
}
.icevn-card-title {
  font-family: 'Cormorant Unicase', serif; font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 700; color: var(--icevn-frost); line-height: 1.15;
}
.icevn-card-subtitle {
  margin-top: 12px; font-size: 1rem; color: var(--icevn-muted); font-style: italic;
}

.icevn-location {
  position: absolute; left: 32px; bottom: 32px;
  z-index: 45; pointer-events: none;
  padding: 10px 18px; border-left: 3px solid var(--icevn-accent-2);
  background: rgba(14,7,16,.72); backdrop-filter: blur(6px);
  border-radius: 0 10px 10px 0;
  animation: icevn-loc-in .5s ease-out both;
}
.icevn-location--out { animation: icevn-loc-out .5s ease-in both; }
@keyframes icevn-loc-in  { from { opacity:0; transform: translateX(-20px); } to { opacity:1; transform: translateX(0); } }
@keyframes icevn-loc-out { from { opacity:1; transform: translateX(0); } to { opacity:0; transform: translateX(-20px); } }
.icevn-location-name { display: block; font-family: 'Cormorant Unicase', serif; font-size: 1.05rem; color: var(--icevn-frost); }
.icevn-location-time { display: block; font-size: .8rem; color: var(--icevn-accent-2); font-family: var(--icevn-mono); margin-top: 2px; }

/* ============== NVL-РЕЖИМ ============== */
.icevn-nvl {
  position: absolute; inset: 0; z-index: 12; pointer-events: none;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 6% 220px;
  background: linear-gradient(180deg, rgba(14,7,16,.85) 0%, rgba(14,7,16,.75) 60%, rgba(14,7,16,.2) 100%);
  animation: icevn-nvl-in .4s ease-out both;
}
@keyframes icevn-nvl-in { from { opacity:0; } to { opacity:1; } }
.icevn-nvl-text {
  max-width: 900px; width: 100%; font-size: 1.15rem; line-height: 1.75;
  color: var(--icevn-ink); white-space: pre-wrap;
}
body.icevn-nvl-mode .icevn-dialogue { display: none; }
body.icevn-nvl-mode .icevn-text,
body.icevn-nvl-mode .icevn-speaker { /* наследуем в .icevn-nvl-text через JS */ }

/* Кинематографичный режим прячет HUD и статус-бар */
body.icevn-cinema .icevn-hud,
body.icevn-cinema .icevn-statusbar { opacity: .15; transition: opacity .4s; }
body.icevn-cinema .icevn-hud:hover,
body.icevn-cinema .icevn-statusbar:hover { opacity: 1; }

.icevn-stage.shake { animation:icevn-shake .4s linear; }
@keyframes icevn-shake {
  0%,100% { transform:translate(0,0); }
  20% { transform:translate(-6px,4px); } 40% { transform:translate(5px,-5px); }
  60% { transform:translate(-4px,-3px); } 80% { transform:translate(4px,4px); }
}
.icevn-stage.glitch { animation:icevn-glitch 1.2s steps(8) infinite; }
@keyframes icevn-glitch {
  0%,100% { filter:none; transform:translate(0,0); }
  20% { filter:hue-rotate(60deg) saturate(2); transform:translate(2px,-2px); }
  40% { filter:invert(.1) hue-rotate(-40deg); transform:translate(-2px,1px); }
  60% { filter:contrast(1.6); transform:translate(1px,2px); }
  80% { filter:hue-rotate(180deg); transform:translate(-1px,-1px); }
}

.icevn-modal { position:fixed; inset:0; z-index:1000; display:flex; align-items:center; justify-content:center; }
.icevn-modal[hidden] { display:none; }
.icevn-modal-bg { position:absolute; inset:0; background:rgba(0,0,0,.6); backdrop-filter:blur(4px); }
.icevn-modal-body {
  position:relative; width:min(720px,92vw); max-height:86vh;
  background:var(--icevn-panel-2); color:var(--icevn-ink); border:1px solid var(--icevn-border);
  border-radius:var(--icevn-radius-lg); overflow:hidden; display:flex; flex-direction:column;
  box-shadow:var(--icevn-shadow);
}
.icevn-modal-head {
  display:flex; justify-content:space-between; align-items:center;
  padding:16px 22px; border-bottom:1px solid var(--icevn-border);
}
.icevn-modal-head h3 { margin:0; font-size:1.05rem; color:var(--icevn-frost); font-family:'Cormorant Unicase',serif; }
.icevn-modal-close { background:none; border:none; font-size:1.5rem; color:var(--icevn-muted); cursor:pointer; }
.icevn-modal-close:hover { color:var(--icevn-accent); }
.icevn-modal-content { padding:18px 22px 22px; overflow-y:auto; }

.icevn-slots { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:12px; }
.icevn-slot {
  border:1px solid var(--icevn-border); border-radius:12px; padding:14px;
  background:rgba(255,255,255,.03); cursor:pointer; transition:.15s;
}
.icevn-slot:hover { border-color:var(--icevn-accent-2); background:rgba(114,186,169,.08); }
.icevn-slot.empty { color:var(--icevn-muted); font-style:italic; }
.icevn-slot-num { font-weight:700; color:var(--icevn-accent-2); margin-bottom:4px; }
.icevn-slot-time { font-size:.82rem; color:var(--icevn-muted); font-family:var(--icevn-mono); }

.icevn-backlog-item { padding:8px 0; border-bottom:1px solid rgba(58,31,44,.5); }
.icevn-backlog-who { font-weight:700; color:var(--icevn-accent-2); font-size:.85rem; text-transform:uppercase; letter-spacing:.04em; margin-bottom:3px; }
.icevn-backlog-text { color:var(--icevn-ink); line-height:1.5; }

.icevn-settings-row { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:10px 0; border-bottom:1px solid rgba(58,31,44,.5); }
.icevn-settings-row label { font-size:.9rem; }
.icevn-settings-row input[type="range"] { flex:1; max-width:240px; accent-color:var(--icevn-accent-2); }
.icevn-settings-row .val { font-family:var(--icevn-mono); font-size:.82rem; color:var(--icevn-muted); min-width:44px; text-align:right; }

.icevn-editor { background:#f1f5f9; color:#1e293b; min-height:100vh; }

/* ============================================================
   3-колоночный рабочий стол редактора
   ============================================================ */
.icevn-editor--3col { background: #eef1f5; padding: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Верхняя плашка */
.ed-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: linear-gradient(135deg, #6e1a37, #4a0f24);
  color: #fff; flex-shrink: 0; height: 52px; z-index: 10;
}
.ed-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ed-header-right { display: flex; align-items: center; gap: 6px; }
.ed-hbtn-sep { width: 1px; height: 22px; background: rgba(255,255,255,.18); margin: 0 4px; }
.ed-hbtn--text { width: auto; padding: 0 12px; font-size: .8rem; }
.ed-cloud-status { font-family: ui-monospace, monospace; font-size: .72rem; opacity: .8; margin-left: 2px; }

/* ============ Presence (кто сейчас в проекте) ============ */
.ed-presence {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 8px;
}
.ed-presence__avatar {
  width: 26px; height: 26px; border-radius: 50%;
  color: #fff; font-size: .68rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: .02em;
  border: 2px solid rgba(255,255,255,.35);
  margin-left: -6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  cursor: default;
}
.ed-presence__avatar:first-child { margin-left: 0; }
.ed-presence__avatar--more {
  background: rgba(255,255,255,.2); color: #fff;
  font-size: .68rem; border-color: rgba(255,255,255,.25);
}
.ed-presence__solo {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(114,186,169,.55);
  box-shadow: 0 0 0 3px rgba(114,186,169,.18);
  cursor: default;
}

/* ============ Модалка блокировки сцены (жёсткая) ============ */
.ed-lockmodal { position: fixed; inset: 0; z-index: 5000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ed-lockmodal[hidden] { display: none; }
.ed-lockmodal__bg {
  position: absolute; inset: 0;
  background: rgba(14,7,16,.78); backdrop-filter: blur(6px);
  animation: edLockFade .25s ease-out both;
}
@keyframes edLockFade { from { opacity: 0; } to { opacity: 1; } }
.ed-lockmodal__box {
  position: relative; width: 100%; max-width: 460px;
  background: #fff; border-radius: 20px; padding: 30px 28px 24px;
  text-align: center;
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.7);
  animation: edLockPop .3s cubic-bezier(.16,1,.3,1) both;
}
@keyframes edLockPop { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.ed-lockmodal__icon {
  width: 62px; height: 62px; border-radius: 50%;
  background: linear-gradient(135deg, #b0802a, #ae2448);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin-bottom: 14px;
  box-shadow: 0 10px 24px -10px rgba(174,36,72,.6);
}
.ed-lockmodal__box h3 {
  margin: 0 0 8px; font-family: 'Cormorant Unicase', serif;
  color: #6e1a37; font-size: 1.4rem;
}
.ed-lockmodal__box p { margin: 0 0 12px; color: #8a6a78; line-height: 1.55; font-size: .9rem; }
.ed-lockmodal__box p b { color: #6e1a37; }
.ed-lockmodal__queue {
  background: rgba(114,186,169,.12); color: #4f8d7e;
  padding: 10px 14px; border-radius: 10px; font-size: .85rem;
  border-left: 3px solid #4f8d7e; text-align: left;
}
.ed-lockmodal__actions {
  display: flex; flex-direction: column; gap: 8px; margin-top: 16px;
}
.ed-lockmodal__actions .ed-btn { justify-content: center; }
.ed-lockmodal__status {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin-top: 16px; padding: 12px; background: #f8fafc; border-radius: 10px;
  font-size: .85rem; color: #4f8d7e; font-weight: 600;
}
.ed-lockmodal__spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(79,141,126,.25);
  border-top-color: #4f8d7e;
  animation: edLockSpin .8s linear infinite;
}
@keyframes edLockSpin { to { transform: rotate(360deg); } }

/* Плашка readonly */
.ed-readonly-banner {
  padding: 10px 16px; background: #e6f2ef; color: #3e7a6c;
  border-bottom: 1px solid #b7d8ce; font-size: .88rem;
  display: flex; align-items: center; gap: 8px;
}
.ed-readonly-banner i { color: #4f8d7e; }

html[data-theme="dark"] .ed-lockmodal__box { background: #26111b; }
html[data-theme="dark"] .ed-lockmodal__box h3 { color: #d5e7b5; }
html[data-theme="dark"] .ed-lockmodal__box p { color: #b89aa6; }
html[data-theme="dark"] .ed-lockmodal__box p b { color: #d5e7b5; }
html[data-theme="dark"] .ed-lockmodal__status { background: #1a0a12; }
html[data-theme="dark"] .ed-readonly-banner { background: #1a0a12; border-color: #3a1f2c; color: #8bd0bf; }

/* ============ Плашка блокировки сцены ============ */
.ed-lockbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; flex-shrink: 0;
  background: #fff7e6; border-bottom: 1px solid #f2c67c;
  color: #7a4d00; font-size: .88rem;
}
.ed-lockbar[hidden] { display: none; }
.ed-lockbar i { color: #b0802a; font-size: 1rem; }
.ed-lockbar b { color: #5c3a00; }
.ed-lockbar span { flex: 1; min-width: 0; }
.ed-lockbar__btn {
  padding: 6px 12px; border-radius: 8px;
  background: #fff; border: 1.5px solid #b0802a; color: #7a4d00;
  font-weight: 600; font-size: .8rem; cursor: pointer;
  font-family: inherit; white-space: nowrap;
  transition: .15s;
}
.ed-lockbar__btn:hover { background: #b0802a; color: #fff; }
.ed-lockbar__close {
  background: none; border: none; font-size: 1.2rem; color: #b0802a;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.ed-lockbar__close:hover { color: #7a4d00; }

html[data-theme="dark"] .ed-lockbar { background: #3a2410; border-color: #6b4a1a; color: #f2c67c; }
html[data-theme="dark"] .ed-lockbar b { color: #ffda94; }
html[data-theme="dark"] .ed-lockbar__btn { background: #26111b; border-color: #b0802a; color: #f2c67c; }
html[data-theme="dark"] .ed-lockbar__btn:hover { background: #b0802a; color: #1f1016; }

/* ============ Облачные бэкапы — модалки ============ */
.ed-cloud-tabs {
    display: flex; gap: 6px; padding: 12px 22px 0;
}
.ed-cloud-tab {
    padding: 8px 16px; border-radius: 60px; border: 1.5px solid #e2e8f0; background: #fff;
    color: #334155; font-weight: 600; font-size: .85rem; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    transition: .15s; font-family: inherit;
}
.ed-cloud-tab:hover { border-color: #4f8d7e; color: #4f8d7e; }
.ed-cloud-tab.active { background: #4f8d7e; color: #fff; border-color: #4f8d7e; }
.ed-cloud-tab span { font-family: ui-monospace, monospace; font-size: .78rem; opacity: .8; }

.ed-cloud-body { flex: 1; overflow-y: auto; padding: 12px 22px 4px; }
.ed-cloud-pane { display: none; }
.ed-cloud-pane.active { display: block; }

.ed-cloud-list { display: flex; flex-direction: column; gap: 8px; }
.ed-cloud-empty { color: #94a3b8; font-size: .85rem; font-style: italic; padding: 20px 0; text-align: center; }

.ed-cloud-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 12px; background: rgba(168,138,149,.06);
    border: 1px solid transparent;
}
.ed-cloud-row:hover { border-color: rgba(79,141,126,.25); }
.ed-cloud-row--empty { opacity: .6; }
.ed-cloud-row__icon {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, #4f8d7e, #6e1a37);
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    font-size: .9rem;
}
.ed-cloud-row__icon--empty { background: #e2e8f0; color: #94a3b8; }
.ed-cloud-row__body { flex: 1; min-width: 0; }
.ed-cloud-row__title { font-weight: 700; color: #1f1016; font-size: .9rem; }
.ed-cloud-row__title b { color: #4f8d7e; }
.ed-cloud-scene { font-family: ui-monospace, monospace; font-size: .72rem; padding: 2px 6px; background: rgba(110,26,55,.10); border-radius: 5px; color: #6e1a37; margin-left: 6px; }
.ed-cloud-row__meta { font-size: .78rem; color: #8a6a78; margin-top: 2px; }
.ed-cloud-row__actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.ed-cloud-row__current { font-size: .75rem; color: #4f8d7e; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

html[data-theme="dark"] .ed-cloud-tab { background: #1a0a12; border-color: #3a1f2c; color: #e5d0d8; }
html[data-theme="dark"] .ed-cloud-tab.active { background: #4f8d7e; border-color: #4f8d7e; color: #fff; }
html[data-theme="dark"] .ed-cloud-row { background: rgba(168,138,149,.10); }
html[data-theme="dark"] .ed-cloud-row__title { color: #f0e4e8; }
html[data-theme="dark"] .ed-cloud-row__icon--empty { background: #3a1f2c; color: #7a5a68; }
html[data-theme="dark"] .ed-cloud-scene { background: rgba(213,231,181,.12); color: #d5e7b5; }
.ed-hbtn:disabled { opacity: .3; cursor: not-allowed; }
.ed-back { color: rgba(255,255,255,.7); text-decoration: none; padding: 6px 8px; border-radius: 8px; }
.ed-back:hover { color: #fff; background: rgba(255,255,255,.12); }
.ed-brand { color: #72baa9; font-size: 1.1rem; }
.ed-project-name { font-weight: 700; font-family: 'Cormorant Unicase', serif; font-size: 1.05rem; }
.ed-project-sep { color: rgba(255,255,255,.4); }
.ed-current-scene { font-size: .85rem; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-hbtn {
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.15); color: #fff;
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: .9rem; transition: .15s;
}
.ed-hbtn:hover { background: rgba(255,255,255,.22); }

/* Flash-сообщения */
.ed-flash {
  padding: 8px 16px; font-size: .85rem; flex-shrink: 0;
  border-left: 3px solid;
  animation: edFlashIn .3s ease-out both;
}
.ed-flash--ok { background: #e3f5ea; color: #1b5c37; border-color: #4f8d7e; }
.ed-flash--err { background: #fde7ec; color: #7e1632; border-color: #ae2448; }
@keyframes edFlashIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Сетка */
.ed-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 440px;
  gap: 10px;
  padding: 10px;
  flex: 1; min-height: 0;
}

.ed-col {
  background: #fff; border-radius: 14px; box-shadow: 0 2px 12px -6px rgba(74,15,36,.10);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}

.ed-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px; border-bottom: 1px solid #eef1f5; flex-shrink: 0;
}
.ed-col-head h3 {
  margin: 0; font-size: .78rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: #6e1a37;
  display: flex; align-items: center; gap: 6px;
}
.ed-count {
  font-family: ui-monospace, monospace; font-size: .7rem;
  background: rgba(110,26,55,.10); padding: 1px 7px; border-radius: 10px;
  color: #6e1a37;
}
.ed-col-head--sub { margin-top: 12px; }
.ed-icon-btn {
  width: 26px; height: 26px; border-radius: 7px; border: none;
  background: rgba(79,141,126,.12); color: #4f8d7e; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; transition: .15s;
}
.ed-icon-btn:hover { background: #4f8d7e; color: #fff; }

/* Список сцен */
.ed-scenes-list {
  list-style: none; padding: 8px; margin: 0;
  overflow-y: auto; flex: 1; min-height: 0;
}
.ed-scene-item {
  display: flex; align-items: center; gap: 4px;
  border-radius: 8px; padding: 0; margin-bottom: 2px;
  transition: background .12s; position: relative;
}
.ed-scene-item:hover { background: rgba(168,138,149,.10); }
.ed-scene-item.active { background: rgba(79,141,126,.16); }
.ed-scene-item.active .ed-scene-title { color: #4f8d7e; font-weight: 700; }
.ed-scene-item.is-start .ed-scene-link { font-weight: 600; }
.ed-scene-item.dragging { opacity: .35; }
.ed-scene-item.drop-above::before,
.ed-scene-item.drop-below::after {
  content: ''; position: absolute; left: 4px; right: 4px; height: 2px;
  background: #4f8d7e; border-radius: 1px;
}
.ed-scene-item.drop-above::before { top: -1px; }
.ed-scene-item.drop-below::after { bottom: -1px; }
.ed-scene-grip {
  color: #b89aa6; cursor: grab; padding: 6px 4px 6px 8px; font-size: .75rem;
}
.ed-scene-grip:active { cursor: grabbing; }
.ed-scene-link {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 8px 10px 8px 0; text-decoration: none; color: #334155;
  flex: 1; min-width: 0; gap: 1px;
}
.ed-scene-title { font-size: .87rem; line-height: 1.25; display: flex; align-items: center; gap: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ed-scene-star { color: #c3dc9e; font-size: .7rem; }
.ed-scene-id { font-size: .68rem; color: #94a3b8; font-family: ui-monospace, monospace; }

.ed-empty-small { padding: 12px 16px; color: #94a3b8; font-size: .82rem; font-style: italic; }

.ed-newscene-form {
  display: grid; grid-template-columns: 1fr auto; gap: 4px;
  padding: 8px; border-top: 1px solid #eef1f5;
}
.ed-newscene-form input[type="text"] {
  padding: 7px 10px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  font: 13px inherit; outline: none; background: #fff; color: #1e293b;
  grid-column: 1 / -1;
}
.ed-newscene-form input[type="text"]:focus { border-color: #4f8d7e; }
.ed-newscene-form button { grid-column: 2 / 3; }

/* Персонажи */
.ed-chars-list { padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 5px; }
.ed-char-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 6px; border-radius: 20px;
  background: #fff; border: 1.5px solid #e2e8f0;
  cursor: pointer; font-family: inherit; font-size: .78rem;
  transition: .15s;
}
.ed-char-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 10px -4px rgba(0,0,0,.15); }
.ed-char-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ed-char-name { font-weight: 600; color: #334155; }

/* Центральная колонка */
.ed-col--editor { padding: 0; }
.ed-editor-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid #eef1f5;
  flex-shrink: 0; flex-wrap: wrap;
}
.ed-editor-toolbar__info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ed-editor-toolbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ed-scene-badge {
  font-family: ui-monospace, monospace; font-size: .8rem;
  background: rgba(110,26,55,.10); color: #6e1a37;
  padding: 4px 10px; border-radius: 8px; font-weight: 600;
}
.ed-start-badge {
  font-size: .74rem; color: #4f8d7e; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 5px;
}

.ed-btn {
  padding: 8px 14px; border-radius: 8px; border: 1.5px solid #e2e8f0;
  background: #fff; color: #334155; cursor: pointer; font-weight: 600;
  font-size: .82rem; display: inline-flex; align-items: center; gap: 6px;
  transition: .15s; font-family: inherit; text-decoration: none;
}
.ed-btn:hover { border-color: #4f8d7e; color: #4f8d7e; }
.ed-btn--primary { background: #4f8d7e; border-color: #4f8d7e; color: #fff; }
.ed-btn--primary:hover { background: #3e7a6c; border-color: #3e7a6c; color: #fff; }
.ed-btn--save { background: #ae2448; border-color: #ae2448; color: #fff; }
.ed-btn--save:hover { background: #7e1632; border-color: #7e1632; color: #fff; }
.ed-btn--ghost { background: transparent; }
.ed-btn--sm { padding: 6px 11px; font-size: .78rem; }

.ed-scene-form {
  padding: 12px 16px; overflow-y: auto; flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 12px;
}

.ed-col--preview { padding: 0; }
.ed-preview-frame {
  flex: 1; min-height: 0; margin: 8px;
  border-radius: 10px; overflow: hidden; background: #000;
}
.ed-preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.ed-preview-actions {
  padding: 8px 12px 12px; display: flex; gap: 8px; flex-shrink: 0;
}

/* Пустое состояние */
.ed-empty {
  text-align: center; padding: 80px 20px; color: #94a3b8;
}
.ed-empty i { font-size: 2.5rem; color: #cbd5e1; display: block; margin-bottom: 14px; }
.ed-empty h2 { font-family: 'Cormorant Unicase', serif; color: #6e1a37; margin: 0 0 8px; }

.ed-overlay {
  position: fixed; inset: 0; background: rgba(14,7,16,.5); z-index: 5;
}

/* ============ Модалки редактора ============ */
.ed-modal { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ed-modal[hidden] { display: none; }
.ed-modal__bg {
    position: absolute; inset: 0;
    background: rgba(14,7,16,.7); backdrop-filter: blur(6px);
    animation: edModalFade .25s ease-out both;
}
@keyframes edModalFade { from { opacity:0; } to { opacity:1; } }
.ed-modal__box {
    position: relative; width: 100%; max-width: 520px;
    background: #fff; border-radius: 18px; padding: 0;
    box-shadow: 0 40px 80px -30px rgba(0,0,0,.6);
    animation: edModalPop .3s cubic-bezier(.16,1,.3,1) both;
    display: flex; flex-direction: column; max-height: 88vh; overflow: hidden;
}
.ed-modal__box--wide { max-width: 780px; }
@keyframes edModalPop { from { opacity:0; transform: translateY(16px) scale(.98); } to { opacity:1; transform:none; } }
.ed-modal__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px; border-bottom: 1px solid #eef1f5;
}
.ed-modal__head h3 {
    margin: 0; font-family: 'Cormorant Unicase', serif;
    color: #6e1a37; font-size: 1.15rem;
}
.ed-modal__close {
    background: none; border: none; font-size: 1.5rem; color: #8a6a78;
    cursor: pointer; padding: 0 6px; line-height: 1;
}
.ed-modal__close:hover { color: #ae2448; }
.ed-modal__hint {
    margin: 0; padding: 12px 22px 0;
    font-size: .85rem; color: #8a6a78; line-height: 1.5;
}
.ed-modal__actions {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 22px 20px;
}

/* Библиотека шаблонов */
.ed-templates {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px; padding: 14px 22px 20px;
    overflow-y: auto;
}
.ed-template-card {
    display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
    padding: 16px; border-radius: 12px;
    background: rgba(168,138,149,.06); border: 1.5px solid transparent;
    cursor: pointer; text-align: left; font-family: inherit;
    transition: .15s;
}
.ed-template-card:hover { background: rgba(79,141,126,.12); border-color: #4f8d7e; transform: translateY(-2px); }
.ed-template-card i {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, #4f8d7e, #6e1a37);
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem; margin-bottom: 4px;
}
.ed-template-card b { font-size: .92rem; color: #6e1a37; }
.ed-template-card span { font-size: .78rem; color: #8a6a78; line-height: 1.4; }

/* Импорт */
.ed-import-file {
    display: block; margin: 16px 22px 0;
    padding: 22px; text-align: center;
    border: 2px dashed #b89aa6; border-radius: 12px;
    cursor: pointer; transition: .15s;
    font-weight: 600; color: #4f8d7e;
}
.ed-import-file:hover { border-color: #4f8d7e; background: rgba(79,141,126,.06); }
.ed-import-file input { display: none; }
.ed-import-modes {
    display: flex; flex-direction: column; gap: 10px;
    padding: 14px 22px 4px; font-size: .88rem;
}
.ed-import-modes label {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 14px; border-radius: 10px;
    background: rgba(168,138,149,.06); cursor: pointer;
}
.ed-import-modes input[type="radio"] { margin-top: 3px; }
.ed-import-modes b { color: #6e1a37; }
.ed-import-modes span { color: #8a6a78; font-size: .82rem; }

html[data-theme="dark"] .ed-modal__box { background: #26111b; }
html[data-theme="dark"] .ed-modal__head { border-color: #3a1f2c; }
html[data-theme="dark"] .ed-modal__head h3 { color: #d5e7b5; }
html[data-theme="dark"] .ed-modal__hint,
html[data-theme="dark"] .ed-modal__close { color: #b89aa6; }
html[data-theme="dark"] .ed-template-card { background: rgba(168,138,149,.12); }
html[data-theme="dark"] .ed-template-card b { color: #d5e7b5; }
html[data-theme="dark"] .ed-template-card span { color: #b89aa6; }
html[data-theme="dark"] .ed-import-modes label { background: rgba(168,138,149,.12); }
html[data-theme="dark"] .ed-import-modes b { color: #d5e7b5; }
html[data-theme="dark"] .ed-import-modes span { color: #b89aa6; }

/* Адаптив */
@media (max-width: 1400px) {
  .ed-grid { grid-template-columns: 220px minmax(0, 1fr) 380px; }
}
@media (max-width: 1100px) {
  .ed-grid {
    grid-template-columns: 220px minmax(0, 1fr);
    position: relative;
  }
  .ed-col--preview {
    position: fixed; top: 60px; right: 0; bottom: 0; width: 92vw; max-width: 520px;
    z-index: 20; transform: translateX(100%); transition: transform .3s cubic-bezier(.16,1,.3,1);
    border-radius: 14px 0 0 14px;
  }
  .ed-grid.show-preview .ed-col--preview { transform: translateX(0); }
}
@media (max-width: 720px) {
  .ed-grid {
    grid-template-columns: 1fr;
    position: relative;
  }
  .ed-col--scenes {
    position: fixed; top: 60px; left: 0; bottom: 0; width: 88vw; max-width: 320px;
    z-index: 20; transform: translateX(-100%); transition: transform .3s cubic-bezier(.16,1,.3,1);
    border-radius: 0 14px 14px 0;
  }
  .ed-grid.show-scenes .ed-col--scenes { transform: translateX(0); }
  .ed-project-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ed-current-scene { display: none; }
}

/* Тёмная тема */
html[data-theme="dark"] .icevn-editor--3col { background: #150a11; }
html[data-theme="dark"] .ed-col { background: #26111b; }
html[data-theme="dark"] .ed-col-head { border-color: #3a1f2c; }
html[data-theme="dark"] .ed-col-head h3 { color: #d5e7b5; }
html[data-theme="dark"] .ed-scene-item:hover { background: rgba(168,138,149,.15); }
html[data-theme="dark"] .ed-scene-item.active { background: rgba(79,141,126,.25); }
html[data-theme="dark"] .ed-scene-link { color: #e5d0d8; }
html[data-theme="dark"] .ed-scene-id { color: #7a5a68; }
html[data-theme="dark"] .ed-scene-badge { background: rgba(213,231,181,.15); color: #d5e7b5; }
html[data-theme="dark"] .ed-editor-toolbar { border-color: #3a1f2c; }
html[data-theme="dark"] .ed-btn { background: #1a0a12; border-color: #3a1f2c; color: #e5d0d8; }
html[data-theme="dark"] .ed-btn:hover { border-color: #72baa9; color: #72baa9; }
html[data-theme="dark"] .ed-btn--primary { background: #4f8d7e; border-color: #4f8d7e; color: #fff; }
html[data-theme="dark"] .ed-btn--save { background: #ae2448; border-color: #ae2448; color: #fff; }
html[data-theme="dark"] .ed-newscene-form input[type="text"] { background: #1a0a12; border-color: #3a1f2c; color: #e5d0d8; }
html[data-theme="dark"] .ed-char-chip { background: #1a0a12; border-color: #3a1f2c; }
html[data-theme="dark"] .ed-char-name { color: #e5d0d8; }
html[data-theme="dark"] .ed-empty h2 { color: #d5e7b5; }

/* Сгруппированная палитра (6 групп) */
.icevn-ed-palette--grouped {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    align-items: start;
    width: 100%;
}
.icevn-ed-palette-group {
    background: rgba(168,138,149,.06);
    border-radius: 12px;
    padding: 12px 14px 14px;
    border-left: 3px solid var(--muted, #8a6a78);
}
html[data-theme="dark"] .icevn-ed-palette-group { background: rgba(168,138,149,.10); }
.icevn-ed-palette-group h4 {
    margin: 0 0 10px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    color: #8a6a78;
}
.icevn-ed-palette-group--speech  { border-left-color: #72baa9; }
.icevn-ed-palette-group--speech h4  { color: #4f8d7e; }
.icevn-ed-palette-group--actors  { border-left-color: #ae2448; }
.icevn-ed-palette-group--actors h4  { color: #ae2448; }
.icevn-ed-palette-group--scene   { border-left-color: #6e1a37; }
.icevn-ed-palette-group--scene h4   { color: #6e1a37; }
.icevn-ed-palette-group--sound   { border-left-color: #72a85a; }
.icevn-ed-palette-group--sound h4   { color: #567f3d; }
.icevn-ed-palette-group--fx      { border-left-color: #4f8d7e; }
.icevn-ed-palette-group--fx h4      { color: #4f8d7e; }
.icevn-ed-palette-group--logic   { border-left-color: #8a6a78; }
.icevn-ed-palette-group--logic h4   { color: #6d4f5c; }
.icevn-ed-palette-group--other   { border-left-color: #b89aa6; }
html[data-theme="dark"] .icevn-ed-palette-group--scene h4 { color: #d5e7b5; }
html[data-theme="dark"] .icevn-ed-palette-group--logic h4 { color: #b89aa6; }

.icevn-ed-palette-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Превью рядом с select-полем */
.icevn-field-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    min-height: 32px;
    font-size: .78rem;
    color: #8a6a78;
}
.icevn-field-preview__img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(168,138,149,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.icevn-field-preview__img img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.icevn-field-preview__img i { color: #4f8d7e; font-size: .85rem; }
.icevn-field-preview__dot {
    width: 18px; height: 18px; border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255,255,255,.5) inset;
}
.icevn-field-preview__label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #4f8d7e;
    font-weight: 600;
}

/* ============ Визуальный редактор choice ============ */
.icevn-choice-table {
    display: flex; flex-direction: column; gap: 4px;
    background: rgba(168,138,149,.04); border-radius: 10px; padding: 8px;
    margin-top: 6px;
}
.icevn-choice-head,
.icevn-choice-row {
    display: grid;
    grid-template-columns: 28px minmax(0,2fr) minmax(0,1.2fr) minmax(0,1.2fr) minmax(0,1.5fr) 32px;
    gap: 6px;
    align-items: center;
}
.icevn-choice-head {
    padding: 0 4px 6px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #8a6a78;
    border-bottom: 1px dashed rgba(168,138,149,.3);
    margin-bottom: 4px;
}
.icevn-choice-head span:nth-child(2)::after { content: ''; }
.icevn-choice-row {
    background: #fff; border-radius: 8px; padding: 4px 6px;
    transition: box-shadow .15s, transform .15s;
    cursor: grab;
}
.icevn-choice-row:hover { box-shadow: 0 3px 10px -4px rgba(0,0,0,.12); }
.icevn-choice-row.dragging { opacity: .35; }
.icevn-choice-row.drop-above { box-shadow: inset 0 2px 0 #4f8d7e; }
.icevn-choice-row.drop-below { box-shadow: inset 0 -2px 0 #4f8d7e; }
.icevn-choice-num {
    text-align: center; font-family: ui-monospace, monospace; font-size: .75rem;
    color: #8a6a78;
}
.icevn-choice-row input {
    width: 100%; padding: 6px 8px;
    border: 1px solid #e2e8f0; border-radius: 6px;
    font: 13px inherit; outline: none; background: #fff; color: #1e293b;
    min-width: 0;
}
.icevn-choice-row input:focus { border-color: #4f8d7e; }
.icevn-choice-del {
    width: 24px; height: 24px; border-radius: 6px; border: none;
    background: rgba(174,36,72,.10); color: #ae2448; cursor: pointer;
    font-size: 1rem; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
}
.icevn-choice-del:hover { background: #ae2448; color: #fff; }
.icevn-choice-empty {
    color: #94a3b8; font-size: .82rem; font-style: italic;
    padding: 8px 6px;
}
.icevn-choice-actions { margin-top: 6px; }
.icevn-choice-actions .icevn-btn { font-size: .78rem; }

html[data-theme="dark"] .icevn-choice-table { background: rgba(168,138,149,.08); }
html[data-theme="dark"] .icevn-choice-row { background: #1a0a12; }
html[data-theme="dark"] .icevn-choice-row input { background: #0e0710; border-color: #3a1f2c; color: #f0e4e8; }
html[data-theme="dark"] .icevn-choice-head { color: #b89aa6; border-bottom-color: #3a1f2c; }
html[data-theme="dark"] .icevn-choice-num { color: #b89aa6; }
.icevn-ed-header {
  display:flex; align-items:center; gap:22px;
  padding:12px 22px; background:linear-gradient(135deg,#6e1a37,#4a0f24); color:#fff;
}
.icevn-ed-brand { font-family:'Cormorant Unicase',serif; font-weight:700; font-size:1.1rem; display:flex; align-items:center; gap:8px; }
.icevn-ed-proj { font-size:.85rem; opacity:.85; }
.icevn-ed-header-actions { margin-left:auto; display:flex; gap:8px; }
.icevn-ed-notice { padding:10px 22px; background:#d9f2e6; color:#0f5c2e; border-bottom:1px solid #a5d9bf; font-size:.9rem; }
.icevn-ed-workspace { display:grid; grid-template-columns:240px minmax(0,1fr) 460px; gap:14px; padding:14px; height:calc(100vh - 60px); }
.icevn-ed-sidebar, .icevn-ed-main, .icevn-ed-preview { background:#fff; border-radius:14px; padding:14px; overflow:auto; box-shadow:0 4px 16px rgba(74,15,36,.06); }
.icevn-ed-section { margin-bottom:20px; }
.icevn-ed-section h4 { margin:0 0 10px; font-size:.78rem; text-transform:uppercase; letter-spacing:.08em; color:#6e1a37; font-weight:700; }
.icevn-ed-scenes { list-style:none; padding:0; margin:0 0 10px; }
.icevn-ed-scenes li a { display:block; padding:7px 10px; border-radius:8px; color:#334155; text-decoration:none; font-size:.88rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.icevn-ed-scenes li a:hover { background:#f1f5f9; color:#ae2448; }
.icevn-ed-scenes li.active a { background:#ae2448; color:#fff; }
.icevn-ed-scenes li.empty { color:#94a3b8; font-size:.82rem; padding:6px 10px; font-style:italic; }
.icevn-ed-newscene { display:flex; gap:6px; }
.icevn-ed-newscene input { flex:1; padding:7px 10px; border:1.5px solid #e2e8f0; border-radius:8px; font-size:.85rem; font-family:inherit; outline:none; min-width:0; }
.icevn-ed-newscene input:focus { border-color:#72baa9; }
.icevn-ed-newscene button { padding:7px 14px; border-radius:8px; border:none; background:#72baa9; color:#fff; font-weight:700; cursor:pointer; }
.icevn-ed-chars { display:flex; flex-wrap:wrap; gap:6px; }
.icevn-ed-char { padding:5px 12px; border-radius:20px; background:#e6f2ef; color:#01796f; border:1px solid #c6e0d8; cursor:pointer; font-size:.8rem; font-weight:600; font-family:inherit; transition:.15s; }
.icevn-ed-char:hover { background:#01796f; color:#fff; border-color:#01796f; }
.icevn-ed-hint { font-size:.78rem; color:#94a3b8; line-height:1.5; margin:0; }
.icevn-ed-toolbar { display:flex; flex-direction:column; gap:10px; margin-bottom:14px; }
.icevn-ed-toolbar h2 { margin:0; font-size:1.1rem; color:#6e1a37; font-family:'Cormorant Unicase',serif; }
.icevn-ed-palette { display:flex; flex-wrap:wrap; gap:6px; }
.icevn-btn { padding:7px 12px; border-radius:8px; border:1.5px solid #e2e8f0; background:#fff; color:#334155; cursor:pointer; font-weight:600; font-size:.78rem; transition:.15s; font-family:inherit; display:inline-flex; align-items:center; gap:5px; }
.icevn-btn:hover { border-color:#72baa9; color:#72baa9; }
.icevn-btn--primary { background:#ae2448; border-color:#ae2448; color:#fff; }
.icevn-btn--primary:hover { background:#7e1632; border-color:#7e1632; color:#fff; }
.icevn-btn--ghost { background:transparent; }
.icevn-ed-commands { display:flex; flex-direction:column; gap:10px; }
.icevn-ed-cmd { border:1px solid #e2e8f0; border-radius:10px; overflow:hidden; background:#fff; }
.icevn-ed-cmd-head { display:flex; align-items:center; gap:10px; padding:8px 12px; background:#f8fafc; border-bottom:1px solid #e2e8f0; cursor:grab; }
.icevn-ed-cmd-num { width:24px; height:24px; background:#6e1a37; color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:.72rem; font-weight:700; }
.icevn-ed-cmd-type { font-weight:700; color:#ae2448; text-transform:uppercase; font-size:.74rem; letter-spacing:.05em; }
.icevn-ed-cmd-actions { margin-left:auto; display:flex; gap:4px; }
.icevn-ed-cmd-actions button { width:26px; height:26px; border-radius:6px; border:none; background:#e2e8f0; cursor:pointer; color:#334155; font-size:.78rem; }
.icevn-ed-cmd-actions button.danger { background:#fde7ec; color:#c41e3a; }
.icevn-ed-cmd-body { padding:10px 12px; display:flex; flex-direction:column; gap:8px; }
.icevn-ed-cmd-body label { display:flex; flex-direction:column; gap:4px; font-size:.74rem; color:#64748b; font-weight:600; }
.icevn-ed-cmd-body input, .icevn-ed-cmd-body textarea, .icevn-ed-cmd-body select { padding:8px 10px; border:1.5px solid #e2e8f0; border-radius:8px; font-size:.86rem; font-family:inherit; outline:none; background:#fff; }
.icevn-ed-cmd-row { display:flex; gap:8px; }
.icevn-ed-cmd-row > * { flex:1; }
.icevn-ed-options { display:flex; flex-direction:column; gap:6px; }
.icevn-ed-option { display:flex; gap:6px; }
.icevn-ed-option input { flex:1; }
.icevn-ed-option button { padding:0 12px; border:none; background:#fde7ec; color:#c41e3a; border-radius:8px; cursor:pointer; }
.icevn-ed-empty { color:#94a3b8; text-align:center; padding:60px 20px; }
.icevn-ed-preview iframe { width:100%; height:calc(100% - 60px); border:0; border-radius:10px; background:#000; }
.icevn-ed-preview-actions { margin-top:10px; display:flex; align-items:center; gap:10px; }
.icevn-ed-preview-hint { font-size:.72rem; color:#94a3b8; }
@media (max-width:1200px) { .icevn-ed-workspace { grid-template-columns:1fr; height:auto; } .icevn-ed-preview iframe { height:420px; } }