/* Prism RP — дизайн-система.
   Идея: свет, разложенный призмой. Спокойные сливово-чернильные поверхности;
   единственный яркий элемент — спектральная линия под шапкой чата, которая
   течёт, пока модель пишет. Интерфейс — Onest, ролевая проза — Literata. */

:root, [data-theme="dusk"] {
  --bg: #15131d;
  --surface: #1c1a27;
  --raised: #252233;
  --sunken: #110f18;
  --line: #322d45;
  --line-soft: #26223a;
  --text: #ece7f6;
  --text-2: #b9b2cf;
  --muted: #8d86a6;
  --accent: #b79cff;
  --accent-strong: #9c7bff;
  --accent-ink: #160f2b;
  --accent-wash: rgba(183, 156, 255, .12);
  --me: #4a3a8c;
  --me-ink: #f3efff;
  --them: #221f30;
  --ok: #6fd6a8;
  --warn: #f2c26b;
  --danger: #ff8a9a;
  --prose: #e9e4f2;
  --action: #a99fc4;
  --speech: #fff6e8;
  --shadow: 0 18px 50px rgba(5, 3, 12, .55);
  --spectrum: linear-gradient(90deg, #7fd1ff, #b79cff 30%, #ff9ec7 55%, #ffd08a 78%, #8ff0c3);
  color-scheme: dark;
}
[data-theme="dawn"] {
  --bg: #f1eef7;
  --surface: #ffffff;
  --raised: #f6f3fb;
  --sunken: #e8e3f2;
  --line: #ddd6ea;
  --line-soft: #ebe6f3;
  --text: #1e1a2b;
  --text-2: #4b4462;
  --muted: #7a7393;
  --accent: #6b4edb;
  --accent-strong: #5636c9;
  --accent-ink: #ffffff;
  --accent-wash: rgba(107, 78, 219, .09);
  --me: #6b4edb;
  --me-ink: #ffffff;
  --them: #ffffff;
  --ok: #1f9d6c;
  --warn: #b7791f;
  --danger: #d0384f;
  --prose: #231e33;
  --action: #6e6788;
  --speech: #1e1a2b;
  --shadow: 0 18px 50px rgba(60, 40, 120, .14);
  --spectrum: linear-gradient(90deg, #39a7e6, #6b4edb 30%, #e05596 55%, #e7a33c 78%, #2fb985);
  color-scheme: light;
}
[data-theme="paper"] {
  --bg: #efe8dc;
  --surface: #f8f3ea;
  --raised: #f2ebdf;
  --sunken: #e6dccc;
  --line: #d9ccb6;
  --line-soft: #e5dacb;
  --text: #2b2318;
  --text-2: #54473a;
  --muted: #85766a;
  --accent: #7a4d9e;
  --accent-strong: #653a8a;
  --accent-ink: #fbf6ff;
  --accent-wash: rgba(122, 77, 158, .1);
  --me: #7a4d9e;
  --me-ink: #fbf6ff;
  --them: #fbf7f0;
  --ok: #3f8a5c;
  --warn: #9c6a12;
  --danger: #b03a3a;
  --prose: #2b2318;
  --action: #7a6a5a;
  --speech: #1f1810;
  --shadow: 0 18px 50px rgba(80, 60, 30, .15);
  --spectrum: linear-gradient(90deg, #3d8fc2, #7a4d9e 30%, #c2507e 55%, #c98a2a 78%, #3f9a72);
  color-scheme: light;
}

:root {
  --ui: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --read: "Literata", Georgia, "Times New Roman", serif;
  --fs: 15px;
  --prose-fs: 17px;
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --rail: 264px;
  --drawer: 384px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs)/1.5 var(--ui); -webkit-font-smoothing: antialiased; text-align: left; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-wash); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ── Каркас ─────────────────────────────────────────────────────────── */
/* Perchance по умолчанию центрирует текст страницы — возвращаем обычное выравнивание. */
.app { text-align: left; display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100dvh; overflow: hidden; }
/* Служебные контейнеры не участвуют в сетке: их содержимое позиционируется фиксированно. */
#pop-root, #modal-root { display: contents; }
.rail { background: var(--surface); border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; min-height: 0; }
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; background: none; border: 0; cursor: pointer; text-align: left; }
.brand-glyph { width: 26px; height: 26px; flex: none; }
.rail-nav { padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
.rail-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-s); border: 0; background: none; cursor: pointer; color: var(--text-2); text-align: left; width: 100%; }
.rail-item:hover { background: var(--raised); color: var(--text); }
.rail-item.active { background: var(--accent-wash); color: var(--text); }
.rail-item svg { width: 18px; height: 18px; flex: none; }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; color: var(--muted); font-size: 13px; }
.rail-chats { flex: 1; overflow: auto; padding: 0 10px 10px; }
.rail-chat { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: var(--r-m); cursor: pointer; }
.rail-chat:hover { background: var(--raised); }
.rail-chat.active { background: var(--raised); box-shadow: inset 2px 0 0 var(--accent); }
.rail-chat .t1 { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-chat .t2 { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-chat .kind { color: var(--muted); }
.rail-chat .kind svg { width: 15px; height: 15px; }
.rail-foot { border-top: 1px solid var(--line-soft); padding: 10px; display: flex; gap: 6px; }

/* ── Кнопки и поля ──────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--raised); padding: 8px 14px; border-radius: var(--r-m); cursor: pointer; white-space: nowrap; color: var(--text); font-weight: 500; line-height: 1.2; }
.btn:hover { border-color: var(--accent); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--raised); border-color: transparent; color: var(--text); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13.5px; border-radius: var(--r-s); }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-s); border: 0; background: none; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--accent-wash); }
.icon-btn svg { width: 19px; height: 19px; }
.file-btn input { display: none; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label, .label { font-size: 13px; color: var(--text-2); font-weight: 500; display: inline-flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
.label svg, .field > label svg { width: 15px; height: 15px; flex: none; }
.field .help { font-size: 12.5px; color: var(--muted); }
.input, .field input:not([type=checkbox]):not([type=range]), .field textarea, .field select {
  width: 100%; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px 10px; color: var(--text);
}
.field textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.row { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.row > .btn { align-self: flex-end; }
.row > .field { flex: 1; min-width: 100px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; margin: 8px 0; cursor: pointer; text-align: left; }
.check > span { flex: 1; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 0 18px; }
.checks .check { margin: 4px 0; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check small { display: block; color: var(--muted); font-size: 12.5px; }

.seg { display: inline-flex; background: var(--sunken); border: 1px solid var(--line-soft); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 13px; border-radius: 999px; cursor: pointer; color: var(--text-2); font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.seg button svg { width: 15px; height: 15px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line-soft); font-size: 13.5px; max-width: 100%; }
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.chip button:hover { background: var(--line); color: var(--text); }
.chip button svg { width: 12px; height: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-add { border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 3px 10px; min-width: 90px; width: 140px; font-size: 13.5px; color: var(--text); }
.chip-add:focus { outline: none; border-color: var(--accent); border-style: solid; }

/* ── Аватары ────────────────────────────────────────────────────────── */
.av { position: relative; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--raised); }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av-34 { width: 34px; height: 34px; font-size: 14px; }
.av-40 { width: 40px; height: 40px; font-size: 16px; }
.av-48 { width: 48px; height: 48px; font-size: 19px; }
.av-me { background: var(--sunken); color: var(--accent); border: 1px solid var(--line); }

/* ── Главный экран ──────────────────────────────────────────────────── */
.home { flex: 1; overflow: auto; }
.home-inner { max-width: 1180px; margin: 0 auto; padding: 34px 32px 60px; }
.home-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.home h1 { font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: -.02em; font-weight: 700; }
.home .sub { color: var(--text-2); margin: 6px 0 0; max-width: 60ch; }
.home-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 0 10px; height: 38px; min-width: 220px; }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { border: 0; background: none; outline: none; width: 100%; height: 100%; }
.search:focus-within { border-color: var(--accent); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 18px; }
.tile { position: relative; border-radius: var(--r-l); overflow: hidden; aspect-ratio: 3 / 4; background: var(--surface); border: 1px solid var(--line-soft); cursor: pointer; display: block; padding: 0; text-align: left; color: #fff; }
.tile:hover .tile-art { transform: scale(1.035); }
.tile-art { position: absolute; inset: 0; transition: transform .45s cubic-bezier(.2,.7,.2,1); display: grid; place-items: center; font-size: 64px; font-weight: 700; color: rgba(255,255,255,.85); }
.tile-art img { width: 100%; height: 100%; object-fit: cover; }
.tile-shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(10, 6, 20, .88)); }
.tile-body { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px; }
.tile-name { font-weight: 700; font-size: 17px; line-height: 1.2; text-shadow: 0 1px 8px rgba(0,0,0,.4); }
.tile-tags { font-size: 12.5px; opacity: .78; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-count { position: absolute; top: 10px; right: 10px; background: rgba(10, 6, 20, .55); backdrop-filter: blur(6px); border-radius: 999px; font-size: 12px; padding: 2px 9px; }
.tile-new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-2); border: 1.5px dashed var(--line); background: transparent; }
.tile-new:hover { border-color: var(--accent); color: var(--text); }
.tile-new svg { width: 30px; height: 30px; }
.tile-new label, .tile-new span { cursor: pointer; }

