
/* ==============================
   NEURAL PLAYGROUND - UI DESIGN
================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #080d1a;
    --panel: rgba(17, 27, 49, 0.85);
    --border: rgba(120, 150, 200, 0.15);
    --blue: #38bdf8;
    --purple: #a78bfa;
    --text: #e5edff;
    --muted: #8493ad;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 15% 10%, #172b50 0%, transparent 40%),
        radial-gradient(ellipse at 85% 85%, #24194b 0%, transparent 40%),
        var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Arial, sans-serif;
    padding: 25px 4%;
}

body.intro-active {
    overflow: hidden;
    height: 100dvh;
    min-height: 100dvh;
}

html.intro-active {
    overflow: hidden;
}

.intro-screen {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100dvh;
    min-height: 100svh;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 50% 42%, #12315a 0%, transparent 34%),
        radial-gradient(circle at 18% 80%, #172a52 0%, transparent 32%),
        #050914;
    opacity: 1;
    transition: opacity .55s ease, visibility .55s ease;
}

.intro-screen.is-exiting,
.intro-screen[hidden] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.intro-atmosphere,
.intro-atmosphere::before,
.intro-atmosphere::after {
    position: absolute;
    inset: 0;
    content: "";
    pointer-events: none;
}

.intro-atmosphere {
    overflow: hidden;
    background-image:
        linear-gradient(#ffffff08 1px, transparent 1px),
        linear-gradient(90deg, #ffffff08 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(ellipse at center, #000 0%, transparent 72%);
    opacity: .35;
}

.intro-atmosphere::before {
    background: radial-gradient(circle at 50% 48%, #67e8f91a, transparent 22%);
    animation: introBreathe 5s ease-in-out infinite alternate;
}

.intro-atmosphere::after {
    background: linear-gradient(115deg, transparent 30%, #67e8f909 48%, transparent 66%);
    transform: translateX(-80%);
    animation: introSweep 7s ease-in-out infinite;
}

.intro-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(720px, 92vw);
    max-height: 100%;
    padding: clamp(12px, 3vh, 30px) 0;
    text-align: center;
}

.intro-brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin: 0 auto clamp(8px, 1.8vh, 18px);
    border: 1px solid #67e8f966;
    border-radius: 13px;
    background: linear-gradient(135deg, #0284c7, #6d28d9);
    box-shadow: 0 0 30px #38bdf844;
    color: #effcff;
    font-size: 21px;
    font-weight: 700;
}

.intro-overline {
    color: #67e8f9;
    font-size: 10px;
    letter-spacing: 3px;
}

.intro-content h1 {
    margin-top: clamp(7px, 1.5vh, 12px);
    color: #f0f9ff;
    font-size: clamp(29px, 6vw, 58px);
    font-weight: 500;
    letter-spacing: clamp(4px, 1.3vw, 12px);
    text-indent: clamp(4px, 1.3vw, 12px);
}

.intro-subtitle {
    margin-top: clamp(6px, 1.5vh, 12px);
    color: #9fb6d3;
    font-size: clamp(13px, 2vw, 17px);
    letter-spacing: 2px;
}

.intro-network {
    width: min(640px, 92vw, 72vh);
    margin: clamp(5px, 1.5vh, 15px) auto 0;
    filter: drop-shadow(0 0 18px #38bdf82b);
}

.intro-network svg {
    display: block;
    width: 100%;
    height: auto;
}

.intro-fibers path {
    fill: none;
    stroke: url(#introFiber);
    stroke-width: 1;
    stroke-dasharray: 8 15;
    opacity: .65;
    animation: introFiberFlow 4.5s linear infinite;
}

.intro-fibers path:nth-child(2) {
    animation-delay: -1.5s;
}

.intro-fibers path:nth-child(3) {
    animation-delay: -3s;
    opacity: .35;
}

.intro-nodes circle {
    fill: url(#introNode);
    stroke: #d8fbff;
    stroke-width: 1;
    filter: url(#introGlow);
    animation: introNodePulse 3.2s ease-in-out infinite alternate;
}

.intro-nodes circle:nth-child(2) { animation-delay: -.8s; }
.intro-nodes circle:nth-child(3) { animation-delay: -1.6s; }
.intro-nodes circle:nth-child(4) { animation-delay: -2.2s; }

.intro-signals circle {
    fill: #ecfeff;
    filter: url(#introGlow);
    animation: introSignalPulse 1.7s ease-in-out infinite alternate;
}

.intro-signals circle:nth-child(2) { animation-delay: -.55s; }
.intro-signals circle:nth-child(3) { animation-delay: -1.1s; }

.intro-status {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    min-height: 18px;
    color: #b7cce5;
    font-size: 11px;
    letter-spacing: 1.3px;
    text-transform: uppercase;
}

.intro-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #67e8f9;
    box-shadow: 0 0 12px #67e8f9;
}

.intro-progress {
    width: min(320px, 70vw);
    height: 2px;
    margin: clamp(8px, 1.8vh, 15px) auto 0;
    overflow: hidden;
    border-radius: 2px;
    background: #29415e;
}

.intro-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #a5f3fc);
    box-shadow: 0 0 12px #67e8f9;
    transition: width .35s ease;
}

.intro-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    min-height: clamp(46px, 7vh, 62px);
}

.intro-enter {
    border: 1px solid #67e8f9;
    border-radius: 8px;
    padding: 11px 20px;
    background: #0c4060aa;
    color: #effcff;
    font: inherit;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 22px #38bdf82b;
}

.intro-enter:disabled {
    opacity: 0;
    pointer-events: none;
}

.intro-enter:hover,
.intro-enter:focus-visible {
    background: #155e85;
    box-shadow: 0 0 28px #38bdf866;
}

.intro-skip {
    border: 0;
    background: transparent;
    color: #7892b1;
    font: inherit;
    font-size: 10px;
    cursor: pointer;
}

.intro-skip:hover,
.intro-skip:focus-visible {
    color: #d6efff;
}

@keyframes introFiberFlow {
    to { stroke-dashoffset: -92; }
}

@keyframes introNodePulse {
    to { transform: translateY(-3px); opacity: .82; }
}

@keyframes introSignalPulse {
    to { opacity: .25; transform: scale(.7); }
}

@keyframes introBreathe {
    to { opacity: .45; transform: scale(1.12); }
}

@keyframes introSweep {
    0%, 100% { transform: translateX(-80%); }
    50% { transform: translateX(80%); }
}

@media (prefers-reduced-motion: reduce) {
    .intro-screen,
    .intro-progress span {
        transition-duration: .01ms;
    }

    /* CINEMATIC INTRO */

    .intro-screen {
        place-items: center;
        background:
            radial-gradient(ellipse at 50% 42%, #123d68 0%, transparent 28%),
            radial-gradient(ellipse at 15% 80%, #182b55 0%, transparent 35%),
            radial-gradient(ellipse at 88% 18%, #241b4f 0%, transparent 32%),
            #030711;
    }

    .intro-atmosphere {
        background-image:
            linear-gradient(#79d9ff0a 1px, transparent 1px),
            linear-gradient(90deg, #79d9ff0a 1px, transparent 1px);
        background-size: 58px 58px;
        mask-image: radial-gradient(ellipse at center, #000 0%, transparent 78%);
        opacity: .48;
    }

    .intro-atmosphere::before {
        background:
            radial-gradient(circle at 50% 45%, #6ee7f91e, transparent 20%),
            radial-gradient(circle at 50% 45%, transparent 28%, #38bdf809 29%, transparent 44%);
        animation: introBreathe 5s ease-in-out infinite alternate;
    }

    .intro-atmosphere::after {
        background: linear-gradient(105deg, transparent 27%, #9beafe0b 46%, transparent 64%);
    }

    .intro-orb {
        position: absolute;
        display: block;
        width: clamp(140px, 24vw, 360px);
        aspect-ratio: 1;
        border: 1px solid #67e8f91a;
        border-radius: 50%;
        filter: blur(.2px);
    }

    .intro-orb-one {
        top: 10%;
        left: 7%;
        box-shadow: inset 0 0 70px #38bdf80d, 0 0 80px #38bdf80b;
    }

    .intro-orb-two {
        right: 3%;
        bottom: 3%;
        width: clamp(100px, 18vw, 260px);
        border-color: #a78bfa17;
        box-shadow: inset 0 0 60px #a78bfa0b, 0 0 70px #a78bfa08;
    }

    .intro-grid-line {
        position: absolute;
        width: 42vw;
        height: 1px;
        background: linear-gradient(90deg, transparent, #67e8f91c, transparent);
        transform: rotate(-24deg);
    }

    .intro-grid-line-one { top: 19%; left: -8%; }
    .intro-grid-line-two { right: -8%; bottom: 22%; transform: rotate(-24deg); }

    .intro-content {
        width: min(1120px, 94vw);
        max-height: 100%;
        padding: clamp(12px, 3vh, 30px) 0;
        gap: 0;
    }

    .intro-console-line {
        display: flex;
        align-items: center;
        gap: 9px;
        color: #7692b4;
        font-size: 9px;
        letter-spacing: 2.4px;
        text-transform: uppercase;
    }

    .intro-console-line span,
    .intro-console-line i {
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: #67e8f9;
        box-shadow: 0 0 10px #67e8f9;
    }

    .intro-console-line i {
        width: 34px;
        height: 1px;
        margin-left: 4px;
        border-radius: 0;
        opacity: .45;
    }

    .intro-core-shell {
        position: relative;
        width: min(620px, 78vw, 49vh);
        margin: clamp(7px, 1.2vh, 14px) auto clamp(-8px, -1vh, -3px);
        aspect-ratio: 1.7;
    }

    .intro-core-rings,
    .intro-core-rings::before,
    .intro-core-rings::after {
        position: absolute;
        inset: 12%;
        border: 1px solid #67e8f92a;
        border-radius: 50%;
        transform: rotate(-14deg) scaleY(.42);
        box-shadow: 0 0 22px #38bdf81a;
        content: "";
    }

    .intro-core-rings::before {
        inset: -11%;
        border-color: #a5f3fc16;
        transform: rotate(56deg) scaleY(.68);
    }

    .intro-core-rings::after {
        inset: 9%;
        border-color: #a78bfa20;
        transform: rotate(78deg) scaleY(.32);
    }

    .intro-network {
        position: relative;
        z-index: 1;
        width: 100%;
        margin: 0;
        filter: drop-shadow(0 0 22px #38bdf84d);
    }

    .intro-network svg {
        overflow: visible;
    }

    .intro-core-aura {
        fill: #38bdf80c;
        filter: none;
        transform-origin: center;
        animation: introCoreAura 4s ease-in-out infinite alternate;
    }

    .intro-fibers path {
        stroke-width: 1.1;
        stroke-dasharray: 4 13;
        opacity: .52;
        animation: introFiberFlow 3.8s linear infinite;
    }

    .intro-fibers .intro-fiber-inner {
        stroke-width: 1.8;
        stroke-dasharray: 2 10;
        opacity: .68;
    }

    .intro-signals circle {
        fill: #f0fdff;
        filter: url(#introGlow);
    }

    .intro-nodes circle {
        stroke-width: 1.2;
        transform-origin: center;
        animation: introNodePulse 3.6s ease-in-out infinite alternate;
    }

    .intro-nodes circle:nth-child(2n) { animation-delay: -.8s; }
    .intro-nodes circle:nth-child(3n) { animation-delay: -1.6s; }

    .intro-nodes .intro-node-core {
        fill: url(#introNode);
        stroke: #e0fbff;
        stroke-width: 1.8;
        filter: url(#introGlow);
        animation: introCorePulse 2.8s ease-in-out infinite alternate;
    }

    .intro-core-caption {
        position: absolute;
        right: 5%;
        bottom: 11%;
        color: #7fa8c9;
        font-size: 8px;
        letter-spacing: 2px;
    }

    .intro-core-caption b {
        color: #67e8f9;
        font-weight: 400;
    }

    .intro-copy {
        position: relative;
        z-index: 2;
    }

    .intro-overline {
        font-size: 9px;
        letter-spacing: 4px;
        color: #67e8f9;
    }

    .intro-content h1 {
        margin-top: 8px;
        font-size: clamp(30px, 5vw, 64px);
        font-weight: 500;
        letter-spacing: clamp(5px, 1vw, 13px);
        text-indent: clamp(5px, 1vw, 13px);
        text-shadow: 0 0 32px #67e8f944;
    }

    .intro-subtitle {
        margin-top: 7px;
        font-size: clamp(13px, 1.7vw, 18px);
        letter-spacing: 2.5px;
    }

    .intro-tagline {
        margin-top: 13px;
        color: #b7cde4;
        font-size: 11px;
        letter-spacing: 1.5px;
    }

    .intro-status {
        margin-top: clamp(8px, 1.4vh, 15px);
        font-size: 10px;
    }

    .intro-progress {
        width: min(300px, 55vw);
        margin-top: 10px;
    }

    .intro-actions {
        min-height: 58px;
    }

    .intro-enter {
        border-radius: 4px;
        padding: 12px 21px;
        background: linear-gradient(110deg, #0b4566cc, #26306acc);
        letter-spacing: 2px;
        box-shadow: 0 0 25px #38bdf82b, inset 0 0 18px #67e8f914;
    }

    .intro-enter b {
        margin-left: 7px;
        color: #67e8f9;
        font-size: 14px;
    }

    @keyframes introCoreAura {
        to { opacity: .72; transform: scale(1.12); }
    }

    @keyframes introCorePulse {
        to { transform: scale(1.06); opacity: .9; }
    }

    @media (max-width: 550px) {
        .intro-content {
            width: 94vw;
        }

        @media (min-width: 700px) {
            .intro-content h1 {
                white-space: nowrap;
            }
        }

        .intro-core-shell {
            width: min(92vw, 50vh);
        }

        .intro-console-line {
            font-size: 7px;
            letter-spacing: 1.6px;
        }

        .intro-content h1 {
            font-size: clamp(25px, 8vw, 38px);
            letter-spacing: clamp(2px, .9vw, 6px);
            text-indent: clamp(2px, .9vw, 6px);
        }

        .intro-tagline {
            margin-top: 8px;
            font-size: 9px;
        }

        .intro-core-caption {
            display: none;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .intro-core-aura,
        .intro-fibers path,
        .intro-nodes circle,
        .intro-nodes .intro-node-core {
            animation: none;
        }
    }

    .intro-atmosphere::before,
    .intro-atmosphere::after,
    .intro-fibers path,
    .intro-nodes circle,
    .intro-signals circle {
        animation: none;
    }
}

/* HEADER */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 25px;
    background: rgba(15, 25, 45, 0.75);
    border: 1px solid var(--border);
    border-radius: 16px;
    backdrop-filter: blur(15px);
    margin-bottom: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #0284c7, #7c3aed);
    font-size: 25px;
    font-weight: bold;
    box-shadow: 0 0 25px #2563eb55;
}

.brand h1 {
    font-size: 21px;
    letter-spacing: 0.5px;
}

.brand p {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--muted);
    margin-top: 5px;
}

.header-status {
    color: #4ade80;
    font-size: 11px;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 9px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 12px #4ade80;
    display: inline-block;
}

/* DASHBOARD LAYOUT */

.dashboard {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 25px;
    align-items: start;
}

/* CONTROL PANEL */

.control-panel,
.visualization-card,
.info-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    backdrop-filter: blur(15px);
    box-shadow: 0 15px 40px #00000030;
}

.control-panel {
    padding: 25px;
}

.section-heading {
    margin-bottom: 25px;
}

.section-heading > span,
.eyebrow {
    color: var(--blue);
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 2px;
}

.section-heading h2 {
    font-size: 20px;
    margin: 9px 0 6px;
}

.section-heading p {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-bottom: 20px;
}

.control-group label {
    font-size: 12px;
    color: #bdc9dc;
}

.control-group small {
    color: var(--muted);
    font-size: 10px;
}

.control-group input,
.control-group select {
    width: 100%;
    padding: 12px;
    background: #0a1325;
    border: 1px solid #293c5a;
    border-radius: 9px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: 0.3s;
}

.control-group input:focus,
.control-group select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 15px #38bdf830;
}

.primary-btn,
.secondary-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 9px;
    color: white;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.primary-btn {
    background: linear-gradient(100deg, #0284c7, #6366f1);
    box-shadow: 0 5px 20px #2563eb40;
}

.secondary-btn {
    background: linear-gradient(100deg, #6d28d9, #9333ea);
    box-shadow: 0 5px 20px #9333ea30;
}

.primary-btn:hover,
.secondary-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

.panel-divider {
    height: 1px;
    background: var(--border);
    margin: 28px 0;
}

/* WORKSPACE */

.workspace {
    min-width: 0;
}

.visualization-card {
    padding: 25px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 21px;
    margin-top: 7px;
}

.live-badge {
    color: #4ade80;
    border: 1px solid #4ade8050;
    background: #4ade8010;
    border-radius: 20px;
    padding: 7px 12px;
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.network-container {
    position: relative;
    width: 100%;
    overflow-x: auto;
    background:
        linear-gradient(#ffffff05 1px, transparent 1px),
        linear-gradient(90deg, #ffffff05 1px, transparent 1px),
        #0a1325;
    background-size: 25px 25px;
    border: 1px solid #263b5b;
    border-radius: 13px;
    padding: 12px;
}

#network3d {
    display: block;
    width: 100%;
    min-height: 360px;
    height: min(58vw, 560px);
    cursor: grab;
    touch-action: none;
    background: radial-gradient(circle at 50% 42%, #14294a 0%, #0a1325 68%);
    border-radius: 9px;
}

#network3d:active {
    cursor: grabbing;
}

#network3d.is-fallback {
    display: none;
}

#network {
    display: none;
}

#network.is-fallback {
    display: block;
}

.network-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    padding-top: 10px;
}

.network-tools button {
    border: 1px solid #2e4d72;
    border-radius: 7px;
    padding: 6px 9px;
    background: #10233d;
    color: #b9d5f3;
    font: inherit;
    font-size: 10px;
    cursor: pointer;
}

.network-tools button:hover,
.network-tools button:focus-visible {
    border-color: #67e8f9;
    color: #f0fbff;
}

.network-help {
    color: var(--muted);
    font-size: 10px;
    margin-right: auto;
}

.network-tooltip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    padding: 7px 9px;
    border: 1px solid #3c668f;
    border-radius: 7px;
    background: #081426eF;
    color: #dff7ff;
    font-size: 10px;
    white-space: nowrap;
    transform: translate(10px, 10px);
}

.network-tooltip[hidden] {
    display: none;
}

.neuron-inspector {
    position: absolute;
    z-index: 4;
    top: 62px;
    right: 24px;
    width: min(290px, calc(100% - 48px));
    max-height: calc(100% - 90px);
    overflow: auto;
    padding: 16px;
    border: 1px solid #365a83;
    border-radius: 12px;
    background: #0c1a30ee;
    box-shadow: 0 16px 38px #0008;
    backdrop-filter: blur(12px);
}

.neuron-inspector[hidden] {
    display: none;
}

.neuron-inspector > button {
    float: right;
    border: 0;
    background: transparent;
    color: #a9c5e5;
    font-size: 22px;
    cursor: pointer;
}

.neuron-inspector h3 {
    margin: 6px 0 12px;
}

.inspector-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 11px;
}

.inspector-grid dt {
    color: var(--muted);
}

.inspector-grid dd {
    margin: 0;
    color: #e0f2fe;
    text-align: right;
    word-break: break-word;
}

@media (max-width: 600px) {
    #network3d {
        min-height: 290px;
        height: 72vw;
    }

    .network-help {
        width: 100%;
        margin-right: 0;
    }

    .network-tools button {
        min-height: 34px;
        padding: 7px 10px;
    }

    .neuron-inspector {
        top: 42px;
        right: 12px;
        width: calc(100% - 24px);
    }
}

#network {
    display: none;
    width: 100%;
    min-width: 500px;
    height: auto;
    overflow: visible;
}

#network.is-fallback {
    display: block;
}

.network-container circle {
    stroke: #dbeafe;
    stroke-width: 1.5px;
    filter: drop-shadow(0 0 7px #38bdf880);
}

.network-container line {
    opacity: 0.55;
}

.network-container path {
    fill: none;
    stroke: #58708e;
    stroke-width: 0.9px;
    opacity: 0.42;
    transition: opacity 0.25s, stroke 0.25s;
}

.network-container path.signal-active,
.network-container path.backward-active {
    opacity: 1;
    stroke: url(#signalGradient);
    stroke-width: 1.8px;
    filter: url(#softGlow);
    stroke-dasharray: 0.08 0.92;
    animation: threadSignal 0.65s linear infinite;
}

.network-container path.backward-active {
    stroke: #fb923c;
    animation-name: reverseThreadSignal;
}

/* LEGEND */

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    padding-top: 18px;
}

.legend span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
}

.legend i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.legend-input {
    background: #3498db;
}

.legend-hidden {
    background: #f39c12;
}

.legend-output {
    background: #9b59b6;
}

.legend-signal {
    background: #67e8f9;
    box-shadow: 0 0 8px #67e8f9;
}

/* BOTTOM CARDS */

.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 22px;
}

.info-card {
    padding: 23px;
    min-height: 145px;
    transition: 0.3s;
}

.info-card:hover {
    transform: translateY(-4px);
    border-color: #38bdf855;
}

.info-card h3 {
    font-size: 16px;
    margin: 10px 0;
}

.value-display {
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

/* FOOTER */

footer {
    text-align: center;
    padding: 30px 10px 10px;
    color: #64748b;
    font-size: 10px;
    letter-spacing: 2px;
}

footer span {
    color: var(--blue);
}

/* RESPONSIVE DESIGN */

@media (max-width: 900px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .control-panel {
        width: 100%;
        position: static;
        height: auto;
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 550px) {
    body {
        padding: 15px;
    }

    .topbar {
        padding: 15px;
    }

    .brand h1 {
        font-size: 16px;
    }

    .brand p {
        font-size: 8px;
    }

    .header-status {
        font-size: 8px;
    }

    .bottom-grid {
        grid-template-columns: 1fr;
    }

    .visualization-card {
        padding: 15px;
    }

    .card-header h2 {
        font-size: 17px;
    }
}

/* NEURAL SIGNAL ANIMATION */

.network-container line.signal-active {
    stroke: #38bdf8;
    stroke-width: 3px;
    stroke-dasharray: 8 12;
    animation: signalFlow 0.65s linear infinite;
    filter: drop-shadow(0 0 5px #38bdf8);
    opacity: 1;
}

.network-container circle.neuron-active {
    stroke: #ffffff;
    stroke-width: 3px;
    filter:
        drop-shadow(0 0 8px #38bdf8)
        drop-shadow(0 0 18px #38bdf8);
    animation: neuronPulse 0.8s ease-in-out infinite alternate;
}

@keyframes signalFlow {
    from {
        stroke-dashoffset: 40;
    }

    to {
        stroke-dashoffset: 0;
    }
}

@keyframes neuronPulse {
    from {
        r: 22;
        opacity: 0.8;
    }

    to {
        r: 27;
        opacity: 1;
    }
}

/* CALCULATION PANEL */

.calculation-card {
    margin-top: 22px;
    padding: 25px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 15px 40px #00000030;
}

#calculationStatus {
    padding: 13px;
    margin: 15px 0;
    border-radius: 9px;
    background: #0a1325;
    border: 1px solid #263b5b;
    color: var(--blue);
    font-size: 13px;
}

#calculationLog {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 350px;
    overflow-y: auto;
}

#calculationLog p {
    padding: 12px 15px;
    background: #0a1325;
    border-left: 3px solid var(--purple);
    border-radius: 6px;
    color: #bdc9dc;
    font-size: 12px;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

#calculationLog .step-title {
    color: var(--blue);
    font-weight: bold;
}

/* BACKWARD SIGNAL FLOW */

.network-container line.backward-active {
    stroke: #fb923c;
    stroke-width: 3px;
    stroke-dasharray: 8 12;
    animation: backwardFlow 0.65s linear infinite;
    filter: drop-shadow(0 0 7px #fb923c);
    opacity: 1;
}

@keyframes backwardFlow {
    from {
        stroke-dashoffset: 0;
    }

    to {
        stroke-dashoffset: 40;
    }
}

.network-container circle.neuron-active {
    stroke: white;
    stroke-width: 3px;
    filter:
        drop-shadow(0 0 8px #38bdf8)
        drop-shadow(0 0 18px #38bdf8);
    animation: neuronPulse 1s ease-in-out infinite alternate;
}

.network-container circle.backward-neuron {
    filter: drop-shadow(0 0 12px #fb923c);
}

@keyframes threadSignal {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
}

@keyframes reverseThreadSignal {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: 1; }
}

/* =================================
   SIDE-BY-SIDE SIMULATION LAYOUT
================================= */

.simulation-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.85fr);
    gap: 20px;
    align-items: stretch;
}

.visualization-card {
    min-width: 0;
    height: 100%;
}

.calculation-card {
    min-width: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.calculation-card .card-header {
    align-items: flex-start;
}

#calculationStatus {
    min-height: 65px;
    display: flex;
    align-items: center;
    line-height: 1.6;
    font-weight: 600;
}

#calculationLog {
    flex: 1;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 5px;
    scroll-behavior: smooth;
}

#calculationLog p {
    animation: logAppear 0.35s ease;
}

@keyframes logAppear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* CUSTOM SCROLLBAR */

#calculationLog::-webkit-scrollbar {
    width: 5px;
}

#calculationLog::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 10px;
}

#stageIndicator {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 10px 0;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#stageLabel {
    color: var(--blue);
    font-weight: 700;
}

.progress-track {
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: #17243b;
}

#progressBar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blue), var(--purple));
    transition: width 0.35s ease;
}

.current-step-panel {
    min-height: 245px;
    padding: 18px;
    margin: 14px 0;
    border: 1px solid #38bdf844;
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(20, 42, 72, 0.9), rgba(11, 20, 38, 0.95));
    box-shadow: inset 0 1px 0 #ffffff0a;
}

.step-kicker {
    color: var(--blue);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.current-step-panel h3 {
    margin: 10px 0 14px;
    color: #f4f8ff;
    font-size: 16px;
}

#currentStepContent {
    color: #c4d2e8;
    font-size: 12px;
    line-height: 1.85;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.history-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(8, 19, 37, 0.55);
}

.history-panel summary {
    padding: 12px 14px;
    color: #c4d2e8;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    list-style-position: inside;
}

.history-panel summary span {
    float: right;
    color: var(--muted);
    font-weight: 400;
}

#calculationLog {
    max-height: 190px;
    padding: 0 10px 10px;
}

.empty-history {
    color: var(--muted);
}

/* BOTTOM INFORMATION */

.bottom-grid {
    margin-top: 20px;
    width: 100%;
}

/* TABLET AND MOBILE */

@media (max-width: 1100px) {

    .simulation-grid {
        grid-template-columns: 1fr;
    }

    .calculation-card {
        min-height: 400px;
    }

    #calculationLog {
        max-height: 350px;
    }
}

