/*
 * CLEARLi — platform chrome (userbar, practice header, floating toolbar)
 * Visual polish only — DOM, hooks, and behavior unchanged.
 */

/* ── Shared: grouped toolbar pill ── */
.elite-userbar__actions .elite-toolbar-actions,
.practice-m-chrome__trailing .elite-toolbar-actions,
.rc-m-chrome__trailing .elite-toolbar-actions,
.elite-floating-toolbar .elite-toolbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(75, 131, 255, 0.16);
    box-shadow: var(--clearli-inset-hi), 0 2px 12px rgba(7, 43, 110, 0.06);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
}

[data-theme="dark"] .elite-userbar__actions .elite-toolbar-actions,
[data-theme="dark"] .practice-m-chrome__trailing .elite-toolbar-actions,
[data-theme="dark"] .rc-m-chrome__trailing .elite-toolbar-actions,
[data-theme="dark"] .elite-floating-toolbar .elite-toolbar-actions {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(124, 199, 255, 0.18);
    box-shadow: var(--clearli-inset-hi), var(--glow-soft);
}

.elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip,
.practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip,
.rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip,
.elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    max-width: 36px;
    max-height: 36px;
    border: none;
    background: transparent;
    box-shadow: none;
    color: var(--blue-bright);
}

.elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip:hover,
.elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip:focus-visible,
.elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip[aria-expanded="true"],
.practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip:hover,
.practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip:focus-visible,
.practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip[aria-expanded="true"],
.rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip:hover,
.rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip:focus-visible,
.rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip[aria-expanded="true"],
.elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip:hover,
.elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip:focus-visible,
.elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip[aria-expanded="true"] {
    background: rgba(75, 131, 255, 0.14);
    border: none;
    transform: none;
    box-shadow: none;
    color: var(--blue);
}

[data-theme="dark"] .elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip,
[data-theme="dark"] .practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip,
[data-theme="dark"] .rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip,
[data-theme="dark"] .elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip {
    color: #8ec0ff;
}

[data-theme="dark"] .elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip:hover,
[data-theme="dark"] .elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip:focus-visible,
[data-theme="dark"] .elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip[aria-expanded="true"],
[data-theme="dark"] .practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip:hover,
[data-theme="dark"] .practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip:focus-visible,
[data-theme="dark"] .practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip[aria-expanded="true"],
[data-theme="dark"] .rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip:hover,
[data-theme="dark"] .rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip:focus-visible,
[data-theme="dark"] .rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip[aria-expanded="true"],
[data-theme="dark"] .elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip:hover,
[data-theme="dark"] .elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip:focus-visible,
[data-theme="dark"] .elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip[aria-expanded="true"] {
    background: rgba(124, 199, 255, 0.16);
    color: #b8d9ff;
}

/* Subtle dividers between chips inside the group */
.elite-toolbar-actions .elite-toolbar-chip + .elite-toolbar-chip {
    box-shadow: inset 1px 0 0 rgba(75, 131, 255, 0.12);
}

[data-theme="dark"] .elite-toolbar-actions .elite-toolbar-chip + .elite-toolbar-chip {
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.08);
}

/* ── App mark — glass frame in chrome ── */
.elite-userbar__brand .clearli-mark--header,
.practice-m-chrome__logo .clearli-mark--sm,
.rc-m-chrome__logo .clearli-mark--sm {
    padding: 4px;
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.38));
    border: 1px solid rgba(75, 131, 255, 0.14);
    box-shadow: var(--clearli-inset-hi), 0 4px 16px rgba(7, 43, 110, 0.07);
    box-sizing: border-box;
}

[data-theme="dark"] .elite-userbar__brand .clearli-mark--header,
[data-theme="dark"] .practice-m-chrome__logo .clearli-mark--sm,
[data-theme="dark"] .rc-m-chrome__logo .clearli-mark--sm {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
    border-color: rgba(124, 199, 255, 0.2);
    box-shadow: var(--clearli-inset-hi), 0 4px 18px rgba(0, 0, 0, 0.28);
}

.practice-m-chrome__logo .clearli-mark--sm,
.rc-m-chrome__logo .clearli-mark--sm {
    width: 40px;
    height: 40px;
}

