:root {
    /* §2 Color Palette - Monochromatic */
    --base-black: #000000;
    --base-white: #ffffff;
    --dark-gray: #1a1a1a;
    --light-gray: #f5f5f5;
    --grid-gray: #d1d1d1;
    --tech-red: #ff0000;

    --page-bg: var(--base-white);
    --text-primary: var(--base-black);
    --text-secondary: #888;
    --border-color: #d1d1d1;
    /* §6.2: 1px gray lines, NOT black */
    --card-bg: var(--light-gray);

    /* §3 Typography - Dual Track */
    --font-display: 'VT323', 'Noto Sans SC', monospace;
    /* §3.1 Display/Dot-matrix */
    --font-body: 'Noto Sans SC', 'Inter', sans-serif;
    /* §3.2 Body/Sans-serif */
    --font-mono: 'Space Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* §3.2: Body font Regular/Light, line-height 1.5-1.6 */
/* §8.3: Body text 12-14px */
body {
    background-color: var(--page-bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 13px;
    line-height: 1.6;
    /* §4.1: Dot Grid, 32px spacing, 1px dots */
    background-image: radial-gradient(var(--grid-gray) 1px, transparent 1px);
    background-size: 32px 32px;
    /* §4.2: Generous padding */
    padding: 48px;
    min-height: 100vh;
}

/* §4.2: 8pt grid, generous spacing */
.container {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 48px;
}

/* §3.1: Display text = dot-matrix, ALL CAPS, letter-spacing 0.05-0.1em */
.display-text {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: normal;
    /* VT323 has only normal weight */
}

/* ===== HEADER ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* §6.2: 1px gray divider only when necessary */
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

/* Logo: dot-matrix font, moderate size */
.logo {
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background: var(--tech-red);
    border-radius: 50%;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.led-red {
    width: 6px;
    height: 6px;
    background-color: var(--tech-red);
    border-radius: 50%;
    /* §7: Hard blink, no smooth transition */
    animation: hard-blink 2s step-end infinite;
}

@keyframes hard-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ===== §8.1 CARDS ===== */

/* Solid/Glass Card: §8.1 light-gray fill OR glassmorphism */
/* §8.1: border-radius 8-12px, usually NO border */
/* §8.2: padding 24px or 32px */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    /* §8.1: usually borderless */
    padding: 24px;
    border-radius: 10px;
}

/* Ghost Card: §8.1 no background, no border */
.ghost-card {
    background: transparent;
    border: none;
    padding: 0;
}

/* ===== §6.1 BUTTONS ===== */
/* Primary: solid fill, 2-4px radius, sans-serif ALL CAPS */
.btn {
    font-family: var(--font-body);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 3px;
    transition: none;
    /* §7: no smooth transitions */
    font-size: 11px;
}

.btn-primary {
    background-color: var(--base-black);
    color: var(--base-white);
    border: none;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--base-white);
    color: var(--base-black);
    border: 1px solid var(--base-black);
}

.btn-primary:active:not(:disabled) {
    /* §8.4: mechanical press scale(0.98) */
    transform: scale(0.98);
}

.btn-primary:disabled {
    background-color: var(--grid-gray);
    color: var(--base-white);
    cursor: not-allowed;
}

/* §6.1 Ghost/Secondary: 1px border, transparent fill */
.btn-ghost {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--base-black);
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--base-black);
    color: var(--base-white);
}

.btn-ghost:disabled {
    border-color: var(--grid-gray);
    color: var(--grid-gray);
    cursor: not-allowed;
}

/* ===== INPUTS ===== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.input-group label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.input-pure {
    background: transparent;
    border: none;
    /* §6.2: use thin gray line for minimal inputs */
    border-bottom: 1px solid var(--border-color);
    padding: 6px 0;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 300;
    color: var(--text-primary);
    outline: none;
    border-radius: 0;
}

