:root {
  --bg-deep: #0a0e1a;
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2333;
  --bg-surface: #21283b;
  --border: #30363d;
  --border-focus: #00ff41;
  --green: #00ff41;
  --green-dim: #00cc33;
  --amber: #ffb000;
  --cyan: #00d4ff;
  --magenta: #ff6ec7;
  --red: #ff4444;
  --yellow: #ffd700;
  --white: #e6edf3;
  --gray: #8b949e;
  --gray-dim: #484f58;
}

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

body {
  background: var(--bg-deep);
  color: var(--white);
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  height: 100vh;
}

#root {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ========== APP ROOT ========== */
.app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-deep);
}

/* ========== HEADER ========== */
.app-header {
  background: linear-gradient(180deg, #0f1629 0%, #0a0e1a 100%);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
}

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

.chip-icon {
  color: var(--green);
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.retro-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: var(--green);
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.5), 0 0 20px rgba(0, 255, 65, 0.2);
}

.header-sub {
  color: var(--gray);
  font-size: 10px;
  font-style: italic;
}

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

.btn {
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  transition: all 0.15s ease;
  outline: none;
}

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

.btn-assemble {
  background: rgba(0, 255, 65, 0.12);
  color: var(--green);
  border: 1px solid var(--green);
  font-weight: 700;
}
.btn-assemble:hover:not(:disabled) {
  background: rgba(0, 255, 65, 0.22);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
}

.btn-default {
  background: var(--bg-tertiary);
  color: var(--gray);
  border: 1px solid var(--border);
}
.btn-default:hover:not(:disabled) {
  color: var(--white);
  border-color: var(--gray);
}

.btn-copied {
  color: var(--green) !important;
  border-color: var(--green) !important;
}

.btn-ref-active {
  background: rgba(0, 212, 255, 0.1);
  color: var(--cyan);
  border: 1px solid var(--cyan);
}

.auto-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--gray);
  font-size: 11px;
  cursor: pointer;
}
.auto-toggle input {
  accent-color: var(--green);
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.toolbar-select {
  background: var(--bg-tertiary);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  cursor: pointer;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-editor {
  flex: 1;
  border-right: 1px solid var(--border);
}

.panel-output {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.panel-label {
  background: var(--bg-tertiary);
  padding: 3px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  color: var(--gray-dim);
  letter-spacing: 1px;
  flex-shrink: 0;
}

/* ========== EDITOR ========== */
.editor-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg-primary);
  position: relative;
}

.scanline {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 65, 0.012) 2px,
    rgba(0, 255, 65, 0.012) 4px
  );
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 1;
}

.line-numbers {
  font-size: 13px;
  line-height: 20px;
  color: var(--gray-dim);
  text-align: right;
  user-select: none;
  padding: 8px 10px 8px 0;
  min-width: 38px;
  overflow: hidden;
  flex-shrink: 0;
}

.line-num {
  height: 20px;
}

.editor-textarea {
  flex: 1;
  background: transparent;
  color: var(--white);
  border: none;
  outline: none;
  resize: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 20px;
  padding: 8px;
  white-space: pre;
  overflow-wrap: normal;
  tab-size: 8;
  overflow-y: auto;
}

.editor-textarea::selection {
  background: rgba(0, 212, 255, 0.25);
}

/* ========== OUTPUT PANELS ========== */
.output-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.output-bottom {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--border);
}

.hex-dump-area {
  flex: 1;
  overflow: auto;
  padding: 8px 12px;
  background: var(--bg-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 18px;
}

.listing-area {
  flex: 1;
  overflow: auto;
  padding: 8px 12px;
  background: var(--bg-primary);
}

.empty-msg {
  color: var(--gray-dim);
  font-style: italic;
  padding: 20px;
  font-size: 12px;
}

/* ========== HEX DUMP ========== */
.hex-dump {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 18px;
}

.hex-line {
  white-space: pre;
}

.hex-addr { color: var(--amber); }
.hex-sep { color: var(--gray-dim); }
.hex-byte { color: var(--cyan); }
.hex-pad { color: var(--gray-dim); }
.hex-ascii { color: var(--magenta); }

/* ========== LISTING ========== */
.listing {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 18px;
}

.listing-line {
  white-space: pre;
  border-left: 2px solid transparent;
  padding-left: 4px;
}

.listing-error {
  background: rgba(255, 68, 68, 0.08);
  border-left-color: var(--red);
}

.list-addr { color: var(--amber); }
.list-sep { color: var(--gray-dim); }
.list-hex { color: var(--cyan); }
.list-code { color: var(--white); }
.list-comment { color: var(--gray-dim); }

/* ========== CONSOLE ========== */
.console-panel {
  height: 90px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.console-output {
  flex: 1;
  overflow: auto;
  padding: 6px 12px;
  background: var(--bg-deep);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 18px;
}

.msg-success { color: var(--green); }
.msg-error { color: var(--red); }
.msg-warn { color: var(--amber); }
.msg-symbols { color: var(--gray); margin-top: 4px; }

/* ========== HELP PANEL ========== */
.help-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 380px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 1px;
}

.help-close {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}
.help-close:hover { color: var(--white); }

.help-search-wrap {
  padding: 8px 12px;
}

.help-search {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--white);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
}
.help-search:focus {
  border-color: var(--cyan);
}

.help-content {
  flex: 1;
  overflow: auto;
  padding: 0 12px 12px;
}

.help-section-regs {
  margin-bottom: 14px;
  padding: 8px;
  background: rgba(0, 255, 65, 0.03);
  border: 1px solid rgba(0, 255, 65, 0.08);
  border-radius: 4px;
}

.help-section-title {
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  letter-spacing: 1px;
}

.help-group {
  margin-bottom: 10px;
}

.help-group-title {
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 3px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
}

.help-group-reg {
  color: var(--magenta);
}

.help-item {
  font-size: 11px;
  padding: 1px 0;
  display: flex;
  gap: 8px;
}

.help-mnemonic {
  color: var(--cyan);
  min-width: 110px;
  flex-shrink: 0;
}

.help-mnemonic-green {
  color: var(--green);
  min-width: 110px;
  flex-shrink: 0;
  font-weight: 500;
}

.help-desc {
  color: var(--gray);
}

/* ========== FOOTER ========== */
.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 5px 16px;
  font-size: 10px;
  color: var(--gray-dim);
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

.footer-link {
  color: var(--cyan);
  text-decoration: none;
}
.footer-link:hover {
  text-decoration: underline;
}

/* ========== ANIMATIONS ========== */
@keyframes flashGreen {
  0% { background-color: rgba(0, 255, 65, 0.12); }
  100% { background-color: transparent; }
}

.flash-success {
  animation: flashGreen 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.2s ease-out;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column !important;
  }
  .panel-editor {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: 200px;
  }
  .help-panel {
    width: 100%;
  }
  .retro-title {
    font-size: 11px;
  }
  .toolbar {
    padding: 4px 8px;
    gap: 4px;
  }
  .btn {
    padding: 4px 8px;
    font-size: 10px;
  }
}