/* NETWORK RESPONSIVE FIT */

.network-container {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

#network {
    display: none;
    width: 100%;
    height: auto;
    max-width: 100%;
    min-width: 0;
}

#network.is-fallback {
    display: block;
}

/* Keep normal architectures inside the card */
.visualization-card {
    min-width: 0;
    overflow: hidden;
}

/* Only allow horizontal scrolling for unusually large networks */
@media (min-width: 1101px) {
    .network-container {
        scrollbar-width: thin;
    }

    #network {
        min-height: 0;
    }
}

/* CLEAN SIDEBAR SCROLL */

.control-panel {
    position: sticky;
    top: 16px;
    height: calc(100vh - 32px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    align-self: start;
    padding-bottom: 20px;
    scrollbar-width: thin;
}

/* Normal button behavior */

#simulateBtn {
    position: static;
    width: 100%;
    margin-top: 12px;
    box-shadow: none;
}

/* Slightly reduce unnecessary vertical spacing */
.control-group {
    margin-bottom: 12px;
}

.section-heading {
    margin-bottom: 14px;
}

/* STEP-BY-STEP CONTROLS */

#stepControls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    margin: 12px 0;
    background: rgba(15, 25, 45, 0.9);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mode-btn,
.next-step-btn {
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #14213a;
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}

