/* FMI public panel — precision layer. Keeps existing component behavior intact. */

:root {
    --bg: #0a0a0a;
    --bg-elev: #111111;
    --glass: rgba(255, 255, 255, .03);
    --glass-hi: rgba(255, 255, 255, .08);
    --bdr: rgba(255, 255, 255, .08);
    --bdr-hi: rgba(255, 255, 255, .15);
    --a-glow: color-mix(in srgb, var(--a) 25%, transparent);
    --a-glow-hi: color-mix(in srgb, var(--a) 40%, transparent);
    --t1: #fafafa;
    --t2: #a1a1aa;
    --t3: #71717a;
    --r-lg: 16px;
    --r-md: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body.fmi-public {
    background:
        radial-gradient(circle at 12% -10%, color-mix(in srgb, var(--a) 12%, transparent), transparent 34rem),
        radial-gradient(circle at 100% 35%, rgba(0, 112, 243, .06), transparent 32rem),
        linear-gradient(155deg, #0a0a0a 0%, #111111 48%, #0a0a0a 100%);
    font-feature-settings: "ss01" 1, "cv02" 1, "cv03" 1;
}

body.fmi-public::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .62), transparent 78%);
}

.ambient {
    opacity: .6;
}

.orb {
    filter: blur(120px);
}

.app {
    width: min(100%, 1380px);
    padding:
        max(22px, env(safe-area-inset-top))
        max(18px, env(safe-area-inset-right))
        max(34px, env(safe-area-inset-bottom))
        max(18px, env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
}

.topbar {
    min-height: 68px;
    padding: 13px 15px 13px 14px;
    margin-bottom: clamp(34px, 5vw, 62px);
    border-color: rgba(255, 255, 255, .08);
    border-radius: 16px;
    background: rgba(255, 255, 255, .03);
    backdrop-filter: blur(20px);
    box-shadow: 0 18px 46px rgba(0, 0, 0, .3), inset 0 1px rgba(255, 255, 255, .05);
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--a), var(--a2));
    box-shadow: 0 4px 12px rgba(0, 112, 243, .3);
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

.brand-mark:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 112, 243, .4);
}

.brand-name {
    font-size: 14.5px;
    font-weight: 750;
}

.brand-sub {
    color: #778398;
}

.chip,
.ix-lang {
    border-radius: 10px;
}

.chip {
    min-height: 32px;
    padding: 7px 11px;
    background: rgba(255, 255, 255, .038);
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
}

.chip:hover {
    background: rgba(255, 255, 255, .08);
    transform: translateY(-1px);
}

.chip-access-open {
    color: var(--warn);
    border-color: rgba(245, 166, 35, .24);
    background: rgba(245, 166, 35, .09);
}

.theme-switch {
    appearance: none;
    color: var(--t2);
    font-family: inherit;
    cursor: pointer;
}

.theme-switch:hover {
    color: var(--a);
    border-color: color-mix(in srgb, var(--a) 32%, transparent);
    background: color-mix(in srgb, var(--a) 9%, transparent);
}

.admin-link {
    color: #60a5fa;
    text-decoration: none;
    border-color: rgba(96, 165, 250, .25);
    background: rgba(0, 112, 243, .08);
}

.admin-link:hover {
    color: #93c5fd;
    border-color: rgba(96, 165, 250, .4);
    background: rgba(0, 112, 243, .15);
}

.main {
    gap: clamp(26px, 4vw, 54px);
}

.hero {
    max-width: 720px;
    padding: 6px 4px 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.hero-eyebrow,
.step-tag {
    border-radius: 8px;
    letter-spacing: 1.35px;
}

.hero-h1 {
    max-width: 20ch;
    font-size: clamp(28px, 7vw, 48px);
    font-weight: 780;
    line-height: 1.1;
    letter-spacing: clamp(-1.5px, -.04em, -0.8px);
    text-wrap: balance;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.hero-h1 .grad {
    background-image: linear-gradient(105deg, #fff 0%, var(--a) 58%, #60a5fa 100%);
    animation-duration: 8s;
    background-size: 200% 100%;
}

.hero-sub {
    max-width: 58ch;
    font-size: clamp(13px, 2.5vw, 15px);
    line-height: 1.6;
    text-wrap: pretty;
    margin-bottom: 24px;
}

.stage {
    min-height: 360px;
}

.pane,
.tl-card {
    position: relative;
    border-color: rgba(255, 255, 255, .08);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, .03), transparent 38%),
        rgba(17, 17, 17, .9);
    box-shadow:
        0 32px 74px -28px rgba(0, 0, 0, .6),
        inset 0 1px rgba(255, 255, 255, .05);
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

.pane:hover,
.tl-card:hover {
    border-color: rgba(255, 255, 255, .12);
    box-shadow:
        0 40px 80px -28px rgba(0, 0, 0, .7),
        inset 0 1px rgba(255, 255, 255, .08);
}

.pane::before,
.tl-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--a) 8%, transparent), transparent 44%);
    opacity: .6;
}

