/* ═══ Reset + shared form controls ═══ */

/* Inter, self-hosted (vendor/fonts). Variable weight 400-800, split by
   script so a Latin-only user never downloads Cyrillic. Self-hosting removes
   the Google Fonts dependency: no CDN, no ad-blocker variable, works offline
   from the service worker precache. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../vendor/fonts/inter-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../vendor/fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../vendor/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../vendor/fonts/inter-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;
}


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

html, body {
  /* pan only: excluding pinch-zoom here is what Safari 13+ actually honors,
     unlike the viewport meta; double-tap zoom dies with it too */
  touch-action: pan-x pan-y;
  overscroll-behavior-x: none;   /* kills swipe-navigation on Android Chrome */
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
  font-synthesis-weight: none;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-1);
  background: var(--bg-0);
  /* Text rendering is a PREFERENCE, not a fact: how glyphs land depends on the
     panel, the OS scaling and the eye. Subpixel (ClearType) is crisper on most
     Windows LCDs but can fringe on dark backgrounds; grayscale is smoother but
     thinner. Settings > Appearance drives data-text on <html>; "auto" leaves
     the platform default alone. */
}

:root[data-text="smooth"] body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
:root[data-text="sharp"] body {
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: auto;
}

.app { height: 100%; display: flex; flex-direction: column; }

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img, canvas, video { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--stroke); }
::-webkit-scrollbar-track { background: transparent; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-m);
  border: 1px solid var(--stroke); background: var(--bg-2); color: var(--text-1);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast), transform var(--dur-fast);
}
.btn:hover { background: var(--bg-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary {
  background: var(--accent-grad); border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px rgba(79, 124, 255, .35);
}
.btn-primary:hover { background: var(--accent-grad); filter: brightness(1.1); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-1); }

.btn-danger { color: var(--bad); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 14%, transparent); border-color: var(--bad); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: var(--radius-s); }
.btn-icon { padding: 7px; border-radius: var(--radius-s); }
.btn-icon svg { width: 17px; height: 17px; }

/* ── Inputs ── */
.input, .select, .textarea {
  width: 100%; padding: 8px 11px; border-radius: var(--radius-s);
  border: 1px solid var(--stroke); background: var(--bg-2); color: var(--text-1);
  outline: none; transition: border-color var(--dur-fast);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 64px; }
.select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }

/* ── Slider row (label · track · value chip, per reference design) ── */
.slider-row { display: grid; grid-template-columns: 86px 1fr 52px; align-items: center; gap: 10px; padding: 3px 0; }
.slider-row > label { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slider-row > output, .slider-row > .slider-val { font-size: 12px; color: var(--text-2); background: var(--bg-2); border: 1px solid var(--stroke-soft); border-radius: var(--radius-s); text-align: center; padding: 3px 4px; font-variant-numeric: tabular-nums; width: 100%; min-width: 0; font-family: inherit; }
.slider-row > .slider-val:focus { outline: none; border-color: var(--accent); color: var(--text-1); }

input[type="range"].range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; cursor: pointer; margin: 0;
  --fill: 0%;
}
input[type="range"].range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--bg-3) var(--fill));
}
input[type="range"].range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); margin-top: -5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
input[type="range"].range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--bg-3); }
input[type="range"].range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"].range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }

/* ── Segmented control ── */
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--stroke); border-radius: var(--radius-m); padding: 3px; gap: 2px; }
.seg > button {
  border: 0; background: transparent; color: var(--text-2); padding: 5px 12px;
  border-radius: calc(var(--radius-m) - 4px); cursor: pointer; font-size: 12.5px; line-height: 1.3;
  display: inline-flex; align-items: center; gap: 6px; transition: background var(--dur-fast), color var(--dur-fast);
}
.seg > button svg { width: 15px; height: 15px; }
.seg > button:hover { color: var(--text-1); }
.seg > button.on { background: var(--bg-3); color: var(--text-1); box-shadow: var(--shadow-1); }

/* ── Checkbox / switch ── */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; color: var(--text-1); }
.check input { display: none; }
.check .box {
  width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--stroke); background: var(--bg-2);
  display: inline-flex; align-items: center; justify-content: center; transition: background var(--dur-fast), border-color var(--dur-fast); flex: none;
}
.check .box svg { width: 11px; height: 11px; color: #fff; opacity: 0; transform: scale(.6); transition: all var(--dur-fast); }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box svg { opacity: 1; transform: scale(1); }

.switch { position: relative; width: 34px; height: 20px; border-radius: 10px; background: var(--bg-3); border: 1px solid var(--stroke); cursor: pointer; transition: background var(--dur-fast); flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: all var(--dur-fast); }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on::after { left: 16px; background: #fff; }

/* ── Chips ── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--stroke); background: var(--bg-2); color: var(--text-2);
  font-size: 12.5px; cursor: pointer; user-select: none; white-space: nowrap;
  transition: all var(--dur-fast);
}
.chip:hover { color: var(--text-1); border-color: var(--text-3); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ── Utility ── */
.muted { color: var(--text-2); }
.tiny { font-size: 12px; color: var(--text-3); }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
hr.sep { border: 0; border-top: 1px solid var(--stroke-soft); margin: 12px 0; }
