/* Vibe RGB. Правила оформления: web/DESIGN.md, поведение: web/UIUX.md. */

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(fonts/onest-cyrillic.woff2) format("woff2");
  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: 400 800;
  font-display: swap;
  src: url(fonts/onest-latin.woff2) format("woff2");
  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: #000;
  --panel: #0a0a0a;
  --inset: #141414;
  --led-off: #1c1c1c;
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .18);
  /* Текст. --faint только для декора: 3,9:1 на чёрном. */
  --fg: #ededed;
  --dim: #a1a1a1;
  --faint: #6b6b6b;
  /* Семантика состояния. */
  --good: #50c878;
  --warn: #f5a623;
  --bad: #ff5a5f;
  /* Акцент берёт цвет эффекта выбранной части ленты, app.js подменяет оба значения. */
  --accent: #ffc46b;
  --on-accent: #000;
  /* Срез двух углов: форма главных кнопок, общая с сайтом Skyshard Cloud. */
  --cut: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pad: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 400 15px/1.5 var(--font); min-height: 100vh; }
.hidden { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 19px; line-height: 1.25; font-weight: 650; text-wrap: balance; }
h3 { font-size: 15px; line-height: 1.3; font-weight: 600; color: var(--dim); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* ---------- Вход ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); }
.login-card { width: min(340px, 100%); display: flex; flex-direction: column; }
.mark { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin-bottom: 32px; }
.mark i { height: 10px; background: var(--c); }
.mark i:nth-child(1) { --c: #38d7e8; } .mark i:nth-child(2) { --c: #23c262; }
.mark i:nth-child(3) { --c: #3f6fe6; } .mark i:nth-child(4) { --c: #e8322a; }
.mark i:nth-child(5) { --c: #f2b81c; } .mark i:nth-child(6) { --c: #ff6a1c; }
.mark i:nth-child(7) { --c: #9b4ee8; } .mark i:nth-child(8) { --c: #c48af0; }
.mark i:nth-child(9) { --c: #3fbfa6; } .mark i:nth-child(10) { --c: #ffd25a; }
.login h1 { font-size: 28px; line-height: 1.15; font-weight: 700; }
.login-lead { color: var(--dim); margin: 6px 0 32px; }
.field-label { font-size: 13px; color: var(--dim); margin-bottom: 8px; }
.login input { height: 48px; padding: 0 14px; background: var(--inset); border: 1px solid var(--line-strong);
  border-radius: 0; font-size: 17px; outline: none; }
.login input:focus-visible { border-color: var(--fg); }
.btn-primary { height: 48px; margin-top: 16px; border: 0; background: var(--fg); color: #000; font-weight: 650;
  font-size: 16px; clip-path: var(--cut); transition: background-color .12s ease; }
.btn-primary:focus-visible { outline: none; box-shadow: inset 0 0 0 3px #000, inset 0 0 0 5px var(--fg); }
.btn-primary:disabled { opacity: .5; }
.login-error { color: var(--bad); min-height: 24px; margin-top: 12px; font-size: 14px; }

/* ---------- Каркас ---------- */
.app { max-width: 1200px; margin: 0 auto; padding: 0 max(var(--pad), env(safe-area-inset-right)) 48px max(var(--pad), env(safe-area-inset-left)); }

.bar { display: flex; align-items: center; gap: 12px; height: 56px; padding-top: env(safe-area-inset-top);
  box-sizing: content-box; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: flex; gap: 2px; }
.brand-mark i { width: 6px; height: 14px; background: var(--accent); }
.brand-mark i:nth-child(2) { opacity: .7; }
.brand-mark i:nth-child(3) { opacity: .4; }
.brand-name { font-weight: 700; font-size: 17px; white-space: nowrap; }
.link { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--dim);
  font-size: 13px; white-space: nowrap; }
.link span:last-child { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; flex: none; background: var(--faint); }
.dot.ok { background: var(--good); }
.dot.warn { background: var(--warn); }
.icon-btn { width: 44px; height: 44px; margin-right: -10px; flex: none; display: grid; place-items: center;
  background: none; border: 0; }
.icon-btn svg { width: 20px; height: 20px; fill: var(--dim); transition: fill .12s ease; }

/* ---------- Лента ---------- */
.strip { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 8px 0 12px;
  margin: 0 calc(-1 * var(--pad)); padding-left: var(--pad); padding-right: var(--pad); }
.zones { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.zones.single { grid-template-columns: 1fr; }
.zone { --zone-accent: var(--accent); position: relative; min-width: 0; padding: 0 0 10px; text-align: left;
  background: none; border: 0; display: flex; flex-direction: column; gap: 8px; }
.zone .leds { display: block; width: 100%; height: 22px; background: var(--panel); }
.zone::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line); }
.zone.sel::after { background: var(--zone-accent); }
.zone-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.zone-line b { font-size: 17px; font-weight: 650; }
.zone-range { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone-summary { display: block; margin-top: -6px; color: var(--dim); font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.zone.sel .zone-summary { color: var(--fg); }
.zone:disabled { cursor: default; }
.zone:focus-visible { outline-offset: 4px; }

/* ---------- Рабочая область ---------- */
.workspace { display: flex; flex-direction: column; gap: 32px; padding-top: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 20px var(--pad); }
.panel > h2 { margin-bottom: 16px; }
.hint { color: var(--dim); font-size: 13px; margin-top: 2px; }

.zone-head { display: flex; align-items: flex-start; gap: 16px; }
.zone-text { flex: 1; min-width: 0; }
.zone-head h2 { font-size: 24px; line-height: 1.2; font-weight: 700; }
.power { flex: none; display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 18px 0 14px;
  border: 0; background: var(--inset); color: var(--fg); font-weight: 600; clip-path: var(--cut);
  box-shadow: inset 0 0 0 1px var(--line-strong); transition: background-color .15s ease, color .15s ease; }
.power svg { width: 20px; height: 20px; fill: currentColor; }
.power.on { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.power:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--fg), inset 0 0 0 4px var(--bg); }
.power:disabled { opacity: .45; }

.now { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 20px 0 8px;
  padding-top: 16px; border-top: 1px solid var(--line); }
.now-name { font-size: 17px; font-weight: 600; }
.now-sub { color: var(--dim); font-size: 14px; }

/* Ползунок из сегментов: каждый сегмент читается как светодиод. */
.slider { padding: 12px 0 4px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.slider-head label { color: var(--dim); }
.slider-head b { font-weight: 600; font-size: 16px; }
.slider-track { position: relative; }
.blocks { display: flex; gap: 2px; height: 28px; touch-action: none; }
.blocks i { flex: 1; background: var(--led-off); transition: background-color .12s ease; }
.blocks i.on { background: var(--accent); }
.slider-track input, .hue input { position: absolute; inset: -8px 0; width: 100%; height: calc(100% + 16px); margin: 0;
  opacity: 0; cursor: pointer; touch-action: pan-y; }
.slider-track input:disabled, .hue input:disabled { cursor: default; }
.slider-track:focus-within, .hue:focus-within { outline: 2px solid var(--fg); outline-offset: 4px; }
.slider-track:has(input:disabled) .blocks { opacity: .45; }

/* ---------- Эффекты ---------- */
.effects > h2 { margin-bottom: 4px; }
.effects h3 { margin: 20px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { position: relative; padding: 6px 6px 8px; background: var(--panel); border: 1px solid var(--line);
  text-align: left; min-width: 0; transition: border-color .12s ease; }
.tile canvas { display: block; width: 100%; aspect-ratio: 102 / 60; image-rendering: pixelated; background: #050505; }
.tile span { display: block; margin-top: 8px; padding: 0 2px; font-size: 13px; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile.sel span { color: var(--fg); font-weight: 600; }
.tile:disabled { opacity: .55; }

/* ---------- Цвет и Авто ---------- */
.swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.sw { aspect-ratio: 1; min-height: 32px; padding: 0; border: 0; background: var(--c); }
.sw.sel { outline: 2px solid var(--fg); outline-offset: 3px; }
.sw:disabled { opacity: .45; }
.hue { position: relative; height: 32px; margin-top: 20px; touch-action: none;
  background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.hue:has(input:disabled) { opacity: .45; }
.hue-mark { position: absolute; top: -4px; bottom: -4px; width: 6px; margin-left: -3px; background: #fff;
  box-shadow: 0 0 0 2px #000; pointer-events: none; }

.toggle { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 56px; padding: 8px 0; cursor: pointer; }
.toggle small { display: block; color: var(--dim); font-size: 13px; margin-top: 2px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle i { position: relative; flex: none; width: 48px; height: 28px; background: var(--led-off);
  transition: background-color .15s ease; }
.toggle i::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; background: var(--dim);
  transition: transform .15s ease, background-color .15s ease; }
.toggle input:checked + i { background: color-mix(in srgb, var(--accent) 35%, var(--led-off)); }
.toggle input:checked + i::after { transform: translateX(20px); background: var(--accent); }
.toggle input:focus-visible + i { outline: 2px solid var(--fg); outline-offset: 3px; }
.toggle:has(input:disabled) { cursor: default; }
.toggle input:disabled + i { opacity: .45; }
#autoSection .toggle { margin-top: 8px; border-top: 1px solid var(--line); }

/* ---------- Вся лента ---------- */
.sync-toggle { padding-top: 0; }
.whole #hardwareSliders { border-top: 1px solid var(--line); margin-top: 4px; }
.facts { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; text-align: right; }

/* ---------- Сообщения ---------- */
.banner { border: 1px solid var(--line-strong); background: var(--panel); padding: 14px var(--pad); color: var(--dim); }
.banner b { display: block; color: var(--fg); font-weight: 600; margin-bottom: 2px; }
.banner.warn b { color: var(--warn); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 5; max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; background: var(--inset);
  border: 1px solid var(--line-strong); font-size: 14px; }

/* ---------- Наведение: только там, где есть мышь ---------- */
@media (hover: hover) {
  .tile:not(:disabled):not(.sel):hover { border-color: var(--line-strong); background: var(--inset); }
  .zone:not(:disabled):not(.sel):hover::after { background: var(--line-strong); }
  .zone:not(:disabled):hover .zone-summary { color: var(--fg); }
  .power:not(:disabled):not(.on):hover { background: #1d1d1d; }
  .btn-primary:not(:disabled):hover { background: #fff; }
  .icon-btn:hover svg { fill: var(--fg); }
  .sw:not(:disabled):not(.sel):hover { outline: 1px solid var(--line-strong); outline-offset: 3px; }
}

/* ---------- Узкие телефоны: iPhone SE, 8 ---------- */
@media (max-width: 380px) {
  :root { --pad: 12px; }
  .zone-range { display: none; }
  .zone-head h2 { font-size: 22px; }
  .power { padding: 0 14px 0 12px; }
  .swatches { gap: 6px; }
}

/* ---------- Планшет и ПК ---------- */
@media (min-width: 720px) {
  :root { --pad: 24px; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .zone .leds { height: 26px; }
}
@media (min-width: 1000px) {
  .bar { height: 72px; }
  .strip { padding-top: 4px; padding-bottom: 16px; }
  .zone .leds { height: 30px; }
  .workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; column-gap: 32px; row-gap: 16px;
    grid-template-areas: "banner banner" "fx zone" "fx tune" "fx whole" "fx ."; align-items: start;
    grid-template-rows: auto auto auto auto 1fr; padding-top: 24px; }
  .banner { grid-area: banner; }
  .zone-panel { grid-area: zone; }
  .effects { grid-area: fx; }
  .tune { grid-area: tune; }
  .whole { grid-area: whole; }
  .panel { padding: 20px 24px; }
  .effects > h2 { font-size: 22px; }
}
@media (min-width: 1180px) {
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .workspace { grid-template-columns: minmax(0, 1fr) 400px; column-gap: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
