/* «Лаборатория точности»: почти-чёрный и графит, один сигнальный цвет (циан #35F2D0), тонкие линии, сетка, моно для приборов. */
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/onest-cyrillic-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/onest-latin-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Unbounded'; font-style: normal; font-weight: 200 900; font-display: swap; src: url(/fonts/unbounded-cyrillic-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Unbounded'; font-style: normal; font-weight: 200 900; font-display: swap; src: url(/fonts/unbounded-latin-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 100 800; font-display: swap; src: url(/fonts/jetbrains-mono-cyrillic-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 100 800; font-display: swap; src: url(/fonts/jetbrains-mono-latin-wght-normal.woff2) format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: dark;
  --bg: #0A0B0D; --bg-2: #0E1013; --surface: #12151A; --surface-2: #171B21; --surface-3: #1E232B;
  --line: #232830; --line-2: #313844;
  --text: #E8EBEF; --text-2: #A3ABB7; --text-3: #7B8491;
  --accent: #35F2D0; --accent-ink: #35F2D0; --on-accent: #04110E;
  --accent-dim: rgba(53, 242, 208, .11); --accent-line: rgba(53, 242, 208, .38); --accent-glow: rgba(53, 242, 208, .25);
  --danger: #FF7A7A; --danger-dim: rgba(255, 122, 122, .12);
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --overlay: rgba(4, 5, 6, .62);
  --code-bg: #0D0F13; --code-line: #1D2128;
  --font-ui: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Onest', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --r-sm: 6px; --r: 10px; --r-lg: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
[data-theme='light'] {
  color-scheme: light;
  --bg: #F2F3EF; --bg-2: #ECEEE9; --surface: #FFFFFF; --surface-2: #F7F8F5; --surface-3: #EDEFEA;
  --line: #DCDFD8; --line-2: #C6CBC2;
  --text: #0C0F12; --text-2: #434B55; --text-3: #5F6875;
  --accent: #0FD9B5; --accent-ink: #00705F; --on-accent: #032620;
  --accent-dim: rgba(0, 160, 135, .09); --accent-line: rgba(0, 130, 110, .4); --accent-glow: rgba(15, 217, 181, .3);
  --danger: #C62828; --danger-dim: rgba(198, 40, 40, .09);
  --shadow: 0 18px 44px rgba(20, 30, 28, .14);
  --overlay: rgba(235, 238, 232, .7);
  --code-bg: #F4F6F2; --code-line: #E2E6DE;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.55 var(--font-ui); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img, svg, canvas { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--on-accent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 16px; height: 16px; }
.ico-fill { fill: currentColor; stroke: none; }

.mono { font-family: var(--font-mono); }
.label { font: 500 11px/1.2 var(--font-mono); letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); }
.display { font-family: var(--font-display); letter-spacing: -.02em; font-weight: 600; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: var(--r); border: 1px solid var(--line-2); font: 600 15px/1 var(--font-ui); color: var(--text); background: transparent; text-decoration: none; transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease); white-space: nowrap; user-select: none; -webkit-tap-highlight-color: transparent; }
.btn:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: 0 0 0 0 var(--accent-glow); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: var(--r-sm); }
.btn-danger { color: var(--danger); border-color: var(--danger-dim); }
.btn-danger:hover { background: var(--danger-dim); border-color: var(--danger); }
.btn-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r); color: var(--text-2); transition: background .18s var(--ease), color .18s var(--ease); -webkit-tap-highlight-color: transparent; }
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon.sm { width: 36px; height: 36px; border-radius: var(--r-sm); }
.btn-icon.xs { width: 32px; height: 32px; border-radius: var(--r-sm); }
.btn-icon.on { color: var(--accent-ink); background: var(--accent-dim); }

/* ---------- поля ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-2); }
.input { width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); color: var(--text); transition: border-color .18s, box-shadow .18s; }
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-dim); }
textarea.input { padding: 12px 14px; resize: vertical; min-height: 90px; }

/* ---------- мелочи ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line-2); font: 500 12px/1 var(--font-mono); color: var(--text-2); background: var(--surface); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.warn { background: #FFC857; }
.dot.bad { background: var(--danger); }
.dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent-ink); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-sm); color: transparent !important; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* уровень «ума»: пять точек */
.level { display: inline-flex; gap: 3px; vertical-align: middle; }
.level i { width: 7px; height: 7px; border-radius: 2px; background: var(--line-2); }
.level i.on { background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }

/* угловые метки «приборной» рамки */
.frame { position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); }
.frame::before, .frame::after { content: ''; position: absolute; width: 10px; height: 10px; border: 1.5px solid var(--accent-ink); opacity: .75; pointer-events: none; }
.frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--r); }
.frame::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--r); }

.grid-bg { position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 56px 56px; -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 75%); mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 75%); opacity: .55; }

/* всплывающие уведомления */
.toasts { position: fixed; z-index: 200; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--r); background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 14px; animation: toast-in .28s var(--ease); }
.toast.err { border-color: var(--danger); }
.toast.out { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* модальные окна */
.modal-wrap { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 16px; background: var(--overlay); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .18s ease; }
.modal { width: min(680px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); animation: modal-in .26s var(--ease); overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font: 600 17px/1.2 var(--font-display); letter-spacing: -.01em; flex: 1; }
.modal-body { padding: 18px; overflow: auto; overscroll-behavior: contain; }
@keyframes fade { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }

/* тач-цели ≥ 44 px на сенсорных экранах */
@media (pointer: coarse) {
  .btn-icon.sm, .btn-icon.xs { width: 44px; height: 44px; }
  .btn-sm { min-height: 44px; }
  .chip { min-height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.6s linear infinite !important; animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}
