/**
 * emu8086-modern.css - Modern 2026 Web Application Theme for Intel 8086 IDE
 * Sleek, flexible, responsive, dark-mode first developer tool UI.
 */

:root {
    --bg-base: #090d16;
    --bg-surface: #121826;
    --bg-card: #1a2234;
    --bg-card-hover: #222d44;
    --border-color: #2a364f;
    --border-subtle: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-blue: #38bdf8;
    --accent-blue-bg: rgba(56, 189, 248, 0.12);
    --accent-green: #22c55e;
    --accent-green-bg: rgba(34, 197, 94, 0.15);
    --accent-yellow: #eab308;
    --accent-yellow-bg: rgba(234, 179, 8, 0.22);
    --accent-red: #ef4444;
    --accent-purple: #a855f7;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;

    --editor-font-size: 13px;
    --editor-line-height: 22px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Header & Navbar
   ========================================================================== */
.app-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
}

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

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #fff;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-icon-svg {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    vertical-align: middle;
    filter: drop-shadow(0 2px 4px rgba(56, 189, 248, 0.3));
}

.brand-badge {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Hamburger toggle for <= 1024px */
.hamburger-toggle-btn {
    display: none;
    background: #1e293b;
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.hamburger-toggle-btn:hover {
    background: #334155;
}

.hamburger-bar {
    width: 20px;
    height: 2px;
    background: #cbd5e1;
    border-radius: 2px;
}

/* Nav Menu bar */
.nav-menus,
.nav-menu-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.nav-dropdown-btn:hover,
.nav-dropdown.active .nav-dropdown-btn {
    color: var(--text-primary);
    background: var(--bg-card);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 6px;
    display: none;
    flex-direction: column;
    z-index: 200;
}

.nav-dropdown.active .dropdown-menu {
    display: flex;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    transition: background 0.1s ease;
}

.dropdown-item:hover {
    background: var(--bg-card-hover);
    color: var(--accent-blue);
}

.dropdown-item-shortcut {
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-mono);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Header Right: Sample Selector & Telemetry */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sample-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
}

.sample-picker-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.modern-select {
    background: transparent;
    color: var(--text-primary);
    border: none;
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    cursor: pointer;
    padding: 4px 8px;
}

.modern-select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.telemetry-pills {
    display: flex;
    align-items: center;
    gap: 8px;
}

.telemetry-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    display: inline-block;
}

.status-dot.running {
    background: var(--accent-blue);
    box-shadow: 0 0 8px var(--accent-blue);
    animation: pulse-dot 1.5s infinite;
}

.status-dot.halted {
    background: var(--accent-yellow);
}

.status-dot.error {
    background: var(--accent-red);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ==========================================================================
   Main Command Toolbar
   ========================================================================== */
.command-toolbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.toolbar-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 95px;
    gap: 1px;
    padding: 5px 12px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    line-height: 1.2;
}

.toolbar-btn .btn-main-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    font-weight: 600;
}

.toolbar-btn .btn-subtext {
    font-size: 10px;
    font-weight: 500;
    font-family: var(--font-mono, monospace);
    opacity: 0.8;
    color: var(--text-muted, #94a3b8);
}

.toolbar-btn-stop {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.toolbar-btn-stop:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
}

.arch-selector-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.arch-select-label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
}

.arch-select-dropdown {
    background: #0f172a;
    border: 1px solid #334155;
    color: #38bdf8;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, background-color 0.15s;
}

.arch-select-dropdown:hover,
.arch-select-dropdown:focus {
    border-color: #38bdf8;
    background-color: #1e293b;
}

.toolbar-btn:hover {
    background: var(--bg-card-hover);
    border-color: #3b4d70;
}

.toolbar-btn:active {
    transform: translateY(1px);
}

.toolbar-btn-primary {
    background: linear-gradient(135deg, #15803d, #22c55e);
    border-color: #16a34a;
    color: #fff;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.toolbar-btn-primary:hover {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
}

.toolbar-btn-accent {
    background: var(--accent-yellow-bg);
    border-color: rgba(234, 179, 8, 0.4);
    color: #fef08a;
}

.toolbar-btn-accent:hover {
    background: rgba(234, 179, 8, 0.3);
    border-color: var(--accent-yellow);
}

.toolbar-btn-reload {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: #7dd3fc;
}

.toolbar-btn-reload:hover {
    background: rgba(56, 189, 248, 0.25);
    border-color: var(--accent-blue);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

/* ==========================================================================
   Workspace Grid (Two-Column Master View)
   ========================================================================== */
.workspace-container {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 14px;
    padding: 14px 16px 80px 16px; /* bottom pad for bottom peripherals bar */
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

@media (max-width: 1100px) {
    .workspace-container {
        grid-template-columns: minmax(0, 1fr);
        padding: 10px 10px 80px 10px;
    }
}

.workspace-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

/* Modern Card Panels */
.modern-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.panel-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: nowrap;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: auto;
    scrollbar-width: none;
}

.panel-header::-webkit-scrollbar {
    display: none;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: 0;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 0;
}

.badge-tag {
    font-size: 11px;
    font-family: var(--font-mono);
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

/* ==========================================================================
   Code Editor Pane, Syntax Highlighter & Locked Execution Line
   ========================================================================== */
.editor-panel-body {
    position: relative;
    display: flex;
    height: 380px;
    background: #090d16;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden;
    transition: height 0.2s ease-in-out;
}

.editor-panel-body.shrunk,
#editorPanelBody.shrunk {
    height: 222px !important;
    max-height: 222px !important;
    min-height: 0 !important;
}

#editorSection.shrunk {
    height: auto !important;
}

.editor-line-numbers {
    width: auto;
    min-width: 56px;
    background: #0c111d;
    border-right: 1px solid var(--border-subtle);
    padding: 12px 6px 12px 4px;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    color: #475569;
    text-align: right;
    user-select: none;
    overflow: hidden;
    box-sizing: border-box;
    white-space: nowrap;
}

.line-num {
    height: var(--editor-line-height);
    line-height: var(--editor-line-height);
    box-sizing: border-box;
    padding-right: 4px;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s ease;
}

.line-num:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
}

.editor-line-numbers .line-num.breakpoint-line {
    color: #f87171 !important;
    font-weight: 700;
}

.editor-line-numbers .line-num.breakpoint-line::before {
    content: "● ";
    color: #ef4444;
    font-size: 10px;
    margin-right: 2px;
}

.editor-line-numbers .line-num.run-target-line {
    color: #38bdf8 !important;
    font-weight: 700;
    background: rgba(56, 189, 248, 0.15);
}

.editor-line-numbers .line-num.run-target-line::before {
    content: "🎯 ";
    color: #38bdf8;
    font-size: 10px;
    margin-right: 2px;
}

.editor-line-numbers .active-line-marker {
    color: #facc15;
    font-weight: 700;
}

.editor-line-numbers .active-line-marker::after {
    content: " ▶";
    color: #facc15;
    font-size: 9px;
    display: inline-block;
    vertical-align: baseline;
    margin-left: 2px;
}

.editor-line-numbers .error-line-marker {
    color: #ef4444 !important;
    font-weight: 700;
}

.editor-line-numbers .error-line-marker::after {
    content: " ✖";
    color: #ef4444;
    font-size: 10px;
}

