/*
 * Callboto — дизайн-система.
 * Liquid glass: backdrop-filter + блик по курсору (--mx/--my из ui.js);
 * в Chromium дополнительно преломление через SVG-фильтр #liquid-glass (класс .has-refraction на <html>).
 */

:root {
    --bg: #121212;
    --bg-2: #181818;
    --bg-3: #202020;
    --text: #ffffff;
    --text-2: rgba(255, 255, 255, 0.64);
    --text-3: rgba(255, 255, 255, 0.42);
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.14);

    --accent: rgb(173, 201, 72);
    --accent-rgb: 173, 201, 72;
    --accent-ink: #121212;
    --accent-soft: rgba(173, 201, 72, 0.14);
    --danger: #ff6b6b;
    --danger-rgb: 255, 107, 107;
    --warning: #ffc857;

    --glass-fill: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035));
    --glass-blur: blur(24px) saturate(170%);
    --glass-edge: rgba(255, 255, 255, 0.14);
    --glass-shadow: 0 1px 0 rgba(255, 255, 255, 0.16) inset, 0 -1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 40px rgba(0, 0, 0, 0.45);

    --font-display: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
    --font-text: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 22px;
    --r-xl: 30px;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
    color-scheme: dark;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

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

/* ---------- Иконки ---------- */

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 22px; height: 22px; }
.icon--xl { width: 28px; height: 28px; }

.icon-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.icon-tile--sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-tile--lg { width: 64px; height: 64px; border-radius: 20px; }
.icon-tile--danger { background: rgba(var(--danger-rgb), 0.12); color: var(--danger); }

/* ---------- Фон ---------- */

.ambient {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(255, 255, 255, 0.05), transparent 60%),
        var(--bg);
}

.ambient__blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.55;
    will-change: transform;
}

.ambient__blob--a {
    width: 520px;
    height: 520px;
    left: -120px;
    top: 10%;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.55), transparent 65%);
    animation: drift-a 22s ease-in-out infinite alternate;
}

.ambient__blob--b {
    width: 460px;
    height: 460px;
    right: -140px;
    top: 45%;
    background: radial-gradient(circle, rgba(120, 190, 170, 0.35), transparent 65%);
    animation: drift-b 26s ease-in-out infinite alternate;
}

.ambient__blob--c {
    width: 380px;
    height: 380px;
    left: 40%;
    bottom: -160px;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.25), transparent 65%);
    animation: drift-a 30s ease-in-out infinite alternate-reverse;
}

.ambient::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 70%);
}

@keyframes drift-a {
    to { transform: translate(120px, 60px) scale(1.15); }
}

@keyframes drift-b {
    to { transform: translate(-100px, -80px) scale(1.1); }
}

/* ---------- Liquid glass ---------- */

.glass {
    position: relative;
    background: var(--glass-fill);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid transparent;
    box-shadow: var(--glass-shadow);
    isolation: isolate;
}

/* Кромка стекла: светлее сверху-слева, как у Apple */
.glass::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.06) 38%, rgba(255, 255, 255, 0.04) 62%, rgba(255, 255, 255, 0.22));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* Блик, следующий за курсором */
.glass::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(360px circle at var(--mx, 50%) var(--my, -40%), rgba(255, 255, 255, 0.09), transparent 45%);
    opacity: 0;
    transition: opacity 0.4s var(--ease-out);
    pointer-events: none;
    z-index: -1;
}

.glass:hover::after {
    opacity: 1;
}

.has-refraction .glass--refract {
    -webkit-backdrop-filter: url(#liquid-glass) blur(18px) saturate(180%);
    backdrop-filter: url(#liquid-glass) blur(18px) saturate(180%);
}

/* ---------- Кнопки: glass pill ---------- */

.pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 22px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    backdrop-filter: blur(20px) saturate(170%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 -1px 0 rgba(0, 0, 0, 0.25) inset, 0 6px 20px rgba(0, 0, 0, 0.3);
    color: var(--text);
    font: 600 15px/1 var(--font-text);
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    overflow: hidden;
    isolation: isolate;
    transition: transform 0.45s var(--ease-spring), box-shadow 0.3s var(--ease-out), background 0.3s var(--ease-out), opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.pill::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.05) 45%, rgba(255, 255, 255, 0.18));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.pill::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(120px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, 0.28), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s var(--ease-out);
    z-index: -1;
    pointer-events: none;
}

.pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset, 0 -1px 0 rgba(0, 0, 0, 0.25) inset, 0 10px 28px rgba(0, 0, 0, 0.38);
}

.pill:hover::after {
    opacity: 1;
}

.pill:active {
    transform: scale(0.96);
    transition-duration: 0.12s;
}

.pill:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.45), 0 6px 20px rgba(0, 0, 0, 0.3);
}

.pill:disabled,
.pill[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.pill--accent {
    background: linear-gradient(180deg, rgba(196, 222, 104, 0.98), rgba(var(--accent-rgb), 0.95) 55%, rgba(150, 178, 52, 0.95));
    color: var(--accent-ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 -1px 0 rgba(0, 0, 0, 0.18) inset, 0 8px 28px rgba(var(--accent-rgb), 0.32);
}

.pill--accent:hover {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 -1px 0 rgba(0, 0, 0, 0.18) inset, 0 12px 36px rgba(var(--accent-rgb), 0.45);
}

.pill--accent::after {
    background: radial-gradient(120px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, 0.5), transparent 60%);
}

/* Фирменный терракотовый Claude */
.pill--claude {
    background: linear-gradient(180deg, rgba(232, 150, 120, 0.98), rgba(217, 119, 87, 0.96) 55%, rgba(193, 95, 60, 0.96));
    color: #1f1410;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 -1px 0 rgba(0, 0, 0, 0.18) inset, 0 8px 28px rgba(217, 119, 87, 0.3);
}

.pill--claude:hover {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 -1px 0 rgba(0, 0, 0, 0.18) inset, 0 12px 36px rgba(217, 119, 87, 0.45);
}

.pill--claude::after {
    background: radial-gradient(120px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, 0.45), transparent 60%);
}

.pill--danger {
    color: var(--danger);
    background: linear-gradient(180deg, rgba(var(--danger-rgb), 0.16), rgba(var(--danger-rgb), 0.07));
}

.pill--ghost {
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    color: var(--text-2);
}

.pill--ghost::before {
    opacity: 0.4;
}

.pill--ghost:hover {
    color: var(--text);
    box-shadow: none;
    background: rgba(255, 255, 255, 0.05);
}

.pill--sm {
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
    gap: 6px;
}

.pill--lg {
    height: 52px;
    padding: 0 28px;
    font-size: 16px;
}

.pill--block {
    width: 100%;
}

.pill--icon {
    width: 40px;
    height: 40px;
    padding: 0;
}

.pill .spinner {
    display: none;
}

/* Иконки внутри подписи прячутся вместе с текстом во время загрузки */
.pill__label-idle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pill.is-loading .spinner {
    display: inline-block;
}

.pill.is-loading .pill__label-idle {
    display: none;
}

/* ---------- Навигация: glass pill ---------- */

.topbar {
    position: sticky;
    top: 16px;
    z-index: 50;
    display: flex;
    justify-content: center;
    padding: 0 16px;
    pointer-events: none;
}

.nav-pill {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    width: min(100%, 1080px);
    height: 60px;
    padding: 0 8px 0 18px;
    border-radius: 999px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font: 600 18px/1 var(--font-display);
    letter-spacing: -0.02em;
    text-decoration: none;
    color: var(--text);
}

.brand__mark {
    position: relative;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.9), transparent 32%),
        radial-gradient(circle at 70% 75%, rgba(80, 110, 20, 0.9), transparent 55%),
        var(--accent);
    box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.55);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 18px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s, background 0.2s;
}

.nav-link:hover,
.nav-link.is-active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
}

.nav-spacer {
    flex: 1;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(var(--accent-rgb), 0.9), rgba(120, 150, 40, 0.9));
    color: var(--accent-ink);
    font: 700 14px/1 var(--font-display);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}

/* ---------- Сегментированный переключатель ---------- */

.segmented {
    position: relative;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.35);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) inset, 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.segmented__thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.09));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: transform 0.5s var(--ease-spring), width 0.5s var(--ease-spring);
}

.segmented__btn {
    position: relative;
    z-index: 1;
    height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-2);
    font: 600 14px/1 var(--font-text);
    cursor: pointer;
    transition: color 0.25s;
}

.segmented__btn.is-active {
    color: var(--text);
}

