/* ═══════════════════════════════════════════════════════════════════════════
   RubiStories · «Рубин в золе» · БАЗА
   Ресет, типографика, кнопки, поля, селекты, чипы, панели, меню, окна,
   скроллбары, фокус, орнамент, утилиты. Правит только арт-директор.
   Страничный CSS строится на этих классах и не переопределяет их глобально:
   нужен другой вид - селектор ограничен корнем своей страницы.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── ресет ──────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--light-candle), var(--light-moon), var(--ash-0);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss03", "calt";   /* Inter: однозарядная a, округлые знаки */
}
body.is-play { overflow: hidden; }

::selection { background: rgba(242, 104, 42, .38); color: #fff4e4; }
textarea, input { caret-color: var(--ember-hi); }
input[type="number"], input[type="checkbox"], input[type="radio"] { accent-color: var(--ember); }
a { color: var(--ember-hi); text-underline-offset: 3px; text-decoration-color: var(--ember-line); }
a:hover { text-decoration-color: var(--ember-hi); }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: var(--s-4) 0; }

:focus-visible {
  outline: 2px solid var(--ember-hi);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* полосы прокрутки в палитре */
* { scrollbar-width: thin; scrollbar-color: var(--ash-5) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ash-5); border-radius: 10px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--line-hi); background-clip: content-box; border: 3px solid transparent; }

/* ── типографика ────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5 { font-weight: 500; text-wrap: balance; }
h1, h2, h3, .display {
  font-family: var(--display); color: var(--bone);
  line-height: var(--lh-tight); letter-spacing: -.005em;
  font-variation-settings: "wdth" 100;
}
.display-xl { font-family: var(--display); font-size: var(--fs-4xl); line-height: .95; letter-spacing: -.02em; color: var(--bone); font-weight: 400; }
.display-lg { font-family: var(--display); font-size: var(--fs-3xl); line-height: 1; letter-spacing: -.012em; color: var(--bone); font-weight: 400; }
.display-md { font-family: var(--display); font-size: var(--fs-2xl); line-height: 1.05; color: var(--bone); font-weight: 500; }
.display-sm { font-family: var(--display); font-size: var(--fs-xl); line-height: 1.12; color: var(--bone); font-weight: 500; }
.display em, h1 em, h2 em, h3 em { font-style: italic; font-weight: 400; }

/* метка: моно, заглавные, широкий трекинг. Разделы, подписи полей, мета. */
.eyebrow {
  font-family: var(--mono); font-size: var(--fs-2xs); font-weight: 500;
  letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--brass);
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num  { font-variant-numeric: tabular-nums; }
.prose { font-family: var(--serif); font-size: var(--fs-lg); line-height: var(--lh-prose); color: var(--prose); text-wrap: pretty; }
/* буквица для первого абзаца вступлений и сводок */
.dropcap::first-letter {
  float: left; font-family: var(--display); font-weight: 400; color: var(--ember-hi);
  font-size: 3.4em; line-height: .82; padding: .06em .12em 0 0;
}

/* ── утилиты ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.spacer { flex: 1; }
.small { font-size: var(--fs-xs); }
.muted { color: var(--text-dim); }
.dim { color: var(--text-far); }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
.strong { font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.row input { flex: 1; min-width: 160px; }
.row select { width: auto; }
.empty { font-size: var(--fs-sm); color: var(--text-far); font-style: italic; padding: 2px 0 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── иконки ─────────────────────────────────────────────────────────────── */
.ico {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -.2em;
}
.ico.chev { width: 1em; height: 1em; transition: transform var(--dur-2) var(--ease); }

/* ── орнамент ───────────────────────────────────────────────────────────── */
/* линейка с ромбом: <div class="orn"><i></i></div> */
.orn { display: flex; align-items: center; gap: 12px; color: var(--brass); }
.orn::before, .orn::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass-line) 40%, var(--brass-line));
}
.orn::after { transform: scaleX(-1); }
.orn > i { flex: none; width: 7px; height: 7px; transform: rotate(45deg); background: var(--brass); box-shadow: 0 0 10px var(--brass-line); }
.orn.ember { color: var(--ember); }
.orn.ember::before, .orn.ember::after { background: linear-gradient(90deg, transparent, var(--ember-line) 40%, var(--ember-line)); }
.orn.ember > i { background: var(--ember); box-shadow: 0 0 12px var(--ember-glow); }
/* простая волосяная линия с затуханием по краям */
.hairline { height: 1px; border: 0; background: linear-gradient(90deg, transparent, var(--brass-line), transparent); margin: var(--s-4) 0; }

