/* denisva.ru — «Пульт» с элементами чертежа.
   Тёмная панель управления; от чертежа — сетка на фоне, разделы с буквенными
   позициями, штамп внизу страницы и схемы. */

:root {
  --bg: #0d0f13;
  --panel: #14171e;
  --panel2: #1a1e27;
  --line: #232935;
  --line2: #2f3646;
  --text: #e7e9ef;
  --soft: #b4bac7;
  --muted: #8b92a3;
  --faint: #5d6474;
  --accent: #f5a524;
  --accent-ink: #15110a;
  --ok: #3fb950;
  --warn: #e3b341;
  --err: #f85149;
  --info: #58a6ff;
  --grid: rgba(255, 255, 255, .022);
  --sel: #232937;
  --sel-text: #fff;
  --topbar: rgba(13, 15, 19, .88);
  --avatar: #2a3140;
  --hover-line: #3d4658;
  --shadow: rgba(0, 0, 0, .5);
  --backdrop: rgba(0, 0, 0, .6);
  --stamp: rgba(20, 23, 30, .7);
  --tip: #0b0d11;
  --node: #10131a;
  --input: #0f1217;
  --frame: #131417;
  --alert-err: #ffb4ae;
  --alert-ok: #9be3a8;
  --chart-grid: #2a3040;
  --chart-cross: #5d6474;
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --cond: "IBM Plex Sans Condensed", "Arial Narrow", sans-serif;
  --side: 240px;
  --top: 56px;
  color-scheme: dark;
}

/* Светлая тема — «бумага» чертежа. Выбор хранится в браузере, см. base.html */
:root[data-theme="light"] {
  --bg: #f3f1ec;
  --panel: #ffffff;
  --panel2: #f4f2ed;
  --line: #e3dfd6;
  --line2: #d2cdc2;
  --text: #1c2026;
  --soft: #3b414b;
  --muted: #676d78;
  --faint: #9a9ea6;
  --accent: #c97a00;
  --accent-ink: #ffffff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --err: #cf222e;
  --info: #0969da;
  --grid: rgba(28, 32, 38, .045);
  --sel: #ece8df;
  --sel-text: #1c2026;
  --topbar: rgba(243, 241, 236, .88);
  --avatar: #e6e1d6;
  --hover-line: #b9b3a6;
  --shadow: rgba(40, 36, 28, .18);
  --backdrop: rgba(28, 32, 38, .35);
  --stamp: rgba(255, 255, 255, .75);
  --tip: #ffffff;
  --node: #fbfaf7;
  --input: #ffffff;
  --frame: #eceae5;
  --alert-err: #a40e26;
  --alert-ok: #116329;
  --chart-grid: #e0dbd0;
  --chart-cross: #9a9ea6;
  color-scheme: light;
}
:root[data-theme="light"] .led.ok { box-shadow: none; }
:root[data-theme="light"] .led.warn { box-shadow: none; }
:root[data-theme="light"] .led.err { box-shadow: none; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; }
[hidden] { display: none !important; }