.syntax-error-line {
    background: rgba(239, 68, 68, 0.28) !important;
    border-left: 3px solid #ef4444 !important;
}

/* Synchronized Editor Container */
.editor-scroll-container {
    position: relative;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

/* Syntax Highlighted Backdrop Layer (Sits underneath transparent textarea) */
.syntax-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    padding: 12px 14px;
    box-sizing: border-box;
    white-space: pre;
    tab-size: 4;
    color: #e2e8f0;
    z-index: 1;
}

/* Single line in syntax backdrop */
.code-line {
    height: var(--editor-line-height);
    line-height: var(--editor-line-height);
    white-space: pre;
    box-sizing: border-box;
    overflow: hidden;
}

/* Active Instruction Highlight (Locked directly to code line!) */
.code-line.active-execution-line {
    background: rgba(234, 179, 8, 0.22);
    border-left: 3px solid #facc15;
    margin-left: -14px;
    padding-left: 11px;
}

/* Syntax Highlighting Tokens (Case-Insensitive) */
.tok-kw {
    color: #38bdf8; /* Assembly instructions: Cyan / Sky Blue */
    font-weight: 600;
}

.tok-dir {
    color: #c084fc; /* Directives / Non-assembly (TITLE, SEGMENT...): Purple */
    font-weight: 600;
}

.tok-comm {
    color: #64748b; /* Comments: Slate Gray */
    font-style: italic;
}

.tok-reg {
    color: #4ade80; /* Registers: Emerald Green */
    font-weight: 500;
}

.tok-num {
    color: #fb923c; /* Numbers / Hex: Warm Orange */
}

.tok-str {
    color: #a3e635; /* String literals: Lime */
}

.tok-label {
    color: #f43f5e; /* Labels (arxh:): Coral */
    font-weight: 600;
}

/* Transparent Textarea for User Input (Caret & selection visible) */
.code-textarea {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    padding: 12px 14px;
    background: transparent;
    color: transparent;
    caret-color: #38bdf8;
    border: none;
    outline: none;
    resize: none;
    white-space: pre !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    overflow: auto;
    tab-size: 4;
    z-index: 2;
}

.code-textarea::selection {
    background: rgba(56, 189, 248, 0.35);
    color: transparent;
}

/* Font controls reset button */
.font-reset-btn {
    font-size: 13px !important;
    line-height: 1 !important;
    color: var(--accent-blue) !important;
    cursor: pointer;
    transition: transform 0.2s ease, color 0.15s ease;
}

.font-reset-btn:hover {
    color: #fff !important;
    transform: rotate(-60deg);
}

/* Reload & Reset Notification Toast Banner */
.reload-toast-banner {
    position: fixed;
    top: 55px;
    right: 20px;
    background: #0f172a;
    border: 1px solid #38bdf8;
    color: #f8fafc;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10001;
    font-size: 13px;
    font-weight: 500;
    animation: slideDownToast 0.25s ease-out;
}

@keyframes slideDownToast {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

.toast-icon {
    font-size: 15px;
}

.toast-msg {
    color: #e2e8f0;
}

.toast-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    margin-left: 6px;
}

.toast-close-btn:hover {
    color: #fff;
}

/* ==========================================================================
   Virtual Screen (Directly Below Document Code)
   ========================================================================== */
.screen-panel-body {
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
    gap: 8px;
    box-sizing: border-box;
}

.virtual-canvas-screen {
    background: #000;
    border: 2px solid #1e293b;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8), 0 0 15px rgba(56, 189, 248, 0.1);
    max-width: 100%;
    height: auto;
    aspect-ratio: 640 / 400;
    align-self: flex-start;
    margin: 0;
    image-rendering: pixelated;
    cursor: text;
}

.terminal-stdout-box {
    width: 100%;
    max-height: 100px;
    background: #070a10;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #38bdf8;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Screen Footer & Hardware FIFO Keyboard Buffer (Matching emu8086 Specification) */
.screen-footer-bar {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #0b0f19;
    border: 1px solid #1e293b;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    box-sizing: border-box;
}

.screen-footer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.screen-action-btns {
    display: flex;
    gap: 8px;
    align-items: center;
}

.screen-mini-btn {
    background: #1e293b;
    color: #cbd5e1;
    border: 1px solid #334155;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
}

.screen-mini-btn:hover {
    background: #334155;
    color: #f8fafc;
    border-color: #475569;
}

.screen-status-hint {
    font-size: 11px;
    color: #64748b;
    font-style: italic;
}

.kbd-buffer-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #050811;
    border: 1px solid #1e293b;
    border-radius: 6px;
    padding: 10px 12px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.kbd-buffer-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.kbd-buffer-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kbd-buffer-title {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kbd-count-pill {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.kbd-buffer-stream {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex: 1;
    min-width: 120px;
    font-family: var(--font-mono);
}

.kbd-stream-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.kbd-chars-red {
    font-size: 14px;
    font-weight: 700;
    color: #f87171;
    letter-spacing: 1.5px;
    word-break: break-all;
    min-height: 18px;
}

.kbd-clear-btn {
    background: #18181b;
    color: #a1a1aa;
    border: 1px solid #3f3f46;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 28px;
}

.kbd-clear-btn:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #dc2626;
}

.kbd-buffer-ascii-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: #94a3b8;
    background: #020617;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #0f172a;
    overflow-x: auto;
    white-space: nowrap;
}

.kbd-ascii-label {
    font-weight: 700;
    color: #64748b;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kbd-ascii-codes {
    color: #38bdf8;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.kbd-buffer-input-wrap {
    width: 100%;
}

.kbd-buffer-input {
    width: 100%;
    background: #020617;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 7px 10px;
    color: #f1f5f9;
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kbd-buffer-input:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.telemetry-pill.waiting-input {
    border: 2px solid #ef4444 !important;
    background: rgba(239, 68, 68, 0.22) !important;
    color: #fecaca !important;
    font-weight: 700 !important;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.85) !important;
    animation: pulseWaitingRed 0.8s infinite alternate ease-in-out !important;
}

.status-dot.waiting {
    background: #ef4444 !important;
    box-shadow: 0 0 10px #ef4444 !important;
    animation: pulseWaitingRed 0.8s infinite alternate ease-in-out !important;
}

@keyframes pulseWaitingRed {
    0% {
        border-color: #ef4444;
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
        transform: scale(1);
    }
    100% {
        border-color: #f87171;
        box-shadow: 0 0 20px rgba(239, 68, 68, 1);
        transform: scale(1.04);
    }
}

.kbd-buffer-box.waiting-focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.7) !important;
    animation: pulseWaitingBorder 1s infinite alternate;
}