/* рамка с угловыми скобами: добавь .frame родителю с position (задаётся здесь) */
.frame { position: relative; }
.frame::before {
  --fc: var(--brass-line); --fl: 14px;
  content: ""; position: absolute; inset: 7px; pointer-events: none; z-index: 1;
  background:
    linear-gradient(var(--fc), var(--fc)) top left / var(--fl) 1px no-repeat,
    linear-gradient(var(--fc), var(--fc)) top left / 1px var(--fl) no-repeat,
    linear-gradient(var(--fc), var(--fc)) top right / var(--fl) 1px no-repeat,
    linear-gradient(var(--fc), var(--fc)) top right / 1px var(--fl) no-repeat,
    linear-gradient(var(--fc), var(--fc)) bottom left / var(--fl) 1px no-repeat,
    linear-gradient(var(--fc), var(--fc)) bottom left / 1px var(--fl) no-repeat,
    linear-gradient(var(--fc), var(--fc)) bottom right / var(--fl) 1px no-repeat,
    linear-gradient(var(--fc), var(--fc)) bottom right / 1px var(--fl) no-repeat;
}
.frame.ember::before { --fc: var(--ember-line); }

/* ── поля ───────────────────────────────────────────────────────────────── */
textarea, input, select {
  width: 100%; background: var(--ash-0); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 13px; font-family: inherit; font-size: var(--fs-md);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .5) inset;
  resize: vertical;
  transition: border-color var(--dur-1), box-shadow var(--dur-2), background var(--dur-1);
}
input[type="checkbox"], input[type="radio"] { width: auto; box-shadow: none; }
textarea::placeholder, input::placeholder { color: var(--text-far); }
textarea:hover, input:hover, select:hover { border-color: var(--line-hi); }
textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--ember-lo); background: var(--ash-1);
  box-shadow: 0 0 0 3px rgba(242, 104, 42, .16), 0 1px 0 rgba(0, 0, 0, .5) inset;
}
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%23b3a995' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
label { color: var(--text-dim); }

/* ── кнопки ─────────────────────────────────────────────────────────────── */
button {
  font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  border-radius: var(--r-sm); padding: 8px 15px;
  border: 1px solid var(--line); background: var(--ash-3); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--sh-inset);
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1),
              transform var(--dur-2) var(--ease-snap), box-shadow var(--dur-2);
}
button:hover { border-color: var(--line-hi); background: var(--ash-4); }
button:active { transform: translateY(1px) scale(.99); box-shadow: var(--sh-press); }
button:disabled { opacity: .45; cursor: default; transform: none; }

/* главное действие: раскалённый уголь */
button.primary {
  position: relative; color: var(--ember-ink); font-weight: 650; letter-spacing: .005em;
  background: linear-gradient(180deg, #ff9a58 0%, var(--ember) 52%, #d4521c 100%);
  border-color: #ffae78;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .45) inset, 0 -1px 0 rgba(120, 30, 0, .45) inset, var(--sh-ember);
}
button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffab70 0%, #fa7634 52%, #dc5a22 100%);
  border-color: #ffc196;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 -1px 0 rgba(120, 30, 0, .45) inset, 0 14px 38px -8px rgba(255, 110, 40, .7);
}
button.primary:active:not(:disabled) { box-shadow: 0 2px 6px rgba(120, 30, 0, .6) inset; }
button.accent { background: var(--ember-wash); border-color: var(--ember-line); color: var(--ember-hi); }
button.accent:hover:not(:disabled) { background: rgba(242, 104, 42, .2); border-color: var(--ember-lo); }
button.ghost { background: transparent; color: var(--text-dim); border-color: transparent; box-shadow: none; }
button.ghost:hover:not(:disabled) { background: var(--ash-3); color: var(--text); border-color: var(--line-soft); }
button.danger { background: transparent; border-color: var(--ruby-lo); color: var(--ruby-hi); box-shadow: none; }
button.danger:hover:not(:disabled) { background: var(--ruby-wash); border-color: var(--ruby); }
button.big { padding: 13px 24px; font-size: var(--fs-md); border-radius: var(--r-md); white-space: nowrap; }
button.btn-xl { padding: 0 24px; height: 56px; font-size: 17px; border-radius: var(--r-md); width: 100%; }
button.mini {
  background: none; border: none; box-shadow: none; color: var(--text-dim);
  font-size: var(--fs-xs); padding: 4px 8px; border-radius: var(--r-xs);
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
}
button.mini:hover { color: var(--ember-hi); background: var(--ash-3); border: none; }
button.mini .ico { width: 1.05em; height: 1.05em; }

