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

:root {
    --bg: #080b12;
    --bg-elev: #101521;
    --glass: rgba(20, 27, 42, .72);
    --glass-hi: rgba(255, 255, 255, .065);
    --bdr: rgba(203, 213, 225, .10);
    --bdr-hi: rgba(203, 213, 225, .20);
    --a-glow: color-mix(in srgb, var(--a) 36%, transparent);
    --a-glow-hi: color-mix(in srgb, var(--a) 52%, transparent);
    --t1: #f8fafc;
    --t2: #aeb8c8;
    --t3: #687386;
    --r-lg: 24px;
    --r-md: 15px;
    --font: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body.fmi-public {
    background:
        radial-gradient(circle at 12% -10%, color-mix(in srgb, var(--a) 17%, transparent), transparent 34rem),
        radial-gradient(circle at 100% 35%, rgba(56, 189, 248, .08), transparent 32rem),
        linear-gradient(155deg, #080b12 0%, #0b101a 48%, #080b12 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));
}

.topbar {
    min-height: 68px;
    padding: 13px 15px 13px 14px;
    margin-bottom: clamp(34px, 5vw, 62px);
    border-color: rgba(203, 213, 225, .12);
    border-radius: 19px;
    background: rgba(12, 17, 27, .76);
    box-shadow: 0 18px 46px rgba(1, 4, 10, .28), inset 0 1px rgba(255, 255, 255, .04);
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.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);
}

.chip-access-open {
    color: var(--warn);
    border-color: rgba(251, 191, 36, .24);
    background: rgba(251, 191, 36, .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: #fdba74;
    text-decoration: none;
    border-color: rgba(251, 146, 60, .24);
    background: rgba(194, 65, 12, .10);
}

.admin-link:hover {
    color: #fff7ed;
    border-color: rgba(251, 146, 60, .44);
    background: rgba(194, 65, 12, .20);
}

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

.hero {
    max-width: 720px;
    padding: 6px 4px 2px;
}

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

.hero-h1 {
    max-width: 13ch;
    font-size: clamp(34px, 6vw, 64px);
    font-weight: 780;
    line-height: .98;
    letter-spacing: clamp(-2.6px, -.05em, -1px);
    text-wrap: balance;
}

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

.hero-sub {
    max-width: 58ch;
    font-size: clamp(14px, 2vw, 17px);
    line-height: 1.7;
    text-wrap: pretty;
}

.stage {
    min-height: 360px;
}

.pane,
.tl-card {
    position: relative;
    border-color: rgba(203, 213, 225, .12);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, .025), transparent 38%),
        rgba(15, 21, 33, .82);
    box-shadow:
        0 32px 74px -28px rgba(0, 0, 0, .72),
        inset 0 1px rgba(255, 255, 255, .045);
}

.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) 10%, transparent), transparent 44%);
}

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

.pane {
    padding: clamp(24px, 4vw, 36px);
}

.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;
}

.btn-primary {
    background: var(--a);
    box-shadow: 0 15px 34px -13px color-mix(in srgb, var(--a) 62%, transparent), inset 0 1px rgba(255, 255, 255, .2);
}

.btn-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--a) 88%, white);
}

.btn-ghost {
    background: rgba(255, 255, 255, .045);
}

.field-input {
    min-height: 56px;
    border-radius: 12px;
    border-color: rgba(203, 213, 225, .15);
    background: rgba(5, 9, 16, .5);
}

.field-input:focus {
    background: rgba(8, 13, 22, .82);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--a) 19%, transparent);
}

.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 white theme. The orange accent and semantic states stay intact. */
html[data-theme="light"] {
    --bg: #f5f1e9;
    --bg-elev: #fffdf9;
    --glass: rgba(255, 253, 249, .82);
    --glass-hi: rgba(58, 44, 29, .055);
    --bdr: rgba(58, 44, 29, .11);
    --bdr-hi: rgba(58, 44, 29, .20);
    --t1: #201c18;
    --t2: #625b52;
    --t3: #8d8377;
    --ok: #078260;
    --ok-g: rgba(7, 130, 96, .10);
    --ok-b: rgba(7, 130, 96, .22);
    --err: #c84343;
    --err-g: rgba(200, 67, 67, .09);
    --err-b: rgba(200, 67, 67, .20);
    --warn: #b76d08;
    --warn-g: rgba(183, 109, 8, .10);
}

html[data-theme="light"] body.fmi-public {
    background:
        radial-gradient(circle at 9% -8%, color-mix(in srgb, var(--a) 18%, transparent), transparent 33rem),
        radial-gradient(circle at 100% 42%, rgba(194, 65, 12, .07), transparent 30rem),
        linear-gradient(150deg, #fffdf9 0%, #f5f1e9 52%, #f8f5ef 100%);
}

html[data-theme="light"] body.fmi-public::before {
    background-image:
        linear-gradient(rgba(74, 55, 35, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 55, 35, .035) 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(74, 55, 35, .1);
    background: rgba(255, 253, 249, .86);
    box-shadow: 0 20px 48px -34px rgba(72, 45, 19, .34), inset 0 1px #fff;
}

html[data-theme="light"] .pane,
html[data-theme="light"] .tl-card {
    border-color: rgba(74, 55, 35, .11);
    background:
        linear-gradient(145deg, rgba(245, 158, 11, .035), transparent 36%),
        rgba(255, 253, 249, .9);
    box-shadow: 0 34px 70px -42px rgba(72, 45, 19, .38), inset 0 1px #fff;
}

html[data-theme="light"] .field-input {
    color: var(--t1);
    border-color: rgba(74, 55, 35, .15);
    background: #fbf8f2;
}

html[data-theme="light"] .field-input:focus {
    background: #fff;
}

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

html[data-theme="light"] .chip,
html[data-theme="light"] .ix-lang {
    background: rgba(58, 44, 29, .045);
}

html[data-theme="light"] .chip-access-open {
    color: #9a5704;
    border-color: rgba(183, 109, 8, .25);
    background: rgba(245, 158, 11, .1);
}

html[data-theme="light"] .admin-link {
    color: #9a3f08;
    border-color: rgba(194, 65, 12, .22);
    background: rgba(234, 88, 12, .08);
}

html[data-theme="light"] .admin-link:hover {
    color: #7c2d12;
    border-color: rgba(194, 65, 12, .38);
    background: rgba(234, 88, 12, .14);
}

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);
    }

    .col-t {
        top: 22px;
    }

    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;
    }

    .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(31px, 10vw, 40px);
    }

    .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;
    }
}