/* ── Platform userbar (home, billing, menus) ── */
body.elite-body .elite-userbar,
body.elite-body .elite-userbar--app {
    position: sticky;
    top: 0;
    z-index: 120;
    isolation: isolate;
    overflow: visible;
    padding: calc(12px + env(safe-area-inset-top, 0px)) clamp(16px, 3vw, 28px) 12px;
    border-bottom: 1px solid rgba(75, 131, 255, 0.14);
    background:
        linear-gradient(
            112deg,
            rgba(158, 125, 244, 0.16) 0%,
            rgba(75, 131, 255, 0.11) 34%,
            rgba(103, 216, 200, 0.09) 66%,
            rgba(244, 122, 42, 0.07) 100%
        ),
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.97) 0%,
            rgba(255, 251, 245, 0.93) 52%,
            rgba(248, 241, 232, 0.9) 100%
        );
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.92),
        0 8px 32px rgba(7, 43, 110, 0.08),
        0 2px 8px rgba(75, 131, 255, 0.06);
}

/* Ambient bloom — washes the full bar, not a hairline strip */
body.elite-body .elite-userbar::before,
body.elite-body .elite-userbar--app::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(
            ellipse 90% 120% at 12% -30%,
            rgba(124, 199, 255, 0.28) 0%,
            transparent 58%
        ),
        radial-gradient(
            ellipse 70% 100% at 88% -20%,
            rgba(158, 125, 244, 0.2) 0%,
            transparent 55%
        ),
        radial-gradient(
            ellipse 60% 80% at 50% 120%,
            rgba(103, 216, 200, 0.12) 0%,
            transparent 62%
        );
    pointer-events: none;
    z-index: 0;
}

/* Crisp brand edge along the bottom of the chrome */
body.elite-body .elite-userbar::after,
body.elite-body .elite-userbar--app::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        rgba(103, 216, 200, 0.55) 0%,
        rgba(75, 131, 255, 0.75) 28%,
        rgba(158, 125, 244, 0.7) 52%,
        rgba(244, 122, 42, 0.55) 78%,
        rgba(103, 216, 200, 0.45) 100%
    );
    opacity: 0.72;
    pointer-events: none;
    z-index: 1;
}

body.elite-body .elite-userbar > *,
body.elite-body .elite-userbar--app > * {
    position: relative;
    z-index: 2;
}

[data-theme="dark"] body.elite-body .elite-userbar,
[data-theme="dark"] body.elite-body .elite-userbar--app {
    border-bottom-color: rgba(124, 199, 255, 0.16);
    background:
        linear-gradient(
            112deg,
            rgba(158, 125, 244, 0.18) 0%,
            rgba(38, 119, 255, 0.14) 38%,
            rgba(103, 216, 200, 0.08) 68%,
            rgba(244, 122, 42, 0.06) 100%
        ),
        linear-gradient(
            180deg,
            rgba(14, 26, 48, 0.96) 0%,
            rgba(9, 18, 36, 0.94) 55%,
            rgba(7, 14, 28, 0.92) 100%
        );
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 36px rgba(0, 0, 0, 0.42),
        0 0 40px rgba(38, 119, 255, 0.08);
}

[data-theme="dark"] body.elite-body .elite-userbar::before,
[data-theme="dark"] body.elite-body .elite-userbar--app::before {
    background:
        radial-gradient(
            ellipse 85% 110% at 15% -25%,
            rgba(38, 119, 255, 0.22) 0%,
            transparent 58%
        ),
        radial-gradient(
            ellipse 65% 95% at 90% -15%,
            rgba(158, 125, 244, 0.18) 0%,
            transparent 55%
        );
}

[data-theme="dark"] body.elite-body .elite-userbar::after,
[data-theme="dark"] body.elite-body .elite-userbar--app::after {
    opacity: 0.85;
    height: 2px;
}

body.elite-body .elite-userbar__brand {
    gap: 12px;
}

body.elite-body .elite-userbar__actions {
    gap: 10px;
    overflow: visible;
}

body.elite-body .elite-userbar__cluster {
    overflow: visible;
}

