/* Dromaios */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;700&family=IBM+Plex+Sans:wght@400;600;700&display=swap');

:root {
    --bg: #1a1a2e;
    --bg-panel: #16213e;
    --bg-toolbar: #0f1a30;
    --text: #e0e0e0;
    --text-dim: #8888aa;
    --accent: #0f3460;
    --highlight: #e94560;
    --green: #00ff41;
    --amber: #ffb000;
    --red: #ff5555;
    --blue: #4fc3f7;
    --border: #2a2a4a;
    --radius-panel: 8px;
    --radius-window: 24px;
    --font-mono: "IBM Plex Mono", monospace;
    --font-sans: "IBM Plex Sans", sans-serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
}

/* ==================== */
/* Home page            */
/* ==================== */

header {
    background: var(--accent);
    padding: 8px 16px;
    display: flex;
    align-items: center;
}

header nav {
    display: flex;
    gap: 24px;
    align-items: center;
}

header a {
    color: var(--text);
    text-decoration: none;
}

header .site-title {
    font-weight: 700;
    font-size: 16px;
}

main {
    padding: 16px;
}

h1 { font-size: 24px; margin-bottom: 12px; }

.button {
    display: inline-block;
    padding: 8px 20px;
    background: var(--highlight);
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
}

/* ==================== */
/* Emulator page        */
/* ==================== */

.emulator-page {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Workspace: four columns fill the viewport */
#workspace {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* ==================== */
/* Column base          */
/* ==================== */

.col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Column tabs */
.col-tabs {
    display: flex;
    gap: 2px;
    padding: 4px 4px 0;
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border);
}

.col-tab {
    flex: 1;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.col-tab:hover {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}

.col-tab.active {
    color: var(--text);
    background: var(--bg-panel);
}

.tab-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tab-content.hidden,
.hidden {
    display: none;
}

/* Column controls row (buttons, file inputs) */
.col-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 36px;
}

.col-controls button,
#screen-panel h3 button {
    background: var(--accent);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 4px 12px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 12px;
    border-radius: 3px;
    white-space: nowrap;
}

.col-controls button:hover,
#screen-panel h3 button:hover {
    background: var(--highlight);
    border-color: var(--highlight);
}

#btn-basic-trace.active {
    background: var(--amber);
    color: var(--bg);
    border-color: var(--amber);
}

.col-controls .site-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    text-decoration: none;
    margin-right: 4px;
}

.clock-speed {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.speed-control {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.speed-control input[type="range"] {
    width: 70px;
}

.file-name {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.file-change {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-dim);
    text-decoration: none;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.file-change:hover {
    color: var(--highlight);
    text-decoration: underline;
}

.clear-log {
    margin-left: auto;
}

.clear-log + .live-toggle {
    margin-left: 8px;
}

.file-hidden {
    display: none;
}

/* ==================== */
/* SCREEN + CPU column  */
/* ==================== */

#col-main {
    flex-shrink: 0;
    padding-left: 3px;
}

#screen-panel .panel-body {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    flex-shrink: 0;
    background: #000;
    border-radius: 0 0 var(--radius-panel) var(--radius-panel);
    corner-shape: squircle;
}

#screen-panel {
    margin-bottom: 0;
}

#screen {
    display: block;
    image-rendering: pixelated;
    outline: 2px solid transparent;
    outline-offset: 4px;
    cursor: pointer;
}

#screen:focus {
    outline-color: #1565c0;
}

/* Scanline overlay */
#scanlines {
    display: none;
    position: absolute;
    pointer-events: none;
    /* position, size, and gradient set dynamically by syncScanlines() */
}

#scanlines.active {
    display: block;
}

.control-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 2px;
}

/* CPU sub-columns below screen */
#cpu-panels {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    background: var(--bg);
}

#cpu-left {
    display: flex;
    flex-direction: column;
    width: 50%;
    overflow: hidden;
}

#cpu-right {
    display: flex;
    flex-direction: column;
    width: 50%;
    overflow: hidden;
}

/* Branding */
#branding {
    flex-shrink: 0;
    margin-top: auto;
    padding: 10px 12px;
    background: var(--bg-toolbar);
    border-bottom-left-radius: var(--radius-window);
    corner-bottom-left-shape: squircle;
}

