/* ═══════════════════════════════════════════════════════════════════
   Mr McKenzie — styles for the shared editor and settings panel.

   A real stylesheet rather than CSS injected from JavaScript, because
   the SQL app sends a strict Content-Security-Policy (style-src 'self',
   no 'unsafe-inline'). A <style> element created in script counts as an
   inline style and is dropped silently — the element exists with zero
   rules, the overlay falls back into normal flow, and the code appears
   twice. Served from the same origin, this is allowed as-is, and the
   policy stays strict.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Code editor overlay ───────────────────────────────────────────── */
.ce-wrap {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-self: stretch;
}
.ce-wrap > textarea {
  flex: 1 1 auto;
  min-width: 0;
  align-self: stretch;
  position: relative;
  z-index: 1;
  background: transparent !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent;
  /* The text is transparent, so the caret must be given a real colour of its
     own. Never `auto` here: that means currentColor, i.e. transparent. Each
     site sets --ce-caret to its own ink colour. */
  caret-color: var(--ce-caret, CanvasText);
}
/* Selection has to stay visible even though the text itself is transparent. */
.ce-wrap > textarea::selection {
  background: rgba(120, 170, 255, .35);
  -webkit-text-fill-color: transparent;
}
.ce-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  margin: 0;
  overflow: auto;
  pointer-events: none;
  z-index: 0;
}
.ce-layer code {
  display: block;
  font: inherit;
  color: inherit;
  background: none;
  padding: 0;
  border: 0;
}

/* Token colours. Distinguishable by weight and style as well as hue, so
   they still read for colour-blind pupils. */
.ce-comment { color: var(--ce-comment, #7a8290); font-style: italic; }
.ce-string  { color: var(--ce-string, #1f7a4c); }
.ce-number  { color: var(--ce-number, #b26b08); }
.ce-keyword { color: var(--ce-keyword, #8250c4); font-weight: 700; }
.ce-builtin { color: var(--ce-builtin, #2c5d8a); }
.ce-name    { color: var(--ce-name, inherit); }

/* Occurrence highlight: a box, not just a colour, so the meaning is not
   carried by hue alone. */
.ce-occ {
  background: var(--ce-occ-bg, rgba(255, 196, 0, .28));
  outline: 1px solid var(--ce-occ-line, rgba(180, 120, 0, .55));
  border-radius: 2px;
}

.ce-hint {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  opacity: .75;
}
.ce-hint kbd {
  font: inherit;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 4px;
  opacity: .9;
}

/* ── Settings panel ────────────────────────────────────────────────── */
.ms-btn {
  position: fixed;
  top: .75rem; right: .75rem;
  z-index: 9997;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 17px; line-height: 1;
  background: var(--ms-btn-bg, rgba(127, 127, 127, .14));
  color: var(--ms-btn-fg, currentColor);
  border: 1px solid var(--ms-btn-line, rgba(127, 127, 127, .34));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ms-btn:hover { background: var(--ms-btn-bg-hover, rgba(127, 127, 127, .24)); }

.ms-panel {
  position: fixed;
  top: 3.4rem; right: .75rem;
  z-index: 9997;
  width: 232px;
  padding: 14px;
  border-radius: 12px;
  font: 500 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--ms-panel-bg, #fff);
  color: var(--ms-panel-fg, #14181f);
  border: 1px solid var(--ms-panel-line, rgba(127, 127, 127, .34));
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .5);
}
.ms-panel[hidden] { display: none; }
.ms-panel h3 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .65;
}
.ms-panel h3 + h3 { margin-top: 16px; }
.ms-row { display: flex; gap: 6px; }
.ms-row button {
  flex: 1;
  padding: 7px 4px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  background: transparent;
  color: inherit;
  border: 1px solid var(--ms-panel-line, rgba(127, 127, 127, .34));
}
.ms-row button[aria-pressed="true"] {
  background: var(--ms-sel-bg, rgba(120, 170, 255, .22));
  border-color: var(--ms-sel-line, rgba(120, 170, 255, .75));
  font-weight: 700;
}
.ms-note { margin: 12px 0 0; font-size: 11px; opacity: .6; }

@media print {
  .ms-btn, .ms-panel { display: none !important; }
}
