/* payka.tech — справочник мастерской. Бумага, тушь, медь и зелёная маска. */

:root {
  --paper: #f2ede2;
  --paper-2: #e8e1d1;
  --ink: #1b1c18;
  --ink-2: #4a4940;
  --muted: #6f6b5d;
  --rule: #1b1c18;
  --hair: #c9c0ab;
  --copper: #a2461a;
  --copper-2: #c7672f;
  --mask: #183f2f;
  --mask-2: #0f2c20;
  --brass: #d4b25e;
  --tin: #aeb3ae;
  --serif: "PT Serif", Georgia, "Liberation Serif", "Times New Roman", serif;
  --sans: "PT Sans", "Liberation Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "PT Mono", "Liberation Mono", "DejaVu Sans Mono", Consolas, monospace;
  --measure: 42rem;
  --wide: 62rem;
  --fig-panel: #efe8da;
  --sel-bg: #d4b25e;
  --sel-fg: #1b1c18;
  color-scheme: light;
}

/* Тёмная тема: тёмный текстолит, медь и латунь.
   Значения продублированы для системной тёмной (если человек не выбрал светлую вручную)
   и для явного выбора data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #132019;
    --paper-2: #1b271f;
    --ink: #ede4cf;
    --ink-2: #c7c1ab;
    --muted: #93967c;
    --rule: #ccb87f;
    --hair: #33433a;
    --copper: #e79556;
    --copper-2: #d98040;
    --fig-panel: #e7dec9;
    --sel-bg: #d4b25e;
    --sel-fg: #14201a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #132019;
  --paper-2: #1b271f;
  --ink: #ede4cf;
  --ink-2: #c7c1ab;
  --muted: #93967c;
  --rule: #ccb87f;
  --hair: #33433a;
  --copper: #e79556;
  --copper-2: #d98040;
  --fig-panel: #e7dec9;
  --sel-bg: #d4b25e;
  --sel-fg: #14201a;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 18px/1.62 var(--serif);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body > main, body > #app { flex: 1 0 auto; width: 100%; }
.foot { margin-top: auto; }

img, svg { max-width: 100%; height: auto; }

a { color: var(--copper); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }

::selection { background: var(--sel-bg); color: var(--sel-fg); }

/* ── Шапка ───────────────────────────────────────── */

