/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --glass-bg:     rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-blur:   16px;
    --accent:       rgba(255, 255, 255, 0.85);
    --muted:        rgba(255, 255, 255, 0.45);
    --radius:       14px;
    --font:         'JetBrains Mono', 'Fira Mono', 'Courier New', monospace;
}

html, body {
    height: 100%;
    overflow: hidden;
}

@media (max-width: 680px) {
    html, body {
        height: auto;
        overflow: auto;
        overflow-x: hidden;
    }
}

body {
    font-family: var(--font);
    color: var(--accent);
    background: #05071a;
    background-image:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(30, 60, 140, 0.55) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 90%, rgba(80, 20, 120, 0.45) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 60% 30%, rgba(0, 120, 180, 0.20) 0%, transparent 50%);
}

/* ─── Glass Card ───────────────────────────────────────────────────────────── */
.glass {
    background:    var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border:        1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow:    0 8px 32px rgba(0, 0, 0, 0.4),
                   inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.app {
    display:        flex;
    flex-direction: column;
    height:         100vh;
    padding:        14px;
    gap:            12px;
}

header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         10px 20px;
    flex-shrink:     0;
}

header h1 {
    font-size:      1.2rem;
    font-weight:    700;
    letter-spacing: 0.04em;
    color:          #fff;
}

header p {
    font-size:  0.72rem;
    color:      var(--muted);
    letter-spacing: 0.06em;
}

.status-bar {
    display:     flex;
    align-items: center;
    gap:         8px;
    font-size:   0.72rem;
    color:       var(--muted);
}

.status-dot {
    width:         8px;
    height:        8px;
    border-radius: 50%;
    background:    #555;
    transition:    background 0.3s;
}

.status-dot.running { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.status-dot.idle    { background: #60a5fa; }

/* Main content area */
.content {
    display:   flex;
    flex:      1;
    gap:       12px;
    min-height: 0;
}

/* Left panel */
.left-panel {
    display:        flex;
    flex-direction: column;
    gap:            12px;
    width:          240px;
    flex-shrink:    0;
}

.panel-section {
    padding: 14px 16px;
}

.panel-section h2 {
    font-size:      0.7rem;
    font-weight:    600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color:          var(--muted);
    margin-bottom:  10px;
}

/* Radio group */
.radio-group {
    display:        flex;
    flex-direction: column;
    gap:            8px;
}

.radio-group label {
    display:     flex;
    align-items: center;
    gap:         10px;
    font-size:   0.8rem;
    cursor:      pointer;
    padding:     7px 10px;
    border-radius: 8px;
    transition:  background 0.2s;
    color:       rgba(255,255,255,0.75);
}

.radio-group label:hover {
    background: rgba(255,255,255,0.08);
}

.radio-group input[type="radio"] {
    appearance:  none;
    -webkit-appearance: none;
    width:        15px;
    height:       15px;
    border:       2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    cursor:       pointer;
    flex-shrink:  0;
    transition:   border-color 0.2s, background 0.2s;
}

.radio-group input[type="radio"]:checked {
    border-color: #60a5fa;
    background:   #60a5fa;
    box-shadow:   0 0 8px rgba(96, 165, 250, 0.5);
}

/* Formation preview */
#preview-canvas {
    display:       block;
    width:         100%;
    aspect-ratio:  1;
    border-radius: 8px;
    background:    rgba(0, 0, 0, 0.25);
}

/* Network graph */
#network-graph {
    width:         100%;
    aspect-ratio:  1;
    overflow:      visible;
}

.graph-edge {
    stroke:     rgba(255, 255, 255, 0.6);
    transition: stroke 0.25s;
}

.graph-edge.inactive {
    stroke:           rgba(255, 255, 255, 0.12);
    stroke-dasharray: 5 4;
}

.graph-edge:hover {
    stroke: rgba(96, 165, 250, 0.9);
}

/* Right panel */
.right-panel {
    flex:           1;
    display:        flex;
    flex-direction: column;
    gap:            12px;
    min-width:      0;
}

.sim-wrapper {
    flex:      1;
    padding:   14px;
    display:   flex;
    flex-direction: column;
    gap:       10px;
    min-height: 0;
}

.sim-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    flex-shrink:     0;
}

.sim-header h2 {
    font-size:      0.7rem;
    font-weight:    600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color:          var(--muted);
}

.sim-canvas-wrap {
    flex:     1;
    min-height: 0;
    position: relative;
}

#sim-canvas {
    position:      absolute;
    inset:         0;
    width:         100%;
    height:        100%;
    border-radius: 8px;
    background:    rgba(0, 0, 0, 0.30);
}

/* Progress */
.progress-wrap {
    flex-shrink: 0;
}

.progress-track {
    height:        4px;
    background:    rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow:      hidden;
}

.progress-fill {
    height:     100%;
    width:      0%;
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
    border-radius: 2px;
    transition: width 0.1s linear;
}

#progress-label {
    font-size:  0.65rem;
    color:      var(--muted);
    margin-top: 4px;
}

/* Controls */
.controls {
    display:     flex;
    align-items: center;
    gap:         12px;
    padding:     12px 16px;
    flex-shrink: 0;
}

.btn {
    padding:       9px 28px;
    font-family:   var(--font);
    font-size:     0.8rem;
    font-weight:   600;
    letter-spacing: 0.06em;
    border:        1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor:        pointer;
    background:    rgba(255,255,255,0.08);
    color:         var(--accent);
    transition:    background 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
    backdrop-filter: blur(8px);
}

.btn:hover:not(:disabled) {
    background:   rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.35);
    box-shadow:   0 0 16px rgba(96, 165, 250, 0.2);
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.35;
    cursor:  not-allowed;
}

.btn.primary {
    background:   rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.4);
}

.btn.primary:hover:not(:disabled) {
    background:  rgba(96, 165, 250, 0.28);
    border-color: rgba(96, 165, 250, 0.6);
    box-shadow:  0 0 20px rgba(96, 165, 250, 0.3);
}

.info-text {
    font-size:  0.68rem;
    color:      var(--muted);
    margin-left: auto;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
    .app {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        padding: 10px;
    }

    .content {
        flex-direction: column;
        flex: none;
        overflow: visible;
    }

    .left-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        flex-shrink: 0;
    }

    .panel-section {
        flex: 1;
        min-width: 160px;
    }

    .right-panel {
        flex: none;
    }

    .sim-wrapper {
        flex: none;
        min-height: 0;
    }

    .sim-canvas-wrap {
        flex: none;
        height: 260px;
        min-height: 0;
        position: relative;
    }

    #sim-canvas {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
    }

    #network-graph {
        max-height: 180px;
    }
}