/* ---------- Поля ввода ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap > .icon {
    position: absolute;
    left: 16px;
    color: var(--text-3);
    pointer-events: none;
    transition: color 0.2s;
}

.input {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: rgba(24, 24, 24, 0.85);
    color: var(--text);
    font: 400 15px/1 var(--font-text);
    transition: border-color 0.2s, box-shadow 0.25s var(--ease-out), background 0.2s;
}

.input-wrap > .icon + .input {
    padding-left: 46px;
}

.input::placeholder {
    color: var(--text-3);
}

.input:hover {
    border-color: var(--line-2);
}

.input:focus {
    outline: none;
    border-color: rgba(var(--accent-rgb), 0.7);
    background: var(--bg-2);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.14);
}

.input-wrap:focus-within > .icon {
    color: var(--accent);
}

.input--code {
    height: 60px;
    text-align: center;
    font: 600 26px/1 var(--font-mono);
    letter-spacing: 0.5em;
    padding-left: 0.5em;
}

.input-action {
    position: absolute;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
}

.input-action:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--text-3);
}

.checklist li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.25s;
}

.checklist li.is-valid {
    color: var(--accent);
}

/* ---------- Карточки ---------- */

.card {
    position: relative;
    border-radius: var(--r-xl);
    background: var(--bg-2);
    border: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.card.glass {
    background: var(--glass-fill);
    border-color: transparent;
}

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

.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 14px;
    line-height: 1.45;
    animation: pop-in 0.5s var(--ease-spring) both;
}

.notice .icon {
    margin-top: 1px;
}

.notice--error {
    background: rgba(var(--danger-rgb), 0.1);
    color: #ffb3b3;
    box-shadow: 0 0 0 1px rgba(var(--danger-rgb), 0.25) inset;
}

.notice--success {
    background: rgba(var(--accent-rgb), 0.1);
    color: #d7ec8f;
    box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.25) inset;
}

.notice--info {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-2);
    box-shadow: 0 0 0 1px var(--line) inset;
}

.notice--warning {
    background: rgba(255, 200, 87, 0.08);
    color: var(--warning);
    box-shadow: 0 0 0 1px rgba(255, 200, 87, 0.28) inset;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 14px 0 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}

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

.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- ИИ-визуалы (по мотивам libraries.dev: Thinking Orbs, Voice, Border Beam) ---------- */

.orb {
    --size: 64px;
    position: relative;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95), transparent 22%),
        conic-gradient(from 0deg, rgba(var(--accent-rgb), 1), rgba(120, 200, 170, 0.9), rgba(230, 245, 170, 0.95), rgba(var(--accent-rgb), 1));
    box-shadow: 0 0 40px rgba(var(--accent-rgb), 0.45), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
    animation: orb-spin 8s linear infinite, orb-breathe 3.2s ease-in-out infinite;
}

.orb::after {
    content: "";
    position: absolute;
    inset: 12%;
    border-radius: 50%;
    background: radial-gradient(circle at 60% 65%, rgba(18, 18, 18, 0.55), transparent 70%);
    filter: blur(4px);
    animation: orb-spin 5s linear infinite reverse;
}

@keyframes orb-spin {
    to { rotate: 360deg; }
}

@keyframes orb-breathe {
    50% { scale: 1.06; box-shadow: 0 0 60px rgba(var(--accent-rgb), 0.6), 0 0 0 1px rgba(255, 255, 255, 0.2) inset; }
}

.voice-wave {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 28px;
}

.voice-wave span {
    width: 3px;
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transform-origin: center;
    animation: wave 1.1s ease-in-out infinite;
}

.voice-wave span:nth-child(2n) { animation-duration: 0.9s; }
.voice-wave span:nth-child(3n) { animation-duration: 1.3s; }
.voice-wave span:nth-child(1) { animation-delay: -0.2s; }
.voice-wave span:nth-child(2) { animation-delay: -0.5s; }
.voice-wave span:nth-child(3) { animation-delay: -0.1s; }
.voice-wave span:nth-child(4) { animation-delay: -0.7s; }
.voice-wave span:nth-child(5) { animation-delay: -0.3s; }
.voice-wave span:nth-child(6) { animation-delay: -0.9s; }
.voice-wave span:nth-child(7) { animation-delay: -0.4s; }

@keyframes wave {
    0%, 100% { transform: scaleY(0.25); opacity: 0.6; }
    50% { transform: scaleY(1); opacity: 1; }
}

@property --beam-angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