.mode-btn.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--blue);
    color: var(--blue);
}

.next-step-btn {
    background: var(--blue);
    color: #07111f;
    border: none;
}

.next-step-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.calculation-step {
    padding: 14px;
    margin: 10px 0;
    border-left: 3px solid var(--border);
    border-radius: 7px;
    background: rgba(15, 25, 45, 0.65);
}

.calculation-step.current-step {
    border-left-color: var(--blue);
    background: rgba(56, 189, 248, 0.10);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.08);
}

.step-description {
    margin-top: 9px;
    line-height: 1.8;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .control-panel {
        position: static;
        height: auto;
        max-height: none;
        overflow: visible;
    }
}

/* Initialization and training controls */
.settings-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(8, 19, 37, 0.55);
}

@media (max-width: 550px) {
    .intro-content h1 {
        font-size: clamp(25px, 8vw, 38px);
        letter-spacing: clamp(2px, .9vw, 6px);
        text-indent: clamp(2px, .9vw, 6px);
    }

    .intro-core-shell {
        width: min(92vw, 50vh);
    }
}

@media (min-width: 700px) {
    .intro-content h1 {
        white-space: nowrap;
    }
}

.settings-panel > summary {
    padding: 13px;
    color: #d7e5fa;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.settings-body {
    padding: 0 13px 13px;
}