.brand-name {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
}

.brand-detail {
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
}

/* ==================== */
/* MEMORY column        */
/* ==================== */

#col-memory {
    min-width: 260px;
    flex: 1;
}

/* ==================== */
/* DISK column          */
/* ==================== */

#col-io {
    min-width: 260px;
    flex: 1;
    max-height: 100%;
}

/* ==================== */
/* Panels (shared)      */
/* ==================== */

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-panel);
    corner-shape: squircle;
    flex-shrink: 0;
    min-height: 0;
    margin: 6px 3px 0 3px;
}

.panel:last-child {
    margin-bottom: 6px;
}

.panel h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    user-select: none;
}

.panel h3::before {
    content: "▾";
    font-size: 10px;
    transition: transform 0.15s;
}

.panel.collapsed h3::before {
    transform: rotate(-90deg);
}

.panel.collapsed h3 {
    border-bottom-color: transparent;
}

.panel.collapsed {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
}

.panel.collapsed > .panel-body,
.panel.collapsed > pre,
.panel.collapsed > div:not(:first-child) {
    display: none !important;
}

.live-toggle {
    margin-left: auto;
    width: 8px;
    height: 8px;
    background: #333;
    border: 1px solid var(--border);
    border-radius: 2px;
    cursor: pointer;
    padding: 0;
    font-size: 0;
}

.live-toggle:hover {
    border-color: var(--text-dim);
}

.live-toggle.live {
    background: var(--green);
    border-color: var(--green);
    box-shadow: 0 0 4px var(--green);
}

.panel-body {
    padding: 8px 10px;
}

.panel-body pre {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.disasm-tabs {
    margin-left: auto;
    display: flex;
    gap: 0;
}

.disasm-tab {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 1px 8px;
    cursor: pointer;
}

.disasm-tab:first-child {
    border-radius: 3px 0 0 3px;
}

.disasm-tab:last-child {
    border-radius: 0 3px 3px 0;
    margin-left: -1px;
}

.disasm-tab.active {
    background: var(--accent);
    color: var(--amber);
    border-color: var(--amber);
    z-index: 1;
    position: relative;
}

.disasm-tab:not(.active):hover {
    background: var(--bg);
    color: var(--text);
}

/* View tabs — content subtabs (vs disasm-tabs which are sync-mode selectors) */
.view-tabs {
    margin-left: auto;
    display: flex;
    gap: 0;
}

.view-tab {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    background: transparent;
    color: var(--text-dim);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 1px 8px 2px;
    cursor: pointer;
}

.view-tab.active {
    color: var(--text);
    border-bottom-color: var(--blue);
}

.view-tab:not(.active):hover {
    color: var(--text);
}

/* Panels that expand to fill vertical space */
#disassembly,
#memory-view,
#zeropage-view {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#disassembly .panel-body,
#memory-view .panel-body,
#zeropage-view .panel-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Instruction panel fills remaining space in left sub-column */
#instruction-detail {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#instruction-detail .panel-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Nibble stream panel expands to fill disk column */
#disk-nibbles {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#disk-nibbles .panel-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Stack shares remaining space in memory column */
#stack-view {
    flex: 0.4 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#stack-view .panel-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ==================== */
/* Instruction Detail   */
/* ==================== */

#explain-view {
    font-family: var(--font-mono);
    font-size: 21px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
}

.ex-mnem {
    color: var(--amber);
    font-weight: 700;
}

.ex-op {
    color: var(--blue);
}

#explain-view .ex-addr {
    color: var(--blue);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

#explain-view .ex-addr:hover {
    color: white;
    text-decoration-style: solid;
}

.ex-dim {
    color: var(--text-dim);
}

.ex-taken {
    color: #4caf50;
    font-weight: 700;
}

.ex-not-taken {
    color: var(--highlight);
    font-weight: 700;
}

/* ==================== */
/* Registers            */
/* ==================== */

.reg-grid {
    display: grid;
    grid-template-columns: auto auto auto auto auto auto;
    gap: 2px 6px;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 21px;
}

