/* =========================================================
   NORA — 3D CHARACTER TEST
========================================================= */

:root {
    color-scheme: dark;

    --bg: #0c1118;
    --panel: #141c26;
    --panel-soft: #1b2633;
    --border: rgba(255, 255, 255, 0.09);

    --text: #edf2f7;
    --muted: #9baabd;

    --blue: #48b3dc;
    --gold: #cba557;
    --green: #67c6a4;
    --danger: #f2a2a2;

    --radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

button,
a,
input,
audio {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

button,
.file-label {
    min-height: 44px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
audio:focus-visible,
.file-label:focus-within {
    outline: 2px solid var(--blue);
    outline-offset: 4px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

[hidden] {
    display: none !important;
}

/* =========================================================
   APP LAYOUT
========================================================= */

.app {
    width: min(1600px, 100%);
    min-height: 100vh;
    min-height: 100dvh;

    display: flex;
    flex-direction: column;

    margin: 0 auto;
    padding: 0 32px;
}

.site-header {
    min-height: 96px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;

    color: var(--text);
    text-decoration: none;
}

.brand-symbol {
    width: 44px;
    height: 44px;

    display: grid;
    place-items: center;

    border: 1px solid rgba(72, 179, 220, 0.3);
    border-radius: 14px;

    background: rgba(72, 179, 220, 0.08);
    color: var(--blue);

    font-size: 25px;
    font-weight: 700;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brand-text strong {
    font-size: 21px;
    font-weight: 650;
    letter-spacing: 0.16em;
}

.brand-text small {
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.2em;
}

.test-badge {
    padding: 7px 12px;

    border: 1px solid var(--border);
    border-radius: 100px;

    color: var(--muted);

    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
}

.workspace {
    flex: 1;

    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: stretch;
    gap: 24px;

    min-width: 0;
}

/* =========================================================
   AVATAR STAGE
========================================================= */

.avatar-panel {
    position: relative;
    isolation: isolate;

    min-width: 0;
    min-height: 720px;

    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background:
        radial-gradient(
            ellipse at 50% 38%,
            rgba(59, 102, 126, 0.2),
            transparent 62%
        ),
        linear-gradient(
            160deg,
            #1b2530 0%,
            #111922 60%,
            #0d141c 100%
        );
}

/* Soft floor beneath the character. */
.avatar-panel::before {
    content: "";

    position: absolute;
    left: 20%;
    right: 20%;
    bottom: 90px;
    z-index: 0;

    height: 35px;

    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    filter: blur(20px);

    pointer-events: none;
}

.avatar-stage {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.avatar-stage canvas {
    display: block;

    width: 100%;
    height: 100%;

    touch-action: none;
}

.avatar-caption {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 3;

    display: flex;
    align-items: center;
    gap: 9px;

    max-width: calc(100% - 48px);
    padding: 9px 13px;

    border: 1px solid var(--border);
    border-radius: 100px;

    background: rgba(12, 17, 24, 0.78);

    color: #c6d2df;
    font-size: 12px;

    pointer-events: none;
}

.status-dot {
    flex: 0 0 auto;

    width: 7px;
    height: 7px;

    border-radius: 50%;
    background: var(--gold);
}

.status-dot.is-ready {
    background: var(--green);
}

.status-dot.is-speaking {
    background: var(--blue);
    animation: status-pulse 1.4s ease-in-out infinite;
}

.status-dot.is-error {
    background: var(--danger);
}

.camera-controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    z-index: 3;

    display: flex;
    align-items: center;
    gap: 5px;

    width: max-content;
    max-width: calc(100% - 32px);
    padding: 6px;

    transform: translateX(-50%);

    border: 1px solid var(--border);
    border-radius: 16px;

    background: rgba(12, 17, 24, 0.88);
}

.camera-controls button {
    padding: 9px 14px;

    border: 1px solid transparent;
    border-radius: 10px;

    background: transparent;
    color: var(--muted);

    font-size: 12px;

    transition:
        background-color 160ms ease,
        color 160ms ease,
        border-color 160ms ease;
}

.camera-controls button[aria-pressed="true"] {
    background: rgba(72, 179, 220, 0.12);
    color: #a0d9ee;
}

/* =========================================================
   LOADING
========================================================= */

.loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;

    padding: 30px;

    background: #111922;

    text-align: center;
}

.loading-overlay p {
    max-width: 360px;
    margin: 0;

    color: var(--muted);
    font-size: 14px;
}

.loading-spinner {
    width: 36px;
    height: 36px;

    border: 2px solid rgba(72, 179, 220, 0.15);
    border-top-color: var(--blue);
    border-radius: 50%;

    animation: spin 900ms linear infinite;
}

/* =========================================================
   CONTROL PANEL
========================================================= */

.control-panel {
    min-width: 0;
    padding: 28px;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--panel);
}

.eyebrow {
    margin: 0 0 10px;

    color: var(--gold);

    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.18em;
}

.panel-heading h1 {
    margin: 0 0 12px;

    font-size: clamp(24px, 2.2vw, 31px);
    font-weight: 600;
    line-height: 1.18;
    letter-spacing: -0.035em;
}

.panel-heading > p:last-child {
    margin: 0;

    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.control-section {
    margin-top: 25px;
    padding-top: 23px;

    border-top: 1px solid var(--border);
}

.control-section h2 {
    margin: 0 0 15px;

    color: #d7e0ea;

    font-size: 13px;
    font-weight: 600;
}

/* =========================================================
   MOVEMENT TOGGLES
========================================================= */

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    min-height: 44px;

    color: var(--muted);
    font-size: 13px;

    cursor: pointer;
}

.toggle-row input {
    appearance: none;
    -webkit-appearance: none;

    position: relative;
    flex: 0 0 auto;

    width: 38px;
    height: 22px;
    margin: 0;

    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 100px;

    background: #293442;

    cursor: pointer;

    transition:
        background-color 160ms ease,
        border-color 160ms ease;
}

.toggle-row input::before {
    content: "";

    position: absolute;
    top: 3px;
    left: 3px;

    width: 14px;
    height: 14px;

    border-radius: 50%;
    background: #aeb9c6;

    transition:
        transform 160ms ease,
        background-color 160ms ease;
}

.toggle-row input:checked {
    border-color: rgba(72, 179, 220, 0.5);
    background: rgba(72, 179, 220, 0.25);
}

.toggle-row input:checked::before {
    transform: translateX(16px);
    background: #a0d9ee;
}

/* =========================================================
   EXPRESSIONS
========================================================= */

.expression-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.expression-grid button,
.secondary-button {
    padding: 10px 12px;

    border: 1px solid var(--border);
    border-radius: 11px;

    background: var(--panel-soft);
    color: var(--muted);

    font-size: 12px;

    transition:
        background-color 160ms ease,
        color 160ms ease,
        border-color 160ms ease;
}

.expression-grid button[aria-pressed="true"] {
    border-color: rgba(72, 179, 220, 0.35);
    background: rgba(72, 179, 220, 0.1);
    color: #a0d9ee;
}

/* =========================================================
   AUDIO
========================================================= */

.help-text {
    margin: 0 0 15px;

    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.file-label {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    padding: 11px 16px;

    border: 1px solid rgba(72, 179, 220, 0.3);
    border-radius: 11px;

    background: rgba(72, 179, 220, 0.1);
    color: #a0d9ee;

    font-size: 13px;
    font-weight: 500;

    cursor: pointer;

    transition:
        background-color 160ms ease,
        border-color 160ms ease;
}

/* Keep the native file input accessible to keyboard users. */
#audio-file {
    display: block;

    width: 100%;
    margin-top: 10px;

    color: var(--muted);
    font-size: 11px;
}

#audio-file::file-selector-button {
    margin-right: 8px;
    padding: 7px 9px;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: var(--panel-soft);
    color: var(--text);

    font: inherit;
    cursor: pointer;
}

.file-name {
    margin: 10px 0 14px;

    color: var(--muted);
    font-size: 11px;
    overflow-wrap: anywhere;
}

#speech-audio {
    display: block;

    width: 100%;
    height: 42px;

    margin-bottom: 10px;
}

.secondary-button {
    width: 100%;
}

.range-control {
    margin-top: 20px;
}

.range-control label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    margin-bottom: 12px;

    color: var(--muted);
    font-size: 11px;
}