.pane > *,
.tl-card > * {
    position: relative;
}

.pane {
    padding: clamp(24px, 4vw, 36px);
    -webkit-overflow-scrolling: touch;
}

.pane-h2 {
    font-weight: 760;
    text-wrap: balance;
}

.step-tag,
.tl-status.run,
.log-entry.info .log-chip {
    color: var(--a);
    border-color: color-mix(in srgb, var(--a) 32%, transparent);
    background: color-mix(in srgb, var(--a) 13%, transparent);
}

.pane-p {
    max-width: 58ch;
    line-height: 1.65;
}

.btn {
    border-radius: 12px;
    font-weight: 740;
    min-height: 54px;
    min-width: 44px;
    touch-action: manipulation;
}

.btn-primary {
    background: var(--a);
    box-shadow: 0 2px 8px rgba(0, 112, 243, .2), inset 0 1px rgba(255, 255, 255, .1);
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .2), transparent);
    transition: left .5s;
}

.btn-primary:hover:not(:disabled)::before {
    left: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--a) 90%, white);
    box-shadow: 0 4px 12px rgba(0, 112, 243, .3);
    transform: translateY(-1px);
}

.btn-ghost {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .1);
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .2);
}

.field-input {
    min-height: 56px;
    border-radius: 12px;
    border-color: rgba(255, 255, 255, .1);
    background: rgba(17, 17, 17, .8);
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
    font-size: 16px;
}

.field-input:focus {
    background: rgba(26, 26, 26, .9);
    border-color: var(--a);
    box-shadow: 0 0 0 3px rgba(0, 112, 243, .15);
}

.tl-head {
    padding: 20px 22px;
}

.tl-h3 {
    font-size: 15px;
}

.tl-body {
    padding-top: 17px;
    padding-bottom: 17px;
}

.tl-row {
    min-height: 42px;
}

.tl-foot {
    background: rgba(3, 7, 13, .18);
}

.foot {
    margin-top: clamp(30px, 6vw, 66px);
}

.gate-wrap {
    max-width: 600px !important;
}

.gate-badge,
.gate-modal .box {
    border-radius: 12px !important;
}

.gate-live {
    top: 21px !important;
}

body.fmi-public .gate-live .spin {
    border-color: color-mix(in srgb, var(--a) 26%, transparent);
    border-top-color: var(--a);
}

body.fmi-public .gate-modal .box {
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 0 1px color-mix(in srgb, var(--a) 8%, transparent);
}

body.fmi-public .gate-modal .code {
    color: var(--a);
    border-color: color-mix(in srgb, var(--a) 30%, transparent);
    background: color-mix(in srgb, var(--a) 13%, transparent);
}

@keyframes row-flash {
    0%, 100% { background: transparent; }
    25% { background: color-mix(in srgb, var(--a) 7%, transparent); }
}

.modal {
    background: rgba(2, 6, 12, .78);
}

.sheet {
    border-color: rgba(203, 213, 225, .14);
    box-shadow: 0 -28px 80px rgba(0, 0, 0, .5);
}

:where(a, button, input, select, textarea):focus-visible {
    outline: 3px solid color-mix(in srgb, var(--a) 64%, white);
    outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
    .chip,
    .ix-lang a,
    .tl-log-btn,
    .sheet-close {
        transition: color .2s ease, border-color .2s ease, background .2s ease, transform .2s ease;
    }

    .chip:hover,
    .ix-lang a:hover {
        border-color: var(--bdr-hi);
    }
}

/* Optional light theme. The blue accent and semantic states stay intact. */
html[data-theme="light"] {
    --bg: #ffffff;
    --bg-elev: #f9fafb;
    --glass: rgba(255, 255, 255, .85);
    --glass-hi: rgba(0, 0, 0, .04);
    --bdr: rgba(0, 0, 0, .08);
    --bdr-hi: rgba(0, 0, 0, .15);
    --t1: #111827;
    --t2: #4b5563;
    --t3: #9ca3af;
    --ok: #00a86b;
    --ok-g: rgba(0, 168, 107, .10);
    --ok-b: rgba(0, 168, 107, .22);
    --err: #e5484d;
    --err-g: rgba(229, 72, 77, .09);
    --err-b: rgba(229, 72, 77, .20);
    --warn: #f5a623;
    --warn-g: rgba(245, 166, 35, .10);
}