.reg-label {
    color: var(--text-dim);
}

.reg-val {
    color: var(--green);
    cursor: pointer;
}

.reg-val:hover {
    text-decoration: underline;
}

.reg-edit {
    font-family: var(--font-mono);
    font-size: 21px;
    background: var(--bg);
    color: var(--green);
    border: 1px solid var(--green);
    padding: 0 2px;
    width: 5em;
    border-radius: 2px;
    outline: none;
}

#flags {
    grid-column: 1 / -1;
    display: flex;
    gap: 5px;
    margin-top: 4px;
}

.flag {
    display: inline-block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 700;
    border-radius: 3px;
    background: var(--bg);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.flag.set {
    background: var(--highlight);
    color: white;
    border-color: var(--highlight);
}

.flag-fixed {
    background: var(--accent) !important;
    color: var(--text-dim) !important;
    border-color: var(--border) !important;
}

/* ==================== */
/* Disassembly          */
/* ==================== */

#disasm-view {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

#disasm-view .current {
    background: rgba(233, 69, 96, 0.2);
    color: var(--amber);
}

.mem-current {
    background: rgba(255, 183, 77, 0.1);
    color: var(--amber);
}

.mem-byte-hl {
    background: var(--amber);
    color: var(--bg-panel);
    border-radius: 2px;
}

#rom-routine-list {
    color: var(--text);
}

#disasm-view .disasm-addr,
#explain-view .disasm-addr,
#rom-routine-list .disasm-addr,
#zp-hex .mem-addr,
#mem-hex .mem-addr,
#stack-hex .mem-addr {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

#disasm-view .disasm-addr:hover,
#explain-view .disasm-addr:hover,
#rom-routine-list .disasm-addr:hover {
    color: var(--blue);
    text-decoration-style: solid;
}

#zp-hex .mem-addr:hover,
#mem-hex .mem-addr:hover,
#stack-hex .mem-addr:hover {
    color: var(--blue);
    text-decoration-style: solid;
}

/* ZP name colours by source */
.zp-rom {
    color: var(--green);
    font-size: 0.85em;
    margin-left: 1em;
}

.zp-dos {
    color: var(--blue);
    font-size: 0.85em;
    margin-left: 1em;
}

.zp-u4 {
    color: var(--amber);
    font-size: 0.85em;
    margin-left: 1em;
}

/* Annotated byte highlight in hex view */
.zp-byte-annotated {
    color: var(--green);
    cursor: help;
}

/* Named entries view */
#zp-names {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.zp-entry-hl {
    background: rgba(233, 69, 96, 0.15);
}

.zp-separator {
    color: var(--text-dim);
    display: block;
    margin: 2px 0;
}

.zp-val {
    color: var(--amber);
}

.zp-desc {
    color: var(--text-dim);
    font-size: 0.9em;
}

/* ZP custom tooltip */
.zp-tooltip {
    position: absolute;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #0f1a30;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.08s;
    z-index: 100;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

.zp-tooltip.visible {
    opacity: 1;
}

.zp-tip-left {
    line-height: 1.3;
}

.zp-tip-addr {
    color: var(--text-dim);
}

.zp-tip-sym {
    color: var(--green);
    font-weight: 700;
}

.zp-tip-desc {
    color: var(--text);
    font-size: 0.9em;
}

.zp-tip-val {
    font-size: 30px;
    font-weight: 700;
    color: var(--amber);
    line-height: 1;
}

/* ROM Reference current highlight */
.rom-current {
    background: rgba(233, 69, 96, 0.15);
    border-left: 2px solid var(--highlight);
    margin-left: -6px;
    padding-left: 4px;
}

/* ==================== */
/* Stack                */
/* ==================== */

#stack-hex {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    color: var(--green);
}

/* ==================== */
/* Memory               */
/* ==================== */

#zp-hex {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}

#mem-hex {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    color: var(--green);
}

#mem-addr {
    font-family: var(--font-mono);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 2px 4px;
    border-radius: 3px;
}

#btn-mem-go {
    background: var(--accent);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 3px 10px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px;
    border-radius: 3px;
}

