﻿/* Дизайн-токены, сброс стилей и общие элементы интерфейса. */

:root {
    /* Поверхности: нейтральный тёмный, почти без цветных заливок */
    --bg-0: #0b0c0e;
    --bg-1: #0f1114;
    --bg-2: #15171b;
    --bg-3: #1c1f24;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.13);

    /* Текст */
    --text: #f4f5f7;
    --text-2: #a1a6b0;
    --text-3: #6b7280;

    /* Акцент — один, сдержанный */
    --accent: #8b9dff;
    --accent-rgb: 139, 157, 255;
    --accent-2: #b58cff;
    --danger: #f2555a;
    --danger-rgb: 242, 85, 90;
    --ok: #4ade80;
    --warn: #fbbf24;

    /* Геометрия */
    --radius-xl: 22px;
    --radius-lg: 18px;
    --radius-md: 13px;
    --radius-sm: 10px;
    --gap: clamp(8px, 0.8vw, 14px);
    /* Тени мягкие и «многослойные»: дают глубину без грязи */
    --shadow-tile: 0 2px 6px rgba(0, 0, 0, 0.28), 0 14px 38px rgba(0, 0, 0, 0.42);
    --shadow-bar: 0 2px 10px rgba(0, 0, 0, 0.3), 0 20px 48px rgba(0, 0, 0, 0.46);
    --shadow-card: 0 4px 14px rgba(0, 0, 0, 0.35), 0 32px 90px rgba(0, 0, 0, 0.62);

    /* Высота видимой области (обновляется из JS при повороте и клавиатуре) */
    --viewport-height: 100dvh;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Системные контролы (<select>, скроллбары, автозаполнение) — в тёмной теме.
       Без этого список микрофонов открывался белым с бледным текстом. */
    color-scheme: dark;

    --topbar-height: 56px;
    --controls-height: 68px;
    --controls-offset: 18px;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Text', 'Segoe UI', Roboto,
        'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    letter-spacing: -0.003em;
    color: var(--text);
    background-color: var(--bg-0);
    /* Один спокойный холодный градиент вместо «неонового» свечения */
    background-image:
        radial-gradient(1200px 620px at 50% -22%, rgba(var(--accent-rgb), 0.07), transparent 68%),
        radial-gradient(900px 520px at 100% 110%, rgba(120, 140, 255, 0.05), transparent 70%),
        linear-gradient(180deg, #0c0d10 0%, #090a0c 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv11', 'ss01';
}

img,
svg,
video {
    display: block;
    max-width: 100%;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

ul {
    list-style: none;
}

input,
select {
    font: inherit;
}

::selection {
    background: rgba(var(--accent-rgb), 0.35);
}

.is-hidden,
[hidden] {
    display: none !important;
}

.svg-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: inline-block;
    vertical-align: middle;
    flex: none;
    pointer-events: none;
}


/* ---------- Кнопки ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 20px;
    border-radius: var(--radius-md);
    font-weight: 560;
    font-size: 14.5px;
    letter-spacing: -0.01em;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.btn-primary {
    /* Мягкий градиент + светлая кромка: кнопка читается как «объёмная» */
    background: linear-gradient(180deg, #9aa7ff 0%, var(--accent) 55%, #7f92fb 100%);
    color: #0b0c0e;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        0 10px 26px rgba(var(--accent-rgb), 0.26);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #a7b2ff 0%, #97a4ff 55%, #8798fc 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 14px 34px rgba(var(--accent-rgb), 0.34);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.22);
}

.btn-primary[disabled] {
    opacity: 0.55;
    pointer-events: none;
    box-shadow: none;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    color: var(--text);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--line-strong);
}

.btn:active {
    transform: scale(0.985);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-size: 17px;
    color: var(--text-2);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid transparent;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--text);
    border-color: var(--line);
}

.chip-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 13px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.chip-button:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--line-strong);
}

/* ---------- Уведомления ---------- */

.toasts {
    position: fixed;
    top: calc(var(--safe-top) + var(--topbar-height) + 10px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 4000;
    width: min(92vw, 430px);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 15px;
    border-radius: var(--radius-md);
    background: rgba(21, 23, 27, 0.96);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-bar);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    font-size: 13.5px;
    line-height: 1.35;
    animation: toast-in 0.2s ease-out;
    pointer-events: auto;
}

.toast.is-leaving {
    animation: toast-out 0.2s ease-in forwards;
}

.toast .icon {
    font-size: 17px;
}

.toast-success {
    border-color: rgba(74, 222, 128, 0.32);
}

.toast-success .icon {
    color: var(--ok);
}

.toast-error {
    border-color: rgba(var(--danger-rgb), 0.4);
}

.toast-error .icon {
    color: var(--danger);
}

.toast-warning {
    border-color: rgba(251, 191, 36, 0.32);
}

.toast-warning .icon {
    color: var(--warn);
}

.toast-info .icon {
    color: var(--accent);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Экономный режим для слабых устройств ---------- */

html[data-tier="low"] .panel,
html[data-tier="low"] .sheet,
html[data-tier="low"] .topbar {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

html[data-tier="low"] .panel {
    background: #14161b;
}

html[data-tier="low"] .sheet {
    background: rgba(6, 7, 9, 0.88);
}

html[data-tier="low"] .tile-backdrop {
    display: none;
}

html[data-tier="low"] .tile {
    box-shadow: none;
}

html[data-tier="low"] .control,
html[data-tier="low"] .icon-btn {
    transition: none;
}

/* Уважаем системную настройку «уменьшить движение» */
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
}
/* ---------- Системные контролы и мелочи ---------- */

/* Тонкие скроллбары вместо светлых полос браузера */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Автозаполнение в полях ввода не должно заливать их белым */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px #14161b inset;
    caret-color: var(--text);
    transition: background-color 9999s ease-out;
}

/* Поля ввода: единый вид и заметный фокус */
input[type='text'],
input[type='password'],
input[type='search'],
textarea {
    font-family: inherit;
    color: var(--text);
    caret-color: var(--accent);
}

input[type='text']::placeholder,
input[type='password']::placeholder,
textarea::placeholder {
    color: var(--text-3);
}

/* Кнопки не «прилипают» к тексту и дают нажатие */
button {
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
[role='tab']:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid rgba(var(--accent-rgb), 0.65);
    outline-offset: 2px;
}