/* ═════════ Тема «Инструмент»: плотная, нейтральная; светлая и тёмная ═════════ */
/* Цвета — только токенами: тёмная тема переопределяет их ниже. Пары текст/фон — не ниже 4.5:1 (WCAG AA). */

:root {
  --bg: #f3f3f0;
  --panel: #ffffff;
  --panel2: #f6f6f3;
  --ink: #17171a;
  --muted: #4f4f57;
  --faint: #6b6b73;
  --line: #e1e1dc;
  --line2: #d2d2cc;
  --accent: #2b50c4;
  --accent-ink: #ffffff;
  --soft: #e9eefb;
  --good: #1c7349;
  --good-soft: #e3f2ea;
  --bad: #b3362b;
  --bad-soft: #f8e6e3;
  --warn: #8a5300;
  --warn-soft: #fbf0dc;
  --warn-bar: #c27d0e;
  --secret: #6b3fa0;
  --secret-soft: #f0e9f8;
  --gold: #a87508;
  --gold-soft: #fff4d6;
  --gold-fill: #f3d27a;
  --temp-a: #7aa0e8;
  --temp-b: #a9c0ef;
  --pop: #17171a;
  --pop-ink: #f3f3f0;
  --pop-muted: #b9b9c2;
  --pop-line: #2c2c33;
  --crit: #7ee0a5;
  --fumble: #ff8f84;
  --toast-bad: #b3362b;
  --toast-good: #1c7349;
  --toast-warn: #6b4300;
  --backdrop: rgba(23, 23, 26, .32);
  --knob: #ffffff;
  --code-sel: rgba(43, 80, 196, .22);
  --c-com: #6b6b73;
  --c-str: #1c7349;
  --c-num: #a1520f;
  --c-kw: #2b50c4;
  --c-op: #5a5a62;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --radius: 10px;
  --radius-s: 6px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 14px rgba(20, 20, 30, .05);
  --shadow-l: 0 2px 6px rgba(20, 20, 30, .08), 0 16px 40px rgba(20, 20, 30, .14);
  --ease: cubic-bezier(.2, .7, .2, 1);
  /* Высота шапки: от неё отсчитываются липкие панели. */
  --top: 48px;
  color-scheme: light;
}

/* Тёмная: по системе (если не выбрана светлая явно) или по выбору в меню учётки.
   Для игры вечером за столом — не слепит. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141417; --panel: #1c1c21; --panel2: #24242a; --ink: #ececef; --muted: #a9a9b3; --faint: #8f8f99;
    --line: #2c2c33; --line2: #3a3a42; --accent: #8aa4ff; --accent-ink: #0d1530; --soft: #222b47;
    --good: #5fcf93; --good-soft: #173323; --bad: #ff8a7d; --bad-soft: #3b1f1c; --warn: #e8b04a; --warn-soft: #352a12;
    --warn-bar: #d9962a; --secret: #c7a2f5; --secret-soft: #2c2242; --gold: #e8b04a; --gold-soft: #352a12; --gold-fill: #b98a22;
    --temp-a: #4f6fc4; --temp-b: #3a5296; --pop: #2a2a31; --pop-ink: #ececef; --pop-muted: #a9a9b3; --pop-line: #3a3a42;
    --backdrop: rgba(0, 0, 0, .55); --knob: #ececef; --code-sel: rgba(138, 164, 255, .3);
    --c-com: #8f8f99; --c-str: #5fcf93; --c-num: #f0a35e; --c-kw: #8aa4ff; --c-op: #a9a9b3;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .25);
    --shadow-l: 0 2px 6px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141417; --panel: #1c1c21; --panel2: #24242a; --ink: #ececef; --muted: #a9a9b3; --faint: #8f8f99;
  --line: #2c2c33; --line2: #3a3a42; --accent: #8aa4ff; --accent-ink: #0d1530; --soft: #222b47;
  --good: #5fcf93; --good-soft: #173323; --bad: #ff8a7d; --bad-soft: #3b1f1c; --warn: #e8b04a; --warn-soft: #352a12;
  --warn-bar: #d9962a; --secret: #c7a2f5; --secret-soft: #2c2242; --gold: #e8b04a; --gold-soft: #352a12; --gold-fill: #b98a22;
  --temp-a: #4f6fc4; --temp-b: #3a5296; --pop: #2a2a31; --pop-ink: #ececef; --pop-muted: #a9a9b3; --pop-line: #3a3a42;
  --backdrop: rgba(0, 0, 0, .55); --knob: #ececef; --code-sel: rgba(138, 164, 255, .3);
  --c-com: #8f8f99; --c-str: #5fcf93; --c-num: #f0a35e; --c-kw: #8aa4ff; --c-op: #a9a9b3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-l: 0 2px 6px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--ink); }
ul, ol { margin: 0; padding: 0; list-style: none; }
code, kbd, .mono { font-family: var(--mono); font-size: .93em; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.hidden { display: none !important; }

/* Длинный текст — в одну строку с многоточием; полностью — во всплывающей подсказке (title). */
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