#btn-mem-go:hover {
    background: var(--highlight);
    border-color: var(--highlight);
}

/* ==================== */
/* Disk II State        */
/* ==================== */

#disk-state {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

.disk-on { color: #4ec94e; }
.disk-off { color: #555; }
.disk-dim { color: #555; }
.disk-mode { color: var(--amber); font-weight: bold; }
.disk-latch { color: var(--green); }

/* ==================== */
/* Nibble Stream        */
/* ==================== */

#nibble-stream {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text);
}

.nib-sync { color: #444; }
.nib-addr { color: #4ec94e; font-weight: bold; }
.nib-data { color: #5ba3f5; font-weight: bold; }
.nib-epil { color: var(--amber); }
.nib-normal { color: var(--text); }
.nib-cur {
    background: rgba(233, 69, 96, 0.35);
    color: white;
    font-weight: bold;
    border-radius: 2px;
    padding: 0 2px;
}
.nib-marker { color: var(--highlight); }

/* ==================== */
/* Sector Map           */
/* ==================== */

#sector-map {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.0;
}

.sec-cell {
    display: inline-block;
    width: 28px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 3px;
    margin: 1px;
}

.sec-unknown { color: #444; background: transparent; }
.sec-found { color: var(--amber); background: rgba(255, 183, 77, 0.15); }
.sec-read { color: #4ec94e; background: rgba(78, 201, 78, 0.15); }
.sec-active { border-color: var(--highlight); box-shadow: 0 0 4px var(--highlight); }

/* ==================== */
/* Soft Switches        */
/* ==================== */

.sw-group {
    margin-bottom: 6px;
}

.sw-group:last-child {
    margin-bottom: 0;
}

.sw-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.sw-row {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.6;
}

.sw-led {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #333;
    margin-right: 2px;
    margin-left: 6px;
    vertical-align: middle;
}

.sw-led:first-child {
    margin-left: 0;
}

.sw-led.lit {
    background: var(--green);
    box-shadow: 0 0 4px var(--green);
}

.sw-led.sw-amber.lit {
    background: var(--amber);
    box-shadow: 0 0 4px var(--amber);
}

.sw-mode {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--amber);
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sw-value {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    margin-left: 8px;
}

.sw-value span {
    color: var(--text);
    min-width: 24px;
    display: inline-block;
}

/* ==================== */
/* Disk Log             */
/* ==================== */

#disk-log-panel {
    border-bottom-right-radius: var(--radius-window);
    corner-bottom-right-shape: squircle;
}

#disk-log {
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-dim);
}

/* BASIC listing */
#basic-listing {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.3;
    color: var(--text);
    white-space: pre;
}

#basic-listing > span {
    display: block;
    padding: 0 4px 0 14px;
    border-left: 3px solid transparent;
    cursor: pointer;
    position: relative;
}

#basic-listing > span:hover {
    background: rgba(255, 255, 255, 0.03);
}

.basic-breakpoint {
    border-left-color: var(--red) !important;
}

/* BASIC syntax highlighting */
.basic-linenum { color: var(--text-dim); }
.basic-kw      { color: #4a9eff; }
.basic-str     { color: #50c878; }
.basic-rem     { color: var(--text-dim); font-style: italic; }

.basic-current-line {
    background: rgba(255, 176, 0, 0.15) !important;
    border-left-color: #ffb000 !important;
    color: #fff;
}

.basic-current-line::before {
    content: "▸";
    position: absolute;
    left: 2px;
    color: #ffb000;
    font-size: 12px;
    line-height: inherit;
}

.basic-current-line.basic-breakpoint {
    border-left-color: var(--red) !important;
}

/* Flash highlight when scrolling to a line */
@keyframes basic-flash-fade {
    0%   { background: rgba(74, 158, 255, 0.3); }
    100% { background: transparent; }
}

.basic-flash {
    animation: basic-flash-fade 0.8s ease-out;
}

/* Heat map — warmer = more executed */
.basic-heat {
    background: rgba(255, 100, 50, calc(var(--heat, 0) * 0.15));
}

.basic-heat.basic-current-line {
    background: rgba(255, 176, 0, 0.15) !important;
}

/* Trace history */
#basic-history {
    line-height: 1.6;
}

#basic-history > span {
    display: inline-block;
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
}

