/* ============ Ширма мастера — основа оформления ============
   Дизайн-система «Ширма мастера» (Claude Design): темы «Пергамент» (светлая) и «Таверна ночью» (тёмная).
   Роли цветов: --bg --surface --sunk --ink --muted --line --line-strong --accent --accent-soft --on-accent
   --brass --ok --danger. Тема: системная или выбранная кнопкой (html[data-theme]). */

:root {
  --bg: #f2eadb; --surface: #fbf6ec; --sunk: #e7dcc6; --ink: #2b2118; --muted: #665747;
  --line: #d3c5ab; --line-strong: #8a785f; --accent: #7e2a22; --accent-soft: #f2ddd2; --on-accent: #fff8ee;
  --brass: #7a5a1c; --ok: #2c6656; --danger: #a8381c;
  --field-bg: var(--surface);
  --shadow-1: 0 1px 0 rgba(60,40,20,.08); --shadow-2: 0 6px 18px rgba(60,40,20,.14); --shadow-3: 0 18px 48px rgba(40,25,10,.24);
  --scrim: rgba(30,20,10,.45);
  --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;

  --radius: 10px; --r-md: 6px; --r-xs: 3px;
  --display: "Alegreya SC", "Alegreya", Georgia, serif;
  --body: "Alegreya Sans", "PT Sans", system-ui, sans-serif;
  --read: "Alegreya", Georgia, serif;
  --ease: cubic-bezier(.2,.7,.3,1); --t-fast: 120ms; --t-base: 180ms;
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --tap: 44px;
}
/* «Таверна ночью»: тёплый тёмный, акцент — свет свечи. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1813; --surface: #28211a; --sunk: #15110d; --ink: #efe4d0; --muted: #b3a38b;
    --line: #43392d; --line-strong: #7e6d57; --accent: #e6a061; --accent-soft: #3e2b1b; --on-accent: #1d1813;
    --brass: #d3b274; --ok: #86c4b1; --danger: #f0806a;
    --field-bg: var(--sunk); --shadow-1: 0 1px 0 rgba(0,0,0,.4); --shadow-2: 0 8px 22px rgba(0,0,0,.5); --shadow-3: 0 22px 56px rgba(0,0,0,.6);
    --scrim: rgba(0,0,0,.6);
    --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .95 0 0 0 0 .8 0 0 0 0 .55 0 0 0 .035 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1813; --surface: #28211a; --sunk: #15110d; --ink: #efe4d0; --muted: #b3a38b;
  --line: #43392d; --line-strong: #7e6d57; --accent: #e6a061; --accent-soft: #3e2b1b; --on-accent: #1d1813;
  --brass: #d3b274; --ok: #86c4b1; --danger: #f0806a;
  --field-bg: var(--sunk); --shadow-1: 0 1px 0 rgba(0,0,0,.4); --shadow-2: 0 8px 22px rgba(0,0,0,.5); --shadow-3: 0 22px 56px rgba(0,0,0,.6);
  --scrim: rgba(0,0,0,.6);
  --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .95 0 0 0 0 .8 0 0 0 0 .55 0 0 0 .035 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: dark;
}
@media (prefers-reduced-motion: reduce) { :root { --t-fast: 0ms; --t-base: 0ms; } *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background-color: var(--bg); background-image: var(--paper); color: var(--ink);
  font: 400 17px/26px var(--body); -webkit-font-smoothing: antialiased; padding: 0 16px;
}
.wrap { max-width: 1200px; margin: 0 auto; padding-block: 16px 64px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 500; line-height: 1.17; letter-spacing: .005em; text-wrap: balance; margin: 0; color: var(--ink); }
h1 { font-size: clamp(28px, 5vw, 36px); }
h2 { font-size: 26px; line-height: 32px; }
h3 { font-size: 20px; line-height: 26px; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--ring); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums lining-nums; }
/* Надзаголовок капителью цветом латуни */
.eyebrow, .over { font: 700 13px/18px var(--display); letter-spacing: .12em; color: var(--brass); }
.hint, .small { font-size: 14px; line-height: 20px; }
.hint { color: var(--muted); }
.err { color: var(--danger); font-weight: 700; font-size: 15px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Иконки и орнаменты (рисует js/kit.js) ---------- */
.ico { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -.25em; flex: none; }
[data-i] { display: inline-flex; line-height: 0; }
[data-orn] { display: inline-block; line-height: 0; }
[data-orn] > svg { width: 100%; height: 100%; }
.orn { display: block; color: var(--brass); }
.orn-logo { color: var(--accent); }
.orn-logo .logo-body { fill: var(--accent-soft); }
.orn-seal .seal-wax { fill: var(--accent); }
.divider { display: flex; justify-content: center; color: var(--brass); margin: 24px 0; }
.divider > [data-orn] { display: block; width: min(240px, 70%); height: 16px; }
.flourish { display: flex; justify-content: center; color: var(--brass); }
.flourish > [data-orn] { width: 72px; height: 16px; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- Кнопки ---------- */
.btn {
  --b: var(--line-strong); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 0 18px; border-radius: var(--r-md); border: 1px solid var(--b); background: var(--surface); color: var(--ink);
  font: 500 16px/1.1 var(--body); text-decoration: none; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-1);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-fast);
}
.btn:hover { background: var(--sunk); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:focus-visible { box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary, .btn-primary { --b: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.primary:hover, .btn-primary:hover { background: var(--accent); filter: brightness(1.12) saturate(1.05); }
.btn.primary:active, .btn-primary:active { filter: brightness(.92); }
.btn.ghost, .btn-ghost { --b: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover, .btn-ghost:hover { background: var(--accent-soft); }
.btn.danger, .btn-danger { --b: var(--danger); background: var(--surface); color: var(--danger); }
.btn.danger:hover, .btn-danger:hover, .btn.danger.armed { background: var(--danger); color: var(--surface); }
.btn.small, .btn-sm { min-height: 32px; padding: 0 12px; font-size: 14px; gap: 6px; }
.btn.big, .btn-lg { min-height: 52px; padding: 0 26px; font-size: 18px; }
.btn-icon { width: var(--tap); padding: 0; }
.btn-sm.btn-icon, .btn.small.btn-icon { width: 32px; }
.btn-block { width: 100%; }
a.btn { color: var(--ink); }
a.btn.primary, a.btn-primary { color: var(--on-accent); }
a.btn.danger { color: var(--danger); }
/* Маленькая квадратная кнопка-значок (стрелки, крестики) */
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); font-weight: 700; line-height: 1; padding: 0; transition: background var(--t-fast); }
.icon-btn:hover { background: var(--sunk); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; font: inherit; cursor: pointer; }

/* ---------- Поля ---------- */
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], textarea, select {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--field-bg); color: var(--ink); font: 400 17px/22px var(--body); transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input[type="number"] {
  min-height: 36px; padding: 6px 10px; width: 80px; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--field-bg); color: var(--ink); font: 500 16px/20px var(--body); font-variant-numeric: tabular-nums;
}
select { width: auto; max-width: 100%; appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887760' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
textarea { min-height: 96px; resize: vertical; line-height: 24px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input:hover, textarea:hover, select:hover { border-color: var(--ink); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent) inset; }
input:disabled, textarea:disabled, select:disabled { background: var(--sunk); color: var(--muted); border-style: dashed; cursor: not-allowed; }
input[type="range"] { accent-color: var(--accent); }

/* Чекбокс — квадрат с галочкой; переключатель — .switch */
input[type="checkbox"] { appearance: none; flex: none; width: 22px; height: 22px; margin: 0; border: 1.5px solid var(--line-strong); border-radius: var(--r-xs);
  background: var(--surface); display: inline-grid; place-content: center; cursor: pointer; vertical-align: middle; transition: background var(--t-fast), border-color var(--t-fast); }
input[type="checkbox"]::after { content: ""; width: 12px; height: 7px; border: 2px solid var(--on-accent); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after { opacity: 1; }
input[type="checkbox"]:hover { border-color: var(--ink); }
input[type="checkbox"]:focus-visible { box-shadow: var(--ring); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); cursor: pointer; }
.switch input[type="checkbox"] { width: 46px; height: 28px; border-radius: 999px; background: var(--sunk); position: relative; display: block; }
.switch input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border: 0; border-radius: 50%; background: var(--muted); transform: none; opacity: 1; transition: transform var(--t-fast) var(--ease), background var(--t-fast); }
.switch input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.switch input[type="checkbox"]:checked::after { transform: translateX(18px); background: var(--on-accent); }
.switch .sw-text { display: grid; gap: 2px; }
.switch .sw-text .hint { font-size: 13px; line-height: 18px; }