.range-control output {
    min-width: 32px;

    color: #a0d9ee;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.range-control input[type="range"] {
    display: block;

    width: 100%;
    height: 24px;
    margin: 0;

    accent-color: var(--blue);
    cursor: pointer;
}

.error-message {
    margin: 20px 0 0;
    padding: 13px;

    border: 1px solid rgba(242, 162, 162, 0.25);
    border-radius: 11px;

    background: rgba(242, 162, 162, 0.07);
    color: var(--danger);

    font-size: 12px;
    line-height: 1.6;

    overflow-wrap: anywhere;
}

/* =========================================================
   FOOTER
========================================================= */

.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    min-height: 64px;
    padding: 18px 0;

    color: #7e8da0;
    font-size: 10px;
    letter-spacing: 0.03em;
}

noscript {
    display: block;
    padding: 20px;

    color: var(--danger);
    text-align: center;
}

/* =========================================================
   HOVER
========================================================= */

@media (hover: hover) {
    .camera-controls button:hover,
    .expression-grid button:hover,
    .secondary-button:not(:disabled):hover {
        border-color: rgba(255, 255, 255, 0.18);
        background: #253344;
        color: var(--text);
    }

    .file-label:hover {
        border-color: rgba(72, 179, 220, 0.55);
        background: rgba(72, 179, 220, 0.17);
    }
}