.welcome { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 8px 0 30px; }
.step { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-l); padding: 18px; }
.step h3 { margin: 6px 0 4px; font-size: 16px; }
.step p { margin: 0 0 12px; color: var(--text-2); font-size: 14px; }
.step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); font-weight: 700; font-size: 13px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin: 30px 0 12px; }

/* ── Чат ────────────────────────────────────────────────────────────── */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 18px; background: var(--surface); position: relative; min-height: 64px; }
.chat-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--spectrum); opacity: .35; background-size: 200% 100%; }
.app.generating .chat-head::after { opacity: 1; animation: flow 2.4s linear infinite; }
@keyframes flow { from { background-position: 0 0; } to { background-position: -200% 0; } }
.head-who { min-width: 0; flex: 1; }
.head-name { font-weight: 700; font-size: 16px; display: flex; gap: 10px; align-items: center; }
.head-name .rename { opacity: 0; }
.head-who:hover .rename { opacity: 1; }
.head-scene { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-scene.live { color: var(--accent); }
.head-tools { display: flex; align-items: center; gap: 2px; }

.findbar { display: flex; gap: 8px; align-items: center; padding: 8px 18px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.findbar .search { flex: 1; height: 34px; }
.findbar .count { color: var(--muted); font-size: 13px; min-width: 52px; text-align: right; }
mark { background: color-mix(in srgb, var(--warn) 40%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
mark.cur { background: var(--warn); color: #1b1300; }

.feed { flex: 1; overflow: auto; padding: 26px 22px 12px; scroll-behavior: smooth; }
.feed-inner { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

/* Сцена: проза */
.turn { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; }
.turn-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.turn-name { font-weight: 650; font-size: 14.5px; }
.turn-time { color: var(--muted); font-size: 12px; }
.prose { font-family: var(--read); font-size: var(--prose-fs); line-height: 1.72; color: var(--prose); white-space: pre-wrap; overflow-wrap: anywhere; }
.prose em { color: var(--action); font-style: italic; }
.prose q { quotes: none; color: var(--speech); }
.prose strong { font-weight: 650; }
.turn.user .prose { font-family: var(--ui); font-size: 15.5px; line-height: 1.6; color: var(--text); }
.turn.user .bubble-plain { background: var(--raised); border: 1px solid var(--line-soft); border-radius: 4px var(--r-l) var(--r-l) var(--r-l); padding: 10px 14px; display: inline-block; max-width: 100%; }
.cursor::after { content: ""; display: inline-block; width: .5em; height: 1.05em; vertical-align: -0.15em; margin-left: 2px; background: var(--accent); animation: caret 1s steps(2) infinite; border-radius: 2px; }
@keyframes caret { 50% { opacity: 0; } }

.turn-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 8px; }
.delta { font-size: 12px; color: var(--text-2); background: var(--sunken); border: 1px solid var(--line-soft); padding: 1px 8px; border-radius: 999px; }
.tools { display: flex; align-items: center; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.turn:hover .tools, .turn:focus-within .tools, .turn.last .tools, .msg-row:hover .tools, .msg-row.last .tools { opacity: 1; }
.tool { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12.5px; padding: 4px 7px; border-radius: 7px; }
.tool:hover { background: var(--raised); color: var(--text); }
.tool svg { width: 15px; height: 15px; }
.swipes { display: inline-flex; align-items: center; color: var(--muted); font-size: 12.5px; margin-right: 6px; }
.swipes .tool { padding: 4px; }
details.think { margin: 2px 0 8px; font-size: 13.5px; color: var(--muted); }
details.think summary { cursor: pointer; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.think summary::-webkit-details-marker { display: none; }
details.think summary svg { width: 14px; height: 14px; }
details.think div { white-space: pre-wrap; margin-top: 6px; padding: 8px 12px; border-left: 2px solid var(--line); }
.err { color: var(--danger); font-size: 14px; margin-top: 6px; white-space: pre-wrap; display: flex; gap: 8px; align-items: flex-start; }
.err svg { width: 17px; height: 17px; flex: none; margin-top: 2px; }
.editor { width: 100%; min-height: 140px; background: var(--sunken); border: 1px solid var(--accent); border-radius: var(--r-m); padding: 12px; resize: vertical; font-family: var(--read); font-size: 16px; line-height: 1.6; }

/* Картинки */
.shots { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.shot { position: relative; margin: 0; width: min(100%, 440px); border-radius: var(--r-l); overflow: hidden; background: var(--sunken); border: 1px solid var(--line-soft); }
.shot img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.shot.wait { display: flex; flex-direction: column; }
.shot-wait { flex: 1; display: grid; place-items: center; color: var(--text-2); font-size: 14px; background:
  linear-gradient(110deg, transparent 30%, var(--accent-wash) 50%, transparent 70%) var(--sunken); background-size: 250% 100%; animation: shimmer 1.6s linear infinite; min-height: 120px; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.shot-cap { font-size: 12px; color: var(--muted); padding: 8px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shot-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; background: rgba(12, 8, 22, .62); backdrop-filter: blur(6px); border-radius: 10px; padding: 2px; opacity: 0; transition: opacity .15s; }
.shot:hover .shot-tools, .shot:focus-within .shot-tools { opacity: 1; }
.shot-tools .icon-btn { color: #f2eefc; width: 32px; height: 32px; }
.shot-tools .icon-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.shot.failed { width: auto; max-width: 440px; padding: 12px 14px; aspect-ratio: auto !important; }
.shots.in-bubble .shot { width: min(78%, 360px); }
.msg-row.them .shots.in-bubble { justify-content: flex-start; }
@media (hover: none) { .shot-tools { opacity: 1; } }
.lightbox { background: rgba(6, 4, 12, .88); }
.lb-fig { margin: 0; max-width: min(1200px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 10px; }
.lb-fig img { max-width: 100%; max-height: calc(100dvh - 120px); object-fit: contain; border-radius: var(--r-m); }
.lb-fig figcaption { display: flex; gap: 12px; align-items: center; justify-content: space-between; color: #d9d3ea; font-size: 13.5px; }
.lb-fig figcaption > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-tools { display: flex; gap: 6px; flex: none; }
.lb-tools .icon-btn { color: #f2eefc; }
.lora-rows { display: flex; flex-direction: column; gap: 6px; }
.lora-row { flex-wrap: nowrap; align-items: center; }
.prov.dim { opacity: .55; }

/* Мессенджер */
.app.messenger .feed { background:
  radial-gradient(circle at 15% 10%, var(--accent-wash), transparent 40%),
  radial-gradient(circle at 85% 90%, var(--accent-wash), transparent 45%); }
.app.messenger .feed-inner { max-width: 660px; gap: 2px; }
.daymark { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line-soft); padding: 2px 12px; border-radius: 999px; margin: 12px 0 8px; }
.msg-row { display: flex; flex-direction: column; margin-top: 8px; }
.msg-row.me { align-items: flex-end; }
.msg-row.them { align-items: flex-start; }
.bub { max-width: min(78%, 480px); padding: 8px 13px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.42; margin-top: 3px; font-size: 15.5px; position: relative; }
.msg-row.me .bub { background: var(--me); color: var(--me-ink); }
.msg-row.them .bub { background: var(--them); border: 1px solid var(--line-soft); }
.msg-row.me .bub:last-of-type { border-bottom-right-radius: 6px; }
.msg-row.them .bub:last-of-type { border-bottom-left-radius: 6px; }
.stamp { font-size: 11px; color: var(--muted); margin: 3px 8px 0; }
.typing { display: inline-flex; gap: 4px; padding: 12px 15px !important; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; } .typing i:nth-child(3) { animation-delay: .36s; }
@keyframes dot { 0%, 70%, 100% { opacity: .25; transform: none; } 35% { opacity: 1; transform: translateY(-2px); } }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; }

/* Композер */
.composer-wrap { padding: 8px 18px 16px; }
.composer { max-width: 820px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 8px 8px 8px 14px; box-shadow: var(--shadow); }
.app.messenger .composer { max-width: 660px; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.composer textarea { width: 100%; border: 0; outline: none; background: none; resize: none; max-height: 240px; padding: 6px 0; line-height: 1.5; font-size: 15.5px; }
.composer-bar { display: flex; align-items: center; gap: 6px; }
.composer-bar .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-soft); background: var(--raised); border-radius: 999px; padding: 4px 11px 4px 9px; font-size: 13px; color: var(--text-2); cursor: pointer; max-width: 260px; }
.pill:hover { border-color: var(--accent); color: var(--text); }
.pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill svg { width: 15px; height: 15px; flex: none; }
/* Проверка инициативы (переписка): отдельное действие рядом с отправкой, не похожее на неё. */
.initiative-btn { border-style: dashed; color: var(--accent); flex: none; }
.initiative-btn:disabled { opacity: .45; cursor: default; }
.ini-tag { color: var(--accent); }
@media (max-width: 480px) { .composer-bar { flex-wrap: wrap; } .composer-bar .pill { max-width: 160px; } .composer-bar .initiative-btn { max-width: none; } }
.meter { width: 22px; height: 22px; flex: none; }
.meter circle { fill: none; stroke-width: 3; }
.meter .bg { stroke: var(--line); }
.meter .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .4s; }
.meter.hot .fg { stroke: var(--warn); }
.send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.send:hover { background: var(--accent-strong); }
.send svg { width: 18px; height: 18px; }
.send.stop { background: var(--danger); color: #fff; }

/* Поповеры */
.pop { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); padding: 6px; min-width: 260px; max-width: min(360px, 94vw); max-height: 70vh; overflow: auto; }
.pop-title { font-size: 12.5px; color: var(--muted); padding: 8px 10px 4px; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: var(--r-s); cursor: pointer; color: var(--text); }
.pop-item:hover { background: var(--raised); }
.pop-item.on { background: var(--accent-wash); }
.pop-item small { display: block; color: var(--muted); font-size: 12.5px; }
.pop-item svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.pop-sep { height: 1px; background: var(--line-soft); margin: 6px 4px; }

/* ── Выдвижная панель ───────────────────────────────────────────────── */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer); max-width: 100vw; background: var(--surface); border-left: 1px solid var(--line); z-index: 40; display: flex; flex-direction: column; transform: translateX(102%); transition: transform .26s cubic-bezier(.2,.7,.2,1); box-shadow: var(--shadow); }
.drawer.open { transform: none; }
@media (min-width: 1280px) {
  .app.drawer-open { grid-template-columns: var(--rail) minmax(0, 1fr) var(--drawer); }
  .app.drawer-open .drawer { position: relative; transform: none; box-shadow: none; grid-column: 3; grid-row: 1; transition: none; }
}
.drawer-head { display: flex; align-items: center; gap: 4px; padding: 10px 8px 0 12px; border-bottom: 1px solid var(--line-soft); }
.drawer-tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.dtab { border: 0; background: none; padding: 10px 10px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.dtab svg { width: 16px; height: 16px; }
.dtab.on { color: var(--text); border-bottom-color: var(--accent); }
.drawer-body { flex: 1; overflow: auto; padding: 18px; }
.block { margin-bottom: 22px; }
.block-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 650; font-size: 14.5px; margin-bottom: 10px; }
.block-title small { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.panel { background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r-m); padding: 14px; margin-bottom: 10px; }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.who b { font-size: 15px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.core-preview { border: 1px dashed var(--line); border-radius: var(--r-s); padding: 8px 12px; margin: 0 0 12px; }
.core-preview .hint { margin: 4px 0; overflow-wrap: anywhere; }
.core-block .tag { font-weight: 400; margin-left: 6px; }
.pick { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.pick button { border: 0; background: var(--sunken); padding: 5px 9px; cursor: pointer; font-size: 13px; color: var(--text-2); border-right: 1px solid var(--line); }
.pick button:last-child { border-right: 0; }
.pick button.on { background: var(--accent); color: var(--accent-ink); }
.memo { background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r-m); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; position: relative; }
.memo:hover { border-color: var(--line); }
.memo.off { opacity: .55; }
.memo .ev { font-size: 14.5px; }
.memo .in { font-size: 13px; color: var(--text-2); margin-top: 4px; font-style: italic; }
.memo .mt { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--sunken); color: var(--text-2); }
.tag.pos { color: var(--ok); }
.tag.neg { color: var(--danger); }
.memo-bar { position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.code { white-space: pre-wrap; font: 12.5px/1.55 ui-monospace, "SF Mono", Consolas, monospace; background: var(--sunken); border: 1px solid var(--line-soft); border-radius: var(--r-s); padding: 12px; overflow-wrap: anywhere; max-height: 60vh; overflow: auto; }
.code .role { color: var(--accent); font-weight: 700; }
.bar-meter { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; display: flex; margin: 8px 0 4px; }
.bar-meter i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--text-2); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; background: var(--c); vertical-align: 0; }

/* ── Модальные окна ─────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(8, 5, 16, .55); z-index: 35; backdrop-filter: blur(2px); }
.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(8, 5, 16, .55); backdrop-filter: blur(3px); }
.modal { width: min(920px, 100%); max-height: min(780px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); display: grid; grid-template-columns: 210px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.modal.narrow { width: min(560px, 100%); grid-template-columns: minmax(0, 1fr); }
.modal-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px 22px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; letter-spacing: -.01em; }
.modal-nav { padding: 12px 10px; border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.modal-body { overflow: auto; padding: 22px 26px 26px; }
.modal-body h3 { font-size: 16px; margin: 0 0 4px; }
.modal-body .lead { color: var(--text-2); margin: 0 0 18px; font-size: 14px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding-top: 10px; }
.prov { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--r-m); background: var(--raised); margin-bottom: 8px; cursor: pointer; }
.prov.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.prov .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); }
.prov.on .radio { border: 5px solid var(--accent); }
.prov .nm { font-weight: 600; }
.prov .ds { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.preset { border: 1px solid var(--line-soft); background: var(--raised); border-radius: var(--r-m); padding: 10px 12px; cursor: pointer; text-align: left; }
.preset.on { border-color: var(--accent); background: var(--accent-wash); }
.preset b { display: block; font-size: 14px; }
.preset small { color: var(--muted); font-size: 12.5px; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme { border: 2px solid var(--line-soft); border-radius: var(--r-m); padding: 0; cursor: pointer; overflow: hidden; background: none; text-align: left; }
.theme.on { border-color: var(--accent); }
.theme .sw { height: 64px; display: flex; align-items: flex-end; padding: 8px; gap: 5px; }
.theme .sw i { display: block; height: 10px; border-radius: 3px; }
.theme .nm { padding: 8px 10px; font-size: 13.5px; font-weight: 600; background: var(--raised); }
.card-edit { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 22px; }
.portrait { width: 180px; aspect-ratio: 3 / 4; border-radius: var(--r-l); overflow: hidden; display: grid; place-items: center; font-size: 56px; font-weight: 700; color: #fff; position: relative; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait .chg { position: absolute; bottom: 8px; left: 8px; right: 8px; }
.lore { border: 1px solid var(--line-soft); border-radius: var(--r-m); padding: 12px; margin-bottom: 8px; background: var(--raised); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--raised); border: 1px solid var(--line); padding: 10px 16px; border-radius: var(--r-m); z-index: 90; max-width: min(560px, 92vw); box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.toast.err { border-color: var(--danger); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.err svg { color: var(--danger); }
.toast:not(.err) svg { color: var(--ok); }

.empty-note { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }
.only-narrow { display: none !important; }

/* ── Адаптив ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); z-index: 45; transform: translateX(-102%); transition: transform .26s cubic-bezier(.2,.7,.2,1); box-shadow: var(--shadow); }
  .rail.open { transform: none; }
  .only-narrow { display: inline-grid !important; }
  /* Одна колонка: шапка, лента разделов и тело — три строки. Без третьей строки лента попадала в
     строку minmax(0, 1fr) высотой 0, а тело (неявная строка) начиналось сразу под шапкой и перекрывало ленту. */
  .modal { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .modal.narrow { grid-template-rows: auto minmax(0, 1fr); }
  .modal-nav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line-soft); overflow-x: auto; padding: 8px; }
  .modal-nav .rail-item { width: auto; white-space: nowrap; }
  .card-edit { grid-template-columns: minmax(0, 1fr); }
  .portrait { width: 140px; }
}
@media (max-width: 600px) {
  .home-inner { padding: 20px 16px 40px; }
  .home h1 { font-size: 24px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .feed { padding: 16px 12px 8px; }
  .turn { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
  .turn .av { width: 30px; height: 30px; font-size: 13px; }
  .composer-wrap { padding: 6px 10px 10px; }
  .pill { max-width: 150px; }
  .modal-wrap { padding: 0; }
  .modal { max-height: 100%; height: 100%; border-radius: 0; }
  .drawer { width: 100vw; }
  .head-tools .wide { display: none; }
  :root { --prose-fs: 16px; }
}

/* Редактор карточки: ключ спецификации рядом с подписью */
.spec-key { font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); background: var(--raised); border: 1px solid var(--line-soft); border-radius: 5px; padding: 0 5px; font-weight: 400; }
.alt-greet > label { justify-content: space-between; display: flex; }
.alt-greet .icon-btn { width: 26px; height: 26px; }

/* Где редактировать персонажа: кнопка на плитке и шапка чата */
.tile-edit { position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(10, 6, 20, .6); backdrop-filter: blur(6px); color: #fff; font: 500 12.5px var(--ui); opacity: .9; transition: opacity .15s, background .15s; z-index: 2; }
.tile-edit svg { width: 14px; height: 14px; }
.tile:hover .tile-edit, .tile:focus-within .tile-edit, .tile-edit:focus-visible { opacity: 1; }
.tile-edit:hover { background: var(--accent); }
@media (hover: none) { .tile-edit { opacity: 1; } .tile-edit span { display: none; } .tile-edit { padding: 6px; } }
.head-av { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; line-height: 0; }
.head-av:hover { box-shadow: 0 0 0 2px var(--accent); }
.head-card { border: 0; padding: 0; background: none; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.head-card:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Ассистент — разговор с моделью вне игры */
.assist-mark { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); flex: none; }
.assist-mark svg { width: 22px; height: 22px; }
.assist-head .pill .av { width: 18px; height: 18px; font-size: 10px; flex: none; }
.pop-item .av { flex: none; }
.av-18 { width: 18px; height: 18px; font-size: 10px; }
.av-22 { width: 22px; height: 22px; font-size: 11px; }
.assist-empty { text-align: center; padding: 6vh 8px 10px; max-width: 620px; margin: 0 auto; }
.assist-hero { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); }
.assist-hero svg { width: 34px; height: 34px; }
.assist-empty h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -.01em; }
.assist-empty p { color: var(--text-2); margin: 0 auto 20px; line-height: 1.55; }
.starters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; text-align: left; }
.starter { border: 1px solid var(--line-soft); background: var(--surface); color: var(--text); border-radius: var(--r-m); padding: 12px 14px; cursor: pointer; font: inherit; font-size: 14px; text-align: left; line-height: 1.4; }
.starter:hover { border-color: var(--accent); background: var(--accent-wash); }
.aturn { display: flex; flex-direction: column; min-width: 0; }
.aturn.user { align-items: flex-end; }
.aturn.user .bubble-plain { background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-radius: var(--r-l) var(--r-l) 4px var(--r-l); padding: 10px 14px; max-width: min(640px, 92%); line-height: 1.55; overflow-wrap: anywhere; }
.aturn .tools { margin-top: 4px; }
.aturn:hover .tools, .aturn:focus-within .tools, .aturn.last .tools { opacity: 1; }
.md { font-size: 15.5px; line-height: 1.65; color: var(--text); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .75em; }
.md ul, .md ol { margin: 0 0 .75em; padding-left: 1.4em; }
.md li { margin: .2em 0; }
.md h3, .md h4, .md h5, .md h6 { margin: 1em 0 .4em; font-size: 1.05em; }
.md h3 { font-size: 1.15em; }
.md blockquote { margin: 0 0 .75em; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--text-2); }
.md code { font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--raised); border: 1px solid var(--line-soft); border-radius: 5px; padding: 0 4px; }
.md .mdcode { position: relative; margin: 0 0 .9em; }
.md pre { margin: 0; background: var(--raised); border: 1px solid var(--line-soft); border-radius: var(--r-m); padding: 12px 14px; overflow: auto; white-space: pre-wrap; }
.md pre code { background: none; border: 0; padding: 0; font-size: 13.5px; line-height: 1.55; }
.md .code-copy { position: absolute; top: 6px; right: 6px; opacity: .7; }
.md .code-copy:hover { opacity: 1; }
.md.cursor > :last-child::after, .md.cursor:empty::after { content: ""; display: inline-block; width: .5em; height: 1.05em; vertical-align: -0.15em; margin-left: 2px; background: var(--accent); animation: caret 1s steps(2) infinite; border-radius: 2px; }
.md.cursor::after { content: none; }
@media (max-width: 600px) { .assist-head .pill { max-width: 128px; } .assist-head .assist-mark { display: none; } }
.assist-head .head-who { overflow: hidden; }
.assist-head .head-scene { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Prism: переполнение, отбор опыта, непривязанные записи */
.err-block { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--danger); border-radius: var(--r-m); padding: 10px 12px; color: var(--text); background: color-mix(in srgb, var(--danger) 10%, transparent); font-size: 14px; }
.err-block svg { width: 18px; height: 18px; color: var(--danger); flex: none; margin-top: 2px; }
.exp-debug summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.exp-debug table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.exp-debug th, .exp-debug td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.exp-debug th { color: var(--muted); font-weight: 500; }
.exp-debug tr.sel td:first-child { color: var(--text); font-weight: 600; }
.exp-debug td:not(:first-child) { white-space: nowrap; color: var(--text-2); }
.legacy-block { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 8px; }
.legacy-block .memo { cursor: default; }

/* ── Проверка импорта карточек ───────────────────────────────────────── */
.imp-modal { width: min(720px, 100%); }
.imp-item { border: 1px solid var(--line-soft); border-radius: var(--r-m); background: var(--raised); padding: 14px 16px; margin-bottom: 12px; }
.imp-item.bad { border-color: var(--danger); }
.imp-item h3 { display: flex; align-items: center; gap: 6px; }
.imp-item h3 svg { width: 16px; height: 16px; flex: none; color: var(--danger); }
.imp-fields { list-style: none; padding: 0; margin: 4px 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 12px; font-size: 13.5px; color: var(--muted); }
.imp-fields li.on { color: var(--text); }
.imp-dir, .imp-note { border-left: 3px solid var(--line); padding: 4px 0 4px 10px; margin: 8px 0; font-size: 13.5px; }
.imp-dir { border-left-color: var(--warn); }
.imp-note.warn { border-left-color: var(--warn); }
.imp-item details summary { cursor: pointer; color: var(--text-2); font-size: 13px; margin-top: 4px; }
.imp-item .code { max-height: 220px; margin: 6px 0 0; }
.imp-issues { padding-left: 18px; margin: 10px 0 0; font-size: 13.5px; }
.imp-issues li { margin: 3px 0; }
.imp-issues li.error b { color: var(--danger); }
.imp-issues li.warning b { color: var(--warn); }
.imp-issues li.info { color: var(--muted); }
.dir-badge { font-size: 11.5px; border-radius: 5px; padding: 0 6px; border: 1px solid var(--line-soft); color: var(--muted); font-weight: 500; }
.dir-badge.imported { color: var(--warn); border-color: var(--warn); }

/* ── Пустая сцена: начало ────────────────────────────────────────────── */
.opening-start { max-width: 520px; margin: 48px auto 0; text-align: center; padding: 0 16px; }
.opening-start .lead { color: var(--text-2); font-size: 15px; margin: 0 0 10px; }
.opening-start .btn { margin: 8px 0 14px; }

/* ── Миры: библиотека и линза персонажа ──────────────────────────────── */
.world-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; }
.world-list { display: flex; flex-direction: column; gap: 6px; }
.world-item { text-align: left; border: 1px solid var(--line-soft); background: var(--raised); border-radius: var(--r-m); padding: 10px 12px; cursor: pointer; color: var(--text); }
.world-item.on { border-color: var(--accent); background: var(--accent-wash); }
.world-item b { display: block; font-size: 14px; }
.world-item small { color: var(--muted); font-size: 12.5px; }
.world-editor { min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > .field { flex: 1 1 180px; min-width: 0; }
.world-fact.off, .lens-fact.off { opacity: .6; }
.lens-fact .lf-text { margin-bottom: 6px; }
.eff-world { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.eff-world li { border-left: 3px solid var(--line); padding: 4px 10px; }
.eff-world li.ovr { border-left-color: var(--warn); }
.eff-world li.own { border-left-color: var(--accent); }
.eff-world li.off { color: var(--muted); }
.eff-world s { color: var(--muted); margin-left: 6px; }
@media (max-width: 760px) { .world-layout { grid-template-columns: minmax(0, 1fr); } }

/* ── База не открылась ───────────────────────────────────────────────── */
.storage-error { max-width: 620px; margin: 40px auto 0; padding: 24px; border: 1px solid var(--warn); border-radius: var(--r-l); background: var(--raised); }
.storage-error h1 { display: flex; align-items: center; gap: 10px; font-size: 22px; margin: 0 0 12px; }
.storage-error h1 svg { width: 24px; height: 24px; color: var(--warn); flex: none; }
.storage-error p { margin: 0 0 10px; line-height: 1.5; }

/* Мир чата (FOUNDATION-W2) */
.wc-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.wc-list li { border-left: 3px solid var(--accent); padding: 4px 10px; overflow-wrap: anywhere; }
.wc-list li.off { border-left-color: var(--line); color: var(--muted); }
.wc-list .mt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.wc-list .mt small { color: var(--muted); }
.world-edit textarea { min-height: 70px; }

/* Переписка (FOUNDATION-C): значок режима и вкладка «Среда» */
.mode-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; white-space: nowrap; }
.mode-badge svg { width: 15px; height: 15px; }
.env-world dd { overflow-wrap: anywhere; }
.env-edit .check.sm { font-size: 12px; margin-top: 2px; }
.env-edit .check.sm span { font-size: 12px; }
#drawer-body .row select, #drawer-body .row input { min-width: 0; flex: 1; }
/* Переключатели внутри поля (область «ветка / вся переписка», режим времени) — не растягиваются на всю ширину */
.field .check input[type=radio], .field .check input[type=checkbox] { width: auto; flex: none; height: auto; padding: 0; }