.field, .fld { display: flex; flex-direction: column; gap: 6px; }
.field label, .fld > label, .fld > .lbl, .label { font: 500 15px/20px var(--body); color: var(--ink); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.fld > label small, .fld > .lbl small, .field .hint { font-weight: 400; color: var(--muted); font-size: 14px; line-height: 20px; }
.fld textarea { min-height: 70px; }

/* ---------- Сегменты, чипы, метки ---------- */
.seg { display: inline-flex; flex-wrap: wrap; padding: 3px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--sunk); gap: 2px; }
.seg button { min-height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--muted); font: 500 15px/1 var(--body);
  display: inline-flex; align-items: center; gap: 6px; transition: background var(--t-fast), color var(--t-fast); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 0 rgba(60,40,20,.12), 0 0 0 1px var(--line); }
.seg button[aria-pressed="true"].is-live { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 500 14px/1 var(--body); transition: background var(--t-fast); }
.chips button:hover { background: var(--sunk); }
.chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
/* Неинтерактивная метка: «главное: СИЛ», навык от прошлого */
.chip, .tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-xs); border: 1px solid currentColor;
  font: 700 12px/16px var(--body); letter-spacing: .04em; color: var(--brass); white-space: nowrap; background: transparent; }
.chip.plus, .tag-accent { color: var(--accent); }
.tag-ok { color: var(--ok); } .tag-danger { color: var(--danger); } .tag-muted { color: var(--muted); }
/* Бейдж статуса: латунная рамка «Подготовка», сургучная печать «Идёт игра» */
.seal-badge { display: inline-flex; align-items: center; gap: 8px; padding: 0 14px 0 4px; height: 32px; border-radius: 999px; background: var(--accent);
  color: var(--on-accent); font: 700 14px/1 var(--display); letter-spacing: .06em; white-space: nowrap; }
