/* ========= GLOBAL RESET ========= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #020203;
    --panel-bg: #07080b;
    --panel-bg-alt: #101218;
    --border-soft: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.22);
    --text-main: #f5f5f7;
    --text-muted: #a0a1a8;
    --text-soft: #70727a;
    --radius-xl: 30px;
    --radius-pill: 999px;
    --shadow-strong: 0 40px 120px rgba(0, 0, 0, 0.95);
    --transition-fast: 0.16s ease-out;
    --transition-med: 0.24s ease-out;
    --transition-slow: 0.6s ease-out;
}

html {
    background-color: #020203;
    color-scheme: dark;
    min-height: 100%;
}

body {
    min-height: 100vh;
    background-color: #020203;
    background-image: radial-gradient(circle at top, #16171f 0%, #050507 38%, #000000 100%);
    color: var(--text-main);
    font-family: "Michroma", "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont,
        "SF Pro Text", "Segoe UI", sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: calc( env(safe-area-inset-top) + 24px );
    padding-bottom: calc( env(safe-area-inset-bottom) + 24px );
}

.background-stack {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: -3;
    pointer-events: none;
}

.background-spline {
    position: absolute;
    inset: -5%;
    width: 110%;
    height: 110%;
    opacity: 0.52;
    pointer-events: none;
}

/* ========= ANIMATED BACKGROUND WAVES ========= */

.bg-waves {
    position: absolute;
    inset: -20%;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.06), transparent 55%),
        radial-gradient(circle at 100% 100%, rgba(255, 255, 255, 0.04), transparent 50%),
        repeating-linear-gradient(
            -20deg,
            rgba(255, 255, 255, 0.08) 0,
            rgba(255, 255, 255, 0.08) 1px,
            transparent 1px,
            transparent 10px
        );
    mix-blend-mode: screen;
    opacity: 0.06;
    transform: translate3d(0, 0, 0);
    animation: waveShift 18s linear infinite;
    z-index: 0;
}

.bg-waves--back {
    opacity: 0.03;
    filter: blur(6px);
    background: rgba(0, 0, 0, 0.78);
    animation-direction: reverse;
    z-index: -1;
}

@keyframes waveShift {
    0% {
        transform: translate3d(-6%, 0, 0) skewX(-8deg);
    }
    100% {
        transform: translate3d(6%, 0, 0) skewX(8deg);
    }
}

/* ========= PANEL WRAPPER ========= */


.page-wrap {
    position: relative;
    width: min(520px, 92%);
    padding: 28px 24px;
    margin-top: 40px;
    margin-bottom: 20px;
    z-index: 1;
}

.panel {
    position: relative;
    padding: 40px 38px 32px;
    border-radius: var(--radius-xl);
    background: linear-gradient(160deg, var(--panel-bg), var(--panel-bg-alt));
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-strong);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-sheen {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(
        120deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.08) 35%,
        rgba(255, 255, 255, 0) 70%
    );
    mix-blend-mode: screen;
    opacity: 0;
    animation: sheenSweep 10s linear infinite;
    pointer-events: none;
}

@keyframes sheenSweep {
    0% {
        transform: translateX(-80%);
        opacity: 0;
    }
    10% {
        opacity: 0.18;
    }
    40% {
        transform: translateX(80%);
        opacity: 0;
    }
    100% {
        transform: translateX(80%);
        opacity: 0;
    }
}

/* ========= HEADER ========= */

.panel-header {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.nox-mark {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.nox-mark__label {
    font-size: 19px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--text-main);
    font-family: "Michroma", "Space Grotesk", system-ui, sans-serif;
}

.nox-mark__pill {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    border-radius: var(--radius-pill);
    padding: 4px 10px 4px 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text-muted);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
    font-family: "Manrope", "Michroma", "Space Grotesk", system-ui, sans-serif;
}

.panel-subtitle {
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--text-soft);
    font-family: "Manrope", "Michroma", "Space Grotesk", system-ui, sans-serif;
}

/* ========= BODY ========= */

.panel-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-text {
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-family: "Manrope", "Michroma", "Space Grotesk", system-ui, sans-serif;
}

/* ========= HALO CORE ========= */

.core-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px 0 10px;
    flex-shrink: 0;
}

.core-visual__spline {
    width: min(340px, 75vw);
    height: min(340px, 75vw);
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.85);
}

/* ========= BUTTON ========= */

.controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.primary-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 38px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    background: linear-gradient(135deg, #181921 0%, #09090d 100%);
    color: var(--text-main);
    font-family: "Manrope", "Michroma", "Space Grotesk", system-ui, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.9),
        0 0 0 1px rgba(0, 0, 0, 0.65);
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        border-color var(--transition-fast),
        background var(--transition-fast),
        color var(--transition-fast);
}

.primary-button::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.18), transparent 58%);
    opacity: 0.8;
    pointer-events: none;
}

.primary-button:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.32);
    box-shadow:
        0 22px 60px rgba(0, 0, 0, 0.95),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

.primary-button:active {
    transform: translateY(0);
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.95),
        0 0 0 1px rgba(255, 255, 255, 0.14);
}

.primary-button.recording {
    background: linear-gradient(135deg, #1d1f29 0%, #0d0e13 100%);
    border-color: rgba(255, 255, 255, 0.6);
}

.primary-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.1);
}

/* ========= LOG ========= */

.log {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex: 1;
    min-height: clamp(180px, 32vh, 360px);
    max-height: none;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    overscroll-behavior: contain;
    padding-right: 4px;
}

.log::-webkit-scrollbar {
    width: 6px;
}

.log::-webkit-scrollbar-track {
    background: transparent;
}

.log::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
}

.log-entry {
    margin-bottom: 10px;
}

.log-entry span.role {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-soft);
    margin-bottom: 2px;
    display: block;
    font-family: "Manrope", "Michroma", "Space Grotesk", system-ui, sans-serif;
}

.log-entry.user span.role {
    opacity: 0.8;
}

.log-entry.assistant span.role {
    opacity: 0.95;
}

.log-entry .content {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-main);
    opacity: 0.9;
    font-family: "Manrope", "Michroma", "Space Grotesk", system-ui, sans-serif;
}

/* ========= AUTH OVERLAY ========= */

.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(6px);
    padding: clamp(16px, 3vw, 48px);
}

.auth-shell {
    width: clamp(1200px, 92vw, 1800px);
    height: clamp(640px, 88vh, 960px);
    display: flex;
    gap: 36px;
    align-items: stretch;
    justify-content: center;
}

.auth-visual {
    border-radius: 32px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 60px 180px rgba(0, 0, 0, 0.85);
    flex: 0 0 70%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
}

.auth-visual spline-viewer {
    display: block;
    width: 100%;
    height: 100%;
}

.auth-card {
    padding: 32px;
    border-radius: 20px;
    background: #050607;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 30px 120px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    text-align: left;
    flex: 0 0 30%;
    height: 100%;
}

.auth-card h1 {
    font-size: 20px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.auth-card p {
    font-size: 13px;
    color: var(--text-muted);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-form label {
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.auth-form input {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    font-size: 14px;
}

.auth-form input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
}

.auth-submit {
    margin-top: 6px;
    padding: 12px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, #181921 0%, #09090d 100%);
    color: var(--text-main);
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    cursor: pointer;
}

.auth-error {
    min-height: 18px;
    font-size: 12px;
    color: #ff8a8a;
}

/* ========= GLOBAL CONTROLS ========= */

.logout-button {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 12px);
    right: 24px;
    z-index: 11;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-main);
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.18em;
    font-size: 10px;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.page-wrap,
.panel,
.auth-overlay,
.logout-button {
    z-index: 1;
}

/* ========= RESPONSIVE ========= */

@media (max-width: 1100px) {
    .auth-shell {
        flex-direction: column;
        width: min(96vw, 640px);
        height: auto;
        gap: 24px;
    }

    .auth-visual {
        flex: 0 0 auto;
        width: 100%;
        aspect-ratio: 11 / 9;
        height: auto;
        min-height: auto;
        max-height: none;
    }

    .auth-card {
        width: 100%;
        min-height: auto;
        height: auto;
        flex: 0 0 auto;
    }
}

@media (max-width: 640px) {
    .page-wrap {
        padding: 26px 16px 40px;
    }

    .panel {
        padding: 18px 16px 14px;
        border-radius: 24px;
    }

    .core-visual__spline {
        width: min(240px, 80vw);
        height: min(240px, 80vw);
    }

    .primary-button {
        padding-inline: 26px;
        letter-spacing: 0.16em;
    }

    .log {
        min-height: 200px;
    }

    .auth-card {
        padding: 22px;
    }
}
