/* dstick utility — оформление. Тёмная тема, один акцентный цвет. */
@font-face { font-family: "Unbounded"; src: url("fonts/unbounded-latin.woff2") format("woff2"); font-weight: 400 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; src: url("fonts/unbounded-cyrillic.woff2") format("woff2"); font-weight: 400 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; src: url("fonts/onest-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Onest"; src: url("fonts/onest-cyrillic.woff2") format("woff2"); font-weight: 400 700; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

:root {
  color-scheme: dark;
  --bg: #0a0b0d; --side: #0f1013; --panel: #15171b; --panel2: #1e2126; --panel3: #2a2e35; --line: #262a31;
  --text: #f3f4f6; --muted: #8b919c; --faint: #5a606b;
  --accent: #c8ff2e; --accent-ink: #0a0b0d; --accent-soft: rgba(200, 255, 46, .12);
  --in: #9b8cff; --on: #4fe3ff; --warn: #ffb224; --bad: #ff5f5f; --zone: rgba(200, 255, 46, .07);
  --display: "Unbounded", "Hiragino Sans", "Yu Gothic UI", "PingFang SC", "Microsoft YaHei", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --body: "Onest", "Hiragino Sans", "Yu Gothic UI", "PingFang SC", "Microsoft YaHei", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 18px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- каркас ---------- */
#shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100%; }
#side { background: var(--side); border-right: 1px solid var(--line); padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font: 700 17px/1 var(--display); letter-spacing: -.02em; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand small { display: block; font: 500 10px/1 var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 5px; }
#tabs { display: flex; flex-direction: column; gap: 4px; }
#tabs button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font: 600 15px/1.2 var(--body); text-align: left; white-space: nowrap; cursor: pointer; transition: background .12s, color .12s; }
#tabs button svg { width: 20px; height: 20px; flex: none; }
#tabs button:hover { color: var(--text); background: var(--panel); }
#tabs button.active { color: var(--accent-ink); background: var(--accent); }
/* режим, в котором стик работает сейчас */
#tabs button.live::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); margin-left: auto; flex: none; }
#tabs button.live.active::after { background: var(--accent-ink); box-shadow: none; }
#tabs hr { border: 0; border-top: 1px solid var(--line); margin: 10px 8px; width: auto; align-self: stretch; }
.nav-label { padding: 0 12px; margin-bottom: -14px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
#side:has(#tabs:empty) .nav-label { display: none; }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.status { display: flex; align-items: center; gap: 8px; padding: 0 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status.ok { color: var(--text); }
.status.ok::before { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { padding: 0 8px; font-size: 12px; color: var(--faint); }
#content { min-width: 0; padding: 22px 24px 60px; }
#app { max-width: 1360px; }

/* ---------- кнопки, поля ---------- */
button, select, input[type=number] { font: 600 14px/1.2 var(--body); color: var(--text); background: var(--panel2); border: 1px solid transparent; border-radius: 11px; padding: 10px 16px; transition: background .12s, border-color .12s, transform .06s; }
button { cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { background: var(--panel3); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { background: #d8ff66; }
button.primary:disabled { background: var(--panel2); color: var(--muted); opacity: 1; }
button.danger { color: var(--bad); }
select { appearance: none; padding-right: 34px; cursor: pointer; max-width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238b919c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
select:hover, input[type=number]:hover { border-color: var(--panel3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#lang, #connect { width: 100%; }

.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel2); border-radius: 13px; max-width: 100%; flex-wrap: wrap; }
.seg button { background: transparent; padding: 8px 14px; border-radius: 9px; color: var(--muted); }
.seg button:hover:not(:disabled) { background: transparent; color: var(--text); }
.seg button.active { background: var(--panel3); color: var(--text); }
#title { margin: 0; font: 700 26px/1.1 var(--display); letter-spacing: -.03em; }
.note.lead { margin: -6px 0 2px; }

/* ---------- верхняя полоса ---------- */
#bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.spacer { flex: 1; }
.chip { font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 999px; white-space: nowrap; }
.chip.warn { color: var(--warn); background: rgba(255, 178, 36, .12); }
.banner { display: none; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; padding: 14px 18px; border-radius: var(--r); background: rgba(255, 178, 36, .1); color: var(--warn); font-weight: 500; }
.banner.show { display: flex; }
.banner button { background: var(--warn); color: #1a1200; }
.banner button:hover:not(:disabled) { background: #ffc452; }

/* ---------- рабочая область ---------- */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 18px; align-items: start; }
#rail { position: sticky; top: 22px; order: 2; }
.card { background: var(--panel); border-radius: var(--r); padding: 22px 24px; }
.card > h2 { margin: 0 0 4px; font: 600 15px/1.3 var(--display); letter-spacing: -.01em; }
.card > h2 + div, .card > .note + div { margin-top: 14px; }
.note { color: var(--muted); font-size: 14px; margin: 0 0 4px; max-width: 70ch; }
.panel { display: none; }
.panel.active { display: grid; gap: 14px; animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.row { display: grid; grid-template-columns: minmax(150px, 230px) minmax(0, 1fr) 74px; gap: 16px; align-items: center; padding: 9px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row label { font-weight: 600; overflow-wrap: anywhere; }
.row small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.35; margin-top: 2px; }
.row output { justify-self: end; font: 600 13px/1 var(--body); font-variant-numeric: tabular-nums; color: var(--text); background: var(--panel2); padding: 6px 9px; border-radius: 8px; white-space: nowrap; }
.row output:empty { display: none; }
.row.off { opacity: .35; }
.row .ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.row .ctl > * { max-width: 100%; }
.panel button, .seg button { white-space: normal; }

input[type=range] { appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; --p: 0%; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--p), var(--panel3) var(--p)); }
input[type=range]::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 6px rgba(0, 0, 0, .6); transition: transform .1s; }
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.15); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--panel3); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; }
input[type=range]:disabled { cursor: default; }

.switch { appearance: none; width: 46px; height: 26px; border-radius: 999px; background: var(--panel3); position: relative; cursor: pointer; margin: 0; transition: background .14s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: left .14s, background .14s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 23px; background: var(--accent-ink); }

/* клавиша-кнопка */
.keybtn { min-width: 96px; font: 600 13px/1 var(--display); padding: 12px 16px 13px; background: var(--panel2); border-bottom: 3px solid #08090a; border-radius: 10px; }
.keybtn.wait { background: var(--accent-soft); color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- живая картинка ---------- */
canvas { display: block; touch-action: none; }
#live { width: 100%; aspect-ratio: 1; }
.big { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.big div { background: var(--panel2); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.big span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.big b { display: block; font: 600 24px/1.2 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.big .out b { color: var(--accent); }
.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin-top: 12px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.readout b { color: var(--text); font-weight: 600; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.key { min-height: 40px; padding: 4px 8px; border-radius: 10px; background: var(--panel2); border-bottom: 3px solid #08090a; display: grid; place-items: center; font: 600 12px/1.1 var(--display); color: var(--muted); text-align: center; overflow-wrap: anywhere; transition: background .05s, color .05s; }
.key.on { background: var(--accent); color: var(--accent-ink); border-bottom-color: #7fa800; }
.key.k-up { grid-column: 2; }
.key.k-left { grid-column: 1; }
.key.k-wide { grid-column: 1 / -1; }

/* ---------- кривая ---------- */
.card { min-width: 0; }
/* График и пояснение стоят рядом, только если пояснению хватает места; иначе пояснение уходит вниз */
.curvewrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 18px 22px; align-items: start; }
.curvewrap > * { min-width: 0; }
#curve { width: 100%; max-width: 400px; aspect-ratio: 1; cursor: crosshair; background: var(--panel2); border-radius: 14px; }
.curvewrap .row { grid-template-columns: minmax(0, 1fr) auto; }
.curvewrap .row output { display: none; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 4px; }
.presets button { padding: 8px 13px; font-size: 13px; border-radius: 999px; max-width: 100%; white-space: normal; text-align: left; }

/* ---------- калибровка, сервис ---------- */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; color: var(--muted); }
.steps li::before { content: counter(s); width: 34px; height: 34px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font: 600 13px/1 var(--display); color: var(--muted); }
.steps li.cur { color: var(--text); }
.steps li.cur::before { background: var(--accent); color: var(--accent-ink); }
.bar { height: 10px; background: var(--panel2); border-radius: 999px; overflow: hidden; margin: 18px 0 14px; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; border-radius: 999px; transition: width .12s; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 0; font-size: 13px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; font-variant-numeric: tabular-nums; }
#diag { background: none; padding: 0; font-weight: 500; white-space: normal; justify-self: start; }

/* ---------- приветствие ---------- */
#welcome { min-height: calc(100vh - 90px); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 40px; align-items: center; max-width: 1080px; margin: 0 auto; }
#welcome h2 { margin: 0 0 18px; font: 700 clamp(30px, 4.6vw, 54px)/1.08 var(--display); letter-spacing: -.035em; }
#welcome h2 em { font-style: normal; color: var(--accent); }
#welcome p { color: var(--muted); font-size: 17px; max-width: 46ch; margin: 0 0 12px; }
#welcome .btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }
#welcome .btns button { padding: 15px 24px; font-size: 15px; border-radius: 14px; }
.hero { position: relative; aspect-ratio: 1; max-width: 420px; width: 100%; justify-self: center; }
.hero i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--line); }
.hero i:nth-child(2) { inset: 17%; border-style: dashed; animation: spin 40s linear infinite; }
.hero i:nth-child(3) { inset: 34%; border-color: var(--panel3); }
.hero b { position: absolute; left: 50%; top: 50%; width: 21%; aspect-ratio: 1; margin: -10.5% 0 0 -10.5%; border-radius: 50%; background: var(--accent); box-shadow: 0 0 60px rgba(200, 255, 46, .45); animation: roam 7s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes roam { 0%, 100% { transform: translate(0, 0); } 18% { transform: translate(120%, -70%); } 38% { transform: translate(-40%, -150%); } 58% { transform: translate(-150%, 20%); } 78% { transform: translate(30%, 140%); } }
@media (prefers-reduced-motion: reduce) { .hero b, .hero i, .panel.active { animation: none; } }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 12px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 13px; font-weight: 600; font-size: 14px; opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; max-width: min(90vw, 560px); z-index: 20; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- средняя ширина: картинка над настройками ---------- */
@media (max-width: 1180px) {
  .work { grid-template-columns: 1fr; }
  #rail { position: static; order: 0; }
  #rail .card { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 4px 22px; align-items: center; }
  #rail h2 { grid-column: 1 / -1; }
  #rail .side { min-width: 0; }
}
/* ---------- узкий экран: меню сверху ---------- */
@media (max-width: 780px) {
  #shell { grid-template-columns: minmax(0, 1fr); }
  #side { min-width: 0; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; gap: 12px; }
  #tabs { flex-direction: row; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs button { width: auto; flex: none; padding: 10px 13px; }
  #tabs button.live::after { margin-left: 2px; }
  #tabs hr { border-top: 0; border-left: 1px solid var(--line); margin: 6px 4px; }
  .nav-label { display: none; }
  #title { font-size: 21px; }
  .side-foot { margin-top: 0; grid-template-columns: 1fr 1fr; align-items: center; }
  .side-foot .status { grid-column: 1 / -1; }
  .side-foot .meta { display: none; }
  #content { padding: 16px 16px 50px; }
  .card { padding: 18px 16px; }
  #rail .card { display: block; }
  .row { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .row label { grid-column: 1; }
  .row .ctl { grid-column: 1 / -1; grid-row: 2; }
  .row output { grid-column: 2; grid-row: 1; }
  .curvewrap { grid-template-columns: 1fr; }
  #welcome { grid-template-columns: 1fr; min-height: 0; padding: 20px 0; gap: 28px; }
  .hero { max-width: 240px; order: -1; }
}