/* Блик, бегущий по рамке */
.beam {
    position: relative;
}

.beam::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(from var(--beam-angle), transparent 0 72%, rgba(var(--accent-rgb), 0.9) 84%, rgba(255, 255, 255, 0.9) 88%, transparent 92%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: beam 6s linear infinite;
    pointer-events: none;
    z-index: 2;
}

@keyframes beam {
    to { --beam-angle: 360deg; }
}

.shimmer-text {
    background: linear-gradient(100deg, var(--text-3) 30%, var(--text) 50%, var(--text-3) 70%);
    background-size: 250% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 2.4s linear infinite;
}

@keyframes shimmer {
    from { background-position: 100% 0; }
    to { background-position: -150% 0; }
}

.accent-text {
    background: linear-gradient(100deg, #e4f3a6, var(--accent) 45%, #8fd3b6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Анимации появления ---------- */

[data-reveal] {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
    filter: blur(6px);
    transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out), filter 0.9s var(--ease-out);
    transition-delay: calc(var(--i, 0) * 90ms);
}

[data-reveal].is-visible {
    opacity: 1;
    transform: none;
    filter: none;
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
}

.swap-enter {
    animation: swap-in 0.55s var(--ease-out) both;
}

@keyframes swap-in {
    from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
}

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

    [data-reveal] {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }

/* =====================================================================
   Компоненты внутренних страниц (дашборд, тарифы, админка)
   ===================================================================== */

.page {
    width: min(100%, 1080px);
    margin: 0 auto;
    padding: 40px 20px 96px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: clamp(30px, 4vw, 42px);
    letter-spacing: -0.03em;
}

.page-header p {
    margin-top: 8px;
    color: var(--text-2);
    font-size: 16px;
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stack { display: flex; flex-direction: column; gap: 20px; }
.stack--sm { gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }

.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 860px) {
    .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* Панель: основной контейнер секции */
.panel {
    position: relative;
    padding: 28px;
    border-radius: var(--r-xl);
    background: rgba(24, 24, 24, 0.72);
    border: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 50px rgba(0, 0, 0, 0.25);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.panel--glass {
    background: var(--glass-fill);
    border-color: transparent;
}

.panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.panel__title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.panel__title h2 {
    font-size: 20px;
    letter-spacing: -0.02em;
}

.panel__title p {
    margin-top: 3px;
    font-size: 14px;
    color: var(--text-2);
}

@media (max-width: 640px) {
    .panel { padding: 20px; border-radius: var(--r-lg); }
    .page { padding-top: 24px; }
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.divider {
    height: 1px;
    background: var(--line);
    border: 0;
    margin: 20px 0;
}

/* Метрики */
.stat {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    border-radius: var(--r-lg);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
}

.stat__label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
}

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

.stat__value {
    font: 600 30px/1 var(--font-display);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.stat__value small {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-3);
}

.meter {
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.meter__fill {
    height: 100%;
    width: var(--value, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.7), var(--accent));
    box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.5);
    transition: width 1.2s var(--ease-out);
}

.meter--danger .meter__fill {
    background: linear-gradient(90deg, rgba(var(--danger-rgb), 0.7), var(--danger));
    box-shadow: 0 0 12px rgba(var(--danger-rgb), 0.5);
}

/* Бейджи */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-2);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.badge .icon { width: 14px; height: 14px; }
.badge--accent { background: rgba(var(--accent-rgb), 0.14); color: var(--accent); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.25) inset; }
.badge--danger { background: rgba(var(--danger-rgb), 0.12); color: var(--danger); box-shadow: 0 0 0 1px rgba(var(--danger-rgb), 0.25) inset; }
.badge--warning { background: rgba(255, 200, 87, 0.12); color: var(--warning); box-shadow: 0 0 0 1px rgba(255, 200, 87, 0.25) inset; }
.badge--info { background: rgba(120, 190, 255, 0.12); color: #9fd0ff; box-shadow: 0 0 0 1px rgba(120, 190, 255, 0.22) inset; }

/* Таблицы */
.table-wrap {
    overflow-x: auto;
    margin: 0 -8px;
    padding: 0 8px;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table tbody tr {
    transition: background 0.2s;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* Пустое состояние */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 36px 20px;
    text-align: center;
}

.empty h3 { font-size: 20px; }
.empty p { max-width: 420px; color: var(--text-2); }

/* Текстовая область и селект */
.textarea {
    width: 100%;
    min-height: 120px;
    padding: 14px 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: rgba(24, 24, 24, 0.85);
    color: var(--text);
    font: 400 15px/1.55 var(--font-text);
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.25s var(--ease-out);
}

.textarea:focus {
    outline: none;
    border-color: rgba(var(--accent-rgb), 0.7);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.14);
}

.textarea::placeholder { color: var(--text-3); }

.select {
    width: 100%;
    height: 50px;
    padding: 0 44px 0 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: rgba(24, 24, 24, 0.85) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 16px center;
    color: var(--text);
    font: 400 15px/1 var(--font-text);
    appearance: none;
}

.select:focus {
    outline: none;
    border-color: rgba(var(--accent-rgb), 0.7);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.14);
}