/* --- каркас --------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 14px 10px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; text-decoration: none; }
.logo {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font: 700 16px/1 var(--mono);
}
.brand b { display: block; font-weight: 600; }
.brand small { display: block; color: var(--muted); font: 11px/1.3 var(--mono); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group {
  padding: 16px 10px 6px; color: var(--faint);
  font: 600 10.5px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase;
}
.nav-group a { text-decoration: none; }
.nav-group a:hover { color: var(--soft); }
.nav > a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  color: var(--soft); text-decoration: none;
}
.nav > a:hover { background: var(--panel2); color: var(--text); }
.nav > a.on { background: var(--sel); color: var(--sel-text); box-shadow: inset 2px 0 0 var(--accent); }
.nav > a.sub { padding: 4px 10px 4px 44px; font-size: 13px; color: var(--muted); }
.nav > a.sub:hover { color: var(--text); background: none; }
.nav-ico {
  width: 24px; height: 20px; flex: none; border-radius: 4px;
  display: grid; place-items: center;
  border: 1px solid var(--line2); color: var(--accent);
  font: 700 9px/1 var(--mono); letter-spacing: -.02em;
}
.nav svg.i { width: 24px; }

.side-foot {
  margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--line);
  font: 11px/1.7 var(--mono); color: var(--muted);
}
.side-foot b { color: var(--soft); font-weight: 500; }

.main {
  min-width: 0; display: flex; flex-direction: column;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

.top {
  position: sticky; top: 0; z-index: 20;
  height: var(--top); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; border-bottom: 1px solid var(--line);
  background: var(--topbar); backdrop-filter: blur(8px);
}
.crumbs { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs b { color: var(--text); font-weight: 500; }
.burger { display: none; }

.search {
  margin-left: auto; width: 320px; max-width: 36vw;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 10px; color: var(--muted); cursor: pointer; text-align: left;
}
.search:hover { border-color: var(--line2); color: var(--soft); }
.search span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
kbd {
  font: 11px/1.4 var(--mono); color: var(--muted);
  border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px;
}

.pill {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 99px; padding: 4px 11px;
  font: 12px/1.3 var(--mono); color: var(--soft); text-decoration: none;
}
a.pill:hover { border-color: var(--line2); color: var(--text); }

.icon-btn {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--soft); cursor: pointer;
}
.icon-btn:hover { background: var(--panel2); border-color: var(--line); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn > span { display: contents; }
:root[data-theme="light"] .t-dark, :root:not([data-theme="light"]) .t-light { display: none; }

.account { position: relative; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  background: var(--avatar); border: 1px solid var(--line2); font-weight: 600;
}
.avatar:hover { border-color: var(--accent); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; z-index: 30;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 10px;
  box-shadow: 0 18px 50px var(--shadow); padding: 6px;
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head small { display: block; color: var(--muted); font: 11px/1.5 var(--mono); }
.menu a, .menu button {
  display: block; width: 100%; text-align: left; text-decoration: none;
  padding: 7px 10px; border-radius: 6px; background: none; border: 0; cursor: pointer; color: var(--soft);
}
.menu a:hover, .menu button:hover { background: var(--panel2); color: var(--text); }
.menu .danger { color: var(--err); }

.page { flex: 1; width: 100%; max-width: 1240px; padding: 28px 28px 36px; }
.page.full { max-width: none; padding: 0; display: flex; flex-direction: column; }

/* --- штамп (от чертежа) --------------------------------------------------- */

.stamp {
  margin: 0 28px 24px; max-width: 1184px;
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  border: 1px solid var(--line2); background: var(--stamp);
  font: 11.5px/1.35 var(--mono); color: var(--soft);
}
.stamp > div { padding: 6px 10px; border-right: 1px solid var(--line2); min-width: 0; }
.stamp > div:last-child { border-right: 0; }
.stamp small {
  display: block; color: var(--faint);
  font: 600 9.5px/1.5 var(--cond); letter-spacing: .14em; text-transform: uppercase;
}
.stamp .t { font: 700 15px/1.2 var(--cond); letter-spacing: .08em; text-transform: uppercase; color: var(--text); }

/* --- заголовки и разделы -------------------------------------------------- */

.page-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head .sub { color: var(--muted); }
.page-head .end { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.sec {
  display: flex; align-items: center; gap: 10px; margin: 32px 0 14px;
  font: 600 13px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase;
  scroll-margin-top: calc(var(--top) + 16px);
}
.sec:first-child { margin-top: 0; }
.sec .n {
  width: 23px; height: 23px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--accent); color: var(--accent);
  font: 600 11px/1 var(--mono); letter-spacing: 0;
}
.sec .rule { flex: 1; border-top: 1px solid var(--line2); }
.sec .aside { font: 12px/1 var(--mono); letter-spacing: 0; text-transform: none; color: var(--muted); }
.sec .aside a { text-decoration: none; color: var(--soft); }
.sec .aside a:hover { color: var(--accent); }

/* --- индикаторы ----------------------------------------------------------- */