.runhead {
  display: flex; justify-content: space-between; align-items: center; gap: .4rem 1rem; flex-wrap: wrap;
  padding: .5rem 1rem;
  background: var(--mask-2);
  color: #cfc6a8;
  font: 12px/1.3 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.rh-l, .rh-r { display: flex; align-items: center; gap: .5rem .9rem; min-width: 0; }
.runhead a { color: var(--brass); text-decoration: none; }
.rh-ctx { color: #9fb0a0; }
.rh-lock { color: #cfc6a8 !important; text-decoration: none; }
.rh-lock:hover { color: var(--brass) !important; }
.rh-lock::before {
  content: ""; display: inline-block; width: 9px; height: 8px; margin-right: .35em;
  border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 2px 2px;
  vertical-align: -1px; position: relative;
}
.rh-theme {
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: #cfc6a8; background: transparent;
  border: 1px solid rgba(207, 198, 168, .38); border-radius: 2px;
  padding: .28em .6em; cursor: pointer; white-space: nowrap;
}
.rh-theme:hover { color: var(--brass); border-color: var(--brass); }
.rh-theme:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }

.mast {
  position: relative;
  background: var(--mask);
  color: #efe6c8;
  overflow: hidden;
}
.mast { background-image: url("/assets/traces.svg"); background-size: 640px 320px; background-position: right top; }
.mast-inner {
  position: relative;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 3.2rem 1rem 2.6rem;
}
.mast h1, .mast .title {
  margin: 0;
  font: 700 clamp(3.2rem, 11vw, 7.4rem)/0.92 var(--serif);
  letter-spacing: -.02em;
  color: var(--brass);
}
.mast .title a { color: inherit; text-decoration: none; }
.mast .lede {
  max-width: 34rem;
  margin: 1.2rem 0 0;
  font-size: 1.15rem;
  color: #e9e1c4;
}
.mast.small .mast-inner { padding: 1.6rem 1rem 1.4rem; }
.mast.small .title { font-size: clamp(2rem, 6vw, 2.8rem); }

.topnav {
  border-bottom: 3px double var(--rule);
  background: var(--paper);
}
.topnav ul {
  display: flex; flex-wrap: wrap; gap: .1rem 1.4rem;
  max-width: var(--wide);
  margin: 0 auto; padding: .7rem 1rem;
  list-style: none;
  font: 15px/1.5 var(--sans);
}
.topnav a { color: var(--ink); text-decoration: none; }
.topnav a:hover { color: var(--copper); }
.topnav a[aria-current="page"] { color: var(--copper); text-decoration: underline; text-decoration-thickness: 2px; }

/* ── Лист ────────────────────────────────────────── */

.sheet {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.4rem 1rem 4rem;
}
.sheet > * { max-width: var(--measure); }
.sheet > .wide, .sheet > figure.wide, .sheet > .tbl { max-width: var(--wide); }

.kicker {
  font: 13px/1.4 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--copper);
  margin: 0 0 .4rem;
}

h1.page {
  margin: 0 0 .8rem;
  font: 700 clamp(2.3rem, 7vw, 4rem)/1.02 var(--serif);
  letter-spacing: -.015em;
}
h2 {
  margin: 3.2rem 0 .9rem;
  padding-top: .9rem;
  border-top: 2px solid var(--rule);
  font: 700 clamp(1.6rem, 4.2vw, 2.25rem)/1.12 var(--serif);
  letter-spacing: -.01em;
}
h2 .sec {
  display: block;
  margin-bottom: .3rem;
  font: 400 13px/1.2 var(--mono);
  letter-spacing: .1em;
  color: var(--copper);
}
h3 {
  margin: 2rem 0 .5rem;
  font: 700 1.28rem/1.25 var(--serif);
}
p { margin: 0 0 1rem; hyphens: auto; -webkit-hyphens: auto; }
.lead { font-size: 1.2rem; line-height: 1.55; color: var(--ink-2); }

ul.plain, ol.plain { padding-left: 1.3rem; margin: 0 0 1.2rem; }
ul.plain li, ol.plain li { margin-bottom: .45rem; }
ul.plain li::marker { color: var(--copper); }
ol.plain li::marker { font-family: var(--mono); color: var(--copper); }

strong { font-weight: 700; }
code, .m { font: .88em/1 var(--mono); }
kbd { font: .85em var(--mono); border-bottom: 2px solid var(--hair); padding: 0 .15em; }

/* Примечания на полях: на широком экране уезжают вправо */
.note {
  font: 15px/1.5 var(--sans);
  color: var(--ink-2);
  margin: 0 0 1.2rem;
  padding-left: .9rem;
  border-left: 2px solid var(--copper);
}
.note b { color: var(--copper); font-weight: 700; }
@media (min-width: 1100px) {
  .sheet { position: relative; }
  .note.side {
    float: right; clear: right;
    width: 16rem;
    margin: .2rem 0 1rem 0;
  }
}

/* Оглавление с отточием */
.toc { list-style: none; padding: 0; margin: 1.4rem 0 2rem; font-size: 1.08rem; }
.toc li { display: flex; align-items: baseline; gap: .4rem; padding: .3rem 0; }
.toc li::after { content: ""; order: 2; flex: 1; border-bottom: 1px dotted var(--muted); transform: translateY(-.3em); min-width: 1rem; }
.toc a { order: 1; color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--copper); }
.toc .n { order: 3; font: 14px var(--mono); color: var(--copper); }
.toc.big { font-size: 1.3rem; }
.toc.big li { padding: .55rem 0; border-bottom: 1px solid var(--hair); }
.toc.big li::after { display: none; }
.toc.big a { flex: 1; }
.toc.big small { display: block; font: 15px/1.4 var(--sans); color: var(--muted); }

/* ── Таблицы-реестры ────────────────────────────── */