@keyframes pulseWaitingBorder {
    0% { border-color: #ef4444; }
    100% { border-color: #f97316; }
}

/* ==========================================================================
   Memory Accordion (Closed by default)
   ========================================================================== */
.accordion-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.accordion-header:hover {
    background: var(--bg-card-hover);
}

.accordion-toggle-icon {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.accordion-header.open .accordion-toggle-icon {
    transform: rotate(180deg);
}

.memory-accordion-content {
    display: none;
    padding: 10px 14px;
    background: #0b0f19;
    border-top: 1px solid var(--border-subtle);
}

.memory-accordion-content.open {
    display: block;
}

.memory-controls-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.memory-jump-input {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    width: 120px;
}

.memory-scroll-box {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: #060910;
    font-family: var(--font-mono);
    font-size: 12px;
}

.memory-row {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.memory-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.mem-addr {
    color: var(--accent-blue);
    width: 85px;
    flex-shrink: 0;
    font-weight: 600;
}

.mem-hex-bytes {
    display: flex;
    gap: 6px;
    color: #cbd5e1;
    flex-shrink: 0;
}

.mem-byte-editable {
    cursor: pointer;
    padding: 1px 2px;
    border-radius: 2px;
}

.mem-byte-editable:hover {
    background: #facc15;
    color: #000;
    font-weight: bold;
}

.mem-ascii {
    color: #64748b;
    margin-left: auto;
    letter-spacing: 1px;
}

/* ==========================================================================
   Registers & Flags (Right Column)
   ========================================================================== */
.regs-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 8px 10px;
}

.reg-cell {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 0;
}

.reg-cell:hover {
    border-color: var(--accent-blue);
    background: var(--bg-card-hover);
}

.reg-name {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
}

.reg-hex-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
}

.flag-pill {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.flag-pill.active {
    background: var(--accent-green-bg);
    border-color: var(--accent-green);
    color: #4ade80;
    font-weight: 700;
}

/* Disassembly View (Matching Code Editor Font Size) */
.disasm-box {
    position: relative !important;
    max-height: 240px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 22px;
    background: #060910;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.disasm-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    font-size: 13px;
}

.disasm-line:hover {
    background: rgba(255, 255, 255, 0.04);
}

.disasm-line.current {
    background: rgba(234, 179, 8, 0.3) !important;
    border-left: 4px solid #facc15 !important;
    color: #fef08a !important;
    font-weight: 700 !important;
    box-shadow: inset 0 0 10px rgba(250, 204, 21, 0.2);
}

.disasm-line.selected-line:not(.current) {
    background: rgba(56, 189, 248, 0.18) !important;
    border-left: 4px solid #38bdf8 !important;
    color: #f0f9ff !important;
}

.disasm-line.current .disasm-addr::before {
    content: "▶ ";
    color: #facc15;
    font-weight: bold;
}

.disasm-line.breakpoint .disasm-addr::before {
    content: "● ";
    color: #ef4444;
}

.disasm-line.run-target:not(.current) {
    background: rgba(56, 189, 248, 0.22) !important;
    border-left: 4px solid #38bdf8 !important;
    color: #f0f9ff !important;
    box-shadow: inset 0 0 10px rgba(56, 189, 248, 0.25);
}

.disasm-line.run-target .disasm-addr::before {
    content: "🎯 ";
    color: #38bdf8;
    font-weight: bold;
}

.disasm-line.code-inspect-highlight {
    background: rgba(168, 85, 247, 0.28) !important;
    border-left: 4px solid #c084fc !important;
    color: #faf5ff !important;
    box-shadow: inset 0 0 12px rgba(168, 85, 247, 0.35);
}

.disasm-line.code-inspect-highlight .disasm-addr::before {
    content: "🔍 ";
    color: #c084fc;
    font-weight: bold;
}

/* Machine Code Jump Button next to Line, Col badge */
.badge-btn-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.4);
    color: #d8b4fe;
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.15s ease;
    user-select: none;
}

.badge-btn-link:hover {
    background: rgba(168, 85, 247, 0.32);
    border-color: #c084fc;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
}

.badge-btn-link:active {
    transform: scale(0.97);
}

.disasm-addr {
    color: var(--text-muted);
    width: 95px;
    flex-shrink: 0;
}

.disasm-hex {
    color: #64748b;
    width: 105px;
    flex-shrink: 0;
}

.disasm-mnem {
    color: #f1f5f9;
    font-size: 13px;
}

/* ==========================================================================
   Collapsible Peripherals Drawer / Bar (Bottom Dock)
   ========================================================================== */
.peripherals-dock-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 2px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
    z-index: 150;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.peripherals-tab-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-card);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
}

.peripherals-tab-toggle:hover {
    background: var(--bg-card-hover);
}