.icon-btn {
  width: 38px; height: 38px; padding: 0; border-radius: var(--r-pill);
  background: transparent; border-color: transparent; color: var(--text-dim); box-shadow: none;
}
.icon-btn:hover { background: var(--ash-3); color: var(--text); border-color: var(--line-soft); }
.icon-btn .ico { width: 20px; height: 20px; }
.icon-btn.glass {
  background: rgba(10, 8, 7, .55); border-color: rgba(255, 235, 200, .16);
  backdrop-filter: blur(8px); color: #f3ead8;
}
.icon-btn.glass:hover { background: rgba(10, 8, 7, .78); border-color: var(--ember-line); color: var(--ember-hi); }

.link-btn {
  background: none; border: none; box-shadow: none; padding: 2px 4px; color: var(--text-dim);
  font-size: var(--fs-xs); gap: 6px; border-radius: var(--r-xs);
}
.link-btn:hover { color: var(--ember-hi); background: none; border: none; }

kbd {
  font: 500 11px/1 var(--mono); padding: 4px 7px; border-radius: 6px;
  background: rgba(29, 11, 4, .2); border: 1px solid rgba(29, 11, 4, .32);
  color: inherit; margin-left: 6px;
}

/* ── чипы ───────────────────────────────────────────────────────────────── */
.chip {
  font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; letter-spacing: .02em;
  padding: 4px 11px; border: 1px solid var(--line-soft); border-radius: var(--r-pill);
  color: var(--text-dim); white-space: nowrap; align-self: center; background: rgba(255, 235, 200, .02);
}
.chip.offline, .chip.busy { border-color: rgba(232, 176, 74, .5); color: var(--warn); }
.chip.live { color: var(--text-dim); }
.chip.ember { border-color: var(--ember-line); color: var(--ember-hi); background: var(--ember-wash); }
.chip.verd { border-color: var(--verd-line); color: var(--verd-hi); background: var(--verd-wash); }
.chip.ruby { border-color: var(--ruby-lo); color: var(--ruby-hi); background: var(--ruby-wash); }
.badge {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: var(--r-pill); padding: 1px 9px; color: var(--text-far);
}

/* ── сегментированный переключатель (громкость и др.) ───────────────────── */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--ash-0); border: 1px solid var(--line-soft); border-radius: var(--r-pill);
}
.seg button {
  height: 32px; min-width: 34px; padding: 0 9px; gap: 0;
  border: 0; border-radius: var(--r-pill); background: none; color: var(--text-dim); box-shadow: none;
  font-size: 13px; font-weight: 500;
}
.seg button:hover { color: var(--text); background: var(--ash-3); }
.seg button span {
  max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap;
  transition: max-width var(--dur-2) var(--ease), opacity var(--dur-2), margin var(--dur-2);
}
.seg button .ico { width: 20px; height: 20px; }
.seg button[aria-checked="true"] {
  background: var(--ember-wash); color: var(--ember-hi);
  box-shadow: 0 0 0 1px var(--ember-line) inset;
}
.seg button[aria-checked="true"] span { max-width: 150px; opacity: 1; margin-left: 7px; margin-right: 3px; }