.tbl { margin: 1.4rem 0 2rem; }
table {
  width: 100%;
  border-collapse: collapse;
  font: 15.5px/1.45 var(--sans);
}
caption {
  caption-side: top;
  text-align: left;
  font: 13px/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: .5rem;
}
thead th {
  text-align: left;
  vertical-align: bottom;
  font: 12.5px/1.25 var(--mono);
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: .5rem .6rem .45rem 0;
  border-top: 3px double var(--rule);
  border-bottom: 1.5px solid var(--rule);
}
tbody td, tbody th {
  vertical-align: top;
  text-align: left;
  padding: .6rem .6rem .6rem 0;
  border-bottom: 1px solid var(--hair);
}
tbody th { font: 700 1.02rem/1.3 var(--serif); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 1.5px solid var(--rule); }
td.num { font-family: var(--mono); font-size: 14.5px; white-space: nowrap; }
td .sub, th .sub { display: block; font: 13px/1.35 var(--mono); color: var(--muted); font-weight: 400; }
tbody tr:hover { background: rgba(212, 178, 94, .12); }

@media (max-width: 700px) {
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack, table.stack tbody, table.stack tr, table.stack td, table.stack th, table.stack caption { display: block; width: 100%; }
  table.stack tr { padding: .8rem 0; border-bottom: 1px solid var(--hair); }
  table.stack tbody tr:first-child { border-top: 3px double var(--rule); }
  table.stack tbody tr:last-child { border-bottom: 1.5px solid var(--rule); }
  table.stack td, table.stack th { border: 0; padding: .15rem 0; }
  table.stack td[data-l]::before {
    content: attr(data-l);
    display: block;
    font: 11.5px/1.3 var(--mono);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: .35rem;
  }
  table.stack td.num { white-space: normal; }
}

/* ── Иллюстрации ─────────────────────────────────── */

figure { margin: 1.8rem 0 2.2rem; }
figure svg { display: block; width: 100%; height: auto; background: var(--fig-panel); border-radius: 3px; }
figcaption {
  margin-top: .6rem;
  font: 14.5px/1.45 var(--sans);
  color: var(--ink-2);
}
figcaption b { font: 12.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--copper); margin-right: .4rem; }

/* ── Разделы-шаги ───────────────────────────────── */

.steps { counter-reset: st; list-style: none; padding: 0; margin: 0 0 1.4rem; }
.steps li { counter-increment: st; position: relative; padding-left: 2.6rem; margin-bottom: .8rem; }
.steps li::before {
  content: counter(st);
  position: absolute; left: 0; top: -.15rem;
  font: 700 1.5rem/1 var(--serif);
  color: var(--copper);
}

dl.terms { margin: 0 0 1.4rem; }
dl.terms dt { font-weight: 700; margin-top: 1rem; }
dl.terms dd { margin: .2rem 0 0; }

/* ── Инструмент подбора ─────────────────────────── */

