/* C64 Emulator: app-specific styles (shared styles: /assets/css/site.css) */

:root {
  --c64-blue: #40318d;
  --c64-light: #7869c4;
  --stage: #000;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 1.5rem;
  align-items: start;
}
.app-head { grid-column: 1 / -1; max-width: 75ch; }
.app-head h1 { margin: 0 0 0.35rem; font-size: 2rem; color: var(--brand); }
.app-head p { margin: 0; color: var(--ink-soft); }

/* ---------- Screen ---------- */

.monitor {
  position: relative;
  background: var(--stage);
  border-radius: var(--radius);
  padding: clamp(0.4rem, 1.5vw, 1rem);
  line-height: 0;
}
.monitor canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  outline: none;
  cursor: default;
}
.monitor.smooth canvas { image-rendering: auto; }
.monitor canvas:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.monitor.dragging { outline: 3px dashed var(--c64-light); outline-offset: 3px; }

.drop-hint, .click-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  line-height: 1.4;
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  background: rgba(20, 16, 60, 0.6);
  border: 0;
  border-radius: var(--radius);
  pointer-events: none;
}
.click-hint {
  inset: auto 1rem 1rem auto;
  display: block;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  background: rgba(64, 49, 141, 0.92);
  border-radius: 5px;
  pointer-events: auto;
  cursor: pointer;
}

.fs-bar { display: none; }
.monitor:fullscreen {
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 0;
  background: #000;
}
.monitor:fullscreen canvas { width: auto; height: auto; }
.monitor:fullscreen .fs-bar {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.4rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
}
.monitor:fullscreen.show-bar .fs-bar, .monitor:fullscreen .fs-bar:focus-within { opacity: 1; }
.monitor:fullscreen.hide-cursor { cursor: none; }
.btn-icon {
  width: 2.4rem;
  height: 2.4rem;
  font: inherit;
  font-size: 1rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  cursor: pointer;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.26); }

