:root {
    --phosphor: #33ff33;
    --phosphor-dim: #1a8c1a;
    --phosphor-bright: #66ff66;
    --amber: #ffb000;
    --amber-dim: #8c6000;
    --cyan: #00cccc;
    --cyan-dim: #006666;
    --bg-dark: #0a0e14;
    --bg-panel: #0d1117;
    --bg-header: #060a0f;
    --border: #1a3a1a;
    --text-dim: #4a7a4a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    background: var(--bg-dark);
    font-family: 'Fira Code', monospace;
    color: var(--phosphor);
    overflow-x: hidden;
}

#root::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
}

#root::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9998;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.4) 100%);
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes flash-green {
    0% { background: var(--phosphor); color: var(--bg-dark); }
    100% { background: transparent; color: var(--phosphor); }
}

@keyframes flash-amber {
    0% { background: var(--amber); color: var(--bg-dark); }
    100% { background: transparent; color: var(--amber); }
}

@keyframes flash-cyan {
    0% { background: var(--cyan); color: var(--bg-dark); }
    100% { background: transparent; color: var(--cyan); }
}

@keyframes toggle-click {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes title-morph {
    0% { opacity: 0; transform: translateY(-2px); }
    100% { opacity: 1; transform: translateY(0); }
}

.blink-cursor { animation: blink 1s step-end infinite; }
.flash-register { animation: flash-green 0.5s ease-out; }
.flash-memory { animation: flash-amber 0.3s ease-out; }
.flash-ea { animation: flash-cyan 0.5s ease-out; }
.title-anim { animation: title-morph 0.3s ease-out; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--phosphor-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--phosphor); }

.btn-retro {
    background: transparent;
    border: 1px solid var(--phosphor-dim);
    color: var(--phosphor);
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    padding: 4px 12px;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-retro:hover {
    background: var(--phosphor-dim);
    color: var(--bg-dark);
    box-shadow: 0 0 8px var(--phosphor-dim);
}

.btn-retro:active {
    background: var(--phosphor);
    color: var(--bg-dark);
}

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

.btn-retro:disabled:hover {
    background: transparent;
    color: var(--phosphor);
    box-shadow: none;
}

.btn-retro.amber { border-color: var(--amber-dim); color: var(--amber); }
.btn-retro.amber:hover { background: var(--amber-dim); color: var(--bg-dark); box-shadow: 0 0 8px var(--amber-dim); }
.btn-retro.cyan { border-color: var(--cyan-dim); color: var(--cyan); }
.btn-retro.cyan:hover { background: var(--cyan-dim); color: var(--bg-dark); box-shadow: 0 0 8px var(--cyan-dim); }

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 2px;
}

.panel-title {
    background: rgba(26, 58, 26, 0.3);
    border-bottom: 1px solid var(--border);
    padding: 4px 8px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--phosphor-dim);
}

input[type="text"], input[type="number"] {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--phosphor);
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    padding: 2px 6px;
    outline: none;
}

input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--phosphor-dim);
    box-shadow: 0 0 4px rgba(51, 255, 51, 0.2);
}

.drop-zone {
    border: 2px dashed var(--phosphor-dim);
    transition: all 0.2s;
}

.drop-zone.drag-over {
    border-color: var(--phosphor);
    background: rgba(51, 255, 51, 0.05);
    box-shadow: 0 0 20px rgba(51, 255, 51, 0.1) inset;
}

.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.ok { background: var(--phosphor); box-shadow: 0 0 4px var(--phosphor); }
.status-dot.error { background: #ff3333; box-shadow: 0 0 4px #ff3333; }
.status-dot.pending { background: var(--amber); box-shadow: 0 0 4px var(--amber); }

/* CPU Toggle Switch */
.cpu-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.cpu-toggle-track {
    position: relative;
    width: 56px;
    height: 26px;
    background: #111820;
    border: 1px solid var(--phosphor-dim);
    border-radius: 13px;
    transition: all 0.3s;
    overflow: hidden;
}

.cpu-toggle-track::before {
    content: '';
    position: absolute;
    top: 1px; left: 1px;
    width: calc(100% - 2px);
    height: calc(100% - 2px);
    border-radius: 12px;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2px,
        rgba(51,255,51,0.03) 2px,
        rgba(51,255,51,0.03) 4px
    );
}

.cpu-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--phosphor);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 6px var(--phosphor), 0 0 12px rgba(51,255,51,0.3);
}

.cpu-toggle-thumb.mode-8086 {
    left: 33px;
    background: var(--cyan);
    box-shadow: 0 0 6px var(--cyan), 0 0 12px rgba(0,204,204,0.3);
}

.cpu-toggle-track.mode-8086 {
    border-color: var(--cyan-dim);
}

.cpu-toggle-label {
    font-size: 0.6rem;
    letter-spacing: 1px;
    transition: color 0.3s;
}

