/* ==========================================================================
   Оформление. Цвета и шрифты задаются переменными (--bg, --accent и т.д.),
   их значения приходят из «Панели мастера → Мир», здесь они только по умолчанию.
   Внизу файла — стиль «Современный» (data-skin="modern"); без него — «классический».
   ========================================================================== */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3d7eff;
  --border: #30363d;
  --letter-bg: #1c2b45;
  --letter-text: #dbe7ff;
  --font-heading: system-ui, sans-serif;
  --font-body: system-ui, sans-serif;
  --font-letter: system-ui, sans-serif;
  --bg-dim: 0.6;
  --radius: 6px;
  --glass: color-mix(in srgb, var(--panel) 92%, transparent);
  --hover: color-mix(in srgb, var(--text) 5%, transparent);
  --on-accent: #fff;
  --danger: #d0503c;
  --rarity-common: var(--muted);
  --rarity-uncommon: #6fae4a;
  --rarity-rare: #4a8fd4;
  --rarity-unique: #e0a526;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

#backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
}
#backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: var(--bg-dim);
}

h1, h2, h3, h4, h5 { font-family: var(--font-heading); font-weight: 600; margin: 0; line-height: 1.2; }
p { margin: 0 0 0.5em; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.center { text-align: center; }
.pad { padding: 14px; }
.grow { flex: 1; }
.tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 400;
  line-height: 1.4;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  vertical-align: middle;
  letter-spacing: 0;
  text-transform: none;
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Кнопки и поля ---------- */

button, input, select, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 11px;
  font-size: 0.92em;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.12); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }
.icon-btn { padding: 2px 8px; line-height: 1.3; background: none; }

input, select, textarea {
  width: 100%;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 9px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.5; }
textarea.code { font-family: Consolas, monospace; font-size: 13px; }
input[type="color"] { padding: 2px; height: 30px; cursor: pointer; }
input[type="range"] { padding: 0; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
select option, select optgroup { background: var(--panel); color: var(--text); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { flex: 1; white-space: nowrap; }
.tabs button.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.small-tabs { margin: 4px 0 0; }
.small-tabs button { flex: 0 1 auto; padding: 2px 10px; font-size: 0.85em; }

/* ---------- Вход ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; overflow: auto; }
.auth-card {
  width: min(380px, 100%);
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
}
.auth-emblem:empty { display: none; }
.auth-card h1 { font-size: 1.8em; text-align: center; color: var(--accent); }
.auth-card > p { text-align: center; margin: 6px 0 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.auth-card label { display: flex; flex-direction: column; gap: 3px; font-size: 0.88em; color: var(--muted); }
.auth-card button.primary { margin-top: 6px; padding: 8px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 0.9em; }

/* ---------- Каркас страницы ---------- */

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 260px;
  height: 100vh;
  height: 100dvh;
}
/* Карта, верхушка и лор занимают всё место — OOC-колонки там нет. */
.shell:not([data-view="scene"]) { grid-template-columns: 236px minmax(0, 1fr); }
.shell:not([data-view="scene"]) .ooc { display: none; }

.sidebar, .ooc {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--glass);
  backdrop-filter: blur(8px);
}
.sidebar { border-right: 1px solid var(--border); }
.ooc { border-left: 1px solid var(--border); }
.center-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.world-head { position: relative; padding: 14px 14px 12px; border-bottom: 1px solid var(--border); }
.world-head h1 { font-size: 1.3em; color: var(--accent); }
.world-head p { color: var(--muted); font-size: 0.82em; margin-top: 2px; font-style: italic; }

.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 4px;
  font-size: 0.72em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Дерево каналов */
.scene-list { flex: 1; overflow-y: auto; padding: 0 6px 6px; }
.scene-row { display: flex; align-items: center; gap: 1px; padding-left: calc(var(--depth) * 14px); }
.twisty {
  flex: 0 0 18px;
  width: 18px;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.75em;
  text-align: center;
}
.scene-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  border-radius: 3px;
  padding: 4px 7px;
  font-size: 0.92em;
  color: color-mix(in srgb, var(--text) 85%, var(--muted));
}
.scene-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-item:hover { background: var(--hover); color: var(--text); }
.scene-item.active { background: color-mix(in srgb, var(--accent) 15%, transparent); border-left-color: var(--accent); color: var(--text); }
.scene-item.archived { opacity: 0.55; }
.scene-item.unread .scene-name { font-weight: 700; color: var(--text); }
.scene-item.unread::after { content: ''; flex: 0 0 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: auto; }
.scene-row.special .scene-item { font-family: var(--font-heading); letter-spacing: 0.03em; }
.scene-row.special .twisty { color: var(--accent); font-size: 0.95em; }
.tree-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.add-sub { opacity: 0; padding: 0 5px; font-size: 0.85em; }
.scene-row:hover .add-sub { opacity: 1; }
.archive summary { cursor: pointer; color: var(--muted); font-size: 0.8em; padding: 8px; }