/* ---------- Status and controls ---------- */

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  margin: 0.6rem 0 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.st-right { margin-left: auto; }
.led {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: #4a1d1d;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}
.led.on { background: #ff3b30; box-shadow: 0 0 6px #ff3b30; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 0.5rem 0.9rem;
  color: var(--brand);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--brand); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn[aria-pressed="true"] { color: #fff; background: var(--c64-blue); border-color: var(--c64-blue); }
#btn-open { color: #fff; background: var(--c64-blue); border-color: var(--c64-blue); }
#btn-open:hover { background: #35287a; }

.ckeys { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }
.ckeys button {
  font: 700 0.75rem/1 var(--font);
  letter-spacing: 0.02em;
  padding: 0.5rem 0.6rem;
  color: #e9e6dc;
  background: #4b4540;
  border: 0;
  border-bottom: 3px solid #2d2926;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
}
.ckeys button:active, .ckeys button.down { transform: translateY(2px); border-bottom-width: 1px; }
.ckeys [data-key="RUN_STOP"], .ckeys [data-key="RESTORE"] { background: #6b5f55; }
.ckeys [data-key^="F"] { background: #8a7d6e; }

.error, .notice {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 4px;
}
.error { background: #fdecea; border-left: 4px solid #c62828; color: #7a1c1c; }
.notice { background: #eef1fb; border-left: 4px solid var(--c64-light); color: #2d2766; }

/* ---------- Side panels ---------- */

.side { display: flex; flex-direction: column; gap: 1rem; }
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.1rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.0625rem; color: var(--brand); }
.hint { margin: -0.25rem 0 0.75rem; font-size: 0.875rem; color: var(--ink-soft); }
.panel > .hint:last-child { margin-bottom: 0; }

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem;
  text-align: center;
  border: 2px dashed #b9bccb;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--ink-soft);
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone strong { color: var(--ink); font-size: 1rem; }
.dropzone:hover, .dropzone.dragging { border-color: var(--c64-light); background: #f3f1fd; }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.link-like { color: var(--link); text-decoration: underline; }

.choice { display: flex; align-items: flex-start; gap: 0.45rem; margin: 0.75rem 0 0; font-size: 0.9375rem; cursor: pointer; }
.choice input { margin-top: 0.3rem; }
.choice + .field { margin-top: 0.85rem; }

.slot { margin-top: 0.9rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.slot-head { display: flex; gap: 0.6rem; align-items: baseline; }
.slot-label { flex: none; width: 4.6rem; font-size: 0.875rem; font-weight: 700; }
.slot-name { min-width: 0; overflow-wrap: anywhere; font-size: 0.9375rem; color: var(--ink-soft); }
.slot.filled .slot-name { color: var(--ink); }
.slot-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
.slot-tools select { flex: 1 1 100%; padding: 0.35rem 0.4rem; font: inherit; font-size: 0.875rem; border: 1px solid #c5c8d4; border-radius: 4px; background: #fff; }
.btn-small {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  color: var(--brand);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
.btn-small:hover:not(:disabled) { border-color: var(--brand); }
.btn-small:disabled { opacity: 0.45; cursor: default; }
.tape-bar { height: 4px; margin-top: 0.5rem; background: #ecebf3; border-radius: 2px; overflow: hidden; }
.tape-bar span { display: block; height: 100%; width: 0; background: var(--c64-light); }

.field { margin: 0 0 0.85rem; }
.field > label, .field-label { display: block; margin-bottom: 0.3rem; font-size: 0.875rem; font-weight: 700; }
.field select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.9375rem;
  color: inherit;
  background: #fff;
  border: 1px solid #c5c8d4;
  border-radius: 5px;
}
.rom-status { margin: 0 0 0.45rem; font-size: 0.875rem; color: var(--ink-soft); }
.rom-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* Directory drawn like a C64 screen */
.c64 {
  container-type: inline-size;
  background: var(--c64-blue);
  border: 12px solid var(--c64-light);
  padding: 0.5rem 0;
  max-height: 360px;
  overflow: auto;
  font-family: "Press Start 2P", monospace;
  color: var(--c64-light);
}
.c64-line, .c64-file {
  display: block;
  width: 100%;
  padding: 0.18em 0.5em;
  font: inherit;
  font-size: clamp(7px, 3.6cqi, 10px);
  line-height: 1.4;
  white-space: pre;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
}
.c64-file { cursor: pointer; }
.c64-file:hover { background: rgba(120, 105, 196, 0.25); }
.c64-file:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.c64 .reverse { background: var(--c64-light); color: var(--c64-blue); }

/* Help */
.stage { grid-column: 1; grid-row: 2; }
.side { grid-column: 2; grid-row: 2 / span 2; }
.help { grid-column: 1; grid-row: 3; }
.help p { margin: 0 0 0.75rem; max-width: 80ch; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.3rem 1.5rem; margin: 0 0 1rem; font-size: 0.9375rem; }
.keys div { display: flex; gap: 0.75rem; }
.keys dt { flex: none; width: 9.5rem; font-weight: 700; }
.keys dd { margin: 0; }
.help .small { font-size: 0.875rem; color: var(--ink-soft); margin-bottom: 0; }

/* ---------- Small screens ---------- */

@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .stage, .side, .help { grid-column: 1; grid-row: auto; }
  .app-head h1 { font-size: 1.6rem; }
}

/* ---------- Debugger ---------- */

/* tool panels (debugger, sprites) take the full width below the screen */
.app.debugging .side, .app.spriting .side, .app.charsetting .side, .app.musicking .side { grid-row: 2; }
.debugger, .sprites, .charset, .music { grid-column: 1 / -1; }
.app.debugging .help, .app.spriting .help, .app.charsetting .help, .app.musicking .help { grid-row: auto; }

.debugger, .sprites, .charset, .music {
  --dbg-bg: #1a1640;
  --dbg-pane: #221e52;
  --dbg-line: #37317a;
  --dbg-ink: #dcd7ff;
  --dbg-soft: #9a93d6;
  --dbg-dim: #6d67a9;
  --dbg-sel: #40318d;
  --dbg-pc: #7869c4;
  --dbg-bp: #ff6f61;
  --dbg-chg: #f4e46c;
  --dbg-run: #86dc8f;
  --dbg-link: #a9d8ff;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  background: var(--dbg-bg);
  color: var(--dbg-ink);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 1rem;
  font-size: 0.875rem;
}
.debugger :focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.debugger a { color: var(--dbg-link); text-decoration: none; }
.debugger a:hover { text-decoration: underline; }
.debugger b { font-weight: 600; }

.dbg-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.5rem 1rem; }
.dbg-head h2 { margin: 0; font-size: 1.0625rem; color: #fff; }
.dbg-state { margin: 0; min-width: 0; color: var(--dbg-soft); font-variant-numeric: tabular-nums; }
.dbg-state .cyc { color: var(--dbg-dim); white-space: nowrap; }
.pill { display: inline-block; margin-right: 0.35rem; padding: 0.05rem 0.5rem; border-radius: 999px; font-weight: 700; font-size: 0.8125rem; color: #14122e; }
.pill.run { background: var(--dbg-run); }
.pill.stop { background: var(--dbg-bp); }
.dbg-close { width: 2rem; height: 2rem; font: inherit; color: var(--dbg-soft); background: none; border: 1px solid var(--dbg-line); border-radius: 5px; cursor: pointer; }
.dbg-close:hover { color: #fff; border-color: var(--dbg-soft); }
.dbg-ctl { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.4rem; }

.dbg-btn {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.35rem 0.7rem;
  color: var(--dbg-ink);
  background: var(--dbg-pane);
  border: 1px solid var(--dbg-line);
  border-radius: 5px;
  cursor: pointer;
}
.dbg-btn:hover:not(:disabled) { border-color: var(--dbg-soft); color: #fff; }
.dbg-btn:disabled { opacity: 0.4; cursor: default; }
.dbg-main { min-width: 6.5rem; color: #14122e; background: var(--dbg-bp); border-color: var(--dbg-bp); }
.dbg-main:hover:not(:disabled) { color: #14122e; filter: brightness(1.08); }
.is-stopped .dbg-main { background: var(--dbg-run); border-color: var(--dbg-run); }

.dbg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr) minmax(0, 1fr);
  grid-template-areas: "dis cpu bps" "mem mem tabs" "con con con";
  gap: 0.75rem;
  margin-top: 0.8rem;
}
.dbg-dis { grid-area: dis; }
.dbg-cpu { grid-area: cpu; }
.dbg-bps { grid-area: bps; }
.dbg-mem { grid-area: mem; }
.dbg-tabs { grid-area: tabs; }
.dbg-con { grid-area: con; }

.dbg-pane { min-width: 0; background: var(--dbg-pane); border-radius: 6px; padding: 0.6rem 0.7rem 0.7rem; }
.pane-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin-bottom: 0.5rem; }
.pane-head h3, .dbg-pane h3.sub { margin: 0; font-size: 0.875rem; color: #fff; }
.pane-head h3 { margin-right: auto; }
.dbg-pane h3.sub { margin: 0.8rem 0 0.35rem; }
.pane-note { color: var(--dbg-dim); font-size: 0.8125rem; }
.pane-foot { margin: 0.45rem 0 0; color: var(--dbg-dim); font-size: 0.75rem; }
.dbg-in {
  font: 0.8125rem var(--mono);
  color: var(--dbg-ink);
  background: var(--dbg-bg);
  border: 1px solid var(--dbg-line);
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  min-width: 0;
}
input.dbg-in { width: 7.5rem; }
input.dbg-in::placeholder { color: var(--dbg-dim); }
.scroll-btns { display: inline-flex; gap: 0.2rem; }
.dbg-btn.sb { padding: 0.15rem 0.45rem; font-size: 0.6875rem; }
.dbg-chk { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--dbg-soft); font-size: 0.8125rem; cursor: pointer; }
.soft { color: var(--dbg-dim); }

/* disassembly */
.dis, .mem, .con-out, .stack, .hl, .regs input, .bp-list, .facts dd, .tab-body table { font-family: var(--mono); }
.dis { font-size: 0.8125rem; line-height: 1.5; border-radius: 4px; outline: none; }
.dis:focus-visible { box-shadow: 0 0 0 2px var(--focus); }
.dl { display: grid; grid-template-columns: 1.1rem 3.2rem 6.4rem minmax(7rem, auto) minmax(0, 1fr); align-items: center; gap: 0 0.5rem; padding-right: 0.3rem; border-radius: 3px; cursor: default; white-space: nowrap; }
.dl .ad { color: var(--dbg-soft); }
.dl .by { color: var(--dbg-dim); }
.dl .lb { color: var(--dbg-dim); overflow: hidden; text-overflow: ellipsis; font-size: 0.75rem; }
.dl.ill .in { color: var(--dbg-soft); font-style: italic; }
.dl.sel { background: var(--dbg-sel); }
.dl.pc { background: var(--dbg-pc); color: #fff; }
.dl.pc .ad, .dl.pc .by, .dl.pc .lb, .dl.pc a { color: #fff; }
.gut { width: 0.75rem; height: 0.75rem; margin: 0 auto; padding: 0; border-radius: 50%; border: 1px solid transparent; background: none; cursor: pointer; }
.dl:hover .gut { border-color: var(--dbg-dim); }
.dl.bp .gut { background: var(--dbg-bp); border-color: var(--dbg-bp); box-shadow: 0 0 6px rgba(255, 111, 97, 0.6); }

/* registers and flags */
.regs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.35rem; }
.reg { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.75rem; color: var(--dbg-soft); }
.reg input { width: 100%; font-size: 0.9375rem; text-align: center; padding: 0.2rem 0.1rem; }
.reg input[readonly] { color: var(--dbg-soft); }
.reg input.chg, .flag.chg { color: var(--dbg-chg); border-color: var(--dbg-chg); }
.flags { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.25rem; margin-top: 0.5rem; }
.flag { font: 600 0.8125rem var(--mono); padding: 0.2rem 0; text-align: center; color: var(--dbg-dim); background: var(--dbg-bg); border: 1px solid var(--dbg-line); border-radius: 4px; }
button.flag { cursor: pointer; }
button.flag:disabled { cursor: default; }
.flag[aria-pressed="true"] { color: #14122e; background: var(--dbg-ink); border-color: var(--dbg-ink); }
.flag.fixed { opacity: 0.45; }
.facts { margin: 0.6rem 0 0; display: grid; gap: 0.15rem; }
.facts div { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); gap: 0.5rem; }
.facts dt { color: var(--dbg-dim); }
.facts dd { margin: 0; font-size: 0.8125rem; overflow-wrap: anywhere; }
.stack { list-style: none; margin: 0; padding: 0; font-size: 0.8125rem; }
.stack li { display: grid; grid-template-columns: 3.2rem 1.6rem minmax(0, 1fr); gap: 0.5rem; }
.stack .ad { color: var(--dbg-dim); }
.stack .lb { color: var(--dbg-soft); font-size: 0.75rem; }
.stack .empty, .bp-list .empty { display: block; color: var(--dbg-dim); font-family: var(--font); }

/* breakpoints */
.bp-form { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.bp-form input { flex: 1 1 7rem; }
.bp-err { margin: 0.4rem 0 0; color: var(--dbg-bp); font-size: 0.8125rem; }
.bp-list { list-style: none; margin: 0.6rem 0 0; padding: 0; font-size: 0.8125rem; max-height: 14rem; overflow-y: auto; }
.bp-list li { display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0; border-bottom: 1px solid var(--dbg-line); }
.bp-list li .dbg-chk { color: var(--dbg-ink); margin-right: auto; font-family: var(--mono); }
.bp-list li.off .dbg-chk { color: var(--dbg-dim); text-decoration: line-through; }
.bp-id { color: var(--dbg-bp); }
.hits { color: var(--dbg-chg); font-size: 0.75rem; }
.bp-del { padding: 0.1rem 0.35rem; color: var(--dbg-dim); background: none; border: 0; cursor: pointer; font: inherit; }
.bp-del:hover { color: var(--dbg-bp); }
.stop-on { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; margin: 0.7rem 0 0; padding: 0.45rem 0.6rem 0.5rem; border: 1px solid var(--dbg-line); border-radius: 5px; }
.stop-on legend { padding: 0 0.3rem; color: var(--dbg-dim); font-size: 0.75rem; }

/* memory */
.mem { font-size: 0.8125rem; outline: none; overflow-x: auto; }
.mem:focus-visible { box-shadow: 0 0 0 2px var(--focus); border-radius: 4px; }
.mr { display: flex; align-items: center; gap: 0.75rem; height: 1.3rem; white-space: nowrap; }
.mr .ad { color: var(--dbg-soft); width: 2.6rem; flex: none; }
.mr .hx { display: flex; gap: 0.1rem; flex: none; }
.mr i { font-style: normal; width: 1.45rem; text-align: center; border-radius: 3px; cursor: text; }
.mr i:nth-child(8) { margin-right: 0.45rem; }
.mr i:hover { background: var(--dbg-line); }
.mr i.chg { color: var(--dbg-chg); }
.mr i.sel { background: var(--dbg-sel); color: #fff; box-shadow: inset 0 0 0 1px var(--dbg-soft); }
.mr canvas { width: 256px; height: 16px; flex: none; image-rendering: pixelated; image-rendering: crisp-edges; }

/* tabs: I/O and history */
.tabs { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--dbg-line); }
.tabs button { font: inherit; font-weight: 700; font-size: 0.8125rem; padding: 0.3rem 0.7rem; color: var(--dbg-soft); background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: #fff; border-bottom-color: var(--dbg-pc); }
.tab-body { max-height: 23.5rem; overflow: auto; }
.tab-body h4 { margin: 0.6rem 0 0.25rem; font-size: 0.8125rem; color: #fff; }
.tab-body h4:first-child { margin-top: 0; }
.facts.io { margin: 0; }
.facts.io div { grid-template-columns: 5.6rem minmax(0, 1fr); }
.sw { display: inline-block; width: 0.75rem; height: 0.75rem; margin-right: 0.3rem; vertical-align: -0.1rem; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); }
.spr { width: 100%; margin: 0.35rem 0; border-collapse: collapse; font-size: 0.75rem; }
.spr th { text-align: left; color: var(--dbg-dim); font-weight: 400; font-family: var(--font); }
.spr td, .spr th { padding: 0.1rem 0.3rem 0.1rem 0; }
.hl { display: grid; grid-template-columns: 2.6rem minmax(6.2rem, 1fr) auto 1.9rem 2.2rem; gap: 0.45rem; min-width: 22rem; font-size: 0.75rem; line-height: 1.55; white-space: pre; }
.hl.hh { color: var(--dbg-dim); border-bottom: 1px solid var(--dbg-line); margin-bottom: 0.2rem; }
.hl.hh .in, .hl.hh .ln, .hl.hh .cy, .hl.hh .ad { font-family: var(--font); }
.hl .rg { color: var(--dbg-soft); }
.hl .ln, .hl .cy { text-align: right; color: var(--dbg-dim); }
.hl .intr { color: var(--dbg-bp); font-weight: 600; }

/* monitor console */
.con-out { height: 15rem; overflow-y: auto; padding: 0.4rem 0.5rem; font-size: 0.8125rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--dbg-bg); border-radius: 4px; }
.con-out .cmd { color: #fff; }
.con-out .err { color: var(--dbg-bp); }
.con-out .note { color: var(--dbg-chg); }
.con-line { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; font-family: var(--mono); }
.con-line label { color: var(--dbg-pc); font-weight: 600; white-space: nowrap; }
.con-line input { flex: 1; min-width: 0; font: 0.875rem var(--mono); color: #fff; background: var(--dbg-bg); border: 1px solid var(--dbg-line); border-radius: 4px; padding: 0.35rem 0.5rem; }

/* ---------- Sprite viewer ---------- */

.sprites .dbg-head, .charset .dbg-head, .music .dbg-head { grid-template-columns: auto minmax(0, 1fr) auto; }
.spr-tabs { margin: 0; border-bottom: 0; }
.spr-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0.75rem; margin-top: 0.8rem; align-items: start; }
.spr-main .pane-head h3 { margin-right: auto; }
.spr-gallery { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 6rem; max-height: 30rem; overflow-y: auto; align-content: flex-start; }
.spr-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  width: 7.4rem; padding: 0.5rem 0.3rem 0.4rem;
  font: 0.6875rem/1.35 var(--mono); color: var(--dbg-soft);
  background: var(--dbg-bg); border: 1px solid var(--dbg-line); border-radius: 5px; cursor: pointer;
}
.spr-card:hover { border-color: var(--dbg-soft); }
.spr-card.on { border-color: var(--dbg-chg); box-shadow: 0 0 0 1px var(--dbg-chg); color: var(--dbg-ink); }
.spr-card canvas, .spr-memwrap canvas, .spr-big canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.spr-card canvas {
  width: 72px; height: 63px;
  background: repeating-conic-gradient(#2a2560 0% 25%, #221e52 0% 50%) 0 0 / 12px 12px;
}
.spr-memwrap { overflow-x: auto; }
.spr-memwrap canvas { display: block; width: 100%; min-width: 600px; height: auto; cursor: pointer; border-radius: 4px; }
.spr-big { display: grid; place-items: center; padding: 0.6rem; border-radius: 5px; background: #000; }
.spr-big.bg-checker { background: repeating-conic-gradient(#2a2560 0% 25%, #221e52 0% 50%) 0 0 / 20px 20px; }
.spr-big canvas { display: block; width: 100%; max-width: 240px; height: auto; }
.spr-opts { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; margin-top: 0.5rem; }
.spr-dl { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.spr-msg { margin: 0.4rem 0 0; min-height: 1.2em; color: var(--dbg-chg); font-size: 0.8125rem; }
#spr-tools .dbg-chk select { margin-left: 0.2rem; }

/* the tool panels use display rules that would override [hidden] */
.debugger [hidden], .sprites [hidden], .charset [hidden], .music [hidden] { display: none !important; }

/* ---------- Character set viewer ---------- */

.chr-segs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.55rem; }
.chr-seg {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  padding: 0.3rem 0.6rem; font: 0.75rem/1.3 var(--mono); color: var(--dbg-soft);
  background: var(--dbg-bg); border: 1px solid var(--dbg-line); border-radius: 5px; cursor: pointer;
}
.chr-seg b { color: var(--dbg-ink); font-size: 0.8125rem; }
.chr-seg span { font-family: var(--font); }
.chr-seg[aria-pressed="true"] { border-color: var(--dbg-chg); box-shadow: 0 0 0 1px var(--dbg-chg); }
.chr-wrap { overflow-x: auto; }
.chr-wrap canvas { display: block; width: 100%; max-width: 640px; min-width: 420px; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; cursor: pointer; border-radius: 4px; }
.chr-big-row { display: flex; gap: 0.6rem; align-items: center; }
.chr-big { flex: 0 1 192px; padding: 0.4rem; }
.chr-big canvas { max-width: 192px; image-rendering: pixelated; image-rendering: crisp-edges; }
.chr-bytes { margin: 0; font: 0.75rem/1.55 var(--mono); color: var(--dbg-soft); white-space: pre; }
.chr-dl-label { margin: 0.55rem 0 0.3rem; color: var(--dbg-dim); font-size: 0.75rem; }

/* ---------- Music tools ---------- */

.mus-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 0.75rem; margin-top: 0.8rem; align-items: start; }
.mus-text { margin: 0 0 0.7rem; color: var(--dbg-soft); max-width: 62ch; }
.mus-note { margin: 0.6rem 0 0; min-height: 1.2em; color: var(--dbg-chg); font-size: 0.8125rem; }
.mus-err { margin: 0.6rem 0 0.3rem; color: var(--dbg-bp); }
.rec-row { display: flex; align-items: center; gap: 1rem; }
.rec-btn {
  display: inline-flex; align-items: center; gap: 0.55rem; padding: 0.6rem 1rem;
  font: inherit; font-weight: 700; color: var(--dbg-ink); background: var(--dbg-bg);
  border: 1px solid var(--dbg-line); border-radius: 999px; cursor: pointer;
}
.rec-btn:hover { border-color: var(--dbg-soft); }
.rec-dot { width: 0.9rem; height: 0.9rem; border-radius: 50%; background: var(--dbg-bp); }
.rec-btn.on { color: #14122e; background: var(--dbg-bp); border-color: var(--dbg-bp); }
.rec-btn.on .rec-dot { border-radius: 2px; background: #14122e; animation: rec-blink 1s steps(2) infinite; }
@keyframes rec-blink { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .rec-btn.on .rec-dot { animation: none; } }
.rec-info { display: grid; grid-template-columns: auto auto; gap: 0.2rem 0.8rem; align-items: baseline; flex: 1; }
.rec-time { font: 600 1.6rem/1 var(--mono); color: #fff; font-variant-numeric: tabular-nums; }
.rec-size { color: var(--dbg-dim); font-family: var(--mono); font-size: 0.8125rem; }
.rec-meter { grid-column: 1 / -1; height: 6px; background: var(--dbg-bg); border-radius: 3px; overflow: hidden; }
.rec-meter i { display: block; height: 100%; width: 0; background: var(--dbg-run); transition: width 0.15s; }
.mus-primary { color: #fff; background: var(--dbg-pc); border-color: var(--dbg-pc); }
.mus-primary:hover:not(:disabled) { filter: brightness(1.1); }
.rip-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.rip-bar { flex: 1; min-width: 6rem; height: 6px; background: var(--dbg-bg); border-radius: 3px; overflow: hidden; }
.rip-bar i { display: block; height: 100%; width: 0; background: var(--dbg-pc); }
.rip-out { margin-top: 0.7rem; }
.rip-facts div { grid-template-columns: 7.5rem minmax(0, 1fr); }
.rip-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin: 0.8rem 0; }
.rip-fields label { display: flex; flex-direction: column; gap: 0.2rem; color: var(--dbg-soft); font-size: 0.8125rem; }
.rip-fields input.dbg-in { width: 100%; font-family: var(--font); font-size: 0.875rem; }

@media (max-width: 860px) {
  .mus-grid { grid-template-columns: minmax(0, 1fr); }
  .rip-fields { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1100px) {
  .dbg-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "dis dis" "cpu bps" "mem mem" "tabs tabs" "con con"; }
}
@media (max-width: 980px) {
  .debugger, .sprites, .charset, .music { grid-column: 1; }
  .app.debugging .side, .app.spriting .side, .app.charsetting .side, .app.musicking .side { grid-row: auto; }
}
@media (max-width: 860px) {
  .spr-grid { grid-template-columns: minmax(0, 1fr); }
  .sprites .dbg-head, .charset .dbg-head { grid-template-columns: minmax(0, 1fr) auto; }
  .spr-tabs { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 720px) {
  .dbg-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "dis" "cpu" "bps" "mem" "tabs" "con"; }
  .dl { grid-template-columns: 1.1rem 3.2rem 6.4rem minmax(0, 1fr); }
  .dl .lb { display: none; }
  .mr canvas { width: 128px; height: 8px; }
  .chr-wrap canvas { min-width: 0; }
  .dbg-head { grid-template-columns: minmax(0, 1fr) auto; }
  .dbg-state { grid-column: 1 / -1; grid-row: 2; }
}