#basic-history > span:hover {
    background: rgba(255, 255, 255, 0.08);
}

.basic-history-current {
    color: var(--amber);
    font-weight: bold;
}

/* Program flow annotation chips */
.basic-flow-chip {
    display: inline-block;
    font-size: 10px;
    padding: 0 4px;
    margin-left: 8px;
    border-radius: 3px;
    vertical-align: middle;
    line-height: 16px;
}

.basic-flow-target {
    background: rgba(74, 158, 255, 0.15);
    color: #4a9eff;
}

.basic-flow-src {
    cursor: pointer;
}

.basic-flow-src:hover {
    text-decoration: underline;
}

/* Memory map bar */
.memmap-bar {
    display: flex;
    height: 22px;
    border-radius: 3px;
    overflow: hidden;
    gap: 1px;
}

.memmap-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    cursor: pointer;
}

.memmap-program  { background: #4a9eff; }
.memmap-vars     { background: #50c878; }
.memmap-arrays   { background: #ffb000; }
.memmap-free     { background: rgba(255, 255, 255, 0.06); }
.memmap-strings  { background: #c77dff; }

.memmap-label {
    font-size: 10px;
    font-family: var(--font-sans);
    color: var(--bg);
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    padding: 0 4px;
}

.memmap-free .memmap-label {
    color: var(--text-dim);
}

/* Memory map popover — positioned by JS as a fixed overlay */
#memmap-popover {
    display: none;
    position: fixed;
    background: var(--panel-bg, #1e1e2e);
    border: 1px solid var(--border, #444);
    border-radius: 4px;
    padding: 6px 10px;
    z-index: 1000;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--fg, #cdd6f4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

#memmap-popover::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
}

#memmap-popover.above::after {
    top: 100%;
    border-top-color: var(--border, #444);
}

#memmap-popover.below::after {
    bottom: 100%;
    border-bottom-color: var(--border, #444);
}

.memmap-pop-title {
    font-weight: 600;
    margin-bottom: 3px;
    font-size: 12px;
}

.memmap-pop-row {
    line-height: 1.5;
}

.memmap-pop-key {
    color: var(--text-dim);
    display: inline-block;
    width: 3.5em;
}

.memmap-pop-extra {
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    font-size: 10px;
}

/* PEEK/POKE log */
.peekpoke-grid {
    column-width: 18em;
    column-gap: 0;
}

.peekpoke-row {
    display: block;
    break-inside: avoid;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.6;
    padding: 0 4px;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.peekpoke-poke { color: #ffb000; border-left-color: #ffb000; }
.peekpoke-peek { color: #4a9eff; border-left-color: #4a9eff; }
.peekpoke-call { color: #50c878; border-left-color: #50c878; }

.peekpoke-label {
    color: var(--text-dim);
    font-size: 10px;
    font-style: italic;
}

.peekpoke-line .basic-lineref {
    cursor: pointer;
    color: var(--text-dim);
}

.peekpoke-line .basic-lineref:hover {
    color: var(--amber);
    text-decoration: underline;
}

/* DATA/READ log */
.dataread-grid {
    column-width: 20em;
    column-gap: 0;
}

.dataread-row {
    display: block;
    break-inside: avoid;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.6;
    padding: 0 4px;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.dataread-read { color: #4a9eff; border-left-color: #4a9eff; }
.dataread-restore { color: #ffb000; border-left-color: #ffb000; }

.dataread-line .basic-lineref {
    cursor: pointer;
    color: var(--text-dim);
}

.dataread-line .basic-lineref:hover {
    color: var(--amber);
    text-decoration: underline;
}

/* Subroutine profiler */
.profiler-table {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 11px;
    border-collapse: collapse;
}

.profiler-table th {
    text-align: left;
    color: var(--text-dim);
    font-weight: normal;
    padding: 2px 6px;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profiler-table td {
    padding: 2px 6px;
}

.profiler-table td:nth-child(n+2) {
    text-align: right;
}

.profiler-active {
    background: rgba(80, 200, 120, 0.1);
}

.profiler-active td:first-child::after {
    content: " ▸";
    color: #50c878;
}

.profiler-callstack {
    margin-top: 6px;
    padding: 4px 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
}

/* Memory watch */
.watch-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 3px;
}

.watch-changed {
    background: rgba(255, 176, 0, 0.15);
}

.watch-addr {
    color: var(--text-dim);
}

.watch-label {
    color: var(--text-dim);
    font-size: 10px;
    font-style: italic;
}

.watch-val {
    color: var(--amber);
    font-weight: bold;
}

.watch-dec {
    color: var(--text-dim);
    font-size: 10px;
}

.watch-remove {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    line-height: 1;
}

.watch-remove:hover {
    color: #ff5555;
}

.watch-input-row {
    display: flex;
    gap: 4px;
    padding: 6px 4px 2px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.watch-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 3px;
}

.watch-input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.watch-add-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
}

.watch-add-btn:hover {
    border-color: var(--amber);
    color: var(--amber);
}

/* Execution state panel */
#basic-state {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text);
}

.state-row {
    display: block;
    padding: 0 4px;
}

.state-indent {
    padding-left: 16px;
}

.state-label {
    color: var(--text-dim);
    display: inline-block;
    min-width: 60px;
}

.state-section {
    display: block;
    color: var(--text-dim);
    padding: 4px 4px 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.state-active {
    color: var(--green);
}

.state-error {
    color: var(--red);
}

.state-zp {
    font-size: 10px;
    opacity: 0.5;
}

.state-zp:hover {
    opacity: 1;
}

/* Clickable addresses in BASIC tab */
#basic-listing .basic-addr,
#basic-variables .basic-addr,
#basic-state .basic-addr,
#basic-state .mem-addr {
    color: var(--text-dim);
    cursor: pointer;
    font-size: 11px;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

#basic-listing .basic-addr:hover,
#basic-variables .basic-addr:hover,
#basic-state .basic-addr:hover,
#basic-state .mem-addr:hover {
    color: var(--blue);
    text-decoration-style: solid;
}

/* Variables panel */
#basic-variables {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.3;
    color: var(--text);
    white-space: pre;
}

.var-container {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 4px;
}

/* Two-column layout for simple variables */
.var-grid-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

details.var-array-block {
    padding: 2px 0;
}
details.var-array-block summary {
    cursor: pointer;
    list-style: none;
}
details.var-array-block summary::before {
    content: "▶";
    display: inline-block;
    width: 12px;
    font-size: 8px;
    color: var(--text-dim);
    transition: transform 0.15s;
}
details.var-array-block[open] summary::before {
    transform: rotate(90deg);
}

.var-row {
    display: block;
    padding: 1px 4px;
}

.var-badge {
    display: inline-block;
    width: 14px;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    border-radius: 2px;
    margin-right: 4px;
}

.var-real  { background: #2a4a3a; color: #6fcf97; }
.var-int   { background: #2a3a5a; color: #6fb3f0; }
.var-str   { background: #4a3a2a; color: #f0c06f; }

.var-arr {
    border: 1px solid currentColor;
    border-radius: 3px;
}

.var-separator {
    border-top: 1px solid var(--text-dim);
    margin: 3px 0;
    opacity: 0.3;
}

.var-element {
    color: var(--text-dim);
    padding-left: 30px;
}

.var-name {
    color: #ccc;
    min-width: 40px;
    display: inline-block;
}

.var-value {
    color: var(--text-dim);
}

/* Variable change flash */
@keyframes var-change-fade {
    0%   { background: rgba(80, 200, 120, 0.3); }
    100% { background: transparent; }
}

.var-changed {
    animation: var-change-fade 1s ease-out;
}

/* 2D array grid */
.var-grid {
    border-collapse: collapse;
    margin: 4px 0 4px 30px;
    font-size: 11px;
    font-family: var(--font-mono);
}
.var-grid th, .var-grid td {
    padding: 1px 6px;
    text-align: right;
    white-space: nowrap;
}
.var-grid th {
    color: var(--text-dim);
    font-weight: normal;
}
.var-grid td {
    color: #ccc;
    border: 1px solid #333;
}