.seal-badge [data-orn] { width: 26px; height: 26px; }
.seal-badge .orn-seal .seal-wax { fill: var(--on-accent); opacity: .18; }
.seal-badge.is-prep { background: transparent; color: var(--brass); border: 1px solid var(--brass); padding-left: 12px; }
.saved { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ok); }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { position: relative; min-height: var(--tap); padding: 0 14px; border: 0; background: transparent; color: var(--muted); font: 500 16px/1 var(--body);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; transition: color var(--t-fast); }
.tabs a::after, .tabs button::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: transparent; transition: background var(--t-fast); }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a:hover::after, .tabs button:hover::after { background: var(--line-strong); }
.tabs [aria-selected="true"] { color: var(--ink); font-weight: 700; }
.tabs [aria-selected="true"]::after { background: var(--accent); left: 6px; right: 6px; }
.tabs a:focus-visible, .tabs button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 4px; }
.tabs .count { font-size: 12px; color: var(--brass); font-weight: 700; }

/* ---------- Карточки, раскрывающиеся блоки ---------- */
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card-sm { padding: 16px; }
.card-link { cursor: pointer; transition: border-color var(--t-fast), transform var(--t-fast); box-shadow: var(--shadow-1); }
.card-link:hover { border-color: var(--line-strong); }
/* Рамка с латунными уголками — одна на экран: текущая глава, лист героя */
.frame-corners { border-color: var(--line-strong); }
.frame-corners::before { content: ""; position: absolute; inset: 5px; border: 1px solid var(--line); border-radius: 6px; pointer-events: none; }
.corner { position: absolute; width: 28px; height: 28px; color: var(--brass); pointer-events: none; line-height: 0; z-index: 1; }
.corner svg { width: 100%; height: 100%; }
.corner-tl { top: -3px; left: -3px; } .corner-tr { top: -3px; right: -3px; transform: scaleX(-1); }
.corner-bl { bottom: -3px; left: -3px; transform: scaleY(-1); } .corner-br { bottom: -3px; right: -3px; transform: scale(-1, -1); }
.disc { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.disc + .disc { margin-top: 8px; }
.disc > summary { list-style: none; display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 10px 14px; cursor: pointer; border-radius: 8px; }
.disc > summary::-webkit-details-marker { display: none; }
.disc > summary:hover { background: var(--sunk); }
.disc[open] > summary { border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.disc-body { padding: 14px 16px 16px; }

/* ---------- Пустое состояние, окно, уведомление ---------- */
.empty { text-align: center; padding: 32px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 10px; background: transparent; }
.empty b, .empty h3 { color: var(--ink); font: 500 20px/26px var(--display); }
.empty .big { width: 48px; height: 48px; color: var(--brass); }
.empty .big .ico { width: 100%; height: 100%; }
.gate { max-width: 520px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: grid; gap: 12px; }
.toast {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; align-items: center; gap: 10px;
  width: min(380px, calc(100vw - 32px)); padding: 12px 16px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-2); font-weight: 500; animation: toast-in var(--t-base) var(--ease);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 600px) { .toast { left: 16px; right: 16px; width: auto; } body.has-hp .toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); } }

