:root {
  --bg: #06080f;
  --panel: rgba(15, 19, 32, 0.75);
  --line: rgba(255, 255, 255, 0.1);
  --ink: #e7ecf5;
  --muted: #8b96ad;
  --accent: #67f5c4;
  --accent-2: #7aa2ff;
  --warn: #ffcc66;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(103, 245, 196, 0.08), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(122, 162, 255, 0.09), transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 14px/1.55 "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

code, pre, .stats b, .regs, .memory, .stack {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.app { max-width: 1320px; margin: 0 auto; padding: 22px 22px 40px; }

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 21px; letter-spacing: 0.1em; text-transform: uppercase; }
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 0.05em; }

.brand__led {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
  transition: background 0.2s, box-shadow 0.2s;
}
.brand__led.paused { background: var(--warn); box-shadow: 0 0 16px var(--warn); }
.brand__led.halted { background: #ff6b6b; box-shadow: 0 0 16px #ff6b6b; }

.stats {
  display: grid;
  grid-auto-flow: column;
  gap: 18px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}
.stats div { display: grid; gap: 1px; text-align: right; }
.stats span { font-size: 10px; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; }
.stats b { font-size: 15px; }

/* ---------------- 布局 ---------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 18px;
  align-items: start;
}

/* ---------------- 屏幕 ---------------- */

.screen {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.25));
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6), 0 18px 40px rgba(0, 0, 0, 0.45);
}

#screen {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  image-rendering: pixelated;
  border-radius: 8px;
  background: #0b0b0b;
}

.screen__scan {
  position: absolute;
  inset: 14px;
  border-radius: 8px;
  pointer-events: none;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.42) 100%);
  mix-blend-mode: screen;
  opacity: 0.75;
}

/* ---------------- 控制区 ---------------- */

.controls { display: grid; gap: 14px; margin-top: 16px; }

.group {
  display: grid;
  gap: 9px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.group__label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

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

button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease;
}
button:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
button:active { transform: translateY(0) scale(0.98); }
button.primary { border-color: rgba(103, 245, 196, 0.45); background: rgba(103, 245, 196, 0.16); }
button.on { border-color: rgba(122, 162, 255, 0.5); background: rgba(122, 162, 255, 0.16); }
button[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.file {
  display: inline-flex;
  align-items: center;
  padding: 9px 13px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.file input { display: none; }
.file:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.3); }

.ctl { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.ctl span { display: flex; justify-content: space-between; }
.ctl b { color: var(--ink); }
.ctl--inline { grid-template-columns: auto 1fr; align-items: center; gap: 8px; color: var(--muted); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: #0b0f18; border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(103, 245, 196, 0.8);
  cursor: pointer;
}

select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0d1220;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------------- 键盘 ---------------- */

.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  max-width: 280px;
}

.key {
  position: relative;
  padding: 9px 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.key small { display: block; font-size: 9px; opacity: 0.6; letter-spacing: 0.08em; }
.key.active {
  color: #04140f;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(103, 245, 196, 0.55);
}

.hint { margin: 0; font-size: 11.5px; line-height: 1.7; color: var(--muted); }
.hint code { color: var(--ink); background: rgba(255, 255, 255, 0.07); padding: 1px 5px; border-radius: 5px; }

/* ---------------- 调试面板 ---------------- */

.debug-col { display: grid; gap: 14px; }

.card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}
.card__head h2 {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.tag {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 10.5px;
  color: var(--muted);
}
.tag.ok { color: var(--accent); border-color: rgba(103, 245, 196, 0.4); }
.tag.warn { color: var(--warn); border-color: rgba(255, 204, 102, 0.4); }
.tag.err { color: #ff8080; border-color: rgba(255, 128, 128, 0.45); }

.instruction {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 13px 14px 6px;
}
.instruction #opcodeHex { font-size: 20px; color: var(--accent); }
.instruction #opcodeText { font-size: 13px; color: var(--ink); }

.disasm {
  margin: 0;
  padding: 4px 14px 14px;
  list-style: none;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}
.disasm li { display: flex; gap: 10px; padding: 2px 0; }
.disasm li b { color: rgba(139, 150, 173, 0.75); font-weight: 400; }
.disasm li.current { color: var(--accent); }
.disasm li.current b { color: rgba(103, 245, 196, 0.6); }

.regs {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 12px 14px;
  font-size: 11.5px;
}
.regs div {
  padding: 4px 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}
.regs div span { display: block; font-size: 9px; color: var(--muted); }
.regs div.changed { background: rgba(103, 245, 196, 0.18); }
.regs div.vf { background: rgba(122, 162, 255, 0.16); }

.regs-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0 14px 13px;
  text-align: center;
  font-size: 12px;
}
.regs-meta div { padding: 6px 0; border-radius: 7px; background: rgba(255, 255, 255, 0.03); }
.regs-meta span { display: block; font-size: 9px; letter-spacing: 0.14em; color: var(--muted); }

.stack {
  margin: 0;
  padding: 12px 14px 4px 34px;
  font-size: 12px;
  color: var(--muted);
  max-height: 132px;
  overflow: auto;
}
.stack li { padding: 1px 0; }
.stack li:first-child { color: var(--accent); }
.stack .empty { list-style: none; margin-left: -20px; }

.memory {
  margin: 0;
  padding: 4px 14px 14px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: pre;
  overflow-x: auto;
}
.memory .addr { color: rgba(139, 150, 173, 0.7); }
.memory .hit { color: var(--accent); }

/* ---------------- 提示条 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  font-size: 12.5px;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .debug-col { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .app { padding: 14px; }
  .stats { gap: 12px; padding: 8px 12px; }
  .stats div:nth-child(4) { display: none; }
  .regs { grid-template-columns: repeat(4, 1fr); }
}
