:root {
  --bg: #0a0a0a;
  --bg2: #0f0f0f;
  --bg3: #161616;
  --accent: #33ff33;
  --accent-dim: #1a8a1a;
  --accent-glow: rgba(51, 255, 51, 0.15);
  --text: #33ff33;
  --text-dim: #1a7a1a;
  --border: #1a7a1a;
  --error: #ff4444;
  --warning: #ffaa00;
  --success: #33ff33;
  --cyan: #00ffcc;
  --yellow: #ffd700;
  --magenta: #ff66ff;
  --orange: #ff8c00;
  --white: #e0e0e0;
  --gray: #555555;
}

.amber {
  --accent: #ffb000;
  --accent-dim: #8a6000;
  --accent-glow: rgba(255, 176, 0, 0.15);
  --text: #ffb000;
  --text-dim: #7a5500;
  --border: #7a5500;
  --success: #ffb000;
  --cyan: #ffd060;
  --yellow: #ffe080;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 10px 24px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 0 8px var(--accent-glow);
  box-shadow: 0 0 20px var(--accent-glow), 0 4px 16px rgba(0,0,0,0.5);
  z-index: 10000;
  animation: toastIn 0.3s ease-out;
  letter-spacing: 1px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Header */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 0 8px var(--accent-glow);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 300;
}

.led {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: blink 1.5s infinite;
}

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

.led.assembling {
  animation: fastblink 0.15s infinite;
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

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

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.theme-toggle:hover {
  border-color: var(--accent);
  text-shadow: 0 0 5px var(--accent);
}

/* Toolbar */
.toolbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
  text-shadow: 0 0 5px var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn:disabled:hover {
  border-color: var(--border);
  text-shadow: none;
  box-shadow: none;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent-glow);
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent);
  color: var(--bg);
  text-shadow: none;
}

select.btn {
  appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2333ff33' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

select.btn option {
  background: var(--bg2);
  color: var(--text);
}

.toolbar-spacer { flex: 1; }

.size-indicator {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Message bar */
.message-bar {
  padding: 4px 16px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  max-height: 80px;
  overflow-y: auto;
}

.msg-success { color: var(--success); }
.msg-error { color: var(--error); }
.msg-warning { color: var(--warning); }

/* Main panels */
.main-content {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Editor panel */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.editor-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

.line-numbers {
  width: 44px;
  background: var(--bg2);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 20px;
  padding: 8px 6px 8px 0;
  text-align: right;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.editor-highlight-layer {
  position: absolute;
  top: 0; left: 44px; right: 0; bottom: 0;
  padding: 8px;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  overflow: auto;
  pointer-events: none;
  color: transparent;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  tab-size: 4;
}

.code-textarea {
  position: absolute;
  top: 0; left: 44px; right: 0; bottom: 0;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
  border: none;
  outline: none;
  resize: none;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 20px;
  padding: 8px;
  width: calc(100% - 44px);
  tab-size: 4;
  overflow: auto;
  z-index: 1;
  color: transparent;
}

.code-textarea::selection {
  background: rgba(51, 255, 51, 0.25);
}

/* Output panel */
.output-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tab-bar {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  padding: 8px 16px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 5px var(--accent-glow);
}

.tab-content {
  flex: 1;
  overflow: auto;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  background: var(--bg);
}

.hex-addr { color: var(--cyan); }
.hex-byte { color: var(--text); }
.hex-ascii { color: var(--text-dim); }

.listing-addr { color: var(--cyan); }
.listing-bytes { color: var(--yellow); }
.listing-source { color: var(--text); }

.sym-table { border-collapse: collapse; width: 100%; }
.sym-table th, .sym-table td {
  text-align: left;
  padding: 4px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.sym-table th { color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.sym-table td { color: var(--text); }

/* Instruction reference */
.ref-search {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 10px;
  width: 100%;
  margin-bottom: 8px;
  border-radius: 2px;
  outline: none;
}

.ref-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 4px var(--accent-glow);
}

.ref-table { border-collapse: collapse; width: 100%; }
.ref-table th, .ref-table td {
  text-align: left;
  padding: 3px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 11px;
  white-space: nowrap;
}
.ref-table th { color: var(--accent); text-transform: uppercase; letter-spacing: 1px; font-size: 10px; position: sticky; top: 0; background: var(--bg); }
.ref-table tr { cursor: pointer; }
.ref-table tr:hover { background: var(--accent-glow); }

/* Footer */
.footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-shadow: 0 0 5px var(--accent);
}

/* Syntax highlighting spans */
.syn-inst { color: var(--cyan); font-weight: 500; }
.syn-reg { color: var(--yellow); }
.syn-num { color: var(--magenta); }
.syn-label { color: var(--white); font-weight: 700; }
.syn-comment { color: var(--gray); font-style: italic; }
.syn-dir { color: var(--orange); }
.syn-str { color: #88ddff; }
.syn-prefix { color: var(--orange); }

/* Mobile */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }
  .editor-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: 35vh;
    max-height: 50vh;
  }
  .output-panel {
    min-height: 40vh;
  }
  .header-subtitle { display: none; }
  .toolbar { gap: 4px; }
  .btn { font-size: 11px; padding: 5px 8px; }
  .size-indicator { display: none; }
}