.input-pure:focus {
    border-bottom-color: var(--base-black);
    border-bottom-width: 2px;
}

.input-pure:disabled {
    color: var(--grid-gray);
    border-color: #eee;
}

/* ===== DETAILS/CONFIG PANEL ===== */
details {
    margin-bottom: 0;
}

details summary {
    font-family: var(--font-display);
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    /* §7: opacity for hover interaction */
    opacity: 0.6;
}

details summary:hover {
    opacity: 1;
}

details summary::before {
    content: '+';
    font-size: 14px;
    font-weight: bold;
    font-family: var(--font-mono);
}

details[open] summary::before {
    content: '−';
}

details[open] summary {
    opacity: 1;
}

.config-panel {
    padding: 24px;
    border-bottom: none;
}

/* ===== LAYOUT GRIDS ===== */
/* §4.2: generous gaps (32, 48, 64) */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

/* Section Headers with dot-matrix step numbers */
/* §8.2: large dot-matrix numbers as visual anchor */
.section-title {
    font-family: var(--font-display);
    font-size: 14px;
    margin-bottom: 24px;
    display: flex;
    align-items: baseline;
    gap: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.section-title .dot-number {
    font-size: 32px;
    color: var(--base-black);
    line-height: 1;
}

/* ===== FILE DROP AREA ===== */
/* §8.4 Ghost: hidden border appears on hover */
.file-drop-area {
    border: 1px dashed transparent;
    /* Hidden until hover */
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 14px;
    letter-spacing: 0.05em;
    transition: none;
    /* §7 */
    margin-bottom: 32px;
    color: var(--text-secondary);
}

.file-drop-area:hover,
.file-drop-area.dragover {
    /* §8.4 Ghost hover: instant border appear, color invert */
    background-color: var(--base-black);
    color: var(--base-white);
    border: 1px solid var(--base-black);
}

.file-drop-area input[type="file"] {
    display: none;
}

/* ===== CONTROLS GRID ===== */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

/* §3.1: LCD-style display font for numeric readouts */
.lcd-input {
    font-family: var(--font-display);
    font-size: 24px;
    padding: 6px;
    width: 100%;
    text-align: center;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    outline: none;
    letter-spacing: 0.05em;
}

.lcd-input:focus {
    border-color: var(--base-black);
}

.lcd-input:disabled {
    color: #ddd;
    border-color: #eee;
}

.lcd-input::selection {
    background: var(--base-black);
    color: var(--base-white);
}

/* ===== ACTION GRID ===== */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* ===== EDITOR & PREVIEW ===== */
.terminal-editor {
    width: 100%;
    height: 480px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 300;
    line-height: 1.6;
    padding: 24px;
    /* §8.2: generous internal padding */
    resize: none;
    outline: none;
    border-radius: 8px;
}

.terminal-editor:focus {
    border-color: var(--base-black);
}

.preview-container {
    height: 480px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 24px;
    background: transparent;
    border-radius: 8px;
}

#previewContent {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
}

.preview-container canvas,
.preview-container img {
    width: 100%;
    height: auto;
    filter: grayscale(100%) contrast(1.1);
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--grid-gray);
    border-radius: 2px;
}

/* Cursor blink: §7 hard blink */
.blinking-cursor {
    animation: hard-blink 1s step-end infinite;
}

.hidden {
    display: none !important;
}

/* Utilities */
.text-xs {
    font-size: 10px;
}

.text-sm {
    font-size: 11px;
}

.mt-4 {
    margin-top: 24px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .preview-container,
    .terminal-editor {
        height: 360px;
    }
}

@media (max-width: 640px) {
    body {
        padding: 24px;
    }

    .container {
        gap: 32px;
    }

    .controls-grid,
    .action-grid {
        grid-template-columns: 1fr;
    }

    .file-drop-area {
        padding: 32px 16px;
    }

    .logo {
        font-size: 18px;
    }
}