/* Shared editor windows (js/ui/editorwindow.js): Assembler and BASIC
   editor. Uses the page's colour variables from style.css so it matches the
   rest of the UI. */

.ed-window {
  --ed-bg: #16161f;
  --ed-gutter: #1b1b26;
  --ed-mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  position: fixed;
  z-index: 100;
  display: flex;
  flex-direction: column;
  min-width: 420px;
  min-height: 300px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  color: var(--fg);
}

.ed-window[hidden] { display: none; }

.ed-window.minimized {
  height: auto !important;
  min-height: 0;
}
.ed-window.minimized > :not(.ed-titlebar) { display: none; }

.ed-titlebar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 12px;
  background: linear-gradient(#303044, #2a2a3a);
  border-bottom: 1px solid var(--border);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.ed-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-spacer { flex: 1; }

.ed-winbtn {
  width: 26px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.ed-winbtn:hover { background: rgba(255, 255, 255, 0.1); }
.ed-popbtn { display: inline-flex; align-items: center; justify-content: center; }
.ed-popbtn:not(.ed-docked) { color: var(--accent); }

/* Popped out (floatingwindow.js popOut): the window fills a browser window
   of its own, which the OS moves and resizes. */
body.ed-popout { min-height: 0; overflow: hidden; }
.ed-window.ed-popped {
  position: static;
  flex: 1;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.ed-popped .ed-titlebar { cursor: default; }
.ed-popped .ed-resize,
.ed-popped .ed-minbtn { display: none; }
.ed-winbtn:last-child:hover { background: var(--danger); color: #fff; }

/* Tabs */
.ed-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 8px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}

.ed-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
  padding: 5px 6px 5px 12px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-size: 12px;
  color: rgba(232, 232, 240, 0.65);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.ed-tab:hover { background: rgba(255, 255, 255, 0.05); color: var(--fg); }
.ed-tab.active {
  background: var(--ed-bg);
  border-color: var(--border);
  color: var(--fg);
  margin-bottom: -1px;
  padding-bottom: 6px;
}
.ed-tab-name { overflow: hidden; text-overflow: ellipsis; }
.ed-tab-dot { display: none; color: var(--accent); font-size: 9px; }
.ed-tab.dirty .ed-tab-dot { display: inline; }
.ed-tab-close {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 14px;
  opacity: 0.5;
}
.ed-tab-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.ed-tab.dirty:not(:hover) .ed-tab-close { display: none; }

.ed-tab-new {
  align-self: center;
  margin-left: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  cursor: pointer;
  opacity: 0.7;
}
.ed-tab-new:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }

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

.ed-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--border);
}

.ed-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  font-size: 12px;
  cursor: pointer;
}
.ed-btn:hover { background: rgba(255, 255, 255, 0.1); }
.ed-btn.ed-primary { border-color: rgba(108, 200, 255, 0.45); color: var(--accent); }
.ed-btn.ed-primary:hover { background: rgba(108, 200, 255, 0.12); }

/* Editor */
.ed-editor-host {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--ed-bg);
}

.ed-fallback {
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  outline: none;
  padding: 6px 10px;
  background: var(--ed-bg);
  color: var(--fg);
  font: 13px/1.5 var(--ed-mono);
  tab-size: 8;
}

.ed-window .CodeMirror {
  height: 100%;
  font: 13px/1.5 var(--ed-mono);
}