.manual-parameters[hidden],
#seedGroup[hidden] {
    display: none;
}

.parameter-help,
.control-message {
    margin: 8px 0 12px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.6;
}

.control-message {
    color: #7dd3fc;
}

.error-message {
    color: #fb7185;
}

#simulationMessage {
    margin: -4px 0 12px;
    line-height: 1.6;
}

.parameter-layer {
    margin: 8px 0;
    border: 1px solid #263b5b;
    border-radius: 8px;
}

.parameter-layer summary {
    padding: 9px;
    color: #bdc9dc;
    cursor: pointer;
    font-size: 10px;
}

.parameter-table {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 0 8px 8px;
}

.parameter-table label,
.training-actions label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--muted);
    font-size: 9px;
}

.parameter-table input,
.training-actions input {
    width: 100%;
    padding: 7px;
    border: 1px solid #293c5a;
    border-radius: 6px;
    background: #0a1325;
    color: white;
    font-size: 11px;
}

.tertiary-btn {
    width: 100%;
    margin-top: 8px;
    padding: 9px;
    border: 1px solid #365173;
    border-radius: 8px;
    background: #14213a;
    color: #d7e5fa;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.tertiary-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.training-actions {
    display: grid;
    grid-template-columns: 1fr 70px;
    gap: 8px;
    margin-top: 14px;
}