/* Home / menus — chips mounted directly on __actions (no inner wrapper) */
body.elite-body .elite-userbar__cluster > .elite-toolbar-chip {
    border: 1px solid rgba(75, 131, 255, 0.18);
    background: rgba(255, 255, 255, 0.52);
    box-shadow: var(--clearli-inset-hi), 0 2px 12px rgba(7, 43, 110, 0.07);
}

[data-theme="dark"] body.elite-body .elite-userbar__cluster > .elite-toolbar-chip {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(124, 199, 255, 0.2);
    box-shadow: var(--clearli-inset-hi), var(--glow-soft);
}

body.elite-body .elite-userbar__cluster > .elite-toolbar-chip + .elite-toolbar-chip {
    margin-inline-start: -6px;
}

body.elite-body .elite-userbar__logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, 0.42);
    color: var(--ink-muted);
    text-decoration: none;
    font-size: 0.88em;
    font-weight: 600;
    box-shadow: var(--clearli-inset-hi);
    transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

body.elite-body .elite-userbar__logout:hover {
    color: var(--ink);
    border-color: rgba(75, 131, 255, 0.28);
    background: rgba(75, 131, 255, 0.08);
}

[data-theme="dark"] body.elite-body .elite-userbar__logout {
    background: rgba(255, 255, 255, 0.06);
}

/* ── Practice mobile chrome (SC / RE / RC) ── */
@media (max-width: 1024px) {
    .practice-m-chrome {
        position: sticky;
        top: 0;
        z-index: 220;
        isolation: isolate;
        overflow: hidden;
        margin: 0 0 12px;
        padding: calc(10px + env(safe-area-inset-top, 0px)) clamp(10px, 2.5vw, 16px) 12px;
        border-radius: 0 0 22px 22px;
        border: 1px solid rgba(75, 131, 255, 0.12);
        border-top: none;
        background:
            linear-gradient(
                112deg,
                rgba(158, 125, 244, 0.14) 0%,
                rgba(75, 131, 255, 0.1) 40%,
                rgba(103, 216, 200, 0.08) 100%
            ),
            linear-gradient(
                180deg,
                rgba(255, 255, 255, 0.96) 0%,
                rgba(255, 251, 245, 0.92) 100%
            );
        backdrop-filter: blur(22px) saturate(180%);
        -webkit-backdrop-filter: blur(22px) saturate(180%);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.9),
            0 12px 32px rgba(7, 43, 110, 0.08);
    }

    .practice-m-chrome::before {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background:
            radial-gradient(
                ellipse 80% 100% at 50% -20%,
                rgba(124, 199, 255, 0.24) 0%,
                transparent 60%
            );
        pointer-events: none;
        z-index: 0;
    }

    .practice-m-chrome::after {
        content: "";
        position: absolute;
        inset: auto 12px 0;
        height: 2px;
        border-radius: 999px;
        background: linear-gradient(
            90deg,
            rgba(103, 216, 200, 0.5),
            rgba(75, 131, 255, 0.7),
            rgba(158, 125, 244, 0.65),
            rgba(244, 122, 42, 0.5)
        );
        opacity: 0.7;
        pointer-events: none;
        z-index: 1;
    }

    .practice-m-chrome__row {
        position: relative;
        z-index: 2;
    }

    [data-theme="dark"] .practice-m-chrome {
        border-color: rgba(124, 199, 255, 0.14);
        background:
            linear-gradient(
                112deg,
                rgba(158, 125, 244, 0.16) 0%,
                rgba(38, 119, 255, 0.12) 45%,
                rgba(103, 216, 200, 0.06) 100%
            ),
            linear-gradient(
                180deg,
                rgba(14, 26, 48, 0.95) 0%,
                rgba(9, 18, 36, 0.92) 100%
            );
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.07),
            0 10px 32px rgba(0, 0, 0, 0.35);
    }

    [data-theme="dark"] .practice-m-chrome::before {
        background: radial-gradient(
            ellipse 75% 90% at 50% -15%,
            rgba(38, 119, 255, 0.2) 0%,
            transparent 58%
        );
    }

    .practice-m-chrome__row {
        gap: 10px;
        min-height: 52px;
    }

    .practice-m-chrome__stop.stop-practice-btn {
        padding: 8px 14px;
        min-height: 40px;
        border-radius: 999px;
        border: 1px solid var(--border-soft);
        background: rgba(255, 255, 255, 0.5);
        box-shadow: var(--clearli-inset-hi), 0 2px 8px rgba(7, 43, 110, 0.05);
        color: var(--ink-soft);
        font-weight: 600;
        font-size: 0.84em;
    }

    [data-theme="dark"] .practice-m-chrome__stop.stop-practice-btn {
        background: rgba(255, 255, 255, 0.06);
    }

    .practice-m-chrome__stop.stop-practice-btn:hover {
        border-color: rgba(239, 68, 68, 0.35);
        background: rgba(254, 226, 226, 0.35);
        color: #dc2626;
    }

    .practice-m-chrome__trailing {
        gap: 6px;
    }
}