.dock-left-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.dock-quick-badges {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dock-port-telemetry {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-family: var(--font-mono);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.dock-telemetry-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.telemetry-label {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dock-telemetry-in .telemetry-ports {
    color: #38bdf8;
    font-weight: 600;
}

.dock-telemetry-out .telemetry-ports {
    color: #4ade80;
    font-weight: 600;
}

.dock-telemetry-sep {
    color: var(--border-color);
    font-size: 10px;
}

.dock-badge {
    font-size: 11px;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.dock-badge.active-traffic {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.4);
}

/* Informative instruction banners inside peripheral cards */
.peripheral-info-banner {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid #38bdf8;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.peripheral-info-banner strong {
    color: var(--text-primary);
}

.peripheral-info-banner code {
    background: rgba(0, 0, 0, 0.35);
    padding: 1px 5px;
    border-radius: 3px;
    color: #facc15;
    font-family: var(--font-mono);
    font-size: 11px;
}

/* Robot Specification Tables (Matching emu8086 ESipuYPx.png) */
.robot-spec-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.robot-spec-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.robot-spec-title {
    background: rgba(30, 41, 59, 0.8);
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #38bdf8;
    border-bottom: 1px solid var(--border-subtle);
}

.robot-spec-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.robot-spec-table th,
.robot-spec-table td {
    padding: 5px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.robot-spec-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
}

.robot-spec-table tr:last-child td {
    border-bottom: none;
}

.robot-spec-table td strong {
    color: #facc15;
}

.robot-desktop-split {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

@media (max-width: 992px) {
    .robot-desktop-split {
        flex-direction: column;
    }
}

.dock-toggle-chevron {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.peripherals-dock-bar.open .dock-toggle-chevron {
    transform: rotate(180deg);
}

/* Peripherals Content Area (Hidden by default!) */
.peripherals-dock-content {
    display: none;
    padding: 16px;
    background: var(--bg-surface);
    gap: 16px;
    overflow-x: auto;
}

.peripherals-dock-bar.open .peripherals-dock-content {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
}

.dock-device-card {
    flex: 1;
    min-width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.device-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 6px;
}

/* LED array */
.led-array {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 4px;
}

.led-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.led-bulb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1e293b;
    border: 1px solid #475569;
    transition: all 0.15s ease;
}

.led-bulb.on {
    background: #22c55e;
    border-color: #86efac;
    box-shadow: 0 0 10px #22c55e;
}

.led-bit-label {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* Traffic Lights */
.traffic-posts-wrapper {
    display: flex;
    justify-content: space-around;
    gap: 12px;
}

.traffic-post {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.traffic-light-bulb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1e293b;
    border: 1px solid #334155;
    transition: all 0.15s ease;
}

.traffic-light-bulb.red.on {
    background: #ef4444;
    border-color: #fca5a5;
    box-shadow: 0 0 12px #ef4444;
}

.traffic-light-bulb.yellow.on {
    background: #eab308;
    border-color: #fef08a;
    box-shadow: 0 0 12px #eab308;
}

.traffic-light-bulb.green.on {
    background: #22c55e;
    border-color: #86efac;
    box-shadow: 0 0 12px #22c55e;
}

/* Stepper motor */
.stepper-view {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 4px;
}

.stepper-dial-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0f172a;
    border: 2px solid var(--accent-blue);
    position: relative;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.stepper-dial-needle {
    width: 3px;
    height: 24px;
    background: #ef4444;
    position: absolute;
    top: 4px;
    left: 50%;
    transform-origin: 50% 100%;
    border-radius: 2px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stepper-dial-center {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ==========================================================================
   Halt Modal Notification
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.82);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
    box-sizing: border-box;
}

.modal-overlay.open {
    display: flex !important;
}

.modal-dialog {
    position: relative;
    background: #182235;
    border: 2px solid #38bdf8;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9), 0 0 25px rgba(56, 189, 248, 0.2);
    max-width: 500px;
    max-height: calc(100vh - 40px);
    width: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 10000;
    overflow: hidden;
}

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

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
}

.modal-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.modal-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - 160px);
}

.modal-body code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    color: #38bdf8;
    font-family: var(--font-mono);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* ==========================================================================
   Responsive Rules & Mobile Optimization
   ========================================================================== */
@media (max-width: 1024px) {
    .hamburger-toggle-btn {
        display: flex;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
    }

    .app-header {
        flex-wrap: wrap;
        padding: 8px 12px;
        position: relative;
    }

    .nav-menus {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #0f172a;
        border-bottom: 2px solid var(--accent-blue);
        box-shadow: 0 15px 30px rgba(0, 0, 0, 0.7);
        flex-direction: column;
        align-items: stretch;
        padding: 10px 14px;
        gap: 6px;
        z-index: 1000;
    }

    .nav-menus.open {
        display: flex !important;
    }

    .nav-dropdown-btn {
        width: 100%;
        justify-content: space-between;
        padding: 8px 12px;
        background: rgba(255, 255, 255, 0.04);
    }

    .dropdown-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        border: 1px solid rgba(255, 255, 255, 0.1);
        margin-top: 4px;
    }

    .command-toolbar {
        padding: 6px 12px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .toolbar-group {
        flex-wrap: wrap;
        gap: 4px;
    }

    .toolbar-btn {
        padding: 4px 10px;
        font-size: 12px;
        min-height: 32px;
    }

    .workspace-container {
        grid-template-columns: minmax(0, 1fr);
        padding: 10px 12px 75px 12px;
    }

    .ascii-modal-dialog {
        max-width: 95vw;
        max-height: calc(100vh - 30px);
    }

    .ascii-grid-scroll {
        grid-template-columns: repeat(8, 1fr);
        max-height: 240px;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 8px 10px;
        gap: 8px;
    }

    .header-actions {
        width: 100%;
        max-width: 100%;
        gap: 6px;
        flex-direction: column;
        align-items: stretch;
    }

    .sample-picker-wrapper {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .modern-select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        text-overflow: ellipsis;
        overflow: hidden;
    }

    .telemetry-pills {
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        box-sizing: border-box;
    }

    .telemetry-pill {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
        font-size: 11px;
        padding: 4px 6px;
        box-sizing: border-box;
    }

    /* Touch Targets >= 44px on Mobile & Equal-Length Aligned Button Grid */
    .command-toolbar {
        padding: 8px;
        gap: 6px;
        width: 100%;
        box-sizing: border-box;
    }

    .toolbar-group {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
        gap: 6px;
    }

    .toolbar-divider {
        display: none !important;
    }

    #btnEmulate {
        grid-column: 1 / -1;
    }

    .toolbar-btn {
        min-height: 44px;
        padding: 8px 4px;
        font-size: 12.5px;
        width: 100%;
        min-width: 0;
        justify-content: center;
        text-align: center;
        box-sizing: border-box;
        flex: none;
    }

    .regs-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 4px !important;
        padding: 6px 8px !important;
    }

    .toolbar-separator {
        display: none;
    }

    .workspace-container {
        padding: 8px 8px 70px 8px;
        gap: 10px;
        max-width: 100vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* Peripherals Dock Bar on Mobile */
    .peripherals-dock-bar {
        max-width: 100vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .peripherals-tab-toggle {
        padding: 10px 12px;
        min-height: 44px;
        gap: 8px;
        box-sizing: border-box;
    }

    .dock-left-title {
        font-size: 12px;
        min-width: 0;
        flex-shrink: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .dock-quick-badges {
        display: none; /* Hide wide badges to guarantee zero horizontal overflow */
    }

    .peripherals-dock-content {
        flex-direction: column;
        padding: 10px;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .dock-device-card {
        min-width: 0;
        width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 600px) {
    .hide-mobile {
        display: none !important;
    }
    .panel-header {
        padding: 6px 8px;
        gap: 4px;
        flex-wrap: wrap;
    }
    .panel-title {
        font-size: 11px;
        gap: 4px;
        flex-wrap: wrap;
    }
    .badge-tag {
        font-size: 10px;
        padding: 1px 5px;
    }
    .panel-actions {
        gap: 4px;
    }
    .regs-split-container {
        grid-template-columns: 1fr;
    }
    .ascii-modal-dialog {
        max-width: 100vw;
    }
    .ascii-grid-scroll {
        grid-template-columns: repeat(8, 1fr);
    }
    .memory-row {
        gap: 4px;
        font-size: 10px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    .mem-hex-bytes {
        max-width: 150px;
        overflow: hidden;
    }
    .mem-ascii {
        display: none;
    }
    .registers-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .flags-pills-row {
        gap: 4px;
    }
    .flag-pill {
        min-height: 36px;
        padding: 4px 6px;
        font-size: 11px;
    }
}


/* ==========================================================================
   Split Dual-Box Registers (AX, BX, CX, DX -> AH | AL)
   ========================================================================== */
.regs-split-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-subtle);
}

.reg-split-cell {
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all var(--transition-fast);
}

.reg-split-cell:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.08);
}

.reg-split-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reg-hex-composite {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.reg-split-boxes {
    display: flex;
    gap: 6px;
}

.reg-byte-cell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.reg-byte-cell:hover {
    border-color: var(--accent-yellow);
    background: rgba(234, 179, 8, 0.12);
}

.byte-tag {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
}

.reg-byte-hex {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: #4ade80;
}

/* ==========================================================================
   Per-Panel Independent Font Resizing Controls
   ========================================================================== */
.panel-font-controls {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    gap: 0;
}

.font-zoom-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 2px 7px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.font-zoom-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-blue);
}

.font-zoom-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    padding: 0 4px;
    min-width: 26px;
    text-align: center;
    user-select: none;
}

/* ==========================================================================
   Peripherals Dock Selector & Hardware Devices
   ========================================================================== */
.dock-selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dock-selector-label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.dock-device-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: none;
    flex-direction: column;
    gap: 8px;
    min-width: 280px;
    box-sizing: border-box;
}

.dock-device-card.active-device-card {
    display: flex !important;
}

/* Device 4: Thermometer */
.thermo-container {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px;
}

