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

:root {
    --bg-dark: #071328;
    /* Deep blueprint navy */
    --blueprint-grid: #0f396e;
    /* Grid line color */
    --text-main: #FFFFFF;
    --text-muted: #8ab4f8;
    --primary: #08c9ff;
    /* Cyan */
    --primary-hover: #03a3d2;
    --secondary: #6C63FF;
    /* Purple */
    --warning: #FF3B30;
    /* Red for outer bounds */
    --surface: rgba(10, 25, 50, 0.7);
    --surface-border: rgba(8, 201, 255, 0.2);
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}

/* Blueprint Aesthetic Background */
.blueprint-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image:
        linear-gradient(var(--blueprint-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--blueprint-grid) 1px, transparent 1px),
        linear-gradient(rgba(15, 57, 110, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 57, 110, 0.3) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    background-position: -1px -1px;
    z-index: -2;
}

.glass-bg {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(8, 201, 255, 0.05) 0%, rgba(7, 19, 40, 0.8) 60%);
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: left;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.badge {
    display: inline-block;
    background: rgba(8, 201, 255, 0.1);
    color: var(--primary);
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--surface-border);
    font-family: 'Space Mono', monospace;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

header h1 code {
    font-family: 'Space Mono', monospace;
    color: var(--primary);
    background: rgba(8, 201, 255, 0.1);
    padding: 0 0.5rem;
    border-radius: 4px;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
}

/* Layout */
.sandbox-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    flex: 1;
}

.glass-panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Controls */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
}

.control-section h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-main);
    margin-bottom: 0.25rem;
    font-family: 'Space Mono', monospace;
}

.section-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.input-group label,
.select-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-family: 'Space Mono', monospace;
}

input[type="number"],
select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(8, 201, 255, 0.3);
    color: #FFF;
    padding: 0.75rem;
    border-radius: 6px;
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

.select-group {
    margin-bottom: 1rem;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border-color: rgba(255, 255, 255, 0.1);
    flex: 1;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #FFF;
}

.btn-outline.active {
    background: rgba(8, 201, 255, 0.2);
    color: var(--primary);
    border-color: var(--primary);
}

/* Stage */
.stage-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-height: 500px;
    background: repeating-linear-gradient(transparent,
            transparent 49px,
            rgba(255, 255, 255, 0.05) 49px,
            rgba(255, 255, 255, 0.05) 50px),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 49px,
            rgba(255, 255, 255, 0.05) 49px,
            rgba(255, 255, 255, 0.05) 50px);
}

.svg-container-wrapper {
    position: relative;
    box-shadow: 0 0 0 2px var(--warning);
    /* Outer Red Box */
    background: #111;
    transition: all 0.3s ease;
}

.live-svg {
    display: block;
    overflow: visible;
    /* Important to let viewBox bounds show even if they exceed SVG bounds when scaling down */
}

/* Legends */
.legend-box {
    position: absolute;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    z-index: 10;
}

.red-legend {
    top: -30px;
    left: 0;
    color: var(--warning);
    border: 1px solid var(--warning);
}

.blue-legend {
    bottom: -30px;
    right: 0;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.bg-red {
    background: var(--warning);
}

.bg-blue {
    background: var(--primary);
}

/* Code Output */
.code-output {
    padding: 1rem;
}

.code-output pre {
    margin: 0;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    color: #e2e8f0;
    overflow-x: auto;
}

.code-output .language-html {
    color: #4ade80;
    /* green tint for attributes */
}

/* Responsive */
@media (max-width: 900px) {
    .sandbox-layout {
        grid-template-columns: 1fr;
    }
}