::selection { background: var(--soft); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Только для читалок экрана. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* «К содержимому» — первая остановка Tab, видна только в фокусе. */
.skip { position: fixed; left: 8px; top: -60px; z-index: 200; padding: 8px 12px; border-radius: var(--radius-s); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.skip:focus-visible { top: 8px; color: var(--accent-ink); }
main:focus { outline: none; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes flash { 0% { box-shadow: 0 0 0 2px var(--accent); } 100% { box-shadow: 0 0 0 2px transparent; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes tumble {
  0% { transform: rotate(-30deg) scale(.6); opacity: 0; }
  60% { transform: rotate(12deg) scale(1.08); opacity: 1; }
  100% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Отступы (атрибут style запрещён CSP — только классы) */
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.pad { padding: 24px; }
.w-narrow { max-width: 560px; }

/* ═════════ Шрифты: IBM Plex (SIL Open Font License 1.1), свои — без сторонних запросов ═════════ */

@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/a/plex-mono-400-cyrillic.23f08a9ad3.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/a/plex-mono-400-latin.1afad13b8f.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/a/plex-mono-500-cyrillic.505ce113a2.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/a/plex-mono-500-latin.e627b3db6d.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/a/plex-mono-600-cyrillic.649e341c77.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/a/plex-mono-600-latin.48f9df33ad.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/a/plex-sans-cyrillic.f4dec13210.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/a/plex-sans-latin.9966e9b92d.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ═════════ Элементы управления ═════════ */

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 1px solid var(--line2); border-radius: var(--radius-s);
  background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap;
  font-size: 13px; font-weight: 500; line-height: 1;
  transition: border-color .12s, background-color .12s, color .12s, transform .08s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; border-color: var(--line2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel2); border-color: var(--line); }
.btn.on { border-color: var(--accent); background: var(--soft); color: var(--accent); }
.btn.s { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.xs { height: 20px; padding: 0 6px; font-size: 11px; border-radius: 5px; }
.btn.icon { width: 30px; padding: 0; }
.btn.s.icon { width: 24px; }
.btn.xs.icon { width: 20px; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn.s svg { width: 13px; height: 13px; }

/* Сегментированный переключатель */
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--radius-s); overflow: hidden; background: var(--panel); flex: none; }
.seg button { border: 0; background: transparent; padding: 0 10px; height: 28px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--ink); background: var(--panel2); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seg.s button { height: 22px; padding: 0 8px; font-size: 11px; }
.seg.secret button.on { background: var(--secret); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span, .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  height: 32px; padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--radius-s);
  background: var(--panel); outline: none; min-width: 0; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--soft); }
.input.s { height: 26px; padding: 0 8px; font-size: 13px; }
.input.num { font-family: var(--mono); text-align: right; }
.input.bad { border-color: var(--bad); }
select.input { padding-right: 26px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: none; cursor: pointer; }

/* Переключатель-тумблер */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 30px; height: 18px; border-radius: 9px; background: var(--line2); position: relative; transition: background-color .15s; flex: none; }
.switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(12px); }

/* Метки */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; border: 1px solid var(--line2); font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; background: var(--panel); flex: none; }
.tag.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--soft); }
.tag.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: var(--good-soft); }
.tag.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.tag.secret { color: var(--secret); border-color: color-mix(in srgb, var(--secret) 40%, transparent); background: var(--secret-soft); }
.tag button:not(.val) { border: 0; background: none; padding: 0; margin-right: -3px; cursor: pointer; color: inherit; opacity: .6; font-size: 13px; line-height: 1; }
.tag button:not(.val):hover { opacity: 1; }

/* Кнопка-бросок: значение, по клику — бросок */
.roll {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border: 1px solid var(--line2); border-radius: var(--radius-s); background: var(--panel);
  font: 500 12px/1 var(--mono); color: var(--ink); cursor: pointer; white-space: nowrap; flex: none;
  transition: border-color .12s, color .12s, background-color .12s, transform .08s;
}
.roll:hover { border-color: var(--accent); color: var(--accent); background: var(--soft); }
.roll:active { transform: translateY(1px); }
.roll .lbl { font-family: var(--font); color: var(--muted); font-weight: 500; }
.roll:hover .lbl { color: inherit; }
.roll.adv::after, .roll.dis::after { font: 600 9px/1 var(--font); padding: 2px 3px; border-radius: 3px; margin-left: 1px; }
.roll.adv::after { content: 'П'; background: var(--good-soft); color: var(--good); }
.roll.dis::after { content: 'М'; background: var(--bad-soft); color: var(--bad); }
.roll.both::after { content: 'П/М'; background: var(--panel2); color: var(--muted); }
.roll.big { height: 30px; font-size: 14px; padding: 0 10px; }
.roll:disabled { cursor: default; opacity: .6; }

/* Значение с происхождением: по клику — откуда оно */
.val { cursor: help; border: 0; border-bottom: 1px dotted transparent; background: none; padding: 0; margin: 0; text-align: inherit; line-height: inherit; transition: border-color .12s, color .12s; }
.val:hover { border-bottom-color: var(--faint); }

/* Шарики ресурса */
.pips { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.pip { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--accent); background: var(--accent); flex: none; transition: background-color .15s, transform .15s; }
.pip.off { background: transparent; border-color: var(--line2); }
.pips.s .pip { width: 9px; height: 9px; border-width: 1.2px; }

/* Полоска */
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; transition: width .35s var(--ease); }
.bar > i.good { background: var(--good); }
.bar > i.warn { background: var(--warn-bar); }
.bar > i.bad { background: var(--bad); }
.bar > b { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, var(--temp-a), var(--temp-a) 3px, var(--temp-b) 3px, var(--temp-b) 6px); border-radius: 3px; }

.kbd { display: inline-block; padding: 0 4px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; font: 500 11px/16px var(--mono); color: var(--muted); }

.spinner { width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.on-accent { width: 14px; height: 14px; border-color: color-mix(in srgb, var(--accent-ink) 35%, transparent); border-top-color: var(--accent-ink); }
.btn.primary[aria-busy="true"] { opacity: .85; }

.empty { color: var(--faint); font-size: 13px; padding: 6px 0; }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* Иконки: по умолчанию 16 px, в мелких кнопках и меню — меньше */
svg.ic { width: 16px; height: 16px; flex: none; }
.pop-menu button svg.ic { width: 15px; height: 15px; color: var(--muted); }
.pop-menu button.danger svg.ic { color: var(--bad); }
.btn.xs svg.ic, .tag svg.ic { width: 12px; height: 12px; }

/* ═════════ Шапка, карточки, всплывающие слои ═════════ */

#top {
  position: sticky; top: 0; z-index: 20; height: var(--top);
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#top:empty { display: none; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--ink); letter-spacing: -.01em; }
.logo img { width: 28px; height: 28px; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 6px 10px; border-radius: var(--radius-s); color: var(--muted); font-weight: 500; font-size: 13px; }
.nav a:hover { color: var(--ink); background: var(--panel2); }
.nav a.on { color: var(--accent); background: var(--soft); }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 13px; }
.crumbs b { color: var(--ink); font-weight: 600; }