.thermo-tube-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.thermo-scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 110px;
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.thermo-tube {
    width: 14px;
    height: 110px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.thermo-mercury {
    width: 100%;
    background: linear-gradient(to top, #ef4444, #f97316);
    border-radius: 0 0 8px 8px;
    transition: height 0.3s ease;
}

.thermo-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.thermo-digit {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 700;
    color: #f97316;
}

.thermo-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Device 5: Robot World */
.robot-view-wrapper {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 6px;
}

.robot-grid {
    display: grid;
    grid-template-columns: repeat(8, 22px);
    grid-template-rows: repeat(8, 22px);
    gap: 2px;
    background: #000;
    padding: 4px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.robot-grid-cell {
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.robot-grid-cell.robot-here {
    background: rgba(59, 130, 246, 0.3);
    border: 1px solid var(--accent-blue);
    color: #60a5fa;
    font-weight: 700;
}

.robot-grid-cell.robot-led-lit {
    background: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.8);
}

.robot-info-panel {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Device 6: Printer */
.printer-paper-wrapper {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 12px;
    max-height: 140px;
    overflow-y: auto;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.printer-paper-content {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #0f172a;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Device 7: 7-Segment Display */
.seven-seg-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px;
}

.seven-seg-digit {
    position: relative;
    width: 48px;
    height: 80px;
}

.seg {
    position: absolute;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    transition: all 0.15s ease;
}

.seg.on {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.seg-a { top: 0; left: 6px; width: 36px; height: 6px; }
.seg-b { top: 6px; right: 0; width: 6px; height: 32px; }
.seg-c { top: 42px; right: 0; width: 6px; height: 32px; }
.seg-d { bottom: 0; left: 6px; width: 36px; height: 6px; }
.seg-e { top: 42px; left: 0; width: 6px; height: 32px; }
.seg-f { top: 6px; left: 0; width: 6px; height: 32px; }
.seg-g { top: 37px; left: 6px; width: 36px; height: 6px; }
.seg-dp { bottom: 0; right: -8px; width: 6px; height: 6px; border-radius: 50%; }

.seven-seg-legend {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* ==========================================================================
   ASCII Character Map Utility Modal (000-255)
   ========================================================================== */
.ascii-modal-dialog {
    max-width: 860px;
    width: 95vw;
    max-height: calc(100vh - 40px);
    padding: 16px;
    overflow: hidden;
}

.ascii-mode-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 12px;
}

.ascii-modal-toolbar {
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 14px;
    flex-shrink: 0;
}

.ascii-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ascii-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.tag-ctrl { background: rgba(129, 140, 248, 0.15); color: #818cf8; border: 1px solid rgba(129, 140, 248, 0.3); }
.tag-digit { background: rgba(74, 222, 128, 0.15); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.3); }
.tag-upper { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.tag-lower { background: rgba(96, 165, 250, 0.15); color: #60a5fa; border: 1px solid rgba(96, 165, 250, 0.3); }
.tag-punct { background: rgba(250, 204, 21, 0.15); color: #facc15; border: 1px solid rgba(250, 204, 21, 0.3); }
.tag-ext { background: rgba(251, 146, 60, 0.15); color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.3); }

.ascii-grid-scroll {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 4px;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
    background: #060910;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.ascii-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 4px 2px;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    min-height: 42px;
}

.ascii-cell:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

.ascii-cell.selected {
    background: rgba(234, 179, 8, 0.25);
    border-color: #facc15;
}

.ascii-cell-code {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.ascii-cell-glyph {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
}

.ascii-char-inspector {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 10px;
}

.inspector-char-preview {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    color: #facc15;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
}

.inspector-details {
    font-size: 12px;
    line-height: 1.6;
}

.eval-result-card {
    background: #060910;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 13px;
}

.eval-row {
    display: flex;
    justify-content: space-between;
}

/* Changed Register Red Glow & Flash Visual Feedback */
.reg-cell.reg-changed,
.reg-split-cell.reg-changed,
.reg-byte-cell.reg-changed,
.flag-pill.reg-changed {
    border-color: #ef4444 !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.75) !important;
    animation: regChangedFlash 1.4s ease-out;
}

@keyframes regChangedFlash {
    0% {
        background-color: rgba(239, 68, 68, 0.4);
    }
    100% {
        background-color: transparent;
    }
}

/* Stack Inspector Panel */
.stack-accordion-wrapper {
    margin-top: 12px;
}
.stack-accordion-header {
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.02);
}
.stack-accordion-header:hover {
    background: rgba(255, 255, 255, 0.05);
}
.stack-accordion-content {
    display: none;
    padding: 8px 12px 12px;
    background: #080d1a;
    border-top: 1px solid var(--border-subtle);
}
.stack-accordion-content.open {
    display: block;
}
.stack-controls-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.stack-scroll-box {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: #050811;
}
.stack-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12px;
}
.stack-table th {
    position: sticky;
    top: 0;
    background: #0d1527;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
    font-size: 11px;
}
.stack-table td {
    padding: 3px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}
.stack-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}
.stack-table tr.is-sp {
    background: rgba(245, 158, 11, 0.2);
    color: #fef08a;
    font-weight: 600;
}
.stack-table tr.is-bp {
    background: rgba(56, 189, 248, 0.16);
    color: #bae6fd;
}
.stack-ptr-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}
.stack-ptr-sp {
    background: #b45309;
    color: #fff;
}
.stack-ptr-bp {
    background: #0369a1;
    color: #fff;
}

/* Multi-Base Converter Modal */
.converter-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px 14px;
    align-items: center;
}
.conv-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
}
.conv-input {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 6px 10px;
}
.converter-mode-toggle button.active {
    background: var(--accent-blue) !important;
    color: #000 !important;
    font-weight: 700 !important;
}

/* Variables Inspector Modal */
.vars-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.vars-table-scroll {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: #050811;
}
.vars-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12px;
}
.vars-table th {
    position: sticky;
    top: 0;
    background: #0d1527;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}
.vars-table td {
    padding: 5px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}
.vars-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Listing Pre */
.listing-pre {
    background: #050811;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 19px;
    color: #e2e8f0;
    max-height: 480px;
    overflow: auto;
    white-space: pre;
    tab-size: 4;
}

/* ==========================================================================
   Variables Inspector Panel Accordion (Data Segment)
   ========================================================================== */
.vars-accordion-wrapper {
    margin-top: 12px;
    border-top: 1px solid var(--border-subtle);
}
.vars-accordion-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
.vars-accordion-header:hover {
    background: var(--bg-card-hover);
}
.vars-accordion-content {
    display: none;
    padding: 10px 14px;
    background: #080d1a;
    border-top: 1px solid var(--border-subtle);
}
.vars-accordion-content.open {
    display: block;
}
.vars-controls-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.vars-view-radios {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--text-secondary);
}
.vars-view-radios label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
}
.vars-scroll-box {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: #050811;
}

/* ==========================================================================
   Hardware Interrupts Controller Accordion (emu8086.hw)
   ========================================================================== */
.hw-accordion-wrapper {
    margin-top: 12px;
    border-top: 1px solid var(--border-subtle);
}
.hw-accordion-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
.hw-accordion-header:hover {
    background: var(--bg-card-hover);
}
.hw-accordion-content {
    display: none;
    padding: 10px 14px;
    background: #080d1a;
    border-top: 1px solid var(--border-subtle);
}
.hw-accordion-content.open {
    display: block;
}
.hw-quick-irq-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 8px 0;
}
.btn-micro {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 2px 7px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-micro:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}
.hw-trigger-box {
    background: #050811;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

/* ==========================================================================
   5-Digit 7-Segment Word Display (Port 199 - 2 Bytes) - qiYnrdYu.png
   ========================================================================== */
.led5-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px;
    background: #06090e;
    border-radius: var(--radius-sm);
}
.led5-display-box {
    background: #000000;
    border: 2px solid #1e293b;
    border-radius: 6px;
    padding: 12px 20px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    box-shadow: inset 0 0 12px rgba(0,0,0,0.8);
}
.led5-digits {
    display: flex;
    gap: 12px;
}
.led5-digit {
    font-family: 'Courier New', monospace;
    font-size: 38px;
    font-weight: 900;
    color: #22c55e;
    text-shadow: 0 0 12px rgba(34, 197, 94, 0.8), 0 0 20px rgba(34, 197, 94, 0.4);
    letter-spacing: 2px;
    width: 28px;
    text-align: center;
}
.led5-caption {
    font-size: 12px;
    font-family: var(--font-mono);
    color: #38bdf8;
    margin-top: 8px;
}
.led5-info-box {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* ==========================================================================
   Traffic Lights (Port 4) - GpBL5367.png
   ========================================================================== */
.traffic-intersection-layout {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 10px;
}
.traffic-map-box {
    width: 240px;
    height: 240px;
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 8px;
    overflow: hidden;
}
.traffic-svg {
    width: 100%;
    height: 100%;
}
.traffic-reg-panel {
    background: #000000;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 16px;
    font-family: var(--font-mono);
}
.traffic-bits-header {
    font-size: 13px;
    color: #94a3b8;
    letter-spacing: 3px;
    margin-bottom: 4px;
}
.traffic-bits-row {
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 3px;
    display: flex;
}
.bit-grey { color: #64748b; }
.bit-blue { color: #3b82f6; }
.bit-red  { color: #ef4444; }
.traffic-port-label {
    font-size: 12px;
    color: #38bdf8;
    margin-top: 6px;
    text-align: center;
}
.sim-car {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   3-Phase Stepper Motor (Port 7) - DER4zF3V.png
   ========================================================================== */
.stepper-box-layout {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 12px;
}
.stepper-center-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stepper-gear-container {
    position: relative;
    width: 130px;
    height: 130px;
    margin-bottom: 12px;
}
.stepper-dir-mark {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 16px;
    color: #10b981;
    font-weight: bold;
}
.stepper-gear-wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, #e2e8f0 60%, #cbd5e1 65%, #94a3b8 100%);
    border: 3px solid #64748b;
    position: relative;
    transition: transform 0.25s ease-out;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.stepper-needle {
    position: absolute;
    bottom: 50%;
    left: calc(50% - 2px);
    width: 4px;
    height: 44%;
    background: #10b981;
    border-radius: 2px;
    transform-origin: bottom center;
}
.stepper-magnets-row {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 10px;
}
.magnet-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.magnet-box {
    width: 22px;
    height: 22px;
    background: #2563eb; /* Blue when inactive */
    border-radius: 3px;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.magnet-box.active {
    background: #ef4444 !important; /* Red when active */
    box-shadow: 0 0 10px #ef4444;
}
.magnet-num {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: bold;
    color: var(--text-primary);
}
.stepper-binary-display {
    font-family: var(--font-mono);
    text-align: center;
    background: #000;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #334155;
}
.stepper-header-nums {
    font-size: 12px;
    color: #94a3b8;
    letter-spacing: 2px;
}
.stepper-bits-row {
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 2px;
}

/* ==========================================================================
   Thermometer & Heater (Ports 125 - 127) - lj9lxCaW.png
   ========================================================================== */
.thermo-layout {
    display: flex;
    gap: 28px;
    padding: 12px;
    align-items: center;
}
.thermo-column-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    padding-bottom: 40px;
}
.thermo-scale-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 210px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
}
.thermo-glass-tube {
    width: 14px;
    height: 210px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid #64748b;
    border-radius: 7px;
    position: relative;
    overflow: visible;
}
.thermo-mercury-bar {
    position: absolute;
    bottom: 0;
    left: 1px;
    right: 1px;
    background: #ef4444;
    border-radius: 5px 5px 0 0;
    transition: height 0.4s ease;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}
.thermo-bulb-sphere {
    position: absolute;
    bottom: -14px;
    left: -7px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #64748b;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}
.thermo-burner-box {
    position: absolute;
    bottom: 0px;
    left: 55px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.thermo-flame {
    font-size: 20px;
    animation: flamePulse 0.4s infinite alternate;
}
@keyframes flamePulse {
    0% { transform: scale(1) rotate(-2deg); opacity: 0.85; }
    100% { transform: scale(1.15) rotate(2deg); opacity: 1; }
}
.thermo-burner-base {
    width: 32px;
    height: 12px;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 3px;
}
.thermo-controls-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.thermo-digital-val {
    font-size: 26px;
    font-weight: bold;
    color: #ef4444;
    font-family: var(--font-mono);
}
.thermo-port-card {
    background: #000;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 6px 12px;
    font-family: var(--font-mono);
}
.thermo-wire-label {
    font-size: 11px;
    color: #38bdf8;
    margin-bottom: 2px;
}
.thermo-bits-readout {
    font-size: 15px;
    font-weight: bold;
    color: #3b82f6;
    letter-spacing: 2px;
}
.thermo-air-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-primary);
}

/* ==========================================================================
   Robot Controller World Map (Ports 9 - 11) - DVTjwA5J.png
   ========================================================================== */
.robot-workspace-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.robot-world-container {
    background: #ffffff;
    border: 2px solid #475569;
    border-radius: 6px;
    padding: 6px;
    display: inline-block;
    align-self: flex-start;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.robot-world-grid {
    display: grid;
    grid-template-columns: repeat(8, 30px);
    grid-template-rows: repeat(8, 30px);
    gap: 1px;
    background: #e2e8f0;
}
.robot-cell {
    width: 30px;
    height: 30px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    position: relative;
}
.robot-cell:hover {
    background: #f1f5f9;
}
.cell-wall {
    background: repeating-linear-gradient(45deg, #000000, #000000 3px, #ffffff 3px, #ffffff 6px) !important;
    border: 1px solid #000000;
}
.cell-lamp-off {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #94a3b8;
    border: 1px solid #475569;
    position: relative;
}
.cell-lamp-off::before, .cell-lamp-off::after,
.cell-lamp-on::before, .cell-lamp-on::after {
    content: '';
    position: absolute;
    top: 50%; left: 10%; right: 10%;
    height: 1.5px;
    background: #334155;
    transform: rotate(45deg);
}
.cell-lamp-off::after, .cell-lamp-on::after {
    transform: rotate(-45deg);
}
.cell-lamp-on {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #facc15;
    border: 1.5px solid #000000;
    position: relative;
    box-shadow: 0 0 10px #facc15;
}
.cell-robot {
    width: 24px;
    height: 24px;
    background: #2563eb;
    border: 1.5px solid #000000;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
}
.robot-toolbox-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #000000;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px 12px;
}
.robot-tool-btns {
    display: flex;
    gap: 8px;
}
.robot-tool-btn {
    background: #1e293b;
    border: 1px solid #475569;
    color: #e2e8f0;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.robot-tool-btn.active-tool {
    background: #2563eb;
    color: #fff;
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
}
.robot-ports-matrix {
    font-family: var(--font-mono);
    font-size: 12px;
}
.robot-matrix-header {
    color: #94a3b8;
    letter-spacing: 2px;
    text-align: right;
    margin-bottom: 2px;
}
.robot-matrix-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}
.matrix-label { color: #cbd5e1; width: 68px; }
.matrix-bits { letter-spacing: 2px; font-weight: bold; }
.matrix-port-num { color: #facc15; width: 20px; text-align: right; }

/* ==========================================================================
   Printer Emulation Page - eMEhYH4q.png
   ========================================================================== */
.printer-page-wrapper {
    background: #ffffff;
    border: 1px solid #475569;
    border-radius: 4px;
    padding: 8px 12px;
    color: #000000;
}
.printer-header-bar {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: bold;
    color: #000000;
    margin-bottom: 6px;
    border-bottom: 1px dashed #cbd5e1;
    padding-bottom: 4px;
}

/* ==========================================================================
   Simple I/O Test Device - rxai3VHS.png
   ========================================================================== */
.simple-io-layout {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    max-width: 450px;
}
.simple-io-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-family: var(--font-mono);
}
.simple-io-status-badge {
    background: #1e293b;
    border: 1px solid #475569;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #94a3b8;
    margin: 4px 0;
}

/* ==========================================================================
   Virtual Display Enlarge Full Screen / Theater Mode (100% visible window)
   ========================================================================== */
#screenSection.theater-mode,
#screenSection.fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 10000 !important;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.85) !important;
    display: flex !important;
    flex-direction: column !important;
    border: none !important;
    border-radius: 0 !important;
    background: var(--bg-panel, #1e293b) !important;
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

#screenSection.theater-mode .screen-panel-body,
#screenSection.fullscreen-mode .screen-panel-body {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
    padding: 8px 16px 12px 16px !important;
    width: 100% !important;
    max-height: calc(100vh - 44px) !important;
    box-sizing: border-box !important;
    background: #000 !important;
    gap: 8px !important;
}

#screenSection.theater-mode #screenCanvas,
#screenSection.fullscreen-mode #screenCanvas {
    height: calc(100vh - 245px) !important;
    max-height: calc(100vh - 245px) !important;
    width: min(calc((100vh - 245px) * 1.6), calc(100vw - 32px)) !important;
    max-width: min(calc((100vh - 245px) * 1.6), calc(100vw - 32px)) !important;
    aspect-ratio: 640 / 400 !important;
    align-self: center !important;
    margin: 0 !important;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.9) !important;
    cursor: crosshair !important;
    image-rendering: pixelated !important;
    object-fit: fill !important;
}

#screenSection.theater-mode .screen-footer-bar,
#screenSection.fullscreen-mode .screen-footer-bar {
    width: 100% !important;
    max-width: min(calc((100vh - 245px) * 1.6), calc(100vw - 32px)) !important;
    align-self: center !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

#screenSection.theater-mode .screen-footer-header,
#screenSection.fullscreen-mode .screen-footer-header {
    margin-bottom: 6px !important;
}

#screenSection.theater-mode .kbd-buffer-panel,
#screenSection.fullscreen-mode .kbd-buffer-panel {
    padding: 8px 14px !important;
    gap: 6px !important;
    border-color: #334155 !important;
    background: #090d16 !important;
}

#screenSection.theater-mode .kbd-buffer-title,
#screenSection.fullscreen-mode .kbd-buffer-title {
    font-size: 12px !important;
}