/* ---------- Хиты ---------- */
.hpbar { --hp: 100%; --c: var(--ok); position: relative; display: block; height: 8px; border-radius: var(--r-xs); background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.hpbar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--hp); background: var(--c); border-radius: var(--r-xs); transition: width var(--t-base) var(--ease); }
.hpbar[data-state="low"] { --c: var(--brass); }
.hpbar[data-state="crit"] { --c: var(--danger); }
.hpbar[data-state="down"] { background: repeating-linear-gradient(135deg, var(--sunk) 0 4px, var(--line) 4px 6px); }
.hpbar[data-state="down"]::before { display: none; }
.st-full { color: var(--ok); } .st-low { color: var(--brass); } .st-crit { color: var(--danger); } .st-down { color: var(--muted); }

/* ---------- Портрет: круг с картинкой или буквой на штриховке ---------- */
.avatar { --s: 48px; width: var(--s); height: var(--s); border-radius: 999px; flex: none; display: grid; place-items: center; background: var(--sunk); color: var(--ink);
  font: 500 calc(var(--s) * .42)/1 var(--display); border: 1.5px solid var(--line-strong); position: relative; overflow: hidden; }
.avatar > img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.avatar:not(:has(img))::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(122,90,28,.12) 5px 6px); }
.avatar.is-down { filter: grayscale(1); opacity: .55; }
.avatar-lg { --s: 96px; border-width: 2px; }

/* ---------- Текст «зачитать вслух» с буквицей ---------- */
.read-aloud { position: relative; padding: 18px 22px 20px; background: var(--sunk); border-radius: var(--radius); border: 1px solid var(--line); }
.read-aloud > .over { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.read, .read p { font: italic 400 21px/32px var(--read); color: var(--ink); }
.read p + p { margin-top: 12px; }
.read > p:first-child::first-letter, .read.dropcap::first-letter {
  float: left; font: 500 64px/54px var(--display); font-style: normal; color: var(--accent); margin: 4px 10px 0 0; padding: 2px 8px 6px;
  border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface);
}
@media (max-width: 600px) { .read, .read p { font-size: 19px; line-height: 29px; } }

/* ---------- Шапка страниц сайта ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; flex-wrap: wrap; }
.brand { font: 500 22px/1 var(--display); color: var(--ink); text-decoration: none; display: inline-flex; gap: 10px; align-items: center; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.user-slot { display: flex; gap: 12px; align-items: center; font-size: 15px; }
.user-chip { font-weight: 700; color: var(--ink); text-decoration: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: var(--r-md); background: transparent; color: var(--muted); padding: 0; }
.theme-btn:hover { background: var(--sunk); color: var(--ink); }
.theme-btn .ico { width: 20px; height: 20px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin: 4px 0 12px; color: var(--muted); text-decoration: none; font-size: 15px; }
.back-link:hover { color: var(--ink); }

/* ---------- Вход ---------- */
.auth-card { max-width: 440px; margin: 6vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow-1); }
.auth-card h2 { font-size: 26px; }
.auth-providers { display: grid; gap: 8px; }
.auth-providers .btn { justify-content: center; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-form { display: grid; gap: 12px; }
.auth-form .fld span { font-weight: 500; font-size: 15px; }
.auth-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.auth-guest { display: grid; gap: 8px; }
.auth-guest .btn { justify-content: center; }
.claim { background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.claim summary { cursor: pointer; }
.claim-body { display: grid; gap: 12px; margin-top: 12px; max-width: 420px; }

/* ---------- Мои столы ---------- */
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 6px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow-1); transition: border-color var(--t-fast); }
.table-card:hover { border-color: var(--line-strong); }
.table-card .nm { font: 500 21px/1.15 var(--display); overflow-wrap: anywhere; }
.table-card .meta { font-size: 14px; color: var(--muted); }
.new-table { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.new-table .fld { flex: 1 1 240px; }
.new-table label.check { display: flex; gap: 8px; align-items: center; font-size: 15px; min-height: var(--tap); }
.section { display: grid; gap: 14px; margin-top: 32px; }

/* ---------- Согласие на метрику ---------- */
.consent { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 40; max-width: 640px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-2);
  padding: 12px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 15px; }
.consent div { display: flex; gap: 8px; }
.sheet-acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Окно «Предложить идею» ---------- */
.fb-dialog { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow-3); }
.fb-dialog::backdrop { background: var(--scrim); }
.fb-form { display: grid; gap: 12px; padding: 28px; }
.fb-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.fb-state:empty { display: none; }

/* Заголовок страницы с действиями справа */
.room-top { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin: 8px 0 18px; }
.room-top .eyebrow { display: block; margin-bottom: 4px; }
@media (max-width: 480px) {
  .topbar { flex-wrap: nowrap; }
  .brand { font-size: 18px; gap: 8px; min-width: 0; }
  .brand-mark { width: 30px; height: 30px; }
  .user-slot { gap: 6px; }
  .user-chip { max-width: 110px; font-size: 14px; }
}