.tool {
  max-width: var(--wide) !important;
  margin: 1.2rem 0 2.4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 2.6rem;
}
.tool fieldset { border: 0; margin: 0 0 1.3rem; padding: 0; min-width: 0; }
.tool legend {
  padding: 0; margin-bottom: .45rem;
  font: 12.5px/1.3 var(--mono);
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.tool label.opt {
  display: flex; gap: .6rem; align-items: baseline;
  padding: .32rem 0;
  border-bottom: 1px solid var(--hair);
  font: 16px/1.35 var(--sans);
  cursor: pointer;
}
.tool label.opt:hover { color: var(--copper); }
.tool label.opt small { color: var(--muted); font-size: 13.5px; }
.tool input[type="radio"], .tool input[type="checkbox"] { accent-color: var(--copper); transform: translateY(1px); flex: none; }
.tool .out { border-top: 3px double var(--rule); padding-top: .9rem; }
.tool .readout {
  font: 700 clamp(3rem, 9vw, 4.6rem)/1 var(--serif);
  letter-spacing: -.02em;
  color: var(--copper);
  margin: .2rem 0 .3rem;
}
.tool .readout small { font-size: .38em; color: var(--ink-2); font-weight: 400; letter-spacing: 0; }
.tool .rows { margin: .8rem 0 0; font: 15.5px/1.45 var(--sans); }
.tool .rows div { display: grid; grid-template-columns: 9.5rem 1fr; gap: .8rem; padding: .45rem 0; border-bottom: 1px solid var(--hair); }
.tool .rows dt { font: 12.5px/1.6 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tool .rows dd { margin: 0; }
.tool .why { font: 15px/1.5 var(--sans); color: var(--ink-2); margin-top: 1rem; }
.tool .warn { color: var(--copper); font-weight: 700; }
@media (max-width: 760px) {
  .tool { grid-template-columns: 1fr; }
  .tool .rows div { grid-template-columns: 7.2rem 1fr; }
}

/* ── Подвал ──────────────────────────────────────── */

.foot {
  border-top: 3px double var(--rule);
  font: 14px/1.5 var(--sans);
  color: var(--muted);
}
.foot-inner {
  max-width: var(--wide); margin: 0 auto; padding: 1.4rem 1rem 2.4rem;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
}
.foot a { color: var(--ink-2); }
.pager {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 3.5rem; padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font: 16px/1.4 var(--sans);
  max-width: var(--wide) !important;
}
.pager a { text-decoration: none; color: var(--ink); }
.pager a span { display: block; font: 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--copper); }
.pager a:hover { color: var(--copper); }
.pager .next { text-align: right; margin-left: auto; }

@media (max-width: 520px) {
  body { font-size: 17px; }
  .mast-inner { padding: 2.2rem 1rem 1.8rem; }
  h2 { margin-top: 2.6rem; }
  .rh-ctx { display: none; }
}

@media print {
  .runhead, .topnav, .mast .traces, .pager, .foot { display: none; }
  .mast { background: none; color: var(--ink); }
  .mast .title, .mast h1 { color: var(--ink); }
  body { background: #fff; }
}

/* ── Дефекты: рисунок слева, разбор справа ─────── */
.defect {
  max-width: var(--wide) !important;
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  gap: 0 2.2rem;
  align-items: start;
  margin-bottom: 1rem;
}
.defect figure { margin: .4rem 0 1rem; }
.defect figure svg { background: var(--fig-panel); }
.defect dl { margin: 0; }
.defect dt {
  font: 12.5px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  color: var(--copper); margin-top: .9rem;
}
.defect dt:first-child { margin-top: .2rem; }
.defect dd { margin: .25rem 0 0; }
@media (max-width: 760px) {
  .defect { grid-template-columns: 1fr; }
  .defect figure { max-width: 20rem; }
}

ol.legend { margin: .8rem 0 .4rem; padding-left: 1.6rem; font: 15px/1.45 var(--sans); color: var(--ink-2); }
ol.legend li { margin-bottom: .2rem; }
ol.legend li::marker { font-weight: 700; color: var(--copper); }
td.num.wrap { white-space: normal; min-width: 9rem; }

/* ── Мастерская: форма входа ─────────────────────── */
.mstr { max-width: 34rem; }
.mstr-tabs {
  display: flex; gap: 0; margin: 1.4rem 0 1.8rem;
  border-bottom: 2px solid var(--rule);
}
.mstr-tabs button {
  flex: 1; background: transparent; border: 0; cursor: pointer;
  padding: .7rem .4rem; margin-bottom: -2px;
  font: 700 1.02rem/1.2 var(--serif); color: var(--muted);
  border-bottom: 2px solid transparent;
}
.mstr-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--copper); }
.mstr-tabs button:hover { color: var(--ink); }

.mstr form { margin: 0; }
.mstr-pane[hidden] { display: none; }
.mstr .field { margin-bottom: 1.3rem; }
.mstr label.lbl { display: block; font: 13px/1.4 var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); margin-bottom: .35rem; }
.mstr input[type="text"], .mstr input[type="password"], .mstr input[type="email"] {
  width: 100%; box-sizing: border-box;
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--hair); border-bottom: 2px solid var(--rule); border-radius: 2px 2px 0 0;
  padding: .6rem .7rem; font: 17px/1.3 var(--mono);
}
.mstr input:focus { outline: 0; border-bottom-color: var(--copper); background: var(--paper); }
.mstr input::placeholder { color: var(--muted); opacity: .8; }
.mstr .hint { display: block; margin-top: .3rem; font: 13px/1.4 var(--sans); color: var(--muted); }
.mstr .invalid { border-bottom-color: var(--copper); }
.mstr .err { display: block; margin-top: .3rem; font: 13.5px/1.4 var(--sans); color: var(--copper); min-height: 1.1em; }