.field__hint {
    font-size: 13px;
    color: var(--text-3);
}

/* Выпадающий список на стекле */
.dropdown {
    position: relative;
}

.dropdown__toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: rgba(24, 24, 24, 0.85);
    color: var(--text);
    font: 400 15px/1 var(--font-text);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.25s var(--ease-out);
}

.dropdown__toggle > span { flex: 1; }
.dropdown__toggle .icon:last-child { color: var(--text-3); transition: transform 0.35s var(--ease-spring); }
.dropdown.is-open .dropdown__toggle { border-color: rgba(var(--accent-rgb), 0.7); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.14); }
.dropdown.is-open .dropdown__toggle .icon:last-child { transform: rotate(180deg); }

.dropdown__menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    z-index: 40;
    max-height: 280px;
    padding: 6px;
    overflow-y: auto;
    border-radius: var(--r-lg);
    background: rgba(30, 30, 30, 0.82);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 20px 50px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top center;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.35s var(--ease-spring);
}

.dropdown.is-open .dropdown__menu {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

/* В модальных окнах списки стоят внизу формы — открываем вверх, чтобы не обрезались листом */
.modal .dropdown__menu {
    top: auto;
    bottom: calc(100% + 8px);
    transform: translateY(6px) scale(0.98);
    transform-origin: bottom center;
}

.dropdown__option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: 400 14px/1.2 var(--font-text);
    text-align: left;
    cursor: pointer;
}

.dropdown__option:hover { background: rgba(255, 255, 255, 0.07); }
.dropdown__option.is-selected { background: rgba(var(--accent-rgb), 0.14); color: var(--accent); }
.dropdown__option > span { flex: 1; }
.dropdown__option small { color: var(--text-3); font-size: 12px; }

/* Модальные окна: стеклянный лист с пружинящим появлением */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-out);
}

.modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.modal__sheet {
    width: min(100%, 560px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 28px;
    border-radius: var(--r-xl);
    background: linear-gradient(180deg, rgba(40, 40, 40, 0.86), rgba(24, 24, 24, 0.9));
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    backdrop-filter: blur(30px) saturate(180%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 1px 0 rgba(255, 255, 255, 0.16) inset, 0 40px 80px rgba(0, 0, 0, 0.6);
    transform: translateY(24px) scale(0.96);
    transition: transform 0.5s var(--ease-spring);
}

.modal.is-open .modal__sheet {
    transform: none;
}

.modal__sheet--sm { width: min(100%, 420px); }
.modal__sheet--lg { width: min(100%, 720px); }

.modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.modal__head h3 { font-size: 22px; }
.modal__head p { margin-top: 4px; color: var(--text-2); font-size: 14px; }

.modal__body {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.modal__actions--split {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 640px) {
    .modal { align-items: flex-end; padding: 0; }
    .modal__sheet { width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; }
    .modal__actions { flex-direction: column-reverse; }
    .modal__actions .pill { width: 100%; }
}

body.has-modal { overflow: hidden; }

/* Всплывающие уведомления */
.toast-stack {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(92vw, 460px);
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(36, 36, 36, 0.86);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 16px 40px rgba(0, 0, 0, 0.5);
    font-size: 14px;
    pointer-events: auto;
    animation: toast-in 0.5s var(--ease-spring) both;
}

.toast.is-leaving { animation: toast-out 0.3s var(--ease-out) forwards; }
.toast--success .icon { color: var(--accent); }
.toast--error .icon { color: var(--danger); }
.toast--info .icon { color: #9fd0ff; }

@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* Блоки кода */
.code-block {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
    background: rgba(12, 12, 12, 0.7);
}

.code-block__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 6px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.code-block pre {
    margin: 0;
    padding: 14px;
    font: 13px/1.6 var(--font-mono);
    color: var(--text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.code-block .hl { color: var(--accent); }

/* Навигация: пользователь в правой части */
.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 4px;
}

.nav-user__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    line-height: 1.1;
}

.nav-user__meta strong {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.nav-user__meta span {
    font-size: 12px;
    color: var(--text-3);
}

@media (max-width: 1080px) {
    .nav-user__meta { display: none; }
}

@media (max-width: 960px) {
    .nav-link span { display: none; }
}

@media (max-width: 860px) {
    .nav-user__meta { display: none; }
    .nav-link span { display: none; }
    .nav-links { margin-left: 8px; }
    .nav-pill .pill--ghost span { display: none; }
}

@media (max-width: 480px) {
    .nav-pill { gap: 2px; padding: 0 6px 0 14px; }
    .brand { font-size: 16px; }
    .nav-links { margin-left: 4px; }
    .nav-link { padding: 0 10px; }
    .nav-user .avatar { display: none; }
    .brand__name { display: none; }
}

/* ---------- Подсказки онбординга ---------- */

.coach {
    position: fixed;
    z-index: 90;
    width: min(320px, calc(100vw - 32px));
    padding: 16px 16px 14px;
    border-radius: var(--r-lg);
    background: linear-gradient(180deg, rgba(48, 48, 48, 0.82), rgba(28, 28, 28, 0.86));
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.3) inset, 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 24px 60px rgba(0, 0, 0, 0.55);
    animation: coach-in 0.55s var(--ease-spring) both;
}

.coach::before {
    content: "";
    position: absolute;
    top: -7px;
    left: calc(var(--arrow-left, 28px) - 7px);
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: rgba(48, 48, 48, 0.95);
    box-shadow: -1px -1px 0 rgba(var(--accent-rgb), 0.3);
    transform: rotate(45deg);
}

.coach--above::before {
    top: auto;
    bottom: -7px;
    background: rgba(28, 28, 28, 0.95);
    box-shadow: 1px 1px 0 rgba(var(--accent-rgb), 0.3);
}

.coach--inside::before {
    display: none;
}

.coach.is-leaving,
.coach-hint.is-leaving {
    animation: coach-out 0.25s var(--ease-out) forwards;
}

.coach__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.coach__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(var(--accent-rgb), 0.16);
    color: var(--accent);
}

.coach__step {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
}

.coach__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
}

.coach__close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.coach__title {
    display: block;
    font: 600 16px/1.3 var(--font-display);
    letter-spacing: -0.01em;
}

.coach__body {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-2);
}

.coach__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

/* Подсвеченный элемент, к которому относится подсказка */
.coach-target {
    position: relative;
    z-index: 5;
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.55), 0 0 0 8px rgba(var(--accent-rgb), 0.12), 0 20px 50px rgba(0, 0, 0, 0.35) !important;
    border-radius: var(--r-xl);
    transition: box-shadow 0.4s var(--ease-out);
    animation: coach-ring 2.4s ease-in-out infinite;
}

@keyframes coach-ring {
    50% { box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.8), 0 0 0 12px rgba(var(--accent-rgb), 0.06), 0 20px 50px rgba(0, 0, 0, 0.35); }
}

/* Если нужный элемент за пределами экрана — плавающая pill внизу */
.coach-hint {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 90;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: rgba(40, 40, 40, 0.82);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.35) inset, 0 16px 40px rgba(0, 0, 0, 0.5);
    color: var(--text);
    font: 600 14px/1 var(--font-text);
    cursor: pointer;
    transform: translateX(-50%);
    animation: hint-in 0.55s var(--ease-spring) both;
}

.coach-hint .icon:first-child {
    color: var(--accent);
}

.coach-hint .icon:last-child {
    animation: hint-bounce 1.6s ease-in-out infinite;
}

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

@keyframes coach-out {
    to { opacity: 0; transform: translateY(6px) scale(0.97); }
}

@keyframes hint-in {
    from { opacity: 0; transform: translate(-50%, 16px) scale(0.95); }
}

@keyframes hint-bounce {
    50% { transform: translateY(3px); }
}

@media (max-width: 640px) {
    .coach-hint {
        bottom: 96px;
        max-width: calc(100vw - 32px);
    }
}