.training-actions .tertiary-btn {
    grid-column: 1 / -1;
}

.comparison-card,
.parameter-card {
    white-space: pre-line;
}

.comparison-card .value-display,
.parameter-card .value-display {
    line-height: 1.75;
}

.network-container path {
    stroke-width: 1.2px;
    transition: opacity 0.35s ease, stroke-width 0.35s ease;
}

.network-container path.signal-active,
.network-container path.backward-active {
    stroke-width: 2.2px;
    animation-duration: 1.1s;
    animation-name: threadSignal, signalFade;
    animation-timing-function: linear, ease-in-out;
    animation-iteration-count: infinite, 1;
}

.network-container path.backward-active {
    animation-name: reverseThreadSignal, signalFade;
}

@keyframes signalFade {
    0% { opacity: 0.3; }
    35% { opacity: 1; }
    75% { opacity: 0.85; }
    100% { opacity: 0.45; }
}

@media (max-width: 550px) {
    body {
        padding: 10px;
        overflow-x: hidden;
    }

    .topbar {
        margin-bottom: 14px;
        padding: 12px;
    }

    .header-status {
        display: none;
    }

    .dashboard {
        gap: 14px;
    }

    .control-panel,
    .visualization-card,
    .calculation-card {
        border-radius: 13px;
    }

    .control-panel {
        padding: 14px;
    }

    .network-container {
        padding: 6px;
        max-height: 55vh;
        overflow: auto;
    }

    #network {
        min-width: 560px;
    }

    .card-header {
        margin-bottom: 12px;
    }

    .card-header h2 {
        font-size: 16px;
    }

    .current-step-panel {
        min-height: 210px;
        padding: 14px;
    }

    .parameter-table {
        grid-template-columns: 1fr 1fr;
    }

    .legend {
        gap: 10px 14px;
    }

    .intro-content h1 {
        font-size: clamp(24px, 8vw, 36px);
        letter-spacing: clamp(2px, 1vw, 6px);
        text-indent: clamp(2px, 1vw, 6px);
    }

    .intro-network {
        width: min(92vw, 62vh);
    }

    .intro-subtitle {
        font-size: 12px;
        letter-spacing: 1px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.mobile-controls-btn,
.mobile-hint {
    display: none;
}

.math-configuration {
    display: grid;
    gap: 6px;
    margin: -2px 0 14px;
    padding: 11px;
    border: 1px solid #38bdf833;
    border-radius: 9px;
    background: rgba(15, 35, 61, 0.7);
    color: #bcd0e8;
    font-size: 10px;
    line-height: 1.55;
}

.math-configuration strong {
    color: var(--blue);
    font-size: 11px;
}

.math-configuration span:first-of-type {
    color: #f0d7ff;
    font-family: Consolas, monospace;
}

@media (max-width: 550px) {
    .mobile-controls-btn {
        display: block;
        padding: 8px 11px;
        border: 1px solid #38bdf866;
        border-radius: 8px;
        background: #14213a;
        color: var(--blue);
        cursor: pointer;
        font-size: 11px;
        font-weight: 700;
    }

    .mobile-hint {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin: -4px 0 12px;
        padding: 8px 10px;
        border: 1px solid #38bdf833;
        border-radius: 8px;
        color: var(--muted);
        font-size: 10px;
    }

    .mobile-hint[hidden] {
        display: none;
    }

    .mobile-hint button {
        flex: 0 0 auto;
        border: 0;
        background: transparent;
        color: var(--muted);
        cursor: pointer;
        font-size: 18px;
        line-height: 1;
    }

    .controls-collapsed .control-panel {
        display: none;
    }

    .control-panel {
        max-height: 70vh;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .control-group input,
    .control-group select,
    .parameter-table input,
    .training-actions input,
    .primary-btn,
    .secondary-btn,
    .tertiary-btn,
    .mode-btn,
    .next-step-btn {
        min-height: 42px;
    }

    .simulation-grid {
        gap: 12px;
    }

    .calculation-card {
        min-height: 0;
    }

    .current-step-panel {
        min-height: 170px;
        max-height: 260px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    #calculationLog {
        max-height: 150px;
    }

    .network-container {
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }
}