.cpu-toggle-label.active-8088 { color: var(--phosphor); }
.cpu-toggle-label.active-8086 { color: var(--cyan); }
.cpu-toggle-label.inactive { color: #334433; }

.bus-badge {
    font-size: 0.5rem;
    padding: 1px 4px;
    border-radius: 2px;
    letter-spacing: 0.5px;
}

.bus-badge.bus-8 {
    background: rgba(51,255,51,0.1);
    border: 1px solid var(--phosphor-dim);
    color: var(--phosphor);
}

.bus-badge.bus-16 {
    background: rgba(0,204,204,0.1);
    border: 1px solid var(--cyan-dim);
    color: var(--cyan);
}

/* MOD/RM decode box */
.modrm-decode-box {
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--cyan-dim);
    border-radius: 2px;
    padding: 4px 6px;
    font-size: 0.55rem;
}

.modrm-field {
    display: inline-block;
    padding: 0 3px;
    margin: 0 1px;
    border-radius: 1px;
}

.modrm-field.mod-field { background: rgba(255,176,0,0.15); color: var(--amber); }
.modrm-field.reg-field { background: rgba(51,255,51,0.15); color: var(--phosphor); }
.modrm-field.rm-field { background: rgba(0,204,204,0.15); color: var(--cyan); }

/* EA highlight in memory */
.ea-highlight {
    background: rgba(0,204,204,0.3);
    color: #fff;
}

/* ISA Panel styles */
.isa-panel { background: var(--bg-dark); }

.isa-grid {
    display: grid;
    grid-template-columns: 32px repeat(16, 1fr);
    gap: 1px;
    font-size: 0.5rem;
    min-width: 900px;
}

.isa-cell {
    padding: 3px 2px;
    text-align: center;
    border: 1px solid rgba(26, 58, 26, 0.3);
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    cursor: default;
}

.isa-cell:not(.isa-header):not(.isa-empty):hover {
    border-color: var(--phosphor);
    box-shadow: 0 0 6px rgba(51, 255, 51, 0.2);
    z-index: 1;
    transform: scale(1.05);
}

.isa-header {
    background: rgba(26, 58, 26, 0.4);
    color: var(--phosphor-dim);
    font-weight: 600;
    font-size: 0.6rem;
    min-height: 24px;
}

.isa-empty { background: rgba(10, 14, 20, 0.8); }
.isa-cell-content { line-height: 1.2; }
.isa-mnemonic { font-weight: 600; font-size: 0.5rem; white-space: nowrap; }
.isa-operands { font-size: 0.42rem; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px; }
.isa-meta { font-size: 0.38rem; opacity: 0.5; white-space: nowrap; color: var(--phosphor-dim); margin-top: 1px; }

.isa-tooltip {
    position: sticky;
    bottom: 0;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid var(--phosphor-dim);
    padding: 6px 12px;
    margin-top: 8px;
    border-radius: 2px;
}

.isa-legend-item { font-size: 0.5rem; padding: 1px 4px; border-radius: 2px; }

.opcode-alu { background: rgba(100, 180, 100, 0.1); color: #88cc88; }
.opcode-alu .isa-mnemonic { color: #88cc88; }
.opcode-jmp { background: rgba(100, 150, 255, 0.1); color: #88aaff; }
.opcode-jmp .isa-mnemonic { color: #88aaff; }
.opcode-ls { background: rgba(200, 150, 50, 0.1); color: #ccaa55; }
.opcode-ls .isa-mnemonic { color: #ccaa55; }
.opcode-str { background: rgba(200, 100, 200, 0.1); color: #cc88cc; }
.opcode-str .isa-mnemonic { color: #cc88cc; }
.opcode-grp { background: rgba(255, 120, 80, 0.1); color: #ff9966; }
.opcode-grp .isa-mnemonic { color: #ff9966; }
.opcode-pfx { background: rgba(80, 200, 200, 0.1); color: #66cccc; }
.opcode-pfx .isa-mnemonic { color: #66cccc; }
.opcode-misc { background: rgba(150, 150, 150, 0.08); color: #999999; }
.opcode-misc .isa-mnemonic { color: #aaaaaa; }
.opcode-empty { background: rgba(10, 14, 20, 0.5); }

/* MODRM Reference Table */
.modrm-ref-table {
    font-family: 'Fira Code', monospace;
    font-size: 0.5rem;
    border-collapse: collapse;
    width: 100%;
}

.modrm-ref-table th,
.modrm-ref-table td {
    border: 1px solid rgba(26, 58, 26, 0.5);
    padding: 3px 4px;
    text-align: center;
    white-space: nowrap;
}

.modrm-ref-table th {
    background: rgba(26, 58, 26, 0.4);
    color: var(--phosphor-dim);
    font-weight: 600;
}

.modrm-ref-table td {
    background: rgba(0, 0, 0, 0.3);
    color: var(--phosphor);
    transition: all 0.15s;
    cursor: default;
}

.modrm-ref-table td:hover {
    background: rgba(51, 255, 51, 0.1);
    box-shadow: inset 0 0 8px rgba(51, 255, 51, 0.1);
}

.modrm-ref-table td.active-cell {
    background: rgba(0, 204, 204, 0.2);
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: inset 0 0 8px rgba(0, 204, 204, 0.2);
}

.modrm-ref-extra {
    font-size: 0.42rem;
    color: var(--phosphor-dim);
    display: block;
    margin-top: 1px;
}

/* Cycle annotation */
.cycle-col {
    color: var(--amber-dim);
    font-size: 0.55rem;
}

.cycle-col .ea-cycles {
    color: var(--cyan-dim);
}