/* CodeMirror theme */
.cm-s-cpc-dark.CodeMirror { background: var(--ed-bg); color: #d8d8e4; }
.cm-s-cpc-dark .CodeMirror-gutters { background: var(--ed-gutter); border-right: 1px solid #2c2c3c; }
.cm-s-cpc-dark .CodeMirror-linenumber { color: #5c5c74; padding: 0 8px 0 4px; }
.cm-s-cpc-dark .CodeMirror-cursor { border-left: 2px solid var(--accent); }
.cm-s-cpc-dark div.CodeMirror-selected { background: #33405a; }
.cm-s-cpc-dark.CodeMirror-focused div.CodeMirror-selected { background: #2f4a6e; }
.cm-s-cpc-dark .CodeMirror-line::selection,
.cm-s-cpc-dark .CodeMirror-line > span::selection,
.cm-s-cpc-dark .CodeMirror-line > span > span::selection { background: #2f4a6e; }
.cm-s-cpc-dark .CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.035); }
.cm-s-cpc-dark .CodeMirror-activeline .CodeMirror-linenumber { color: #a0a0bc; }
.cm-s-cpc-dark .CodeMirror-matchingbracket { color: #fff !important; background: rgba(108, 200, 255, 0.25); }
.cm-s-cpc-dark span.cm-comment { color: #6a7390; font-style: italic; }
.cm-s-cpc-dark span.cm-keyword { color: #6cc8ff; font-weight: 600; }
.cm-s-cpc-dark span.cm-builtin { color: #c792ea; }
.cm-s-cpc-dark span.cm-variable-2 { color: #ffcb6b; }
.cm-s-cpc-dark span.cm-atom { color: #f78c6c; }
.cm-s-cpc-dark span.cm-number { color: #f78c6c; }
.cm-s-cpc-dark span.cm-string { color: #c3e88d; }
.cm-s-cpc-dark span.cm-def { color: #82e0aa; font-weight: 600; }
.cm-s-cpc-dark span.cm-variable { color: #d8d8e4; }
.cm-s-cpc-dark span.cm-operator { color: #89ddff; }

.ed-error-gutter { width: 14px; }
.ed-error-marker {
  color: var(--danger);
  font-size: 10px;
  line-height: 19.5px;
  text-align: center;
  cursor: help;
}
.cm-s-cpc-dark .ed-error-line { background: rgba(255, 107, 107, 0.14); }

/* Assembler: NOPs per line, and the selection's total in the toolbar */
.ed-nops-gutter { width: 3.4em; }
.ed-nops {
  padding-right: 6px;
  color: #8a8aa8;
  font-size: 11px;
  line-height: 19.5px;
  text-align: right;
  white-space: nowrap;
  cursor: help;
}
.ed-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
}
.ed-nops-sum { margin-left: 6px; font-size: 12px; color: var(--accent); white-space: nowrap; }

.ed-window .CodeMirror-dialog {
  background: var(--bg-panel);
  color: var(--fg);
  border-color: var(--border);
}
.ed-window .CodeMirror-dialog input { color: var(--fg); font-family: var(--ed-mono); }

/* Output panel */
.ed-output {
  flex: 0 0 auto;
  max-height: 30%;
  min-height: 44px;
  overflow-y: auto;
  padding: 6px 10px;
  background: #121219;
  border-top: 1px solid var(--border);
  font: 12px/1.6 var(--ed-mono);
}
.ed-out { white-space: pre-wrap; word-break: break-word; }
.ed-out-ok { color: #82e0aa; }
.ed-out-info { color: rgba(232, 232, 240, 0.7); }
.ed-out-warn { color: #ffcb6b; }
.ed-out-error { color: #ff8a8a; }
.ed-out-link { cursor: pointer; }
.ed-out-link:hover { text-decoration: underline; }
.ed-out-action { margin-left: 8px; padding: 1px 8px; font: 11px var(--ed-mono); }

/* Progress bar shown while BASIC is being typed in */
.ed-progress {
  height: 3px;
  margin-top: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.ed-progress > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* Resize grip (bottom-right) */
.ed-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  touch-action: none;
  z-index: 5;
  background:
    linear-gradient(135deg, transparent 55%, rgba(232, 232, 240, 0.35) 55%, rgba(232, 232, 240, 0.35) 62%, transparent 62%,
      transparent 72%, rgba(232, 232, 240, 0.35) 72%, rgba(232, 232, 240, 0.35) 79%, transparent 79%);
}

/* In-window prompt (Save to disk) */
.ed-prompt {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 16, 0.55);
}
.ed-prompt[hidden] { display: none; }
.ed-prompt-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, 90%);
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.ed-prompt-msg { font-size: 13px; }
.ed-prompt-input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font: 14px var(--ed-mono);
  text-transform: uppercase;
}
.ed-prompt-input:focus { outline: none; border-color: var(--accent); }
.ed-prompt-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* Printer window (js/ui/printerwindow.js) */
.pr-switch { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }
.pr-info { font-size: 11px; color: rgba(232, 232, 240, 0.55); }
.pr-scroll { flex: 1; min-height: 0; overflow: auto; background: #f4f1e6; }
.pr-paper {
  margin: 0;
  padding: 12px 16px;
  color: #222;
  font: 13px/1.45 var(--ed-mono);
  white-space: pre-wrap;
  word-break: break-all;
}
.pr-paper.pr-empty { color: #777; font-style: italic; white-space: normal; }

/* Disk Files window (js/ui/diskfileswindow.js) */
.df-drive {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font-size: 12px;
}
.df-scroll { flex: 1; min-height: 0; overflow: auto; }
.df-table { width: 100%; border-collapse: collapse; font: 12px/1.5 var(--ed-mono); }
.df-table[hidden] { display: none; }
.df-table th {
  position: sticky;
  top: 0;
  padding: 4px 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font: 600 11px system-ui, sans-serif;
  text-align: left;
  white-space: nowrap;
}
.df-table td { padding: 2px 8px; white-space: nowrap; border-bottom: 1px solid rgba(232, 232, 240, 0.06); }
.df-table tbody tr { cursor: default; user-select: none; }
.df-table tbody tr:hover { background: rgba(232, 232, 240, 0.05); }
.df-table tbody tr.df-selected { background: rgba(90, 140, 255, 0.22); }
.df-table .df-num { text-align: right; }
.df-table .df-check { width: 1%; text-align: center; }
.df-table .df-editable { cursor: text; }
.df-table .df-editable:hover { text-decoration: underline dotted rgba(232, 232, 240, 0.5); }
.df-cell-input {
  width: 6.5em; margin: -1px 0; padding: 0 3px; font: inherit; color: inherit; text-align: inherit;
  background: var(--bg); border: 1px solid var(--accent); border-radius: 3px;
}
.df-cell-input:focus { outline: none; }
select.df-cell-input { width: auto; text-align: left; }
.df-name { font-weight: 600; }
.df-message { padding: 24px 16px; color: rgba(232, 232, 240, 0.6); font-size: 13px; text-align: center; }
.df-message[hidden] { display: none; }
.df-status {
  min-height: 1.6em;
  padding: 3px 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: rgba(232, 232, 240, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.df-status.df-error { color: #ff8a80; }
.ed-window.df-drop .df-scroll { outline: 2px dashed var(--accent); outline-offset: -4px; }
.df-note { font-size: 12px; color: rgba(232, 232, 240, 0.7); }
.df-modes { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.df-radio { display: inline-flex; align-items: center; gap: 2px; cursor: pointer; }
.df-addr { display: flex; gap: 14px; font-size: 13px; }
.df-addr[hidden] { display: none; }
.df-addr label { display: inline-flex; align-items: center; gap: 6px; }
.df-hex { width: 7em; }
.df-form-error { font-size: 12px; color: #ff8a80; }
.df-form-error:empty { display: none; }

/* Sector Editor window (js/ui/sectorwindow.js); the hex rows look like the
   debugger's memory pane */
.se-label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.se-label[hidden], .ed-window select[hidden], .se-rows[hidden] { display: none; }
.se-num { width: 4.5em; padding: 3px 6px; font-size: 12px; }
.se-nav { padding: 3px 6px; font-size: 10px; }
.se-sector { font-family: var(--ed-mono); }
.se-infobar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.se-infotext { min-width: 0; font: 11.5px/1.5 var(--ed-mono); }
.se-infobar > .ed-btn, .se-infobar > select { flex: none; white-space: nowrap; }
.se-info { color: rgba(232, 232, 240, 0.85); }
.se-owner { color: #82e0aa; }
.se-scroll { background: rgba(0, 0, 0, 0.12); }
.se-rows { padding: 4px 0; font: 12.5px/18px var(--ed-mono); outline: none; user-select: none; }
.se-row { display: flex; height: 18px; white-space: pre; }
.se-row:hover { background: rgba(255, 255, 255, 0.03); }
.se-off { flex: 0 0 7ch; padding-left: 10px; color: #7f8aa8; }
.se-hex { display: flex; gap: 0.6ch; }
.se-hex .se-b:nth-child(8) { margin-right: 0.8ch; }
.se-b { color: #cfd0e0; cursor: text; border-radius: 2px; }
.se-asc { margin-left: 2ch; color: #8c8ca8; }
.se-c { cursor: text; }
.se-b:hover, .se-c:hover { background: rgba(108, 200, 255, 0.18); }
.se-changed { color: #ff9e64 !important; font-weight: 600; }
.se-cursor { background: rgba(255, 255, 255, 0.12); }
.se-rows:focus .se-active { background: var(--accent); color: #10121a !important; }
.se-rows:focus .se-active.se-nib { background: linear-gradient(90deg, rgba(108, 200, 255, 0.35) 50%, var(--accent) 50%); }
.se-readonly .se-b, .se-readonly .se-c { cursor: default; }
.se-idform { display: flex; flex-wrap: wrap; gap: 8px 12px; }

/* Graphics > Sprite Editor (js/ui/spritewindow.js). */
.sp-body { flex: 1; min-height: 0; display: flex; background: var(--ed-bg); outline: none; }
.sp-main { flex: 1; min-height: 0; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 10px; }
.sp-main[hidden], .sp-notplus[hidden] { display: none; }
.sp-notplus { flex: 1; padding: 32px 16px; text-align: center; font-size: 13px; color: rgba(232, 232, 240, 0.6); }
/* Transparent pixels (pen 0) show as a checkerboard. */
.sp-thumb canvas, .sp-canvas {
  image-rendering: pixelated;
  background: repeating-conic-gradient(#2a2a36 0 25%, #1f1f29 0 50%) 0 0 / 16px 16px;
}
.sp-thumbs { display: grid; grid-template-columns: repeat(4, 44px); grid-auto-rows: 52px; gap: 6px; align-content: start; }
.sp-thumb {
  position: relative; padding: 3px; border: 1px solid var(--border); border-radius: 4px;
  background: #1b1b26; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px;
  color: rgba(232, 232, 240, 0.7); font: 10px var(--ed-mono);
}
.sp-thumb canvas { width: 32px; height: 32px; background-size: 8px 8px; }
.sp-thumb.sp-selected { border-color: var(--accent); color: var(--accent); }
.sp-thumb.sp-hidden canvas { opacity: 0.45; }
.sp-canvas-wrap { min-width: 0; min-height: 0; display: flex; align-items: flex-start; justify-content: center; }
.sp-canvas {
  width: min(100%, 384px); aspect-ratio: 1; height: auto; cursor: crosshair; touch-action: none;
  border: 1px solid var(--border); background-size: 6.25% 6.25%;
}
.sp-side { width: 176px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.sp-heading { color: rgba(232, 232, 240, 0.6); text-transform: uppercase; letter-spacing: 0.05em; font-size: 10px; margin-top: 4px; }
.sp-pens { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sp-pen {
  height: 30px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; font: 11px var(--ed-mono);
  color: #fff; background: repeating-conic-gradient(#2a2a36 0 25%, #1f1f29 0 50%) 0 0 / 10px 10px;
}
.sp-pen.sp-selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.sp-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sp-field input, .sp-field select { width: 84px; }
.sp-bottom { border-top: 1px solid var(--border); border-bottom: none; flex-wrap: wrap; }
.sp-coords { font: 12px var(--ed-mono); color: rgba(232, 232, 240, 0.7); }
.sp-status {
  min-height: 1.6em; padding: 3px 10px; border-top: 1px solid var(--border); font-size: 12px;
  color: rgba(232, 232, 240, 0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ed-btn:disabled { opacity: 0.4; cursor: default; }

/* Graphics > Font Editor (js/ui/fontwindow.js); shares .sp-status/.sp-info. */
.fe-body { flex: 1; min-height: 0; display: flex; background: var(--ed-bg); outline: none; overflow: auto; container-type: inline-size; }
.fe-main {
  flex: 1; display: grid; gap: 12px; padding: 10px; align-content: start;
  grid-template-columns: auto minmax(160px, 256px) minmax(170px, 1fr);
  grid-template-areas: "grid edit side" "preview preview preview";
}
.fe-grid-wrap { grid-area: grid; }
.fe-canvas-wrap { grid-area: edit; }
.fe-side { grid-area: side; display: flex; flex-direction: column; gap: 6px; font-size: 12px; min-width: 0; }
.fe-preview-wrap { grid-area: preview; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fe-grid, .fe-canvas, .fe-preview { image-rendering: pixelated; border: 1px solid var(--border); display: block; }
.fe-grid { width: 320px; height: 320px; cursor: pointer; }
.fe-canvas { width: 100%; aspect-ratio: 1; height: auto; cursor: crosshair; touch-action: none; }
.fe-char { color: rgba(232, 232, 240, 0.8); line-height: 1.4; }
.fe-rows { display: flex; flex-direction: column; gap: 2px; }
.fe-row { display: flex; align-items: center; gap: 8px; }
.fe-bits { font: 12px var(--ed-mono); letter-spacing: 1px; color: rgba(232, 232, 240, 0.75); }
.fe-row input { width: 44px; font: 12px var(--ed-mono); }
.fe-symbol { font: 11px var(--ed-mono); color: rgba(232, 232, 240, 0.7); word-break: break-all; user-select: all; }
.fe-preview-text { font: 12px var(--ed-mono); }
.fe-preview-wrap { overflow-x: auto; }
.fe-preview { height: 32px; align-self: flex-start; }
.fe-bottom { border-top: 1px solid var(--border); border-bottom: none; flex-wrap: wrap; }
/* A narrow window (or a phone): one column. */
@container (max-width: 700px) {
  .fe-main { grid-template-columns: 1fr; grid-template-areas: "grid" "edit" "side" "preview"; }
  .fe-grid { width: min(100%, 320px); height: auto; aspect-ratio: 1; }
  .fe-canvas-wrap { max-width: 256px; }
}

/* Graphics > Screen Converter (js/ui/screenwindow.js); shares .sp-* pieces. */
.sc-body { position: relative; flex: 1; min-height: 0; display: flex; background: var(--ed-bg); outline: none; overflow: auto; container-type: inline-size; }
.sc-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 12px; padding: 10px; align-content: start; }
.sc-centre { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sc-view-wrap { display: flex; justify-content: center; min-width: 0; }
.sc-view { width: 100%; height: auto; max-height: min(52vh, 544px); object-fit: contain; image-rendering: pixelated; display: block; }
.sc-under { display: flex; gap: 10px; align-items: flex-start; }
.sc-thumb { width: 96px; height: 60px; border: 1px solid var(--border); flex: none; }
.sc-pens-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sc-pens { display: grid; grid-template-columns: repeat(8, minmax(30px, 1fr)); gap: 4px; }
.sc-pen {
  height: 28px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; padding: 0;
  display: flex; align-items: flex-end; justify-content: flex-start;
}
.sc-pen span { font: 9px var(--ed-mono); color: #fff; background: rgba(0, 0, 0, 0.55); padding: 0 3px; border-radius: 3px 0 3px 0; }
.sc-pen.sc-locked { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85), inset 0 0 0 3px rgba(0, 0, 0, 0.6); }
.sc-pen.sc-locked span::after { content: ' \2022'; }
.sc-pen.sp-selected, .sc-colour.sp-selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.sc-pen-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.sc-picker { border: 1px solid var(--border); border-radius: 4px; padding: 8px; display: flex; flex-direction: column; gap: 6px; background: #1b1b26; font-size: 12px; }
.sc-picker[hidden] { display: none; }
.sc-picker-head { display: flex; align-items: center; gap: 6px; }
.sc-colours { display: grid; grid-template-columns: repeat(9, minmax(26px, 1fr)); gap: 3px; }
.sc-colour { height: 24px; border: 1px solid var(--border); border-radius: 3px; cursor: pointer; font: 9px var(--ed-mono); color: #fff; text-shadow: 0 0 2px #000; padding: 0; }
.sc-side { display: flex; flex-direction: column; gap: 6px; font-size: 12px; min-width: 0; }
.sc-field { display: grid; grid-template-columns: 74px minmax(0, 1fr) 30px; align-items: center; gap: 6px; }
.sc-field select, .sc-field input[type="text"] { grid-column: 2 / 4; min-width: 0; }
.sc-value { font: 11px var(--ed-mono); color: rgba(232, 232, 240, 0.7); text-align: right; }
.sc-side .ed-btn { align-self: flex-start; }
.sc-dialog { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 2; }
.sc-dialog[hidden] { display: none; }
.sc-dialog-card { background: #1b1b26; border: 1px solid var(--border); border-radius: 6px; padding: 14px; width: min(100%, 380px); display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.sc-dialog-card p { margin: 0; line-height: 1.45; }
.sc-dialog-title { font-weight: 600; }
.sc-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.sc-check { display: flex; align-items: center; gap: 4px; }
.sc-name { font: 13px var(--ed-mono); text-transform: uppercase; }
.sc-indent { margin-left: 20px; }
.sc-field[hidden], .sc-hint[hidden] { display: none; }
.sc-dialog-card .sc-hint { font-size: 12px; color: rgba(232, 232, 240, 0.7); }
/* A narrow window (or a phone): one column, the settings under the picture. */
@container (max-width: 640px) {
  .sc-main { grid-template-columns: 1fr; }
  .sc-pens { grid-template-columns: repeat(4, minmax(30px, 1fr)); }
  .sc-thumb { display: none; }
}

/* Graphics > Palette Editor (js/ui/palettewindow.js); shares .sp-* pieces. */
.pal-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 220px; gap: 14px; padding: 10px; background: var(--ed-bg); overflow: auto; }
.pal-swatches { display: flex; flex-direction: column; gap: 4px; }
.pal-row { display: grid; grid-template-columns: repeat(8, minmax(28px, 1fr)); gap: 4px; }
.pal-sw {
  height: 32px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; padding: 0;
  display: flex; align-items: flex-end; justify-content: flex-end;
}
.pal-sw span { font: 9px var(--ed-mono); color: #fff; background: rgba(0, 0, 0, 0.55); padding: 0 3px; border-radius: 3px 0 3px 0; }
.pal-sw.sp-selected, .pal-fwc.sp-selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.pal-editor { display: flex; flex-direction: column; gap: 10px; font-size: 12px; }
.pal-head { display: flex; gap: 10px; align-items: center; }
.pal-preview { width: 56px; height: 56px; border: 1px solid var(--border); border-radius: 6px; flex: none; }
.pal-name { font-weight: 600; font-size: 13px; }
.pal-value { color: rgba(232, 232, 240, 0.7); font-family: var(--ed-mono); }
.pal-plus { display: flex; flex-direction: column; gap: 6px; }
.pal-plus[hidden], .pal-fw[hidden] { display: none; }
.pal-slider { display: grid; grid-template-columns: 16px 1fr 18px; align-items: center; gap: 6px; font-family: var(--ed-mono); }
.pal-r input { accent-color: #ff5a5a; }
.pal-g input { accent-color: #4ade80; }
.pal-b input { accent-color: #5a9aff; }
.pal-num { text-align: right; }
.pal-hex { width: 5em; font-family: var(--ed-mono); grid-column: 2 / 4; }
.pal-fw { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
.pal-fwc { height: 22px; border: 1px solid var(--border); border-radius: 3px; cursor: pointer; padding: 0; }

/* Tools > Cartridge Builder (js/ui/cartwindow.js); its dialog is the Screen Converter's .sc-dialog. */
.cb-body { position: relative; flex: 1; min-height: 0; display: flex; background: var(--ed-bg); outline: none; overflow: auto; container-type: inline-size; }
.cb-main { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 10px; min-width: 0; font-size: 12px; }
.cb-panel { display: flex; flex-direction: column; gap: 8px; }
.cb-panel[hidden] { display: none; }
.cb-actions { padding: 0; border: none; background: none; flex-wrap: wrap; }
.cb-list, .cb-banks { display: flex; flex-direction: column; gap: 3px; }
.cb-row, .cb-bank { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; min-width: 0; flex-wrap: wrap; }
.cb-name { font: 12px var(--ed-mono); min-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-kind { color: rgba(232, 232, 240, 0.6); }
.cb-len { color: rgba(232, 232, 240, 0.7); flex: 1; min-width: 0; }
.cb-row-btns { display: flex; gap: 4px; margin-left: auto; }
.cb-small { padding: 1px 7px; font-size: 11px; }
.cb-hex { width: 64px; font: 12px var(--ed-mono); }
.cb-empty, .cb-note { color: rgba(232, 232, 240, 0.65); margin: 0; line-height: 1.45; }
.cb-error { color: #ff8a8a; }
.cb-options { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.cb-opt { display: flex; align-items: center; gap: 6px; }
.cb-bank { padding: 2px 6px; }
.cb-bank-n { font: 11px var(--ed-mono); color: rgba(232, 232, 240, 0.6); width: 18px; }
.cb-bank-what { font: 12px var(--ed-mono); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-dim { color: rgba(232, 232, 240, 0.4); }
.cb-disk-list { width: 100%; font: 12px var(--ed-mono); }
.cb-sys { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cb-autorun-row { flex-wrap: wrap; }
.cb-autorun { flex: 1; min-width: 180px; font: 12px var(--ed-mono); }
.cb-page { font-size: 11px; }

/* Firefox, popped-out windows: the <select> list drawn in the page
   (floatingwindow.js installSelectMenus). */
.ed-selectmenu {
  position: fixed;
  z-index: 1000000;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  color: var(--fg);
}
.ed-selectmenu > div {
  padding: 4px 10px;
  border-radius: 3px;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.ed-selectmenu > div:hover { background: rgba(255, 255, 255, 0.08); }
.ed-selectmenu > .current { color: var(--accent); }
.ed-selectmenu > .disabled { opacity: 0.4; }