.mstr .actions { display: flex; align-items: baseline; gap: 1.2rem; margin-top: 1.6rem; flex-wrap: wrap; }
.mstr button.go {
  font: 700 1.02rem/1 var(--sans); letter-spacing: .01em;
  background: var(--copper); color: #f7f1e6;
  border: 0; border-radius: 2px; padding: .8rem 1.6rem; cursor: pointer;
}
.mstr button.go:hover { background: var(--copper-2); }
.mstr button.go:disabled { background: var(--muted); cursor: default; }
.mstr .linkbtn { background: transparent; border: 0; padding: 0; cursor: pointer; color: var(--copper); font: 15px/1.4 var(--sans); text-decoration: underline; text-underline-offset: 3px; }
.mstr .linkbtn:hover { color: var(--ink); }

.mstr .note-out { margin-top: 1.2rem; padding-left: .9rem; border-left: 2px solid var(--copper); font: 15.5px/1.5 var(--sans); color: var(--ink-2); }
.mstr .note-out[hidden] { display: none; }

.mstr-about { margin-top: 3rem; padding-top: 1.3rem; border-top: 2px solid var(--rule); font: 16px/1.55 var(--serif); color: var(--ink-2); }
.mstr-about b { color: var(--ink); font-weight: 700; }

/* ── Жала: профили в таблице (перенесено из инлайна) ── */
.tipimg { width: 200px; max-width: 100%; display: block; }
td.pic { width: 215px; }
@media (max-width: 700px) { td.pic { width: 100%; } .tipimg { width: 230px; } }

/* ── SPA: скелетон, ошибка сети, «нет раздела» ─────── */
#app { min-height: 60vh; }
.skeleton { max-width: var(--measure); }
.skeleton span {
  display: block; height: .95em; margin: .7em 0; border-radius: 3px;
  background: var(--hair); opacity: .55; animation: sk 1.2s ease-in-out infinite;
}
.skeleton .h { height: 2.4em; width: 60%; margin: .2em 0 1em; opacity: .7; }
.skeleton .s { width: 40%; opacity: .4; }
.skeleton .w2 { width: 92%; } .skeleton .w3 { width: 84%; } .skeleton .w4 { width: 74%; }
@keyframes sk { 0%,100% { opacity: .3; } 50% { opacity: .62; } }
@media (prefers-reduced-motion: reduce) { .skeleton span { animation: none; } }

.neterr { max-width: var(--measure); }
.neterr h2 { border: 0; padding: 0; margin: .4rem 0 .6rem; }
.neterr button {
  margin-top: .8rem; font: 700 1rem/1 var(--sans);
  background: var(--copper); color: #f7f1e6; border: 0; border-radius: 2px;
  padding: .7rem 1.3rem; cursor: pointer;
}
.neterr button:hover { background: var(--copper-2); }

.opts { font: 15px/1.5 var(--sans); color: var(--muted); padding: .3rem 0; }

/* ── Тумблер темы: латунный движок на текстолите ── */
.tgl { background: none; border: 0; padding: 2px; cursor: pointer; line-height: 0; border-radius: 14px; }
.tgl:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.tgl-track {
  position: relative; display: inline-block; width: 52px; height: 26px; border-radius: 13px;
  background: linear-gradient(180deg, #0a1d14, #133526);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.55), 0 0 0 1px rgba(212,178,94,.45);
  transition: background .25s;
}
.tgl-ic { position: absolute; top: 5px; width: 16px; height: 16px; fill: none; stroke: #d4b25e; stroke-width: 1.5; stroke-linecap: round; opacity: .55; transition: opacity .25s; }
.tgl-sun { left: 6px; } .tgl-sun circle { fill: #d4b25e; stroke: none; }
.tgl-moon { right: 6px; } .tgl-moon path { fill: #d4b25e; stroke: none; }
.tgl-knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f3dc98, #c79a3b 60%, #8f6a22);
  box-shadow: 0 1px 3px rgba(0,0,0,.5), inset 0 -1px 1px rgba(0,0,0,.25);
  transition: transform .28s cubic-bezier(.3,1.4,.5,1);
}
.tgl[aria-checked="false"] .tgl-knob { transform: translateX(0); }
.tgl[aria-checked="false"] .tgl-sun { opacity: 1; }
.tgl[aria-checked="true"] .tgl-knob { transform: translateX(26px); }
.tgl[aria-checked="true"] .tgl-moon { opacity: 1; }
.tgl:hover .tgl-track { box-shadow: inset 0 1px 3px rgba(0,0,0,.55), 0 0 0 1px #d4b25e; }
@media (prefers-reduced-motion: reduce) { .tgl-knob, .tgl-ic { transition: none; } }