/* =========================================================
   ANIMATIONS
========================================================= */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes status-pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.35;
    }
}

/* =========================================================
   TABLET
========================================================= */

@media (max-width: 1100px) {
    .app {
        padding: 0 20px;
    }

    .workspace {
        grid-template-columns: minmax(0, 1fr) 310px;
        gap: 18px;
    }

    .control-panel {
        padding: 22px;
    }
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 800px) {
    .site-header {
        min-height: 82px;
    }

    .workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .avatar-panel {
        min-height: 520px;
        height: 68vh;
        height: 68svh;
        max-height: 760px;
    }

    .control-panel {
        padding: 25px;
    }

    .panel-heading h1 {
        font-size: 28px;
    }

    .site-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .app {
        padding: 0 12px;
    }

    .brand-symbol {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .brand-text strong {
        font-size: 18px;
    }

    .brand-text small {
        font-size: 8px;
    }

    .test-badge {
        padding: 6px 8px;
        font-size: 8px;
        letter-spacing: 0.06em;
    }

    .avatar-panel,
    .control-panel {
        border-radius: 20px;
    }

    .avatar-panel {
        min-height: 460px;
    }

    .avatar-caption {
        top: 16px;
        left: 16px;

        max-width: calc(100% - 32px);

        font-size: 11px;
    }

    .camera-controls {
        bottom: 16px;
        gap: 2px;
        padding: 4px;
    }

    .camera-controls button {
        padding: 8px 10px;
        font-size: 11px;
    }

    .control-panel {
        padding: 22px;
    }
}

/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
    }

    .loading-spinner {
        animation-duration: 2s;
    }

    .status-dot.is-speaking {
        animation: none;
    }
}
/* Animation library controls */
.motion-panel select{display:block;width:100%;min-height:44px;margin:8px 0 16px;padding:10px;border:1px solid #405064;border-radius:10px;background:#1b2633;color:#edf2f7;font:inherit;font-size:12px;}
.motion-panel label,.motion-panel summary{font-size:12px;color:var(--muted);}
.motion-panel summary{cursor:pointer;padding:12px 0;}
.motion-panel #motion-status{margin:14px 0;color:#a0d9ee;}
.motion-panel .secondary-button{margin-top:8px;}