/* RC mobile chrome — align with practice chrome */
@media (max-width: 1024px) {
    .rc-m-top {
        overflow: hidden;
        background:
            linear-gradient(
                112deg,
                rgba(158, 125, 244, 0.14) 0%,
                rgba(75, 131, 255, 0.1) 40%,
                rgba(103, 216, 200, 0.08) 100%
            ),
            linear-gradient(
                180deg,
                rgba(255, 255, 255, 0.96) 0%,
                rgba(255, 251, 245, 0.92) 100%
            );
        backdrop-filter: blur(22px) saturate(180%);
        -webkit-backdrop-filter: blur(22px) saturate(180%);
        border-bottom: 1px solid rgba(75, 131, 255, 0.12);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.9),
            0 8px 28px rgba(7, 43, 110, 0.07);
    }

    [data-theme="dark"] .rc-m-top {
        background:
            linear-gradient(
                112deg,
                rgba(158, 125, 244, 0.16) 0%,
                rgba(38, 119, 255, 0.12) 45%,
                rgba(103, 216, 200, 0.06) 100%
            ),
            linear-gradient(
                180deg,
                rgba(14, 26, 48, 0.95) 0%,
                rgba(9, 18, 36, 0.92) 100%
            );
        border-bottom-color: rgba(124, 199, 255, 0.14);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.07),
            0 10px 32px rgba(0, 0, 0, 0.35);
    }

    .rc-m-chrome__row {
        min-height: 52px;
        padding: 6px 14px;
    }
}

/* ── Desktop floating toolbar (practice when mobile chrome hidden) ── */
.elite-floating-toolbar {
    top: max(14px, env(safe-area-inset-top, 0px));
    left: max(14px, env(safe-area-inset-left, 0px));
    z-index: 500;
    padding: 0;
    filter: drop-shadow(0 8px 24px rgba(7, 43, 110, 0.12));
}

[data-theme="dark"] .elite-floating-toolbar {
    filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.45));
}

/* ── Compact mobile tweaks ── */
@media (max-width: 640px) {
    .elite-userbar__actions .elite-toolbar-actions .elite-toolbar-chip,
    .elite-userbar__cluster > .elite-toolbar-chip,
    .practice-m-chrome .elite-toolbar-actions .elite-toolbar-chip,
    .rc-m-chrome .elite-toolbar-actions .elite-toolbar-chip,
    .elite-floating-toolbar .elite-toolbar-actions .elite-toolbar-chip {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
        max-width: 34px;
        max-height: 34px;
    }

    .practice-m-chrome__logo .clearli-mark--sm,
    .rc-m-chrome__logo .clearli-mark--sm {
        width: 38px;
        height: 38px;
    }
}

@media (prefers-reduced-transparency: reduce) {
    body.elite-body .elite-userbar,
    body.elite-body .elite-userbar--app {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: linear-gradient(
            180deg,
            #fffdf8 0%,
            #f8f1e8 100%
        );
    }

    [data-theme="dark"] body.elite-body .elite-userbar,
    [data-theme="dark"] body.elite-body .elite-userbar--app {
        background: linear-gradient(
            180deg,
            #0e1a30 0%,
            #091224 100%
        );
    }

    .practice-m-chrome,
    .rc-m-top,
    .elite-userbar__actions .elite-toolbar-actions,
    .practice-m-chrome__trailing .elite-toolbar-actions,
    .rc-m-chrome__trailing .elite-toolbar-actions,
    .elite-floating-toolbar .elite-toolbar-actions {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--card-solid);
    }
}