.led {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--faint);
}
.led.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.led.warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.led.err { background: var(--err); box-shadow: 0 0 6px var(--err); animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.c-ok { color: var(--ok); } .c-warn { color: var(--warn); } .c-err { color: var(--err); }
.c-muted { color: var(--muted); } .c-info { color: var(--info); }

.tag {
  display: inline-block; border: 1px solid var(--line2); border-radius: 4px;
  padding: 0 6px; font: 11px/1.6 var(--mono); color: var(--muted); white-space: nowrap;
}
.tag.ok { border-color: rgba(63, 185, 80, .4); color: var(--ok); }
.tag.warn { border-color: rgba(227, 179, 65, .4); color: var(--warn); }
.tag.err { border-color: rgba(248, 81, 73, .45); color: var(--err); }

/* --- плитки показателей --------------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tiles.six { grid-template-columns: repeat(6, 1fr); }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px 12px; min-width: 0; position: relative;
}
.tile .k {
  display: flex; justify-content: space-between; gap: 8px;
  font: 600 10.5px/1.3 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.tile .k span { font: 11px/1.3 var(--mono); letter-spacing: 0; text-transform: none; color: var(--faint); }
.tile .v { margin-top: 6px; font: 500 24px/1.15 var(--mono); white-space: nowrap; }
.tile .v small { font-size: 12.5px; color: var(--muted); }
.tile .d { margin-top: 3px; font: 11.5px/1.4 var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile svg.spark { display: block; width: 100%; height: 30px; margin-top: 6px; }

/* шкала с делениями — от чертежа */
.gauge {
  position: relative; height: 8px; margin-top: 10px;
  border: 1px solid var(--line2); border-radius: 2px;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--line2) calc(10% - 1px) 10%);
}
.gauge i { position: absolute; inset: 0 auto 0 0; background: var(--accent); opacity: .9; border-radius: 1px; }
.gauge.ok i { background: var(--ok); } .gauge.warn i { background: var(--warn); } .gauge.err i { background: var(--err); }

/* --- карточки разделов ---------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 9px; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px 13px; text-decoration: none;
  transition: border-color .15s, transform .15s;
}
a.card:hover { border-color: var(--hover-line); transform: translateY(-1px); }
.card .head { display: flex; align-items: center; gap: 11px; }
.card .ico {
  width: 36px; height: 36px; flex: none; border-radius: 8px;
  display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line2);
  color: var(--accent); font: 700 12px/1 var(--mono);
}
.card .name { font-weight: 600; }
.card .kind { color: var(--muted); font-size: 12px; }
.card .pos { margin-left: auto; align-self: flex-start; font: 11px/1 var(--mono); color: var(--faint); }
.card p { margin: 0; color: var(--soft); font-size: 13px; line-height: 1.5; }
.card .foot {
  display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 10px;
  border-top: 1px dashed var(--line2); font-size: 12px; color: var(--muted); white-space: nowrap;
}
.card .foot code { margin-left: auto; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }

/* --- таблицы, списки ------------------------------------------------------ */