#screenSection.theater-mode .kbd-chars-red,
#screenSection.fullscreen-mode .kbd-chars-red {
    font-size: 15px !important;
}

#screenSection.theater-mode .kbd-ascii-codes,
#screenSection.fullscreen-mode .kbd-ascii-codes {
    font-size: 13px !important;
}

#screenSection.theater-mode .kbd-buffer-input,
#screenSection.fullscreen-mode .kbd-buffer-input {
    font-size: 14px !important;
    padding: 8px 12px !important;
    height: 36px !important;
}

#screenSection.theater-mode #screenFsControls,
#screenSection.fullscreen-mode #screenFsControls {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
}

#screenSection.theater-mode .panel-actions,
#screenSection.fullscreen-mode .panel-actions,
#editorSection.fullscreen-mode .panel-actions {
    max-width: 100% !important;
}

@media (max-width: 768px) {
    #screenSection.theater-mode .panel-font-controls,
    #screenSection.fullscreen-mode .panel-font-controls,
    #editorSection.fullscreen-mode .panel-font-controls {
        display: none !important;
    }
}

@media (max-width: 600px) {
    #screenSection.theater-mode .panel-header,
    #screenSection.fullscreen-mode .panel-header,
    #editorSection.fullscreen-mode .panel-header {
        flex-direction: column !important;
        align-items: stretch !important;
        height: auto !important;
        padding: 4px 8px !important;
        gap: 4px !important;
    }
    #screenSection.theater-mode .panel-actions,
    #screenSection.fullscreen-mode .panel-actions,
    #editorSection.fullscreen-mode .panel-actions {
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        gap: 4px !important;
    }
    #screenSection.theater-mode #screenFsControls,
    #screenSection.fullscreen-mode #screenFsControls,
    #editorSection.fullscreen-mode #editorFsControls {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 4px !important;
        min-width: 0 !important;
    }
    #screenSection.theater-mode .screen-mini-btn,
    #screenSection.fullscreen-mode .screen-mini-btn,
    #editorSection.fullscreen-mode .screen-mini-btn {
        padding: 3px 6px !important;
        font-size: 11px !important;
    }
}

