/* VEBHOST — дизайн-система. Тёмная тема по умолчанию, светлая — [data-theme=light].
   Ориентир: tiiny.host (радиусы 28/18/12, мягкая тень, градиентная «пилюля»), плюс тёмная тема. */

:root {
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r-xs: 8px; --r-sm: 12px; --r: 16px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --accent: #7a5cff;
  --accent-2: #3d8bff;
  --accent-grad: linear-gradient(120deg, #8a5cff 0%, #5b6bff 48%, #3d9bff 100%);
  --mint: #2de2a6;
  --danger: #ff5d73;
  --warn: #ffb84d;
}

:root, :root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #090a0f;
  --bg-2: #0d0f16;
  --surface: #12141c;
  --surface-2: #181b26;
  --surface-3: #202434;
  --border: rgba(255, 255, 255, .075);
  --border-2: rgba(255, 255, 255, .14);
  --text: #f3f4fa;
  --text-2: #c6cadb;
  --muted: #8d92a8;
  --glass: rgba(18, 20, 28, .62);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --shadow-lg: 0 40px 100px rgba(0, 0, 0, .6);
  --card-glow: 0 0 0 1px var(--border), 0 30px 90px rgba(80, 70, 255, .16);
  --focus: 0 0 0 3px rgba(122, 92, 255, .38);
  --overlay: rgba(4, 5, 9, .72);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #fbfbfd;
  --bg-2: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f4f5fa;
  --surface-3: #eceef6;
  --border: #e6e8f1;
  --border-2: #d3d7e6;
  --text: #0d0f1f;
  --text-2: #3b4056;
  --muted: #6c718a;
  --glass: rgba(255, 255, 255, .72);
  --shadow-sm: 0 1px 2px rgba(15, 20, 50, .06);
  --shadow: 0 10px 40px rgba(30, 30, 90, .1);
  --shadow-lg: 0 40px 100px rgba(40, 40, 110, .18);
  --card-glow: 0 0 0 1px var(--border), 0 2px 50px rgba(30, 30, 90, .1);
  --focus: 0 0 0 3px rgba(122, 92, 255, .28);
  --overlay: rgba(14, 16, 32, .5);
  --accent: #6b4cf5;
  --mint: #12b886;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: auto; }
body {
  margin: 0; min-height: 100vh;
  font: 400 16px/1.55 var(--font);
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }
::selection { background: rgba(122, 92, 255, .4); color: #fff; }
[hidden] { display: none !important; }

.ic { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Кнопки ─────────────────────────────────────────────────────────────────── */
.btn {
  --h: 46px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: var(--h); padding: 0 22px; border-radius: var(--r-pill);
  font-weight: 650; font-size: 15px; letter-spacing: -.005em; white-space: nowrap;
  border: 1px solid transparent; user-select: none;
  transition: transform .25s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease), border-color .3s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }
.btn-sm { --h: 36px; padding: 0 16px; font-size: 14px; }
.btn-lg { --h: 56px; padding: 0 32px; font-size: 17px; }
.btn-block { width: 100%; }

.btn-primary {
  color: #fff; background: var(--accent-grad); background-size: 160% 100%; background-position: 0 0;
  box-shadow: 0 8px 28px rgba(105, 90, 255, .38), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:hover { background-position: 100% 0; box-shadow: 0 12px 38px rgba(105, 90, 255, .55), inset 0 1px 0 rgba(255, 255, 255, .3); transform: translateY(-1px); }
.btn-secondary { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); transform: translateY(-1px); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: rgba(255, 93, 115, .12); color: var(--danger); border-color: rgba(255, 93, 115, .3); }
.btn-danger:hover { background: rgba(255, 93, 115, .2); }
.btn-ink { background: var(--text); color: var(--bg); }
.btn-ink:hover { transform: translateY(-1px); opacity: .92; }

.btn .spin { display: none; width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.is-loading .spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm);
  color: var(--text-2); transition: background .25s, color .25s, transform .25s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }

/* ── Поля ───────────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 7px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; height: 46px; padding: 0 15px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.textarea { height: auto; padding: 13px 15px; min-height: 120px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input:hover, .textarea:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border-2)); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input.is-bad { border-color: var(--danger); }
.input.is-ok { border-color: var(--mint); }
.mono { font-family: var(--mono); }

.check { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; cursor: pointer; font-size: 13.5px; line-height: 1.45; color: var(--text-2); }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--border-2); background: var(--surface-2);
  display: grid; place-items: center; transition: all .25s var(--ease-spring); margin-top: 1px;
}
.check .box .ic { width: 14px; height: 14px; stroke-width: 3; color: #fff; transform: scale(0); transition: transform .25s var(--ease-spring); }
.check input:checked + .box { background: var(--accent-grad); border-color: transparent; box-shadow: 0 4px 14px rgba(105, 90, 255, .45); }
.check input:checked + .box .ic { transform: scale(1); }
.check input:focus-visible + .box { box-shadow: var(--focus); }
.check a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.check a:hover { text-decoration-color: currentColor; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; margin: 0; }
.switch i { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--border-2); transition: background .3s var(--ease), border-color .3s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .35s var(--ease-spring); }
.switch input:checked + i { background: var(--accent-grad); border-color: transparent; }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + i { opacity: .5; }

/* ── Карточки, бейджи, чипы ─────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge-accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.badge-mint { background: color-mix(in srgb, var(--mint) 16%, transparent); color: var(--mint); }
.badge-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge-danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--mint); box-shadow: 0 0 0 0 rgba(45, 226, 166, .6); animation: ping 2s infinite; }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
@keyframes ping { 70% { box-shadow: 0 0 0 9px rgba(45, 226, 166, 0); } 100% { box-shadow: 0 0 0 0 rgba(45, 226, 166, 0); } }

.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; color: var(--text-2);
}
.link-muted { color: var(--muted); transition: color .2s; }
.link-muted:hover { color: var(--text); }
.kbd { font-family: var(--mono); font-size: 12px; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--border-2); }

.grad-text { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ── Модальные окна и тосты ─────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: var(--overlay); backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
  opacity: 0; transition: opacity .3s var(--ease);
}
.overlay.is-open { opacity: 1; }
.modal {
  position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-xl); padding: 32px;
  box-shadow: var(--shadow-lg); transform: translateY(24px) scale(.96); opacity: 0;
  transition: transform .45s var(--ease), opacity .3s var(--ease);
}
.overlay.is-open .modal { transform: none; opacity: 1; }
.modal-wide { max-width: 640px; }
.modal-x { position: absolute; top: 14px; right: 14px; }
.modal h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.modal .lead { margin: 0 0 22px; color: var(--muted); font-size: 15px; }

.toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: grid; gap: 10px; max-width: min(380px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--r);
  background: var(--surface-3); border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 14px;
  transform: translateX(30px); opacity: 0; transition: transform .45s var(--ease), opacity .3s;
}
.toast.is-in { transform: none; opacity: 1; }
.toast .ic { margin-top: 1px; }
.toast.ok .ic { color: var(--mint); } .toast.err .ic { color: var(--danger); } .toast.warn .ic { color: var(--warn); }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Тёмная/светлая переключалка иконок ────────────────────────────────────── */
[data-theme='dark'] .only-light, [data-theme='light'] .only-dark { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