.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.box > h3 {
  margin: 0; padding: 11px 15px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  font: 600 11px/1.3 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--soft);
}
.box > h3 .r { margin-left: auto; font: 11.5px/1 var(--mono); letter-spacing: 0; text-transform: none; color: var(--muted); }
.box .pad { padding: 12px 15px; }
.scroll-x { overflow-x: auto; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 8px 15px; border-bottom: 1px solid var(--line);
  font: 600 10px/1.3 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--faint);
  white-space: nowrap;
}
.tbl td { padding: 8px 15px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.m, .tbl .m { font: 12px/1.4 var(--mono); color: var(--muted); white-space: nowrap; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl .nm { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.tbl .empty { color: var(--muted); text-align: center; padding: 18px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0; font-size: 13px; }
.kv > div { padding: 7px 0; border-bottom: 1px dotted var(--line2); }
.kv > div:nth-child(odd) { color: var(--muted); padding-right: 16px; }
.kv > div:nth-child(even) { text-align: right; font: 12.5px/1.5 var(--mono); }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }

.events { list-style: none; margin: 0; padding: 4px 0; font: 12px/1.5 var(--mono); }
.events li { display: grid; grid-template-columns: 92px 10px 1fr; gap: 10px; align-items: baseline; padding: 5px 15px; }
.events li + li { border-top: 1px solid var(--line); }
.events time { color: var(--faint); white-space: nowrap; }
.events .led { transform: translateY(-1px); }
.events .src { color: var(--muted); }
.events.long { max-height: 520px; overflow-y: auto; }

.two { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; }
.two > * { min-width: 0; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* --- графики -------------------------------------------------------------- */

.chart { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 8px; min-width: 0; }
.chart-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-head b { font: 600 11px/1.3 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.chart-head .now { margin-left: auto; font: 500 15px/1 var(--mono); }
.legend { display: flex; gap: 12px; font: 11px/1 var(--mono); color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 5px; }
.chart svg { display: block; width: 100%; height: 150px; overflow: visible; }
.chart svg text { font: 10px var(--mono); fill: var(--faint); }
.chart svg .gl { stroke: var(--chart-grid); stroke-dasharray: 2 4; }
.chart svg .cross { stroke: var(--chart-cross); }
.chart .tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--tip); border: 1px solid var(--line2); border-radius: 6px;
  padding: 6px 8px; font: 11.5px/1.5 var(--mono); white-space: nowrap;
}
.chart .body { position: relative; }
.chart .nodata { height: 150px; display: grid; place-items: center; color: var(--faint); font: 12px var(--mono); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; padding: 2px; background: var(--panel); }
.seg button {
  border: 0; background: none; padding: 3px 10px; border-radius: 5px; cursor: pointer;
  font: 12px/1.4 var(--mono); color: var(--muted);
}
.seg button.on { background: var(--sel); color: var(--text); }

/* --- схема сети (от чертежа) ---------------------------------------------- */

.schema { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 6px; }
.schema svg { display: block; width: 100%; height: auto; }
.schema .node rect { fill: var(--node); stroke: var(--line2); stroke-width: 1.2; }
.schema .node.ok rect { stroke: rgba(63, 185, 80, .55); }
.schema .node.err rect { stroke: var(--err); }
.schema .node text { fill: var(--text); font: 600 12px var(--cond); letter-spacing: .1em; }
.schema .node text.s { fill: var(--muted); font: 10.5px var(--mono); letter-spacing: 0; }
.schema .wire { stroke: var(--line2); stroke-width: 1.3; fill: none; }
.schema .wire.ok { stroke: rgba(63, 185, 80, .7); stroke-dasharray: 5 4; animation: flow 1.2s linear infinite; }
.schema .wire.err { stroke: var(--err); stroke-dasharray: 2 4; }
.schema .lbl { fill: var(--faint); font: 10px var(--mono); }
.schema .pos { fill: var(--accent); font: 600 10px var(--mono); }
@keyframes flow { to { stroke-dashoffset: -18; } }
.note { margin: 6px 2px 0; font: 11.5px/1.6 var(--mono); color: var(--muted); border-left: 2px solid var(--accent); padding-left: 10px; }

/* --- кнопки, формы -------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 7px 14px; border-radius: 7px; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--panel2); border: 1px solid var(--line2); color: var(--text); font-weight: 500;
}
.btn:hover { border-color: var(--hover-line); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn svg { width: 15px; height: 15px; }

.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font: 600 10.5px/1.3 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.form input[type=text], .form input[type=password] {
  background: var(--input); border: 1px solid var(--line2); border-radius: 7px;
  padding: 9px 11px; color: var(--text); font: 14px var(--mono); outline: none;
}
.form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245, 165, 36, .15); }
.form .checkbox {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font: 13px Inter, sans-serif; letter-spacing: 0; text-transform: none; color: var(--soft);
}
.form .checkbox input { accent-color: var(--accent); }
.form button[type=submit] { margin-top: 16px; }
.form .hint { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.narrow { max-width: 420px; }

.alert { padding: 10px 13px; border-radius: 8px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.alert.error { color: var(--alert-err); border-color: rgba(248, 81, 73, .45); background: rgba(248, 81, 73, .08); }
.alert.ok { color: var(--alert-ok); border-color: rgba(63, 185, 80, .45); background: rgba(63, 185, 80, .08); }

/* --- окна: вход и поиск --------------------------------------------------- */

.backdrop {
  position: fixed; inset: 0; z-index: 50; background: var(--backdrop);
  display: flex; align-items: flex-start; justify-content: center; padding: 14vh 16px 16px;
}
.modal {
  width: 380px; max-width: 100%;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: 0 24px 70px var(--shadow); padding: 18px 20px 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: 18px; }

.palette {
  width: 580px; max-width: 100%; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: 0 24px 70px var(--shadow);
}
.palette input {
  width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 15px 16px; color: var(--text); font: 15px Inter, sans-serif; outline: none;
}
.palette .list { max-height: 50vh; overflow-y: auto; padding: 4px 0 8px; }
.palette .grp {
  padding: 10px 16px 4px; color: var(--faint);
  font: 600 10px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase;
}
.palette a {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  color: var(--soft); text-decoration: none;
}
.palette a.sel { background: var(--sel); color: var(--sel-text); box-shadow: inset 2px 0 0 var(--accent); }
.palette a code { margin-left: auto; font-size: 11.5px; color: var(--faint); }
.palette .none { padding: 16px; color: var(--muted); }
.palette .keys { display: flex; gap: 14px; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--faint); }

/* --- титульный лист (гость) ----------------------------------------------- */

.title-sheet {
  display: grid; grid-template-columns: 1fr 1.1fr; align-items: center; gap: 36px;
  min-height: calc(100vh - var(--top) - 150px);
}
.kicker { font: 600 11px/1 var(--cond); letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.title-sheet h1 { margin: 12px 0 14px; font: 700 clamp(40px, 6vw, 68px)/.95 var(--cond); letter-spacing: .04em; }
.title-sheet p { margin: 0 0 24px; color: var(--soft); font-size: 16px; max-width: 46ch; }
.title-sheet .schema { background: var(--stamp); }

/* --- эмуляторы ------------------------------------------------------------ */

.machines { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.machine { display: flex; flex-direction: column; text-decoration: none; overflow: hidden; }
.machine .screen {
  margin: 14px 14px 0; padding: 14px 13px; min-height: 96px; border-radius: 4px;
  background: #07080a; box-shadow: inset 0 2px 12px rgba(0, 0, 0, .9);
  font: 12px/1.45 var(--mono); white-space: pre; overflow: hidden;
}
.machine .screen.rk86 { color: #b6f0a8; }
.machine .screen.zx { color: #d7d7d7; }
.machine .screen.emu-log { color: var(--muted); }
.machine .screen.korvet { color: #e8e8f0; background: #0000b4; }
.screen .cur { background: currentColor; animation: blink 1s steps(2) infinite; }
.screen .c1 { color: #00d8d8; } .screen .c2 { color: #d8d800; }
.machine .card-body { padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.machine dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font: 12px/1.5 var(--mono); }
.machine dt { color: var(--faint); }
.machine dd { margin: 0; color: var(--soft); }
.machine .go { margin-top: auto; color: var(--accent); font: 600 12px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase; }

.embed-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.embed-bar .title { font-weight: 600; }
.embed-bar .spec { font: 12px var(--mono); color: var(--muted); }
.embed-bar .end { margin-left: auto; display: flex; gap: 8px; }
.embed-frame { flex: 1; width: 100%; min-height: 420px; border: 0; background: var(--frame); display: block; }

/* --- адаптивность --------------------------------------------------------- */

@media (max-width: 1100px) {
  .tiles.six { grid-template-columns: repeat(3, 1fr); }
  .three { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; z-index: 60; left: 0; top: 0; width: 270px;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 0 0 40px var(--shadow);
  }
  body.side-open .side { transform: none; }
  body.side-open::after { content: ""; position: fixed; inset: 0; z-index: 55; background: var(--backdrop); }
  .burger { display: grid; margin-left: -8px; }
  .top { padding: 0 16px; gap: 8px; }
  .search { width: auto; max-width: none; flex: none; }
  .search span, .search kbd, .top .pill.opt { display: none; }
  .page { padding: 20px 16px 28px; }
  .tiles, .tiles.six { grid-template-columns: 1fr 1fr; }
  .two, .three, .grid2 { grid-template-columns: 1fr; }
  .stamp { margin: 0 16px 16px; grid-template-columns: 1fr 1fr; }
  .stamp > div:first-child { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--line2); }
  .stamp > div:nth-child(n+4) { display: none; }
  .title-sheet { grid-template-columns: 1fr; min-height: 0; padding-top: 10px; }
  .embed-bar { padding: 8px 12px; }
  .embed-bar .spec { display: none; }
  .events li { grid-template-columns: 78px 10px 1fr; padding: 5px 12px; }
  #net-schema { overflow-x: auto; }
  #net-schema svg { min-width: 660px; }
}

@media (max-width: 420px) {
  .tile .v { font-size: 20px; }
  .machines { grid-template-columns: 1fr; }
}

/* --- астрономия ------------------------------------------------------------ */

:root {
  --sky-day: #b89148; --sky-civil: #3f6aa6; --sky-naut: #25406f; --sky-astro: #172340; --sky-night: #0a0d15;
}
:root[data-theme="light"] {
  --sky-day: #f1d990; --sky-civil: #8fb3e0; --sky-naut: #4f74ad; --sky-astro: #2f4169; --sky-night: #1d2436;
}
.sky-legend { margin-top: 10px; flex-wrap: wrap; gap: 6px 14px; }
.sky-legend i { width: 12px; height: 8px; border-radius: 2px; }

.daybar { position: relative; padding: 22px 0 18px; }
.daybar canvas { display: block; width: 100%; border-radius: 4px; }
.daybar .over { position: absolute; inset: 0; pointer-events: none; }
.daybar .mark {
  position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap;
  font: 10.5px/1.2 var(--mono); color: var(--muted); text-align: center;
}
.daybar .mark b { display: block; color: var(--text); font-weight: 500; font-size: 12px; }
.daybar .mark::after {
  content: ""; position: absolute; left: 50%; top: 26px; height: 38px; border-left: 1px dashed rgba(255, 255, 255, .45);
}
.daybar .mark { top: -6px; }
.daybar .now {
  position: absolute; top: 18px; bottom: 14px; width: 2px; margin-left: -1px;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
}
.daybar .hour { position: absolute; bottom: 0; transform: translateX(-50%); font: 10px var(--mono); color: var(--faint); }
.daybar .hour:first-of-type { transform: none; }

.yearchart { position: relative; }
.yearchart canvas { display: block; width: 100%; cursor: crosshair; }
.yearchart .tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--tip); border: 1px solid var(--line2); border-radius: 6px;
  padding: 6px 8px; font: 11.5px/1.5 var(--mono); white-space: nowrap;
}

.moonico { vertical-align: middle; flex: none; }
.moonico .dark { fill: #20252f; stroke: var(--line2); }
.moonico .lit { fill: #e8e4d4; }
:root[data-theme="light"] .moonico .dark { fill: #c9cdd4; }
:root[data-theme="light"] .moonico .lit { fill: #fffdf3; stroke: #b9b3a6; stroke-width: .5; }
.moonrow { display: inline-flex; align-items: center; gap: 8px; }
.tile .v .moonrow { font: 500 17px/1.2 Inter, sans-serif; }

.skycal tr.today td { background: rgba(245, 165, 36, .1); }
.skycal tr.today td:first-child { box-shadow: inset 2px 0 0 var(--accent); color: var(--text); }
.skycal tr.weekend td:first-child { color: var(--err); }
.skycal .tag { margin-left: 4px; }

.seg button#year-title, .seg button#calToday, .seg button#nightToday { min-width: 150px; }
.seg-select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  font: 12px var(--mono); padding: 3px 6px;
}

.pdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; margin-right: 2px; box-shadow: 0 0 6px rgba(255, 255, 255, .15); }
.cards.planets { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card.planet .head .pdot { width: 14px; height: 14px; }
.card.planet .kv { font-size: 12.5px; }
.card.planet p { font-size: 12.5px; color: var(--muted); }

.heatmap { padding: 10px 14px 12px; min-width: 760px; }
.hm-row { display: flex; align-items: center; height: 20px; }
.hm-head { height: 18px; }
.hm-name {
  width: 104px; flex: none; display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--soft); white-space: nowrap;
}
.hm-cell { flex: 1; height: 16px; display: grid; place-items: center; min-width: 6px; }
.hm-cell i { display: block; width: calc(100% - 1px); height: 100%; border-radius: 2px; }
.hm-row:not(.hm-head) .hm-cell { background: rgba(127, 127, 127, .06); }
.hm-date { font: 9.5px var(--mono); color: var(--faint); overflow: visible; white-space: nowrap; }
.hm-moon { background: var(--soft); border-radius: 50% !important; width: 9px !important; height: 9px !important; }

.events li time { white-space: nowrap; }
#events li { grid-template-columns: 150px 12px 1fr; }

/* --- графики функций ------------------------------------------------------- */

.mtoolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.msearch {
  display: flex; align-items: center; gap: 8px; max-width: 460px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; color: var(--muted);
}
.msearch:focus-within { border-color: var(--accent); }
.msearch input { flex: 1; background: none; border: 0; outline: none; color: var(--text); font: 14px Inter, sans-serif; }
.mchips { display: flex; flex-wrap: wrap; gap: 6px; }
.mchips button {
  border: 1px solid var(--line); background: var(--panel); color: var(--soft); border-radius: 99px;
  padding: 4px 11px; cursor: pointer; font-size: 12.5px;
}
.mchips button small { color: var(--faint); font: 11px var(--mono); margin-left: 3px; }
.mchips button:hover { border-color: var(--line2); color: var(--text); }
.mchips button.on { background: var(--sel); border-color: var(--accent); color: var(--text); }

.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.mcard {
  display: flex; flex-direction: column; text-decoration: none; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, transform .15s;
}
.mcard:hover { border-color: var(--hover-line); transform: translateY(-2px); }
.mthumb { position: relative; aspect-ratio: 300 / 188; border-bottom: 1px solid var(--line); background: var(--panel); }
.mthumb canvas { display: block; width: 100%; height: 100%; }
.mkind {
  position: absolute; top: 7px; right: 7px; font: 600 10px/1 var(--mono); color: var(--muted);
  background: var(--tip); border: 1px solid var(--line2); border-radius: 4px; padding: 3px 5px; opacity: .9;
}
.mbody { padding: 10px 12px 11px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mname { font-weight: 600; font-size: 13.5px; display: flex; gap: 7px; align-items: baseline; }
.mnum { font: 10.5px var(--mono); color: var(--faint); }
.mform { font: 11.5px/1.4 var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcat { font: 600 10px/1.3 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-top: 2px; }

.mview-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mview-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.mview { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.mplot {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; height: min(72vh, 720px); min-height: 360px;
}
.mplot canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.mplot canvas:active { cursor: grabbing; }
.mcoords {
  position: absolute; left: 10px; bottom: 8px; font-size: 11.5px; color: var(--muted);
  background: var(--tip); border: 1px solid var(--line2); border-radius: 5px; padding: 2px 7px; pointer-events: none;
}
.mcoords:empty { display: none; }
.mtitle { margin: 6px 0 8px; font-size: 21px; }
.mformula {
  font: 13.5px/1.5 var(--mono); color: var(--text); background: var(--input); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 11px; margin-bottom: 12px; overflow-x: auto;
}
.mabout { font-size: 13.5px; line-height: 1.6; color: var(--soft); margin: 0 0 14px; }
.mparams { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.mparam { display: flex; flex-direction: column; gap: 4px; }
.mpl { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.mpl b { font: 500 12.5px var(--mono); color: var(--text); }
.mparam input[type=range] { width: 100%; accent-color: var(--accent); }
.mtools { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; align-items: center; }
.mtools .checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--soft); }
.mtools .checkbox input { accent-color: var(--accent); }
.mtools .mparam { flex: 1 1 100%; }
.mbtns { display: flex; gap: 8px; margin-bottom: 12px; }
.mbtns .btn.on { background: var(--sel); color: var(--text); border-color: var(--accent); }
.mkeys { font-size: 11.5px; margin: 8px 0 0; }

@media (max-width: 900px) {
  .mview { grid-template-columns: 1fr; }
  .mplot { height: 62vh; }
  .mgrid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* --- открытые страницы: эмуляторы для всех, связь с автором, посещения ---- */

.title-sheet { min-height: min(58vh, 520px); }
.public { margin-top: 18px; }
.public .lead { margin: -6px 0 14px; color: var(--soft); }

.stamp .write a { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); text-decoration: none; font-weight: 600; }
.stamp .write a:hover { text-decoration: underline; }
.stamp .write svg { width: 15px; height: 15px; }
.page.full + .stamp, .main > .stamp { margin-top: 18px; }

.avatar { position: relative; }
.avatar .dot { position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border-radius: 50%;
               background: var(--accent); border: 2px solid var(--bg); }
.menu .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
               background: var(--accent); color: var(--accent-ink); font: 600 11px/18px var(--mono); text-align: center; }

.modal.wide { width: 560px; }
.form textarea, .form input[type=text] {
  background: var(--input); border: 1px solid var(--line2); border-radius: 7px;
  padding: 9px 11px; color: var(--text); font: 14px/1.5 Inter, sans-serif; outline: none; width: 100%;
}
.form textarea { resize: vertical; min-height: 120px; }
.form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245, 165, 36, .15); }
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form .row2 > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form .opt { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); }
.form .alert { margin: 8px 0 0; }
.form .trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.contact-done { padding: 8px 0; }
.contact-done p { margin: 0 0 6px; }
.contact-page { max-width: 640px; }

.msgs { display: flex; flex-direction: column; gap: 10px; }
.msg header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; padding: 11px 15px 0; }
.msg header time { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.msg header .reply { font: 12.5px var(--mono); color: var(--info); }
.msg.new { border-color: var(--accent); }
.msg .tag.new { border-color: var(--accent); color: var(--accent); }
.msg .body { padding: 8px 15px 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.msg footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 8px 15px;
              border-top: 1px solid var(--line); background: var(--panel2); }
.msg footer .meta { font: 11.5px var(--mono); color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.msg footer form { margin-left: auto; display: flex; gap: 6px; }
.btn.danger { color: var(--err); }

.tbl .num, .tbl th.num { text-align: right; white-space: nowrap; font-family: var(--mono); }
.tbl.visits small { color: var(--muted); margin-left: 3px; }
.tbl.visits tr.total td { border-top: 1px solid var(--line2); font-weight: 600; }
.mono { font-family: var(--mono); }
.vbars { display: flex; align-items: flex-end; gap: 3px; height: 170px; }
.vbar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; }
.vbar .stack { display: flex; flex-direction: column-reverse; border-radius: 2px 2px 0 0; overflow: hidden; min-height: 1px; background: var(--line); }
.vbar span { font: 10px/1.6 var(--mono); color: var(--faint); text-align: center; }
.vbar:hover .stack { filter: brightness(1.2); }
.s-rk86 { background: #7cc96b; } .s-zx { background: #58a6ff; } .s-korvet { background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12.5px; color: var(--soft); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.embed-bar h1.title { margin: 0; font-size: 15px; font-weight: 600; }
.page.full .embed-frame { flex: none; height: calc(100vh - var(--top) - 53px); }
.emu-about { width: 100%; max-width: 1240px; padding: 8px 28px 8px; }
.prose { max-width: 78ch; color: var(--soft); line-height: 1.65; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 12px; padding-left: 20px; }
.prose li { margin-bottom: 5px; }
.prose a, .others a { color: var(--accent); }
.faq { max-width: 78ch; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 10px 0; font-weight: 600; color: var(--text); }
.faq details p { margin: 0 0 12px; color: var(--soft); line-height: 1.6; }
.others { display: flex; flex-wrap: wrap; gap: 8px 18px; }

@media (max-width: 900px) {
  .stamp > div.write { display: block; grid-column: 1 / -1; border-top: 1px solid var(--line2); }
}
@media (max-width: 760px) {
  .form .row2 { grid-template-columns: 1fr; }
  .emu-about { padding: 8px 16px; }
  .page.full .embed-frame { height: calc(100vh - var(--top) - 46px); }
  .vbar span { font-size: 8px; }
}

/* --- акценты эмуляторов: главное, что видно сразу ------------------------- */

.hl-star { color: var(--accent); font-size: 15px; line-height: 1; }
.machine .hl {
  display: flex; align-items: flex-start; gap: 10px; margin: 12px 14px 0; padding: 10px 12px;
  border: 1px solid var(--accent); border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.machine .hl .hl-star { font-size: 18px; margin-top: 1px; }
.machine .hl b { display: block; color: var(--text); font-size: 14.5px; line-height: 1.3; }
.machine .hl small { display: block; margin-top: 3px; color: var(--soft); font-size: 12.5px; line-height: 1.45; }

.hl-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text); font: 600 13px/1.3 Inter, sans-serif; min-width: 0;
}
.hl-pill:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.hl-pill .go { color: var(--accent); font: 600 11px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase; }

.card .hl-line { display: flex; align-items: center; gap: 7px; margin: -2px 0 10px; font-weight: 600; font-size: 13px; color: var(--text); }

.public .lead b { color: var(--text); }

@media (max-width: 900px) {
  .hl-pill { order: 5; width: 100%; justify-content: center; }
  .hl-pill .go { display: none; }
}
.lead-hl { margin: -10px 0 20px; color: var(--soft); } .lead-hl b { color: var(--text); }

/* --- графики функций открыты: список функций и карточка на титульном листе --- */
.m-about { margin-top: 26px; }
.m-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 24px; margin-top: 8px; }
.m-index h3 { margin: 12px 0 6px; font: 600 12px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.m-index h3 span { font-family: var(--mono); letter-spacing: 0; color: var(--faint); margin-left: 4px; }
.m-index ul { list-style: none; margin: 0; padding: 0; }
.m-index li { padding: 3px 0; font-size: 13.5px; line-height: 1.4; }
.m-index a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line2); }
.m-index a:hover { color: var(--accent); border-color: var(--accent); }
.m-index code { font: 11.5px var(--mono); color: var(--faint); margin-left: 4px; }
.mathcard { display: flex; gap: 0; text-decoration: none; overflow: hidden; max-width: 760px; }
.mathcard svg { flex: none; width: 260px; background: #07080a; }
.mathcard svg path { fill: none; stroke-width: 2; }
.mathcard .g1 { stroke: var(--accent); } .mathcard .g2 { stroke: #58a6ff; }
.mathcard .card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.mathcard .go { margin-top: auto; color: var(--accent); font: 600 12px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase; }
@media (max-width: 640px) { .mathcard { flex-direction: column; } .mathcard svg { width: 100%; height: 110px; } }