/* ==========================================================================
   Waiting for Input Popover (Quick Keystroke Entry)
   ========================================================================== */
.telemetry-pill.waiting-input {
    cursor: pointer !important;
}

.waiting-input-popover {
    position: fixed;
    z-index: 99999;
    display: none;
    background: #0f172a;
    border: 2px solid #ef4444;
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.8), 0 0 15px rgba(239, 68, 68, 0.4);
    min-width: 320px;
    animation: modalSlideIn 0.15s ease-out;
}

/* ==========================================================================
   Peripherals State Reset Button
   ========================================================================== */
.btn-reset-dev {
    cursor: pointer;
    background: #1e293b;
    border: 1px solid #475569;
    color: #94a3b8;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.btn-reset-dev:hover {
    background: #334155;
    color: #ffffff;
    border-color: #64748b;
}

/* ==========================================================================
   Virtual Files Table & Management (Virtual Disk Modal)
   ========================================================================== */
.disk-files-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12px;
}

.disk-files-table th {
    background: #0f172a;
    color: #94a3b8;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.disk-files-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #1e293b;
    color: #e2e8f0;
}

.disk-files-table tr:hover {
    background: #1e293b;
}

.disk-file-btn {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
}

.disk-file-btn:hover {
    background: #334155;
}

.disk-file-btn-view {
    background: #0369a1;
    color: #ffffff;
    border-color: #0284c7;
}

.disk-file-btn-view:hover {
    background: #0284c7;
    color: #ffffff;
}

.disk-file-btn-danger:hover {
    background: #7f1d1d;
    color: #fca5a5;
    border-color: #991b1b;
}