/* ── картины: контейнер с плейсхолдером ─────────────────────────────────── */
.imgbox {
  background-color: var(--ash-3);
  background-image: linear-gradient(110deg, #130f0e 30%, #241b18 46%, #130f0e 62%);
  background-size: 220% 100%;
  animation: shimmer 1.8s linear infinite;
}
.imgbox.ready {
  animation: none; background-size: cover; background-position: center; background-repeat: no-repeat;
}
.imgbox.failed { animation: none; background-image: none; }
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -90% 0; } }

/* ── панели и карточки ──────────────────────────────────────────────────── */
.panel { display: none; padding: var(--s-5); }
.panel.active { display: block; animation: panel-in var(--dur-3) var(--ease) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.pane-head { display: flex; align-items: baseline; gap: 14px; margin: 22px 0 12px; flex-wrap: wrap; }
.pane-head h2 { font-size: 30px; line-height: 1; margin: 0; font-weight: 400; }

.card {
  background: linear-gradient(180deg, var(--ash-2), var(--ash-1));
  border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 18px 20px;
  box-shadow: var(--sh-inset);
}
.card.wide { max-width: 940px; }
.card h3 { margin: 0 0 6px; font-size: 22px; font-weight: 500; }
.card p { margin: 0 0 10px; }
details.card > summary { cursor: pointer; }

/* чек-лист зацепок: общий для боковой колонки и «Курса дела» */
.leads { margin: 10px 0 2px; display: flex; flex-direction: column; gap: 6px; }
.lead { display: flex; gap: 10px; font-size: var(--fs-sm); color: var(--text-dim); align-items: flex-start; line-height: 1.45; }
.lead .box { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--line-hi); display: grid; place-items: center; }
.lead .box .ico { width: 11px; height: 11px; stroke-width: 2.2; }
.lead.done { color: var(--text-dim); }
.lead.done .box { border-color: var(--verd); color: var(--verd); background: var(--verd-wash); }

/* ── выпадающее меню: общий вид ─────────────────────────────────────────── */
.menu {
  position: absolute; z-index: var(--z-menu); min-width: 270px; padding: 6px;
  background: linear-gradient(180deg, var(--ash-3), var(--ash-2) 80px);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--sh-2), 0 0 0 1px rgba(0, 0, 0, .5);
  animation: menu-in var(--dur-2) var(--ease) both;
}
.menu.up { bottom: calc(100% + 10px); right: 0; top: auto; transform-origin: bottom right; animation-name: menu-in-up; }
.menu button {
  display: grid; grid-template-columns: 22px 1fr; column-gap: 12px; align-items: center;
  width: 100%; text-align: left; background: none; border: 0; box-shadow: none;
  padding: 10px 12px; border-radius: var(--r-sm); color: var(--text); font-size: 14px;
}
.menu button .ico { grid-row: span 2; color: var(--ember); width: 20px; height: 20px; }
.menu button small { grid-column: 2; font-size: var(--fs-xs); color: var(--text-far); font-weight: 400; }
.menu button:hover { background: var(--ash-4); }
.menu button.danger { color: var(--ruby-hi); }
.menu button.danger .ico { color: var(--ruby); }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 6px 4px; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes menu-in-up { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ── окна: завеса и модалка (оболочка; содержимое строят страницы) ──────── */
.modal-veil {
  overscroll-behavior: contain;
  position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: clamp(12px, 6vh, 56px) 16px;
  background: radial-gradient(80% 70% at 50% 40%, rgba(40, 14, 10, .55), rgba(5, 3, 3, .86));
  backdrop-filter: blur(8px); animation: veil-in var(--dur-2) ease both;
}
@keyframes veil-in { from { opacity: 0; } }
.modal {
  position: relative; width: min(900px, 100%); margin: 0 auto;
  background: linear-gradient(180deg, var(--ash-3), var(--ash-2) 180px);
  border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--sh-2);
  animation: modal-in var(--dur-3) var(--ease) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.985); } }
.modal-x { position: absolute; top: 14px; right: 14px; z-index: 3; }

/* ── меньше движения ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0s !important; transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* ── окна на узких экранах ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  .modal-veil { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; min-height: 100dvh; width: 100%; }
}