.side-foot { border-top: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.side-foot > button { text-align: left; padding: 4px 9px; }
.me { display: flex; align-items: baseline; gap: 6px; padding: 4px 4px 0; font-size: 0.85em; }
.me small { color: var(--muted); }
.me .link:first-of-type { margin-left: auto; }
.me .link { font-size: 0.85em; }

/* ---------- Объявление ---------- */

.announce {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  font-size: 0.92em;
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  border-bottom: 1px solid var(--accent);
}
.announce-icon { font-size: 1.3em; line-height: 1; }
.announce.alarm {
  background: repeating-linear-gradient(-45deg, #5c1410 0 14px, #3d0d0a 14px 28px);
  border-bottom-color: var(--danger);
  color: #ffd9d0;
  animation: alarm 1.2s ease-in-out infinite;
}
.announce.alarm .announce-icon { color: #ffcc00; }
@keyframes alarm { 50% { box-shadow: inset 0 0 40px rgba(255, 60, 30, 0.5); } }
.preview-ann { border-radius: 4px; margin-bottom: 8px; }

/* ---------- Канал ---------- */

.stage { display: flex; flex-direction: column; min-height: 0; min-width: 0; flex: 1; }

.scene-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
}
.scene-head.has-bg {
  min-height: 120px;
  align-items: flex-end;
  background-image: linear-gradient(to top, var(--bg) 0%, color-mix(in srgb, var(--bg) 40%, transparent) 60%, transparent 100%), var(--scene-bg);
  background-size: cover;
  background-position: center;
}
.scene-titles { flex: 1; min-width: 0; }
.scene-titles h2 { font-size: 1.25em; }
.crumbs { font-size: 0.75em; color: var(--muted); }
.crumbs .link { color: var(--muted); }
/* Описание канала: свёрнуто до двух строк, «описание полностью» раскрывает */
.scene-desc {
  position: relative;
  max-height: 2.9em;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88em;
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent);
  mask-image: linear-gradient(to bottom, #000 45%, transparent);
}
.scene-desc.open { max-height: 40vh; overflow-y: auto; -webkit-mask-image: none; mask-image: none; color: var(--text); }
.desc-toggle { font-size: 0.75em; color: var(--muted) !important; }

/* Блок «в архив / удалить» в настройках канала */
.danger-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 6%, transparent);
}
.danger-zone > div { display: flex; flex-direction: column; flex: 1; min-width: 200px; }
.scene-head.has-bg h2 { text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9); }
.has-notes { color: var(--accent); }

.gm-notes { padding: 8px 16px; border-bottom: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.gm-notes textarea { font-size: 0.88em; }

/* Шапка карты, верхушки и т.п. */
.view-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
}
.view-head h2 { font-size: 1.25em; }
.view-head input, .view-head select { width: auto; min-width: 150px; padding: 4px 8px; font-size: 0.9em; }
.view-scroll { flex: 1; overflow-y: auto; padding: 14px 18px 30px; min-height: 0; }

.feed { flex: 1; overflow-y: auto; padding: 10px 0 6px; }
.load-more { display: block; margin: 0 0 10px 16px; }

.empty { margin: auto; text-align: center; padding: 40px 16px; }
.empty h2 { margin-bottom: 8px; }

/* ---------- Посты: строки слева, как в мессенджере ---------- */

.post {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 6px 16px 6px 14px;
  margin-top: 6px;
  border-left: 2px solid transparent;
}
.post:hover { background: var(--hover); }
.post-main { flex: 1; min-width: 0; }
.post-main header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 1px; }
.post-name {
  background: none; border: none; padding: 0;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.02em;
  color: var(--char);
}
.post-name:hover { text-decoration: underline; }
.post time { color: var(--muted); font-size: 0.72em; }
.post-body { overflow-wrap: anywhere; }
.avatar-btn { background: none; border: none; padding: 0; align-self: flex-start; margin-top: 2px; }