html[data-theme="light"] body.fmi-public {
    background:
        radial-gradient(circle at 9% -8%, color-mix(in srgb, var(--a) 15%, transparent), transparent 33rem),
        radial-gradient(circle at 100% 42%, rgba(0, 112, 243, .06), transparent 30rem),
        linear-gradient(150deg, #ffffff 0%, #f9fafb 52%, #f3f4f6 100%);
}

html[data-theme="light"] body.fmi-public::before {
    background-image:
        linear-gradient(rgba(0, 0, 0, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, .04) 1px, transparent 1px);
}

html[data-theme="light"] .ambient {
    opacity: .18;
}

html[data-theme="light"] .grain {
    opacity: .018;
    mix-blend-mode: multiply;
}

html[data-theme="light"] .topbar {
    border-color: rgba(0, 0, 0, .08);
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 20px 48px -34px rgba(0, 0, 0, .15), inset 0 1px #fff;
}

html[data-theme="light"] .pane,
html[data-theme="light"] .tl-card {
    border-color: rgba(0, 0, 0, .08);
    background:
        linear-gradient(145deg, rgba(0, 112, 243, .03), transparent 36%),
        rgba(255, 255, 255, .95);
    box-shadow: 0 34px 70px -42px rgba(0, 0, 0, .12), inset 0 1px #fff;
}

html[data-theme="light"] .field-input {
    color: var(--t1);
    border-color: rgba(0, 0, 0, .1);
    background: #f9fafb;
}

html[data-theme="light"] .field-input:focus {
    background: #fff;
    border-color: var(--a);
}

html[data-theme="light"] .btn-ghost,
html[data-theme="light"] .tl-log-btn,
html[data-theme="light"] .sheet-close {
    color: var(--t1);
    background: #f3f4f6;
    border-color: rgba(0, 0, 0, .1);
}

html[data-theme="light"] .chip,
html[data-theme="light"] .ix-lang {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .08);
}

html[data-theme="light"] .chip-access-open {
    color: #b45309;
    border-color: rgba(245, 166, 35, .25);
    background: rgba(245, 166, 35, .1);
}

html[data-theme="light"] .admin-link {
    color: #0051c3;
    border-color: rgba(0, 112, 243, .25);
    background: rgba(0, 112, 243, .08);
}

html[data-theme="light"] .admin-link:hover {
    color: #003d91;
    border-color: rgba(0, 112, 243, .4);
    background: rgba(0, 112, 243, .15);
}

html[data-theme="light"] .tl-foot {
    background: rgba(93, 68, 39, .025);
}

html[data-theme="light"] .modal,
html[data-theme="light"] .gate-modal {
    background: rgba(39, 31, 23, .52);
}

html[data-theme="light"] .sheet,
html[data-theme="light"] .gate-modal .box {
    background: var(--bg-elev);
    box-shadow: 0 28px 70px rgba(66, 45, 23, .24);
}

html[data-theme="light"] .log-json {
    background: #f5f1e9;
}

@media (min-width: 980px) {
    .main {
        grid-template-columns: minmax(0, 1.38fr) minmax(330px, .82fr);
    }

    .main.col-t-hidden {
        grid-template-columns: 1fr;
        justify-content: center;
    }

    .col-t {
        top: 22px;
    }
    
    .col-t.visible {
        display: block;
    }

    body.is-gated .topbar {
        width: min(100%, 880px);
        margin-inline: auto;
    }
}

@media (max-width: 760px) {
    .app {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .topbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
        margin-bottom: 30px;
        border-radius: 16px;
    }

    .hero-h1 {
        max-width: 25ch;
        font-size: clamp(26px, 8vw, 42px);
    }

    .top-meta {
        width: 100%;
        margin-left: 0;
        padding-bottom: 2px;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }

    .top-meta::-webkit-scrollbar {
        display: none;
    }

    .chip,
    .ix-lang {
        flex: 0 0 auto;
    }

    .chip-access-open {
        display: inline-flex !important;
    }

    .theme-switch {
        display: inline-flex !important;
    }

    .admin-link {
        display: inline-flex !important;
    }

    .hero {
        padding-inline: 2px;
    }

    .hero-h1 {
        max-width: 14ch;
    }

    .stage {
        min-height: 0;
    }

    .pane,
    .tl-card {
        border-radius: 18px;
    }

    .btn-row .btn {
        flex-basis: calc(100% - 62px);
    }

    .btn-row .btn-icon,
    .btn-row .btn-back {
        flex-basis: 52px;
    }

    .gate-badge-row {
        justify-content: flex-start !important;
    }

    .gate-hero {
        text-align: left !important;
    }

    .gate-eye,
    .gate-hero .hero-sub {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .gate-modal .row {
        flex-direction: column-reverse;
    }
}

@media (max-width: 420px) {
    .app {
        padding-inline: 12px;
    }

    .brand-sub {
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .hero-h1 {
        font-size: clamp(24px, 9vw, 38px);
        max-width: 30ch;
    }

    .hero-sub {
        font-size: clamp(12px, 3.5vw, 14px);
    }

    .pane {
        padding: 22px 17px;
    }

    .res-dev-head {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .res-dev-badge {
        margin-left: 42px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