main { padding: 18px 20px 160px; max-width: 1760px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-height: 32px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.card-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; min-height: 40px; }
.card-h h2 { font-size: 13px; font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-b { padding: 2px 12px 12px; }
.card-b.flush { padding: 0 0 6px; }

/* ── Всплывающее окно (popover в верхнем слое: не уходит под карточки) ── */
#pop {
  margin: 0; inset: auto; position: fixed; padding: 0; border: 0; background: transparent;
  overflow: visible; max-width: min(420px, calc(100vw - 16px));
}
#pop:popover-open { animation: rise .14s var(--ease); }
.pop {
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius);
  box-shadow: var(--shadow-l); padding: 12px; min-width: 220px; max-height: min(70vh, 560px); overflow: auto;
}
.pop.dark { background: var(--pop); color: var(--pop-ink); border-color: var(--pop-line); }
.pop.dark .muted, .pop.dark .faint { color: var(--pop-muted); }
.pop h3 { font-size: 14px; margin-bottom: 2px; }
.pop .big { font: 600 26px/1.1 var(--mono); }
.pop-menu { padding: 4px; min-width: 180px; }
.pop-menu .menu-h { padding: 8px 10px 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pop-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; font-size: 13px; }
.pop-menu button:hover { background: var(--panel2); }
.pop-menu button.danger { color: var(--bad); }
.pop-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* Слои значения: откуда оно */
.layers { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.layer { display: grid; grid-template-columns: 34px 54px 1fr; gap: 6px; align-items: baseline; padding: 4px 0; border-top: 1px solid var(--line); font-size: 12px; }
.layer:first-child { border-top: 0; }
.layer .op { font: 600 11px var(--mono); color: var(--muted); }
.layer .v { font: 500 12px var(--mono); text-align: right; }
.layer .src { min-width: 0; color: var(--ink); }
.layer .src i { font-style: normal; color: var(--faint); }
.layer.over { opacity: .5; }
.layer.over .v { text-decoration: line-through; }
.formula { margin-top: 6px; padding: 6px 8px; background: var(--panel2); border-radius: 6px; font: 12px/1.4 var(--mono); color: var(--muted); word-break: break-word; }

/* ── Диалоги (модальные, верхний слой) ── */
dialog.dlg {
  padding: 0; border: 1px solid var(--line2); border-radius: 14px; background: var(--panel); color: var(--ink);
  box-shadow: var(--shadow-l); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.dlg:not([open]) { display: none; }
dialog.dlg.wide { width: min(860px, calc(100vw - 32px)); }
dialog.dlg.xwide { width: min(1180px, calc(100vw - 32px)); }
dialog.dlg[open] { animation: rise .18s var(--ease); }
dialog.dlg::backdrop { background: var(--backdrop); animation: fade .18s; }
.dlg-h { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 10px; }
.dlg-h h2 { font-size: 16px; flex: 1; min-width: 0; }
.dlg-h .sub { font-size: 12px; color: var(--muted); margin-top: 3px; font-weight: 400; }
.dlg-b { padding: 4px 18px 16px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.dlg-f { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel2); }
.dlg-f .grow { font-size: 12px; color: var(--muted); }

/* ── Уведомления ── */
#toasts { position: fixed; inset: auto auto 20px 50%; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; align-items: center; }
.toast { pointer-events: auto; padding: 9px 14px; border-radius: 8px; background: var(--pop); color: var(--pop-ink); box-shadow: var(--shadow-l); font-size: 13px; max-width: min(560px, calc(100vw - 24px)); animation: rise .18s var(--ease); display: flex; gap: 10px; align-items: center; }
.toast.bad { background: var(--toast-bad); color: #fff; }
.toast.good { background: var(--toast-good); color: #fff; }
.toast.warn { background: var(--toast-warn); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.toast-act { border: 0; background: none; color: inherit; font: 600 13px var(--font); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px 2px; }
.toast-x { border: 0; background: none; color: inherit; opacity: .75; cursor: pointer; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border-radius: 4px; }
.toast-x:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.toast .grow { min-width: 0; }
.loading { padding: 40px 0; }
#app.busy { pointer-events: none; opacity: .55; transition: opacity .15s .1s; }

/* ── Подсказка при наведении: раскладка значения ── */
#tip { margin: 0; inset: auto; position: fixed; padding: 0; border: 0; background: transparent; overflow: visible; pointer-events: none; max-width: min(340px, calc(100vw - 16px)); }
#tip:popover-open { animation: fade .1s; }
.tip { background: var(--pop); color: var(--pop-ink); border-radius: 8px; box-shadow: var(--shadow-l); padding: 8px 10px; font-size: 12px; min-width: 200px; }
.tip .faint, .tip .muted { color: var(--pop-muted); }
.tip-h { display: flex; gap: 10px; align-items: baseline; font-weight: 600; margin-bottom: 4px; }
.tip-h .num { font-size: 14px; }
.tip .part { border-top-color: var(--pop-line); }
.tip .part .src { color: var(--pop-ink); }
.tip .part .src i, .tip .part .op { color: var(--pop-muted); }

/* Раскладка «из чего»: знак, вклад, источник */
.parts { display: flex; flex-direction: column; margin-top: 2px; }
.part { display: grid; grid-template-columns: 14px minmax(44px, max-content) minmax(0, 1fr); gap: 6px; align-items: baseline; padding: 3px 0; border-top: 1px solid var(--line); font-size: 12px; }
.part:first-child { border-top: 0; }
.part .op { font: 600 11px var(--mono); color: var(--muted); }
.part .v { font: 500 12px var(--mono); text-align: right; }
.part .src { min-width: 0; }
.part .src i { font-style: normal; color: var(--faint); }

/* Лоток: «втихую» у мастера — своим цветом */
.btn.secret-on { border-color: var(--secret); color: var(--secret); background: var(--secret-soft); }

/* Быстрый поиск по листу */
.pal-btn { color: var(--muted); min-width: 0; }
.pal-btn .kbd { margin-left: 4px; }
.pal-list { display: flex; flex-direction: column; max-height: min(60vh, 520px); overflow: auto; }
.pal-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; min-width: 0; }
.pal-list li.on { background: var(--soft); box-shadow: inset 3px 0 0 var(--accent); }
.pal-list li:hover:not(.on) { background: var(--panel2); }
.pal-list .tag { width: 96px; justify-content: center; }

/* Логотип: тёмные линии на светлой теме, светлые — на тёмной (без серого ореола исходника) */
.logo .logo-d { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo .logo-l { display: none; }
  :root:not([data-theme="light"]) .logo .logo-d { display: inline; }
}
:root[data-theme="dark"] .logo .logo-l { display: none; }
:root[data-theme="dark"] .logo .logo-d { display: inline; }
/* Подсказка броска: откуда Преимущество и Помеха */
.tip-adv { margin-top: 6px; font-size: 12px; font-weight: 500; }
.tip-adv.adv { color: var(--good); }
.tip-adv.dis { color: var(--bad); }
.tip .tip-adv.adv { color: var(--pop-good, #7fd69a); }
.tip .tip-adv.dis { color: var(--pop-bad, #f29a9a); }
.part .src .faint { font-size: 11px; }
.part .src .deps { display: block; }

/* ═════════ Вход и главная ═════════ */

.auth { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.auth-card { width: 400px; padding: 28px; }
.logo.big { font-size: 22px; gap: 10px; }
.logo.big img { width: 56px; height: 56px; }

.home { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tile { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 0; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile-main { display: flex; align-items: center; gap: 12px; padding: 8px 4px 8px 12px; flex: 1; min-width: 0; color: var(--ink); }
.tile-main:hover { color: var(--ink); }
.crest { width: 40px; height: 40px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; }
.crest.s { width: 30px; height: 30px; font-size: 14px; border-radius: 7px; }
.empty-big { grid-column: 1 / -1; }
.camp { padding: 14px; }

/* ═════════ Лист ═════════ */

.sheet { display: flex; flex-direction: column; gap: 12px; }

.vitals { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(250px, 1fr) auto minmax(360px, 1.4fr) auto; gap: 18px; align-items: center; padding: 14px 16px; position: sticky; top: calc(var(--top) + 8px); z-index: 10; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who .crest { width: 48px; height: 48px; font-size: 22px; border-radius: 11px; }
.who h1 { font-size: 20px; }
.xp-b { margin-top: 4px; margin-left: -6px; color: var(--muted); }
.xp-b.ready { color: var(--accent); font-weight: 600; }
.stat-l { font-size: 11px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.hp { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hp-n { display: flex; align-items: baseline; gap: 4px; }
.hp-n .big { font-size: 24px; font-weight: 600; }
.hp .bar { height: 7px; }
.hp-b { margin-top: 2px; }
.hp.down .hp-n .big { color: var(--bad); }
.death { display: flex; flex-direction: column; gap: 4px; padding: 6px 10px; border: 1px dashed var(--bad); border-radius: 8px; background: var(--bad-soft); }
.pip.good-pip { border-color: var(--good); background: var(--good); }
.pip.bad-pip { border-color: var(--bad); background: var(--bad); }
.pip.off.good-pip, .pip.off.bad-pip { background: transparent; border-color: var(--line2); }
.stats { display: flex; gap: 6px; justify-content: space-between; min-width: 0; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 6px; min-width: 58px; }
.stat-v { display: flex; align-items: baseline; min-height: 30px; align-items: center; }
.unit { margin-left: .3em; }
.stat .big { font-size: 20px; font-weight: 600; }
.vit-act { display: grid; grid-template-columns: auto auto; gap: 6px; align-items: center; }

.insp { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line2); background: var(--panel); color: var(--faint); cursor: pointer; display: grid; place-items: center; transition: all .15s; }
.insp svg { width: 16px; height: 16px; }
.insp.on { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.insp:not([data-act]) { cursor: default; }
svg.gold { width: 16px; height: 16px; color: var(--gold); fill: var(--gold-fill); }

.banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); font-size: 13px; animation: rise .2s var(--ease); }
.banner svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.warn svg { color: var(--warn); }
.banner.accent { background: var(--soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.banner.accent svg { color: var(--accent); }

.palette { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px dashed var(--accent); border-radius: var(--radius); background: var(--soft); animation: rise .2s var(--ease); }
.palette-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 24px; }
.palette-add .tag { cursor: grab; height: 24px; }

.grid { display: grid; gap: 12px; align-items: start; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.column { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 40px; }
.editing .column { min-height: 120px; border-radius: var(--radius); outline: 1px dashed transparent; transition: outline-color .15s; }
.editing .column:hover { outline-color: var(--line2); }
.drop-empty { border: 1px dashed var(--line2); border-radius: var(--radius); padding: 28px 10px; text-align: center; color: var(--faint); font-size: 12px; }
.drop-line { height: 4px; border-radius: 2px; background: var(--accent); margin: -8px 0; box-shadow: 0 0 0 3px var(--soft); }
.wcard { animation: rise .2s var(--ease); }
.editing .wcard .card-h { cursor: grab; background: var(--panel2); border-radius: var(--radius) var(--radius) 0 0; }
.editing .wcard.collapsed .card-h { border-radius: var(--radius); }
.wcard.dragging { opacity: .35; }
.wcard.collapsed .card-h { padding-bottom: 10px; }
.grip { color: var(--faint); display: flex; }
.grip svg { width: 14px; height: 14px; }
.chev { border: 0; background: none; padding: 0; width: 18px; height: 18px; display: grid; place-items: center; color: var(--faint); cursor: pointer; flex: none; }
.chev svg { width: 14px; height: 14px; transition: transform .15s; }
.chev.open svg { transform: rotate(90deg); }
.chev:hover { color: var(--ink); }

.link { border: 0; background: none; padding: 0; color: var(--ink); cursor: pointer; text-align: left; font: inherit; }
.link:hover { color: var(--accent); }

/* Характеристики */
.abils { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid.c2 .abils, .grid.c3 .abils:only-child { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.abil { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); min-width: 0; }
.abil-n { font-size: 12px; color: var(--muted); font-weight: 500; max-width: 100%; }
.abil-mod.roll { height: 34px; font-size: 18px; padding: 0 12px; }
.abil-s { font: 500 13px var(--mono); color: var(--muted); }
.abil-save { display: flex; align-items: center; gap: 4px; }
.pd { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line2); flex: none; }
.pd.p1 { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.pd.p2 { border-color: var(--accent); background: var(--accent); }
.pd.p3 { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 2px var(--soft), 0 0 0 3px var(--accent); }

/* Навыки */
.skills { display: flex; flex-direction: column; }
.skill { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-top: 1px solid var(--line); min-width: 0; }
.skill:first-child { border-top: 0; }
.skill .ab { font-size: 11px; width: 26px; text-align: right; flex: none; }

/* Атаки */
.atks { display: flex; flex-direction: column; }
.atk { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; padding: 5px 0; border-top: 1px solid var(--line); min-width: 0; }
.atk:first-child { border-top: 0; padding-top: 2px; }
.atk-n { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; flex: 1 0 auto; }
.atk-n .link { font-weight: 500; }
.atk-r { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.slot-sel { height: 24px; border: 1px solid var(--line2); border-radius: 6px; background: var(--panel); font-size: 11px; padding: 0 4px; cursor: pointer; }
.roll.rolling { animation: pulse .5s ease-in-out infinite; }

/* Заклинания */
.casters { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.caster { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.conc { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--soft); color: var(--accent); font-size: 12px; margin-bottom: 8px; }
.conc svg { width: 14px; height: 14px; flex: none; }
.slots { display: flex; flex-direction: column; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.sp-group { margin-top: 6px; }
.sp-h { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 4px 0; }
.sp { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 5px 0; min-width: 0; border-top: 1px solid var(--line); }
.sp-l { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; flex: 1 0 auto; }
.sp-r, .atk .atk-r { margin-left: auto; justify-content: flex-end; }
.sp-t { max-width: 90px; flex: none; }
.mk { font: 600 9px/1 var(--font); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 3px; padding: 2px 3px; flex: none; }

/* Ресурсы */
.ress { display: flex; flex-direction: column; }
.res { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); min-width: 0; }
.res:first-child { border-top: 0; }
.res-b { display: flex; gap: 3px; flex: none; }

/* Особенности */
.feat-g + .feat-g { margin-top: 6px; }
.feat-h { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: var(--panel2); border-radius: 7px; padding: 6px 8px; cursor: pointer; text-align: left; min-width: 0; }
.feat-h:hover { background: var(--soft); }
.feat-l { padding: 2px 0 2px 8px; }
.feat { padding: 5px 0 5px 0; border-bottom: 1px solid var(--line); }
.feat:last-child { border-bottom: 0; }
.feat.d1 { padding-left: 12px; } .feat.d2 { padding-left: 24px; } .feat.d3 { padding-left: 36px; }
.feat .link { font-weight: 500; font-size: 13px; }
.feat-t { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* Действия */
.acts { display: flex; flex-direction: column; }
.act-row { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px 8px; padding: 4px 0; border-top: 1px solid var(--line); min-width: 0; }
.act-row > .link { flex: 1 1 8em; }
.feat > .spread { flex-wrap: wrap; justify-content: flex-end; }
.feat > .spread > .link { flex: 1 1 8em; }
.act-row:first-child { border-top: 0; }
details.basic { margin-top: 8px; }
details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
details summary:hover { color: var(--ink); }

/* Снаряжение */
.inv-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.money { border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 5px 9px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.money:hover { border-color: var(--accent); }
.money:not([data-act]) { cursor: default; }
.inv-w { display: flex; flex-direction: column; gap: 3px; }
.items { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-top: 1px solid var(--line); min-width: 0; }
.item:first-child { border-top: 0; }
.item.eq .link { font-weight: 500; }
.eq-b { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line2); background: var(--panel); display: grid; place-items: center; padding: 0; cursor: pointer; flex: none; color: var(--accent-ink); }
.eq-b svg { width: 12px; height: 12px; }
.item.eq .eq-b { background: var(--accent); border-color: var(--accent); }
.eq-b:not([data-act]) { cursor: default; }
.w-wt { width: 26px; text-align: right; flex: none; }
.item .tag svg, .tag svg { width: 11px; height: 11px; }

/* Состояния */
.conds { display: flex; flex-direction: column; gap: 4px; }
.cond { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; min-width: 0; }
.cond.is-cond { background: var(--warn-soft); }
.cond.is-eff { background: var(--soft); }
.cond .faint { color: var(--muted); }

/* Ключ — значение */
.kv { display: grid; grid-template-columns: minmax(7em, max-content) minmax(0, 1fr); gap: 3px 12px; margin: 8px 0 0; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; overflow-wrap: anywhere; }
.kv.wide { grid-template-columns: 110px minmax(0, 1fr); }
.kv.wide dd { font-family: var(--font); text-align: left; }

.notes { display: flex; flex-direction: column; gap: 6px; }
.notes li { padding: 7px 10px; background: var(--panel2); border-radius: 8px; font-size: 13px; white-space: pre-wrap; }
.journal { display: flex; flex-direction: column; font-size: 12px; max-height: 360px; overflow: auto; }
.journal li { display: flex; gap: 8px; padding: 3px 0; border-top: 1px solid var(--line); min-width: 0; }
.journal li:first-child { border-top: 0; }
.journal .num { width: 24px; text-align: right; flex: none; }
.journal code { font-size: 11px; }

.inst-pop { max-width: 400px; }
.inst-text { font-size: 13px; margin-top: 6px; white-space: pre-wrap; }
.inst-notes { margin-top: 6px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.inst-notes li { padding-left: 10px; position: relative; }
.inst-notes li::before { content: '•'; position: absolute; left: 0; color: var(--faint); }
.hp-pop { width: 220px; }
.warn-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; font-size: 13px; max-width: 380px; }

/* Лоток костей */
#tray { position: fixed; right: 18px; bottom: 18px; z-index: 30; width: max-content; max-width: calc(100vw - 36px); align-items: flex-end; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
#tray > * { pointer-events: auto; }
.tray-bar { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.tray-res { width: 360px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--pop); color: var(--pop-ink); border-radius: 12px; box-shadow: var(--shadow-l); cursor: pointer; }
.tray-res .muted { color: var(--pop-muted); }
.tray-res.fresh { animation: rise .2s var(--ease); }
.tray-res.fresh .tray-total { animation: tumble .45s var(--ease); }
.tray-res.public { box-shadow: var(--shadow-l), inset 3px 0 0 var(--temp-a); }
.tray-res.secret { box-shadow: var(--shadow-l), inset 3px 0 0 var(--secret); }
.tray-t { font-weight: 500; }
.tray-total { font: 600 30px/1 var(--mono); min-width: 48px; text-align: right; }
.tray-total.crit, b.crit { color: var(--crit); }
.tray-total.fumble, b.fumble { color: var(--fumble); }
.feed b.crit { color: var(--good); }
.feed b.fumble { color: var(--bad); }
.feed { display: flex; flex-direction: column; gap: 2px; min-width: 300px; max-width: 380px; }
.feed li { padding: 6px 8px; border-radius: 7px; display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.feed li:nth-child(odd) { background: var(--panel2); }
.feed li b { font-family: var(--mono); font-size: 16px; }

/* ═════════ Диалог записи ═════════ */

.entry-dlg .dlg-b { display: flex; flex-direction: column; gap: 12px; }
.qs { display: flex; flex-direction: column; gap: 10px; }
.q { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: var(--panel); transition: border-color .15s; }
.q.need { border-color: color-mix(in srgb, var(--warn) 45%, transparent); box-shadow: inset 3px 0 0 var(--warn-bar); }
.q-h { display: flex; align-items: flex-start; gap: 8px; }
.q-h h3 { font-size: 14px; }
.opts { display: flex; flex-direction: column; gap: 4px; }
.opts.scroll { max-height: 300px; overflow: auto; padding-right: 4px; }
.opt { display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-align: left; cursor: pointer; transition: border-color .12s, background-color .12s; }
.opt:hover { border-color: var(--accent); }
.opt.on { border-color: var(--accent); background: var(--soft); box-shadow: 0 0 0 1px var(--accent); }
.opt.unfit { opacity: .62; }
.opt.unfit.on { opacity: 1; }
.opt .mark { color: var(--accent); font-size: 14px; line-height: 18px; width: 14px; flex: none; }
.opt-t { display: block; font-weight: 500; font-size: 13px; }
.opt-d { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.assign { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.w60, .input.w60 { width: 60px; flex: none; } .w80, .input.w80 { width: 80px; flex: none; } .w120, .input.w120 { width: 120px; flex: none; }
.w160, .input.w160 { width: 160px; flex: none; } .w200, .input.w200 { width: 200px; flex: none; }
.row > .input:not([class*=" w"]) { flex: 1 1 auto; }
details.more > summary { font-size: 13px; padding: 4px 0; }
.warns { border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); border-radius: 10px; padding: 10px 12px; }
.warns h3 { display: flex; align-items: center; gap: 6px; color: var(--warn); }
.warns h3 svg { width: 14px; height: 14px; }
.warns ul { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.notes-box { background: var(--soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
details.dsl code { display: block; margin-top: 6px; padding: 8px 10px; background: var(--panel2); border-radius: 8px; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.intro { font-size: 13px; color: var(--muted); }

/* ═════════ Стол мастера ═════════ */

.table { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.party { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.pc { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.pc.flash { animation: flash 1.4s ease-out; }
.pc.down { border-color: var(--bad); }
.pc-h { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pc-name { font-weight: 600; font-size: 15px; color: var(--ink); display: block; }
.pc-hp { display: flex; flex-direction: column; gap: 3px; }
.minis { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.mini { display: flex; flex-direction: column; gap: 2px; padding: 5px 7px; background: var(--panel2); border-radius: 7px; min-width: 0; }
.mini-v { font-size: 15px; font-weight: 600; min-height: 24px; display: flex; align-items: center; }
.pc-saves { display: flex; flex-wrap: wrap; gap: 4px; }
.pc-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; min-width: 0; }
.pc-res { display: flex; flex-wrap: wrap; gap: 4px; }
.slot-mini { display: inline-flex; align-items: center; gap: 3px; margin-right: 4px; }
.conc-mini { color: var(--accent); }
.conc-mini svg { width: 13px; height: 13px; }
.pc-f { display: flex; gap: 4px; border-top: 1px solid var(--line); padding-top: 6px; margin-top: auto; }
.side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: calc(var(--top) + 16px); max-height: calc(100vh - var(--top) - 32px); overflow: auto; padding-bottom: 80px; }
.init { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.init li { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; min-width: 0; }
.init li b { width: 26px; text-align: right; }
.init li.turn { background: var(--soft); box-shadow: inset 3px 0 0 var(--accent); }
.roll-picker { width: 400px; }
.pc-roll-list { max-height: 360px; overflow: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.prl { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px 0; border-top: 1px solid var(--line); }

/* ═════════ Мастерская ═════════ */

.ws { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.ws-side { position: sticky; top: calc(var(--top) + 16px); max-height: calc(100vh - var(--top) - 32px); overflow: auto; }
.decls { display: flex; flex-direction: column; gap: 4px; }
.decls li { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 7px; min-width: 0; }
.decls li.on { background: var(--soft); }
.decls code { font-size: 11px; }
.ws-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ws-step { padding: 16px; }
.kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.kind { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; text-align: left; min-width: 0; }
.kind:hover, .found-i:hover { border-color: var(--accent); }
.kind.on, .found-i.on { border-color: var(--accent); background: var(--soft); }
.found { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; margin-top: 8px; max-height: 260px; overflow: auto; }
.found-i { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; text-align: left; min-width: 0; }
.ws-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.span2 { grid-column: span 2; }
.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 6px 14px; margin-top: 8px; }
.member { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; padding: 3px 0; }
.m-l { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.effects { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.eff { display: grid; grid-template-columns: 1.3fr 64px 1fr 1fr 24px; gap: 6px; align-items: center; }
.eff.rollrow { grid-template-columns: 1fr 1.2fr 1fr 24px; }
.diags { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; font-size: 13px; }
.diags li { display: flex; gap: 8px; align-items: baseline; }
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.help summary { font-size: 13px; }

/* Код: подсветка поверх поля ввода */
.code-view { margin: 0; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; overflow: auto; max-height: 420px; }
.code-ed { position: relative; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel); overflow: hidden; }
.code-ed:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--soft); }
.code-ed.r16 { height: 360px; } .code-ed.r18 { height: 400px; } .code-ed.r28 { height: 620px; }
.code-hl, .code-ta { position: absolute; inset: 0; margin: 0; padding: 10px 12px; font: 13px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; overflow: auto; tab-size: 4; letter-spacing: 0; }
.code-hl { pointer-events: none; color: var(--ink); }
.code-ta { color: transparent; caret-color: var(--ink); background: transparent; border: 0; outline: none; resize: none; }
.code-ta::selection { background: var(--code-sel); color: transparent; }
.c-com { color: var(--c-com); font-style: italic; }
.c-str { color: var(--c-str); }
.c-num { color: var(--c-num); }
.c-dice { color: var(--c-num); font-weight: 600; }
.c-kw { color: var(--c-kw); font-weight: 600; }
.c-id { color: var(--ink); }
.c-op { color: var(--c-op); }
.c-bad { background: var(--bad-soft); text-decoration: underline wavy var(--bad); text-decoration-skip-ink: none; }
.q > .btn { align-self: flex-start; }
.cat-list { display: flex; flex-direction: column; max-height: 460px; overflow: auto; }
.cat-i { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-top: 1px solid var(--line); min-width: 0; }
.cat-i:first-child { border-top: 0; }
.dice-panel { width: 300px; max-width: 100%; }
.wcard .dice-panel { width: auto; }
.dice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.die-b { height: 38px; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel); cursor: pointer; font: 600 14px var(--mono); transition: border-color .12s, background-color .12s, transform .08s; }
.die-b:hover { border-color: var(--accent); background: var(--soft); color: var(--accent); }
.die-b:active { transform: translateY(1px); }
.pd-b { border: 0; background: none; padding: 3px; margin: -3px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; flex: none; }
.pd-b:hover { background: var(--soft); }
.pd-b:hover .pd { border-color: var(--accent); }
.manual { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.feat-a { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.qg { display: flex; flex-direction: column; gap: 8px; }
.qg + .qg { margin-top: 6px; }
.qg-h { padding: 2px 2px 0; }
.qg-path { font-size: 13px; font-weight: 600; color: var(--accent); }
.qg-t { font-size: 13px; color: var(--muted); margin-top: 2px; }
.other { border-top: 1px dashed var(--line2); padding-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chips .chip-add { width: auto; min-width: 120px; flex: 1 1 120px; }
.eff { grid-template-columns: 1.4fr 140px 1fr 1.3fr 24px; }
.gains { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 8px 12px; }
.gains summary { font-size: 13px; }
.gains .kv { margin-top: 6px; }
.opt-d.clamp2 { display: -webkit-box; }
.opt.on .opt-d.clamp2 { -webkit-line-clamp: 3; }
.feat-a .tag, .inst-pop .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; height: auto; min-height: 20px; white-space: normal; line-height: 1.3; padding: 2px 7px; }
.pop-menu button .faint { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Навыки по характеристикам */
.skills.grouped { gap: 8px; }
.sk-g { display: flex; flex-direction: column; }
.sk-h { display: flex; align-items: center; gap: 8px; padding: 2px 0 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line2); }
.sk-h + .skill { border-top: 0; }

/* Свой предмет в окне «Добавить предмет» */
.own { border: 1px dashed var(--accent); border-radius: 10px; padding: 10px 12px; background: var(--soft); margin: 8px 0; }
.own-grid { display: grid; grid-template-columns: minmax(0, 2fr) 100px; gap: 8px; }
.own-text { grid-column: 1 / -1; }

/* Экономия хода: что потрачено в этом ходу */
.turn { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.turn-b { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--accent); border-radius: 14px; background: var(--soft); color: var(--accent); font: 600 12px var(--font); cursor: pointer; }
.turn-b i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.turn-b.used { border-color: var(--line2); background: var(--panel2); color: var(--faint); text-decoration: line-through; }
.turn-b.used i { background: transparent; border: 1.5px solid var(--line2); }
.turn-b:not([data-act]) { cursor: default; }
.act-g + .act-g { margin-top: 8px; }
.act-h { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 2px 0 3px; border-bottom: 1px solid var(--line2); }
.act-g.spent .act-h::after { content: ' · потрачено'; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); }
.act-g.spent .act-row { opacity: .6; }
.act-h + .act-row { border-top: 0; }
.act-basic { padding: 5px 0 2px; gap: 4px; }

/* Что действует сейчас — строкой в шапке листа */
.vit-status { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); margin-top: -4px; }
.vit-status .tag { height: 24px; font-size: 12px; cursor: pointer; }

/* Атаки: мастерство, свёрнутое оружие, подзаголовок заклинаний */
.tag.mastery { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: var(--gold-soft); cursor: pointer; }
.atk-h { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 0 3px; border-bottom: 1px solid var(--line2); }
.atk-h + .atk { border-top: 0; }
details.more-w { margin-top: 6px; }
details.more-w > summary { font-size: 12px; color: var(--muted); padding: 4px 0; }

/* Заклинания: ячейки шариками, вкладки кругов, книга */
.slotbar { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.slot-l { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.slot-l > b { font: 600 12px var(--mono); color: var(--muted); }
.sp-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 4px; }
.sp-tabs button { height: 24px; padding: 0 9px; border: 1px solid var(--line2); border-radius: 12px; background: var(--panel); color: var(--muted); font: 500 12px var(--font); cursor: pointer; }
.sp-tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sp-tabs .sp-q { width: auto; flex: 1 1 120px; margin-left: auto; max-width: 200px; }
.book { display: flex; flex-wrap: wrap; gap: 4px; }

/* Шарики-кнопки: тратить и возвращать нажатием */
.act-pips button.pip { padding: 0; cursor: pointer; appearance: none; }
.act-pips button.pip:hover { transform: scale(1.2); }
.act-pips button.pip.off:hover { border-color: var(--accent); }
@media (pointer: coarse) { .act-pips button.pip { width: 20px; height: 20px; } .act-pips { gap: 6px; } }

/* Снаряжение: количество у стопок */
.qty { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.qty .num { min-width: 22px; text-align: center; }

/* Деньги */
.money-total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.money-total .big { font-size: 22px; font-weight: 600; }
.money-in .input { flex: none; }
.money-log { display: flex; flex-direction: column; font-size: 12px; }
.money-log li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; border-top: 1px solid var(--line); min-width: 0; }
.money-log li:first-child { border-top: 0; }
.money-log b { width: 12px; text-align: center; }
.res-g + .res-g { margin-top: 8px; }
.res-all { width: 20px; flex: none; }
.hd { white-space: nowrap; }

/* Мастерская: заметки к другим фичам */
.eff.aug { grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) minmax(0, 1fr) 24px; }

/* Своё состояние: строки эффектов */
.effs { display: flex; flex-direction: column; gap: 6px; }
.eff-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.eff-row > select:not(.w80):not(.w160) { flex: 1 1 200px; width: auto; }
.eff-row > input:not(.w80):not(.w160) { flex: 1 1 200px; width: auto; }
.eff-row > input.w160 { flex: 0 1 160px; }
/* Длинный список заклинаний — прокрутка внутри карточки, страница не растягивается */
.sp-list.capped { max-height: min(62vh, 640px); overflow: auto; overscroll-behavior: contain; padding-right: 4px; margin-right: -4px; }
@media (max-width: 720px) { .sp-list.capped { max-height: none; } }
.money-in { flex-wrap: wrap; }
.money-in .btn { flex: 1 1 auto; }
.tag.mastery { color: var(--warn); }
.sp-tablist { display: flex; flex-wrap: wrap; gap: 4px; }
.sp-tablist button { height: 24px; padding: 0 9px; border: 1px solid var(--line2); border-radius: 12px; background: var(--panel); color: var(--muted); font: 500 12px var(--font); cursor: pointer; }
.sp-tablist button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* Приглушённый текст внутри цветной метки — цветом метки: на её фоне серый не читается */
.tag .faint { color: inherit; }

/* Покупка значений характеристик */
.pb-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.pb-head b { font-size: 16px; }
.pb { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 16px; margin-top: 6px; }
.pb-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.pb-v { width: 28px; text-align: center; font-size: 16px; }
.pb-m { width: 26px; text-align: right; }
.notes li { display: flex; gap: 6px; align-items: flex-start; }
.notes .note-t { white-space: pre-wrap; min-width: 0; }
.notes .note-b { display: flex; gap: 2px; opacity: .55; flex: none; }
.notes li:hover .note-b, .notes li:focus-within .note-b { opacity: 1; }
.notes li.note-edit { display: block; }

/* Вариант выбора: «Полностью» раскрывает описание, не выбирая */
.opt-w { position: relative; }
.opt-w .opt { padding-bottom: 9px; }
.opt-more { position: absolute; right: 8px; bottom: 4px; border: 0; background: var(--panel); color: var(--accent); font: 500 11px var(--font); padding: 1px 4px; border-radius: 4px; cursor: pointer; }
.opt.on + .opt-more { background: var(--soft); }
.opt-more:hover { text-decoration: underline; }
.tray-crit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; background: var(--panel); border: 1px solid var(--good); border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; max-width: 420px; }
.tray-crit b { color: var(--good); }

/* Заклинания: каждое — отдельной строкой; броски под своим, с отступом и чертой слева */
.sp-h + .sp, .sp-group > .sp:first-child { border-top: 0; }
.sp-l .link { font-weight: 500; }
.sp-group + .sp-group { margin-top: 10px; }
.sp-h { position: sticky; top: 0; z-index: 1; background: var(--panel); border-bottom: 1px solid var(--line2); }
/* «Полностью» — отдельной строкой под описанием, не поверх текста */
.opt-w.long .opt { padding-bottom: 24px; }
.opt-more { bottom: 6px; }

/* Снять эффект прямо из шапки; значки «что дополняет вещь» — у оружия, заклинаний, предметов */
.link-plain { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }
.tag > button.link-plain { opacity: 1; margin-right: 0; font-size: inherit; line-height: inherit; }
.vit-status .tag > button:not(.link-plain):hover { opacity: 1; }
.augs { display: inline-flex; flex: 0 1 auto; gap: 4px; min-width: 0; overflow: hidden; }
.augs .tag.aug { flex: 0 1 auto; min-width: 0; max-width: 200px; cursor: pointer; }
.tag.aug .clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ws-grid.faded { opacity: .45; }
.kv dd.txt { font-family: var(--font); text-align: left; }

/* Мастерская: способности предмета, понятные названия правок */
.ability { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 8px; background: var(--panel); }
.ability textarea { width: 100%; }
.eff.no-when { grid-template-columns: minmax(0, 2fr) auto minmax(0, 1fr) auto; }
.decl-t b { font-weight: 600; }
.decl-t .faint { margin-left: 4px; }
.eff.give { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr) 24px; }

/* «Что даёт» в подробностях фичи */
.gives { margin: 4px 0 0; padding-left: 16px; font-size: 12px; }
.gives li { margin: 2px 0; }
.gives li.off { color: var(--muted); }

/* Подтверждение удаления: записи журнала, которые уйдут вместе с объявлением */
.uses { margin: 6px 0 0 18px; font-size: 12px; }
.uses code { font-size: 11px; overflow-wrap: anywhere; }

/* ═════════ Ширины экрана и сенсорный ввод ═════════
   Лист открывают за столом — на планшете и телефоне не реже, чем на ноутбуке.
   ≤1180 — ноутбук, ≤900 — планшет, ≤720 — телефон. */

/* Навигация по разделам листа — только на телефоне. */
.jump { display: none; }

@media (max-width: 1180px) {
  .vitals { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 12px; }
  .vitals .stats { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .vitals .vit-act { grid-column: 1 / -1; display: flex; flex-wrap: wrap; }
  .vitals .death { grid-column: 1 / -1; }
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (max-width: 900px) {
  .home { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .table { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; overflow: visible; padding-bottom: 0; }
  .ws { grid-template-columns: minmax(0, 1fr); }
  .ws-side { position: static; max-height: 240px; }
  .help-grid { grid-template-columns: minmax(0, 1fr); }
  .eff, .eff.rollrow, .eff.give, .eff.no-when, .eff.aug { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .eff > :last-child { justify-self: end; }
}

@media (max-width: 720px) {
  :root { --top: 52px; }
  #top { gap: 10px; padding: 0 12px; height: var(--top); }
  .logo-t, .acct-name { display: none; }
  .crumbs { font-size: 13px; }
  .crumbs > a, .crumbs > span:not(.tag) { display: none; }
  main { padding: 12px 12px calc(150px + env(safe-area-inset-bottom)); }
  h1 { font-size: 19px; }
  .page-head { flex-wrap: wrap; }

  /* Лист: шапка не липкая (съела бы пол-экрана), липкая — навигация по разделам. */
  .vitals { position: static; grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 12px; }
  .vitals .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .vitals .stat { min-width: 0; }
  .vitals .vit-act > .btn { flex: 1 1 auto; }
  .hp-b { flex-wrap: wrap; }
  .hp-b .btn { flex: 1 1 auto; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .editing .column { min-height: 60px; }
  .palette { flex-wrap: wrap; }
  .jump {
    display: flex; gap: 6px; overflow-x: auto; position: sticky; top: var(--top); z-index: 9;
    margin: 0 -12px; padding: 8px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(8px); scrollbar-width: none; border-bottom: 1px solid var(--line);
  }
  .jump::-webkit-scrollbar { display: none; }
  .jump button { flex: none; }
  .wcard { scroll-margin-top: calc(var(--top) + 56px); }

  /* Диалоги — листом снизу на всю ширину. */
  dialog.dlg, dialog.dlg.wide, dialog.dlg.xwide {
    width: 100%; max-width: 100%; max-height: calc(100dvh - 24px); margin: auto 0 0;
    border-radius: 16px 16px 0 0; border-bottom: 0;
  }
  .dlg-f { padding-bottom: calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .dlg-f .grow { flex-basis: 100%; }
  .dlg-f .btn { flex: 1 1 auto; }

  .auth-card { width: 100%; padding: 22px; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .party { grid-template-columns: minmax(0, 1fr); }
  .ws-grid { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .members { grid-template-columns: minmax(0, 1fr); }
  .member { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .eff, .eff.rollrow, .eff.give, .eff.no-when, .eff.aug { grid-template-columns: minmax(0, 1fr); padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
  .row > .input.w200, .row > select.w200 { width: auto; flex: 1 1 140px; }
  .cat-i { flex-wrap: wrap; }
  .cat-i > .grow { flex-basis: 100%; }
  .roll-picker, .feed { width: auto; min-width: 0; max-width: 100%; }

  /* Лоток костей — панелью внизу во всю ширину. */
  #tray { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; max-width: none; align-items: stretch; }
  .tray-bar { flex-wrap: wrap; justify-content: space-between; }
  .tray-res { width: auto; }
  .tray-bar .seg button { padding: 0 7px; }
}

/* Пальцы толще курсора: цели не меньше 24×24 (WCAG 2.5.8), основные — около 40. */
@media (pointer: coarse) {
  .btn { height: 38px; }
  .btn.s { height: 34px; }
  .btn.xs { height: 30px; padding: 0 9px; }
  .btn.icon { width: 38px; }
  .btn.s.icon { width: 34px; }
  .btn.xs.icon { width: 30px; }
  .roll { height: 34px; padding: 0 10px; }
  .roll.big { height: 38px; }
  .seg button { height: 34px; }
  .seg.s button { height: 30px; }
  .pd-b { padding: 8px; margin: -8px; }
  .eq-b { width: 26px; height: 26px; }
  .chev { width: 28px; height: 28px; }
  .pop-menu button { padding: 11px 12px; }
  .opt { padding: 10px 11px; }
  .link { min-height: 28px; }
  .tag[data-act], button.tag { min-height: 28px; }
  .die-b { height: 46px; }
  /* Шрифт полей не меньше 16px: иначе iOS увеличивает страницу при фокусе. */
  .input, select.input, textarea.input, .input.s { font-size: 16px; height: 40px; }
  textarea.input { height: auto; }
  .slot-sel { height: 32px; font-size: 14px; }
}

@media print {
  #top, #tray, .jump, .vit-act, .hp-b, .card-h .btn, .res-b, .skip { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  .vitals { position: static; }
}

/* Уведомления на телефоне — сверху: внизу лоток костей и большой палец. */
@media (max-width: 720px) {
  #toasts { inset: calc(var(--top) + 8px) 8px auto 8px; transform: none; align-items: stretch; }
}

/* Сегменты с длинными подписями (мастерская) на телефоне — во всю ширину, текст переносится. */
@media (max-width: 720px) {
  .seg:not(.s) { display: flex; width: 100%; }
  .seg:not(.s) button { flex: 1 1 0; min-width: 0; white-space: normal; height: auto; min-height: 34px; padding: 6px 8px; line-height: 1.2; }
}