.post-tools { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.post:hover .post-tools, .ooc-msg:hover .post-tools { opacity: 1; }
.post-tools button { background: none; border: none; padding: 0 5px; color: var(--muted); }
.post-tools button:hover { color: var(--accent); }
.post.letter .post-tools, .post.roll-only .post-tools { position: absolute; top: 4px; right: 12px; }

/* Голос рассказчика / хроника — тоже слева, с полосой */
.post.narration {
  display: block;
  margin: 10px 16px 10px 14px;
  padding: 6px 12px 8px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.narr-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.narr-label {
  font-family: var(--font-heading);
  font-size: 0.72em;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.post.narration .post-body { font-style: italic; }

/* Письмо / телеграмма — документ под строкой, по левому краю */
.post.letter { display: block; padding: 6px 16px 6px 66px; }
.letter-paper {
  max-width: 560px;
  padding: 16px 20px;
  background: var(--letter-bg);
  color: var(--letter-text);
  font-family: var(--font-letter);
  font-size: 0.95em;
  border-radius: 2px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.letter-head { font-size: 0.72em; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.7; margin-bottom: 8px; }
.letter-sign { margin-top: 10px; }
.post.letter > time { display: block; margin-top: 3px; }

/* Личное сообщение */
.post.whisper { border-left-color: var(--accent); background: color-mix(in srgb, var(--panel) 60%, #000 40%); }
.whisper-to { font-size: 0.78em; color: var(--accent); margin-bottom: 2px; }

/* Бросок кубиков */
.roll-result {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin: 1px 0 4px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  font-family: var(--font-letter);
  font-size: 0.88em;
}
.die {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 3px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
}
.roll-result .total { font-size: 1.25em; font-weight: 700; color: var(--accent); }
.post.roll-only { display: block; padding-left: 66px; }
.post.roll-only time { margin-left: 8px; }

/* Служебная строка */
.post.system {
  display: block;
  padding: 2px 16px 2px 66px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82em;
  font-style: italic;
}
.post.system time { margin-left: 6px; }

/* ---------- Оформленный текст ---------- */

.post-body em, .rich em { color: color-mix(in srgb, var(--text) 80%, var(--muted)); }
.spoiler {
  background: var(--text);
  color: transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  user-select: none;
}
.spoiler * { color: transparent !important; }
.spoiler.shown { background: color-mix(in srgb, var(--text) 12%, transparent); color: inherit; user-select: auto; }
.spoiler.shown * { color: inherit !important; }
code {
  font-family: var(--font-letter);
  font-size: 0.9em;
  padding: 0 4px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border: 1px solid var(--border);
}
blockquote {
  margin: 0 0 0.5em;
  padding: 2px 12px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  color: color-mix(in srgb, var(--text) 85%, var(--muted));
}
ul { margin: 0 0 0.5em; padding-left: 1.3em; }
hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.md-h { color: var(--accent); margin: 0.5em 0 0.25em; }
h3.md-h { font-size: 1.25em; }
h4.md-h { font-size: 1.08em; }
h5.md-h { font-size: 0.95em; }
.t-center { display: block; text-align: center; }
.lore-link { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }
.lore-link:hover { border-bottom-style: solid; }

/* Аватары */
.avatar {
  --size: 40px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--char, var(--accent));
  background: color-mix(in srgb, var(--char, var(--accent)) 25%, var(--panel));
  font-family: var(--font-heading);
  font-size: calc(var(--size) * 0.45);
  color: var(--text);
  vertical-align: middle;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { --size: 26px; }
.avatar.xs { --size: 20px; }
.avatar.lg { --size: 110px; border-radius: 10px; }

.typing { min-height: 18px; padding: 0 16px; font-size: 0.75em; color: var(--muted); font-style: italic; }

/* ---------- Поле ввода ---------- */

.composer {
  margin: 0 12px 10px;
  padding: 6px 10px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95em;
}
.composer.closed { color: var(--muted); font-style: italic; padding: 10px; }
.composer-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.as { display: flex; align-items: center; gap: 5px; min-width: 0; transition: opacity 0.15s; }
.as.dimmed { opacity: 0.35; pointer-events: none; }
.as select { width: auto; max-width: 220px; padding: 2px 6px; }
.types { display: flex; gap: 3px; flex-wrap: wrap; }
.types button { padding: 2px 8px; font-size: 0.85em; }
.types button.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.composer-extra:empty { display: none; }
.composer-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 0.88em; }
.composer textarea { border: none; background: transparent; padding: 3px; min-height: 54px; }
.composer-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.composer-foot small { font-size: 0.75em; }
.composer-foot button { margin-left: auto; }

.dice-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.dice-row input#dice-expr { width: 96px; padding: 2px 6px; font-family: var(--font-letter); }
.dice-row button { padding: 2px 8px; font-size: 0.85em; }

.picker { position: relative; }
.picker summary { cursor: pointer; padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px; list-style: none; }
.picker summary::-webkit-details-marker { display: none; }
.picker[open] summary { border-color: var(--accent); }
.picker-list {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 10;
  min-width: 230px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.picker-list .check { display: flex; align-items: center; gap: 7px; padding: 2px 4px; cursor: pointer; }

/* Кнопки форматирования */
.fmt-bar { display: flex; flex-wrap: wrap; gap: 1px; margin-bottom: 3px; border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.fmt-bar button, .fmt-color {
  min-width: 26px;
  padding: 0 6px;
  font-size: 0.8em;
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fmt-bar button:hover, .fmt-color:hover { border-color: var(--border); color: var(--text); }
.fmt-color { position: relative; overflow: hidden; }
.fmt-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; height: auto; }
.fmt-help { width: 100%; border-collapse: collapse; }
.fmt-help td, .fmt-help th { padding: 5px 7px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.fmt-help td p, .fmt-help td ul, .fmt-help td blockquote { margin: 0; }

/* ---------- OOC ---------- */

.ooc-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 12px 8px; border-bottom: 1px solid var(--border); }
.ooc-head h3 { font-size: 1em; }
.ooc-feed { flex: 1; overflow-y: auto; padding: 8px 12px; font-family: system-ui, sans-serif; font-size: 0.82em; }
.ooc-msg { position: relative; padding: 4px 0; border-bottom: 1px dashed color-mix(in srgb, var(--border) 60%, transparent); }
.ooc-msg b { color: var(--accent); }
.ooc-msg time { color: var(--muted); font-size: 0.85em; }
.ooc-msg .post-tools { position: absolute; top: 3px; right: 0; }
.ooc-form { display: flex; gap: 5px; padding: 8px; border-top: 1px solid var(--border); }
.ooc-form input { font-family: system-ui, sans-serif; font-size: 0.88em; }

/* ---------- Лор ---------- */

.lore { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100%; min-height: 0; }
.lore-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-right: 1px solid var(--border);
  background: var(--glass);
  overflow-y: auto;
  min-height: 0;
}
.lore-list-head { display: flex; align-items: center; gap: 6px; }
.lore-list-head h2 { font-size: 1.1em; color: var(--accent); }
.lore-list nav { display: flex; flex-direction: column; gap: 1px; }
.lore-cat { margin: 10px 0 3px; font-size: 0.7em; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.lore-item { text-align: left; background: none; border: none; border-left: 2px solid transparent; border-radius: 3px; padding: 3px 8px; }
.lore-item:hover { background: var(--hover); }
.lore-item.active { border-left-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lore-page { overflow-y: auto; padding: 22px 28px; min-height: 0; }
.lore-page > * { max-width: 760px; }
.lore-page h1 { font-size: 1.9em; color: var(--accent); margin-bottom: 12px; }
.lore-image { display: block; width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 14px; }
.lore-meta { font-size: 0.75em; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.lore-updated { margin-top: 20px; }
.lore-back { display: none; margin-bottom: 10px; }
.lore-preview { min-height: 200px; padding: 10px; border: 1px dashed var(--border); border-radius: 6px; }

/* ---------- Карта мира ---------- */

.map-view, .people-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.map-wrap {
  --country: color-mix(in srgb, var(--panel) 70%, var(--text) 14%);
  --sea: color-mix(in srgb, var(--bg) 82%, #1d4f8a 18%);
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 92%, #000);
}
#map-svg, #ru-svg { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
#map-svg.dragging, #ru-svg.dragging { cursor: grabbing; }
.sphere { fill: var(--sea); }
.graticule { fill: none; stroke: color-mix(in srgb, var(--text) 7%, transparent); stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.country {
  fill: var(--fill, var(--country));
  stroke: color-mix(in srgb, var(--bg) 70%, transparent);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: filter 0.12s;
}
.country:hover { filter: brightness(1.25); }
.country.selected { stroke: var(--accent); stroke-width: 2; filter: brightness(1.2); }
.zone {
  fill: var(--fill);
  fill-opacity: 0.32;
  stroke: var(--fill);
  stroke-width: 1.6;
  stroke-dasharray: 5 3;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}
.zone:hover, .zone.selected { fill-opacity: 0.5; }
.zone.editing { fill-opacity: 0.15; }
.country-label, .zone-label, .mk, #map-edit circle { transform: scale(var(--k, 1)); }
.country-label, .zone-label {
  text-anchor: middle;
  dominant-baseline: middle;
  font-family: var(--font-heading);
  paint-order: stroke;
  stroke: color-mix(in srgb, var(--bg) 85%, transparent);
  stroke-width: 2.5px;
  pointer-events: none;
}
.country-label { fill: color-mix(in srgb, var(--text) 85%, transparent); font-size: 9px; font-weight: 600; }
.zone-label { fill: #fff; font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.lbl.hidden { display: none; }
.marker { cursor: pointer; }
.marker circle, .marker rect, .marker path { fill: var(--text); stroke: var(--bg); stroke-width: 0.8; }
.marker.kind-capital .ring { fill: none; stroke: var(--text); stroke-width: 1; }
.marker.kind-fortress rect { fill: #9aa4b2; }
.marker.kind-front path { fill: #e5484d; }
.marker text {
  fill: var(--text);
  font-family: var(--font-body);
  font-size: 9px;
  paint-order: stroke;
  stroke: color-mix(in srgb, var(--bg) 90%, transparent);
  stroke-width: 2.5px;
}
.marker.selected text { fill: var(--accent); }
.edit-shape { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }
#map-edit .handle { fill: #fff; stroke: var(--accent); stroke-width: 2; cursor: move; vector-effect: non-scaling-stroke; }
#map-edit .mid { fill: var(--accent); stroke: #fff; stroke-width: 1; cursor: copy; opacity: 0.75; vector-effect: non-scaling-stroke; }

.map-zoom { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 3px; }
.map-zoom button { width: 30px; height: 30px; padding: 0; background: var(--glass); font-size: 1.05em; }
.map-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  max-width: 60%;
  padding: 6px 10px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75em;
}
.map-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.map-tip {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  max-width: 220px;
  padding: 6px 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  font-size: 0.82em;
  pointer-events: none;
}
.map-tip small { color: var(--muted); }
.map-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: calc(100% - 100px);
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.85em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.map-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  bottom: 10px;
  width: min(330px, calc(100% - 60px));
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  font-size: 0.92em;
}
.map-panel header { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.map-panel h3 { font-size: 1.15em; }
.map-panel h4 { margin: 12px 0 5px; font-size: 0.72em; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.map-panel .actions { justify-content: flex-start; margin-top: 14px; }
.swatch { flex: 0 0 14px; height: 14px; margin-top: 4px; border-radius: 3px; background: var(--fill); }
#country-jump { width: auto; max-width: 200px; padding: 4px 8px; font-size: 0.9em; }

/* ---------- Карта России (public/js/regions.js) ---------- */

.ru-neighbours { fill: color-mix(in srgb, var(--country) 55%, var(--sea)); stroke: color-mix(in srgb, var(--bg) 70%, transparent); stroke-width: 0.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.region { fill: var(--fill, var(--country)); cursor: pointer; transition: filter 0.12s; }
.region:hover { filter: brightness(1.25); }
.region.foreign { opacity: 0.55; }
.region-borders { fill: none; stroke: color-mix(in srgb, var(--bg) 75%, transparent); stroke-width: 0.6; vector-effect: non-scaling-stroke; pointer-events: none; }
.owner-borders { fill: none; stroke: var(--text); stroke-width: 1.8; stroke-dasharray: 6 3; vector-effect: non-scaling-stroke; pointer-events: none; opacity: 0.85; }
.region-selected { fill: none; stroke: var(--accent); stroke-width: 2.4; vector-effect: non-scaling-stroke; pointer-events: none; }
#ru-jump, #ru-mode { width: auto; max-width: 190px; padding: 4px 8px; font-size: 0.9em; }
.ru-hide { display: flex; white-space: nowrap; }
.view-head .ru-hide input { width: auto; min-width: 0; flex: none; }
.ru-grad { display: flex; align-items: center; gap: 6px; }
.ru-grad i { width: 110px; height: 9px; border-radius: 3px; background: linear-gradient(90deg, var(--country), var(--c)); }
.ru-bar { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 6px 0; font-size: 0.9em; }
.ru-bar i { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: linear-gradient(90deg, var(--c) var(--v), color-mix(in srgb, var(--text) 12%, transparent) var(--v)); }
.ru-forces dd { text-align: right; font-variant-numeric: tabular-nums; }
.ru-table-wrap { overflow: auto; height: 100%; }
.ru-table { width: 100%; border-collapse: collapse; font-size: 0.86em; }
.ru-table th { position: sticky; top: 0; z-index: 1; padding: 6px 8px; text-align: left; white-space: nowrap; cursor: pointer; background: var(--panel); border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 600; }
.ru-table th.sorted { color: var(--accent); }
.ru-table td { padding: 5px 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ru-table td.c-name { white-space: normal; min-width: 170px; }
.ru-table td.c-name small { display: block; color: var(--muted); font-size: 0.85em; }
.ru-table tbody tr { cursor: pointer; }
.ru-table tbody tr:hover { background: var(--hover); }
.ru-table tr.foreign { opacity: 0.6; }
.ru-pill { display: inline-block; min-width: 34px; padding: 1px 6px; border-radius: 10px; text-align: center; background: color-mix(in srgb, var(--c) var(--v), transparent); }

.person-lines { display: flex; flex-direction: column; gap: 2px; }
.person-line { display: flex; align-items: center; gap: 8px; padding: 3px 5px; text-align: left; background: none; border: 1px solid transparent; }
.person-line:hover { background: var(--hover); border-color: var(--border); }
.person-line span { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.person-line small { color: var(--muted); font-size: 0.82em; }

/* ---------- Персонажи: три списка ---------- */

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 18px 0 8px;
  padding-bottom: 5px;
  font-size: 0.85em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.section-title small { font-size: 0.85em; letter-spacing: 0; text-transform: none; color: var(--muted); font-weight: 400; }
.tier-section:first-child .section-title { margin-top: 4px; }
.tier-primary .section-title { border-bottom-color: var(--accent); }
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px; }
.person-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-left: 3px solid var(--char);
  border-radius: var(--radius);
  cursor: pointer;
}
.person-card:hover, .person-card:focus { background: var(--hover); border-color: var(--char); outline: none; }
.person-card.mine::after { content: 'мой'; position: absolute; top: 4px; right: 8px; font-size: 0.65em; color: var(--accent); }
.pc-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.pc-text b { font-family: var(--font-heading); color: var(--char); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-text small { font-size: 0.8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tier-other .person-card { opacity: 0.8; }
.tier-move {
  position: absolute;
  right: 6px;
  bottom: 5px;
  width: auto;
  padding: 0 4px;
  font-size: 0.7em;
  background: var(--panel);
  opacity: 0;
  transition: opacity 0.15s;
}
.person-card:hover .tier-move, .tier-move:focus { opacity: 1; }
.o-position { color: var(--muted); font-size: 1.02em; margin-bottom: 4px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 8px 0 12px; font-size: 0.92em; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---------- Окна ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.modal {
  width: min(500px, 100%);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal.wide { width: min(820px, 100%); }
.modal > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.modal > header h3 { font-size: 1.05em; }
.modal-body { overflow-y: auto; padding: 12px 16px 16px; }
.modal-body section { margin-bottom: 16px; }
.modal-body h4 { margin: 12px 0 6px; color: var(--accent); font-size: 0.95em; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 0.86em; color: var(--muted); }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 0.88em; }
.form label.check input[type="color"] { width: 48px; height: 24px; }
.form label.color-inline { flex-direction: row; align-items: center; gap: 10px; }
.form label.color-inline input { width: 56px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 5px; }
.image-field { display: flex; gap: 5px; }
.image-field button { flex-shrink: 0; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.actions.left { justify-content: flex-start; margin: 0 0 10px; }
.actions.left input { width: auto; }
.actions.sticky { position: sticky; bottom: -16px; background: var(--panel); padding: 10px 0; justify-content: space-between; }

.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.char-card { display: flex; align-items: center; gap: 8px; text-align: left; padding: 6px; }
.char-card .avatar { --size: 36px; }
.char-card span { display: flex; flex-direction: column; min-width: 0; }
.char-card b { font-family: var(--font-heading); color: var(--char); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-card small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-view { display: flex; gap: 16px; }
.char-view h2 { color: var(--char); font-size: 1.5em; }
.char-view .bio { margin-top: 8px; }
.char-edit-top { display: flex; gap: 12px; align-items: flex-start; }
.char-edit-top .grow { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Предметы и рюкзак ---------- */

.money-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 10px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 4px; background: color-mix(in srgb, var(--bg) 50%, transparent); }
.money b { font-size: 1.15em; color: var(--accent); }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.inv-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 3px; text-align: center; }
.inv-name { font-size: 0.78em; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-icon {
  --rarity: var(--rarity-common);
  position: relative;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  border: 1px solid var(--rarity);
  border-radius: 4px;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--rarity) 22%, transparent), color-mix(in srgb, var(--bg) 80%, transparent) 70%);
  font-family: var(--font-heading);
  font-size: 1.4em;
  color: var(--rarity);
}
.item-icon img { width: 88%; height: 88%; object-fit: contain; }
.item-icon .qty {
  position: absolute;
  right: -6px;
  bottom: -6px;
  min-width: 20px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-body);
  font-size: 0.5em;
  line-height: 18px;
}
.item-icon.big { width: 120px; height: 120px; font-size: 2.6em; }
.rarity-common { --rarity: var(--rarity-common); }
.rarity-uncommon { --rarity: var(--rarity-uncommon); }
.rarity-rare { --rarity: var(--rarity-rare); }
.rarity-unique { --rarity: var(--rarity-unique); }
.rarity-text { color: var(--rarity); font-weight: 600; }
.item-view { display: flex; gap: 16px; margin-bottom: 6px; }
.item-view h2 { font-size: 1.4em; }
.item-note { padding: 4px 8px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.give-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 5px; max-height: 300px; overflow-y: auto; }
.give-item { flex-direction: row !important; align-items: center; gap: 8px !important; padding: 5px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; color: var(--text) !important; }
.give-item:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.give-item .item-icon { width: 38px; height: 38px; font-size: 1em; }
.give-item span { display: flex; flex-direction: column; }

.list { display: flex; flex-direction: column; gap: 4px; }
.list-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 5px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.list-row input { flex: 1; min-width: 150px; font-size: 0.8em; padding: 3px 7px; }
.list-row code { font-size: 1em; color: var(--accent); }
.list-row button { padding: 2px 8px; font-size: 0.82em; }
.list-row.blocked b { text-decoration: line-through; color: var(--muted); }
.log { display: flex; flex-direction: column; font-size: 0.88em; }
.log-row { display: grid; grid-template-columns: 140px 1fr auto; gap: 10px; padding: 4px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.log-row time { color: var(--muted); font-size: 0.85em; }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 6px; }
.toast { background: var(--panel); border: 1px solid var(--accent); border-radius: 4px; padding: 6px 14px; font-size: 0.92em; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }

/* ==========================================================================
   Стиль «Современный»: наши дни. Ситуационный центр и лента новостей —
   аккуратные карточки, сводки с отметкой «в эфире», сообщения как в мессенджере.
   ========================================================================== */

body[data-skin="modern"] { --radius: 8px; }

/* Фон по умолчанию: мягкое свечение и еле заметная сетка, как на экранах штаба */
[data-skin="modern"] #backdrop {
  background-image:
    radial-gradient(ellipse 80% 60% at 70% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    linear-gradient(color-mix(in srgb, var(--text) 3%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--text) 3%, transparent) 1px, transparent 1px);
  background-size: auto, 40px 40px, 40px 40px;
}

[data-skin="modern"] h1, [data-skin="modern"] h2, [data-skin="modern"] h3 { letter-spacing: -0.01em; font-weight: 800; }
[data-skin="modern"] .world-head h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
[data-skin="modern"] .world-head h1::before {
  content: '';
  flex: 0 0 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}
[data-skin="modern"] .world-head p { font-style: normal; }
[data-skin="modern"] button { border-radius: 6px; }
[data-skin="modern"] button.primary { box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 35%, transparent); }
[data-skin="modern"] input, [data-skin="modern"] select, [data-skin="modern"] textarea { border-radius: 6px; }
[data-skin="modern"] .scene-item { border-left: none; border-radius: 6px; }
[data-skin="modern"] .scene-item.active { background: color-mix(in srgb, var(--accent) 18%, transparent); }
[data-skin="modern"] .scene-head, [data-skin="modern"] .view-head { backdrop-filter: blur(10px); }

/* Экран входа */
[data-skin="modern"] .auth-card { border-radius: 14px; }
[data-skin="modern"] .auth-emblem {
  display: block;
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background:
    radial-gradient(circle, transparent 54%, var(--accent) 55% 58%, transparent 59%),
    linear-gradient(var(--accent), var(--accent)) center / 2px 100% no-repeat,
    linear-gradient(var(--accent), var(--accent)) center / 100% 2px no-repeat;
  opacity: 0.9;
}
[data-skin="modern"] .auth-card h1 { color: var(--text); }

/* Посты: аватары-кружки, как в мессенджерах */
[data-skin="modern"] .post { border-radius: 6px; margin-right: 8px; }

/* Сводка — как новостная плашка с отметкой «в эфире» */
[data-skin="modern"] .post.narration {
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
[data-skin="modern"] .narr-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  letter-spacing: 0.1em;
}
[data-skin="modern"] .narr-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: live 1.6s ease-in-out infinite;
}
@keyframes live { 50% { opacity: 0.25; } }
[data-skin="modern"] .post.narration .post-body { font-style: normal; }

/* Сообщение — пузырь мессенджера */
[data-skin="modern"] .letter-paper {
  position: relative;
  max-width: 480px;
  padding: 10px 14px 12px;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  font-size: 0.95em;
}
[data-skin="modern"] .letter-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78em;
  font-weight: 700;
  opacity: 0.75;
}
[data-skin="modern"] .letter-head::before { content: '✉'; }
[data-skin="modern"] .letter-sign { display: none; }
[data-skin="modern"] .post.letter > time::after { content: ' ✓✓'; color: var(--accent); }

/* Лично — зашифрованный канал */
[data-skin="modern"] .post.whisper {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, color-mix(in srgb, var(--panel) 70%, #000));
}
[data-skin="modern"] .whisper-to::after { content: ' · зашифровано'; color: var(--muted); }

[data-skin="modern"] .modal { border-radius: 12px; overflow: hidden; }
[data-skin="modern"] .announce { border-bottom-width: 2px; }
[data-skin="modern"] .tag { border-radius: 4px; }

/* ---------- Узкие экраны: панели выезжают сбоку ---------- */

.side-toggle, .ooc-toggle, .mobile-bar, .panel-shade { display: none; }
/* Только для телефона: «⋯» в шапке, список видов сообщения, «Aa», значки вместо подписей на кнопках */
.scene-more, .types-select, .fmt-toggle, .m-ico { display: none; }

@media (max-width: 1100px) {
  .shell, .shell:not([data-view="scene"]) { grid-template-columns: 220px minmax(0, 1fr); }
  .ooc {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 20;
    width: min(320px, 88vw);
    background: var(--panel);
    transform: translateX(100%);
    transition: transform 0.2s;
  }
  body.show-ooc .ooc { transform: none; }
  .ooc-toggle { display: inline-block; }
  body.show-ooc .panel-shade, body.show-sidebar .panel-shade { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, 0.5); }
  .lore { grid-template-columns: 210px minmax(0, 1fr); }
}

@media (max-width: 800px) {
  .shell, .shell:not([data-view="scene"]) { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 20;
    width: min(280px, 85vw);
    background: var(--panel);
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  body.show-sidebar .sidebar { transform: none; }
  .side-toggle, .mobile-bar { display: inline-block; }
  .mobile-bar { padding: 8px; }
  /* Шапка канала — одна тонкая строка: ☰, название, ⋯, OOC. Остальное — в меню «⋯». */
  .scene-head, .scene-head.has-bg { min-height: 0; align-items: center; padding: 3px 6px; background-image: none; }
  .scene-head .crumbs, .scene-head .scene-desc, .scene-head .desc-toggle, .scene-head .head-tool { display: none; }
  .scene-titles h2 { font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .scene-head.has-bg h2 { text-shadow: none; }
  .scene-more { display: inline-block; }
  .scene-menu { margin-top: 12px; }
  .post { padding: 5px 10px; gap: 9px; }
  .person-grid { grid-template-columns: minmax(0, 1fr); }
  .tier-move { opacity: 1; }
  .avatar { --size: 34px; }
  .post.letter, .post.system, .post.roll-only { padding-left: 10px; }
  .post.narration { margin: 8px 10px; }
  /* Поле ввода — две строки: [персонаж 🎒 вид Aa] и [текст 🤖 ➤]. Оформление — по «Aa». */
  .composer { margin: 0 4px 4px; padding: 4px 6px; }
  .composer-bar { flex-wrap: nowrap; align-items: center; gap: 4px; margin-bottom: 2px; }
  .composer-bar .as { flex: 1; }
  .composer-bar .as select { flex: 1; min-width: 0; max-width: none; }
  .composer-bar .types { display: none; }
  .types-select { display: block; flex: none; width: auto; max-width: 112px; padding: 2px 4px; font-size: 0.88em; }
  .fmt-toggle { display: inline-block; flex: none; font-weight: 700; }
  .composer.show-fmt .fmt-toggle { color: var(--accent); }
  .composer .fmt-bar { display: none; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .composer.show-fmt .fmt-bar { display: flex; }
  .fmt-bar button { flex-shrink: 0; }
  .composer-main { display: flex; align-items: flex-end; gap: 4px; }
  .composer textarea { flex: 1; min-height: 71px; resize: none; }
  /* Значки квадратом 2×2 (у игрока — столбиком), чтобы полю текста досталась почти вся ширина */
  .composer-foot { display: grid; flex: none; grid-template-rows: repeat(2, 34px); grid-auto-flow: column; gap: 3px; }
  .composer-foot [hidden] { display: none; }
  .composer-foot small, .composer-foot .d-lbl { display: none; }
  .composer-foot .m-ico { display: inline; }
  .composer .composer-foot button { min-width: 34px; height: 34px; margin-left: 0; padding: 0 7px; font-size: 1em; }
  .char-view, .item-view { flex-direction: column; }
  .lore { grid-template-columns: minmax(0, 1fr); }
  .lore.has-page .lore-list { display: none; }
  .lore.has-page .lore-back { display: inline-block; }
  .lore:not(.has-page) .lore-page { display: none; }
  .log-row { grid-template-columns: 1fr; gap: 0; }
  .view-scroll { padding: 10px; }
  .view-head input, .view-head select { flex: 1; }
  .map-panel { top: auto; left: 10px; width: auto; max-height: 55%; }
  .ru-view .view-head { flex-wrap: wrap; }
  #ru-jump, #ru-mode { max-width: none; }
  .map-legend { display: none; }
}

/* ==========================================================================
   «Штаб ИИ» — страница мастера с черновиками хода (public/js/ai.js)
   ========================================================================== */

.ai-view .view-scroll { display: flex; flex-direction: column; gap: 14px; max-width: 980px; }
.ai-card { background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.ai-card h3 { margin: 0 0 6px; font-size: 1.05em; }
.ai-card h3 small { font-weight: normal; font-size: 0.8em; }
.ai-card textarea { width: 100%; }
.ai-draft { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.ai-draft.error { border-color: var(--danger); }
.ai-sec { margin: 10px 0; padding: 8px 10px; border-left: 3px solid var(--border); background: color-mix(in srgb, var(--bg) 40%, transparent); }
.ai-sec.publish { border-left-color: var(--accent); }
.ai-sec.secret { border-left-color: var(--muted); }
.ai-sec summary { cursor: pointer; }
.ai-sec-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ai-sec-head label { display: flex; align-items: center; gap: 6px; font-size: 0.85em; color: var(--muted); }
.ai-sec-head select { width: auto; max-width: 260px; padding: 2px 6px; }
.ai-map-row { display: grid; grid-template-columns: auto 200px 1fr; gap: 6px; align-items: center; margin: 4px 0; }
.ai-chron { margin: 8px 0; }
.ai-old { margin: 6px 0; }
.ai-old summary { cursor: pointer; color: var(--muted); }
.ai-wait { display: flex; align-items: center; gap: 10px; }
.warn { color: #e0a526; margin: 4px 0; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.composer-foot .ai-npc-btn { padding: 3px 10px; font-size: 0.85em; }
.composer-foot .ai-npc-btn + .primary, .composer-foot .ai-npc-btn + .ai-npc-btn { margin-left: 0; }

@media (max-width: 700px) {
  .ai-map-row { grid-template-columns: auto 1fr; }
  .ai-map-row input { grid-column: 1 / -1; }
}

/* Заблокированные поля (например, страна и должность, назначенные мастером) */
.form input:disabled, .form select:disabled { opacity: 0.55; cursor: not-allowed; }

/* Шапка сцены: [сцена]ИРАК | МЕСТО · ВРЕМЯ · ДАТА[/сцена] */
.scene-header { margin: 2px 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.scene-header .sh-title { font-family: var(--font-heading); font-weight: 800; font-size: 1.15em; letter-spacing: 0.04em; text-transform: uppercase; }
.scene-header .sh-sub { margin-top: 2px; font-family: var(--font-heading); font-weight: 600; font-size: 0.82em; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }

/* Бот в каналах: «Штаб ИИ» */
.game-clock { margin: 4px 0 0; font-size: 0.78em; color: var(--muted); letter-spacing: 0.03em; }
.game-clock:empty { display: none; }
.bot-mark { font-size: 0.75em; margin-left: 4px; opacity: 0.8; }
.ai-bot.on { border-color: color-mix(in srgb, #3fb950 55%, var(--border)); }
.ai-bot.off { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.ai-bot-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ai-bot-head h3 { margin: 0; }
.ai-clock { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.ai-clock input { width: 110px; padding: 3px 7px; }
.ai-clock input:nth-of-type(2), .ai-clock input:nth-of-type(3) { width: 70px; }
.ai-clock small { flex-basis: 100%; }
.ai-log { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; font-size: 0.86em; }
.ai-log-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.ai-log-row time { color: var(--muted); font-size: 0.85em; white-space: nowrap; }
.ai-log-row button { padding: 1px 8px; font-size: 0.85em; }
.ai-log-row.undone .grow { text-decoration: line-through; color: var(--muted); }
.ai-log-row.kind-error .grow, .ai-log-row.kind-notice .grow { color: #e0a526; }
.ai-mem { margin: 6px 0; }
.ai-mem summary { cursor: pointer; }
.ai-mem textarea { margin-top: 6px; font-size: 0.9em; }
.ai-test { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: color-mix(in srgb, var(--bg) 50%, transparent); line-height: 1.6; }

/* NPC, которого ведёт только мастер (бот за него не пишет) */
.gm-lock { font-size: 0.8em; opacity: 0.85; }

/* Кнопка «🤖 Боту» в поле ввода: нажата — пост уйдёт боту как обращение */
.composer-foot .to-bot { padding: 3px 10px; font-size: 0.85em; }
.composer-foot .to-bot.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.composer-foot .to-bot + .ai-npc-btn, .composer-foot .to-bot + .primary { margin-left: 0; }
.to-bot-mark { margin-left: 6px; font-size: 0.75em; color: var(--muted); }