/* ==========================================================================
   Code Editor Enlarge / Full Screen (100% visible window)
   ========================================================================== */
/* Baseline legacy modal definition (height: 90vh !important; width: 92vw !important) */
@media (max-width: 0px) {
    #editorSection.enlarge-mode {
        width: 92vw !important;
        height: 90vh !important;
    }
}

#editorSection.enlarge-mode,
#editorSection.fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 10000 !important;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.85) !important;
    display: flex !important;
    flex-direction: column !important;
    border: none !important;
    border-radius: 0 !important;
    background: var(--bg-panel, #0f172a) !important;
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

#editorSection.enlarge-mode .editor-panel-body,
#editorSection.fullscreen-mode .editor-panel-body {
    flex: 1 1 auto !important;
    height: calc(100vh - 48px) !important;
    max-height: calc(100vh - 48px) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

#editorSection.enlarge-mode .editor-scroll-container,
#editorSection.fullscreen-mode .editor-scroll-container,
#editorSection.enlarge-mode #codeEditor,
#editorSection.fullscreen-mode #codeEditor,
#editorSection.enlarge-mode #syntaxBackdrop,
#editorSection.fullscreen-mode #syntaxBackdrop {
    height: 100% !important;
    min-height: calc(100vh - 48px) !important;
}

#editorSection.enlarge-mode .editor-line-numbers,
#editorSection.fullscreen-mode .editor-line-numbers {
    height: 100% !important;
    min-height: calc(100vh - 48px) !important;
}

#editorSection.enlarge-mode #editorFsControls,
#editorSection.fullscreen-mode #editorFsControls {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
}

/* Execution Toolbar in Fullscreen Mode (Editor & Screen) */
.fs-execution-toolbar {
    display: none;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}

.fs-execution-toolbar .screen-mini-btn {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 7px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #f1f5f9;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.fs-execution-toolbar .screen-mini-btn:hover {
    background: #334155;
    border-color: #64748b;
}

.fs-execution-toolbar .btn-fs-run {
    background: #065f46 !important;
    border-color: #10b981 !important;
    color: #ecfdf5 !important;
}

.fs-execution-toolbar .btn-fs-run:hover {
    background: #047857 !important;
}

.fs-execution-toolbar .btn-fs-stop {
    background: #7f1d1d !important;
    border-color: #ef4444 !important;
    color: #fee2e2 !important;
}

.fs-execution-toolbar .btn-fs-stop:hover {
    background: #991b1b !important;
}

.fs-execution-toolbar .btn-fs-build {
    background: #1e3a5f !important;
    border-color: #38bdf8 !important;
    color: #e0f2fe !important;
}

.fs-execution-toolbar .btn-fs-build:hover {
    background: #0284c7 !important;
}

.fs-execution-toolbar .btn-fs-switch {
    background: #312e81 !important;
    border-color: #6366f1 !important;
    color: #e0e7ff !important;
}

.fs-execution-toolbar .btn-fs-switch:hover {
    background: #3730a3 !important;
}

/* Pinned Sibling Switch Button & Fullscreen Controls (Identical Visual Coordinates) */
@media (min-width: 601px) {
    #editorSection.fullscreen-mode .panel-header,
    #screenSection.fullscreen-mode .panel-header,
    #screenSection.theater-mode .panel-header {
        position: relative !important;
        height: 44px !important;
        min-height: 44px !important;
        max-height: 44px !important;
        box-sizing: border-box !important;
    }

    #editorSection.fullscreen-mode #btnFsEditorSwitchConsole,
    #screenSection.fullscreen-mode #btnFsScreenSwitchEditor,
    #screenSection.theater-mode #btnFsScreenSwitchEditor {
        position: absolute !important;
        right: 140px !important;
        top: 7px !important;
        width: 145px !important;
        height: 30px !important;
        min-width: 145px !important;
        max-width: 145px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        padding: 0 8px !important;
        box-sizing: border-box !important;
        z-index: 1000 !important;
        margin: 0 !important;
    }

    #editorSection.fullscreen-mode #btnEditorFullScreen,
    #screenSection.fullscreen-mode #btnEnlargeScreen,
    #screenSection.theater-mode #btnEnlargeScreen {
        position: absolute !important;
        right: 12px !important;
        top: 7px !important;
        width: 120px !important;
        height: 30px !important;
        min-width: 120px !important;
        max-width: 120px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        padding: 0 8px !important;
        box-sizing: border-box !important;
        z-index: 1000 !important;
        margin: 0 !important;
    }

    #editorSection.fullscreen-mode #btnEditorScale {
        display: none !important;
    }

    #editorSection.fullscreen-mode .panel-actions,
    #screenSection.fullscreen-mode .panel-actions,
    #screenSection.theater-mode .panel-actions {
        position: static !important;
        margin-right: 285px !important;
    }
}

/* ==========================================================================
   In-Editor Find / Search Bar (Ctrl+F)
   ========================================================================== */
.editor-search-bar {
    position: absolute;
    top: 48px;
    right: 16px;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0f172a;
    border: 1px solid var(--accent-blue, #38bdf8);
    border-radius: 6px;
    padding: 6px 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.15s ease-out;
}

.editor-search-bar .search-icon {
    font-size: 13px;
    color: #94a3b8;
}

.editor-search-bar input {
    background: #020617;
    border: 1px solid #334155;
    color: #f8fafc;
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    width: 200px;
    outline: none;
    transition: border-color 0.15s ease;
}

.editor-search-bar input:focus {
    border-color: var(--accent-blue, #38bdf8);
    box-shadow: 0 0 0 1px var(--accent-blue, #38bdf8);
}

.search-match-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: #cbd5e1;
    min-width: 50px;
    text-align: center;
    user-select: none;
}

.search-nav-btn, .search-close-btn {
    background: #1e293b;
    border: 1px solid #475569;
    color: #e2e8f0;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s ease;
    padding: 0;
}

.search-nav-btn:hover {
    background: #334155;
    border-color: #64748b;
    color: #fff;
}

.search-close-btn:hover {
    background: #7f1d1d;
    border-color: #ef4444;
    color: #fca5a5;
}

/* ==========================================================================
   Disassembly Jump Navigation Input (CS:IP, [IP+3], CS:[BX+SI+1], 0100h)
   ========================================================================== */
.disasm-nav-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
}

.disasm-addr-input {
    background: #020617;
    border: 1px solid var(--border-color, #334155);
    border-radius: 4px;
    color: #38bdf8;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    width: 145px;
    outline: none;
    transition: all 0.15s ease;
}

.disasm-addr-input:focus {
    border-color: var(--accent-blue, #38bdf8);
    box-shadow: 0 0 0 1px var(--accent-blue, #38bdf8);
    background: #060910;
}

.disasm-nav-go-btn {
    background: var(--bg-card, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 4px;
    color: var(--text-primary, #e2e8f0);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.disasm-nav-go-btn:hover {
    background: var(--accent-blue, #38bdf8);
    border-color: var(--accent-blue, #38bdf8);
    color: #000;
}

@media (max-width: 768px) {
    .disasm-addr-input {
        width: 120px;
        font-size: 10.5px;
    }
    .disasm-nav-wrap {
        margin-left: 2px;
    }
}
