/* ============================================================
   style_rprt_gray.css — NMMI.AI Report Smart Editor
   Dark mode only · green accent baseline
   ============================================================ */

:root {
    --header-h: 2rem;
    --footer-h: 2rem;
    --pad: 0.75rem;
    --gap: 0.75rem;
    --box-pad: 14px;
    --panel-head-h: 1.2rem;
    --btn-size: 1.5rem;
    --review-w: 16.5rem;
    --tbar-chip-h: 1.3rem;
    --tbar-tool-h: 1.3rem;

    --bg-body: rgb(50, 50, 50);
    --bg-surface: #202020;
    --bg-panel: rgba(20,20,20, 0.4);

    --header-text: var(--green);
    --header-text-shadow: var(--green);
    --input-text: rgba(255, 255, 255, 0.95);
    --output-text: var(--input-text);
    --footer-text-c: rgba(var(--accent-rgb), 0.5);

    --accent: #c8c8c8;
    --accent-dim: rgba(var(--accent-rgb), 0.25);
    --accent-soft: rgba(var(--accent-rgb), 0.5);
    --accent-border: rgba(var(--accent-rgb), 0.1);
    --accent-focus: rgba(var(--accent-rgb), 0.75);
    --accent-glow: rgba(var(--accent-rgb), 0.05);

    --tog-on-track: rgba(var(--accent-rgb), 0.09);
    --tog-on-thumb: rgba(var(--accent-rgb), 0.55);
    --tog-on-border: rgba(var(--accent-rgb), 0.28);
    --tog-on-label: rgba(var(--accent-rgb), 0.50);
    --tog-on-glow: rgba(var(--accent-rgb), 0.20);

    --accent-rgb: 200, 200, 200;
    --muted-rgb: 185, 185, 185;
    --apply-rgb: 140, 140, 140;
    --apply-color: #909090;
    --bg-select-option: #1a1a1a;

    --green: 34, 255, 0;
    --blue: 0, 229, 255;
    --cyan: 0, 255, 255;
    --gray: 20, 20, 20;
    --shadow-colour: rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

body {
  margin: 0; padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-surface);
  font-size: 1rem;
  color: var(--input-text);
  display: flex; flex-direction: column;
  width: 100vw; height: 100vh;
  overflow: hidden;
}

header {
  height: var(--header-h);
  max-height: clamp(1rem, calc(var(--header-h) * 0.8), 3rem);
  flex-shrink: 0;
  padding: 0.5rem;
  background: rgba(0,0,0,0.1);
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}

h1 {
  color: rgba(var(--header-text), 0.1);
  text-shadow: 0 0 6px rgba(var(--header-text), 0.3);
  margin: 1rem; font-weight: 500;
  font-size: clamp(1rem, calc(var(--header-h) * 0.7), 2.8rem);
  transition: color 0.3s, text-shadow 0.35s;
}
h1:hover {
  color: rgba(var(--header-text), 0.3);
  text-shadow: 0 0 7px rgba(var(--header-text), 0.95);
}

main {
  flex: 1 1 0;
  min-height: 0;
  display: flex; flex-direction: column;
  padding: var(--pad); gap: var(--gap);
  overflow: hidden;
}

/* ══ SHARED GRID ══════════════════════════════════════════════ */
.panels-row {
  display: grid;
  grid-template-columns: 1fr 1fr var(--review-w);
  gap: var(--gap);
  flex: 1; min-height: 0; overflow: hidden;
  z-index: 1;
}

/* ── PANELS ─────────────────────────────────────────────────── */
.panel {
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    min-width: 0;
    min-height: 0;
}

.panel-head {
  height: var(--panel-head-h);
  display: flex; align-items: center;
  justify-content: space-between;
  flex-shrink: 0; padding: 0 2px;
  overflow: visible;
}
.panel-label {
  font-size: 1rem; letter-spacing: 2.5px;
  color: rgba(var(--accent-rgb), 0.95); text-transform: uppercase;
}

/* ── TEXTAREAS ──────────────────────────────────────────────── */
textarea {
  flex: 1; padding: var(--box-pad);
  font-family: inherit; font-size: 1rem; line-height: 1.5;
  resize: none; outline: none;
  overflow-y: auto; border-radius: 4px; min-height: 0;
  border: 1px solid var(--accent-border);
  background: rgba(0,0,0,0.35);
  box-shadow: 0px 0px 10px rgba(0,0,0,0.4);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  scrollbar-color: rgba(var(--muted-rgb), 0.10) transparent;
}

textarea.input-box { color: var(--input-text); }
textarea.input-box:focus {
  border-color: var(--accent-glow);
  background: rgba(0,0,0,0.30);
}
textarea.input-box::placeholder { color: rgba(var(--muted-rgb), 0.34); font-style: italic; }

textarea.output-box { color: var(--input-text); }
textarea.output-box:focus {
  border-color: var(--accent-glow);
  background: rgba(0,0,0,0.30);
}
textarea.output-box::placeholder { color: rgba(var(--muted-rgb), 0.34); font-style: italic; }

textarea.flash-highlight {
  box-shadow: 0 0 3px rgba(var(--accent-rgb), 0.40) !important;
  transition: box-shadow 0.1s;
}

/* ══════════════════════════════════════════════════════════════
   MID PANEL — SmartEditor suggestion bar
══════════════════════════════════════════════════════════════ */
.suggestion-bar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem;
  background-color: var(--bg-panel);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  padding: 5px 10px;
  min-height: 2rem;
  transition: border-color 0.25s;
}
.suggestion-bar.lit { border-color: var(--accent-soft); }

.sugg-text {
  font-size: 0.76rem; color: rgba(var(--accent-rgb), 0.38);
  font-style: italic; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sugg-controls {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.kbd {
  display: inline-block;
  padding: 1px 5px; border-radius: 3px;
  font-size: 0.68rem;
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid var(--accent-border);
  color: var(--accent-dim);
  font-family: monospace;
}
.kbd-label { font-size: 0.68rem; color: rgba(var(--accent-rgb), 0.30); }

/* ══════════════════════════════════════════════════════════════
   REVIEW PANEL — tab strip + panes
══════════════════════════════════════════════════════════════ */
.review-panel {
  position: relative;
  display: flex; flex-direction: column;
}
.review-panel::before {
  content: "";
  position: absolute; inset: 0;
  background-image: url('../NMMI.AI Logo.svg');
  background-size: contain; background-position: center;
  background-repeat: no-repeat; opacity: 0.07;
  z-index: 0; pointer-events: none;
}

.sidebar-tabs {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid var(--accent-dim);
  position: relative; z-index: 1;
}
.rv-tab {
  flex: 1;
  background: none; border: none;
  border-bottom: 2px solid transparent;
  padding: 0.32rem 4px;
  font-size: 0.60rem; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent-dim);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}
.rv-tab:hover { color: var(--accent-soft); }
.rv-tab.on    { color: var(--accent-focus); border-bottom-color: var(--accent-focus); }

.rv-pane {
  display: none; flex-direction: column;
  flex: 1; overflow-y: auto;
  position: relative; z-index: 1;
}
.rv-pane.on { display: flex; }

/* ── COMMENTARY PANE ───────────────────────────────────────── */
.commentary-list {
  flex: 1; overflow-y: auto;
  padding: 0.5rem 0.4rem;
  display: flex; flex-direction: column; gap: 0.55rem;
  scrollbar-color: rgba(var(--muted-rgb), 0.10) transparent;
}
.commentary-list::-webkit-scrollbar { width: 1px; }
.commentary-list::-webkit-scrollbar-thumb {
  background: rgba(var(--accent-rgb), 0.16); border-radius: 1px;
}

.review-empty {
  font-size: 0.67rem; font-style: italic;
  color: rgba(var(--accent-rgb), 0.18); text-align: left;
  margin-top: 1.6rem; padding: 0 0.5rem;
}

.c-card {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent-dim);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 0.78rem; line-height: 1.55;
  transition: border-left-color 0.25s;
}
.c-card.streaming { border-left-color: rgba(255,195,50,0.60); }

.c-meta {
  font-size: 0.60rem; letter-spacing: 0.5px;
  color: rgba(var(--accent-rgb), 0.28); margin-bottom: 5px;
  text-transform: uppercase;
}
.c-body { color: rgba(var(--muted-rgb), 0.75); }

/* ── PROPERTIES PANE ───────────────────────────────────────── */
.props-list {
  flex: 1; overflow-y: auto;
  padding: 0.5rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.55rem;
  scrollbar-color: rgba(var(--muted-rgb), 0.10) transparent;
}
.props-list::-webkit-scrollbar { width: 1px; }
.props-list::-webkit-scrollbar-thumb {
  background: rgba(var(--accent-rgb), 0.05); border-radius: 1px;
}

.p-section { margin-bottom: 0.8rem; }
.p-section-title {
  font-size: 0.53rem; letter-spacing: 2px; text-transform: uppercase;
  color: rgba(var(--accent-rgb), 0.24);
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.07);
  padding-bottom: 3px; margin-bottom: 4px;
}
.p-row {
  display: flex; justify-content: flex-start; align-items: center; gap: 0.4rem;
  padding: 4px 4px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.04);
  font-size: 0.74rem;
  overflow: visible;
}
.p-row:last-child { border-bottom: none; }
.p-key {
  color: rgba(var(--muted-rgb), 0.40);
  flex: 1 1 auto; min-width: 0;
}
.p-val {
  flex: 0 1 auto;
  max-width: none;
  white-space: normal;
  text-overflow: clip;
  color: rgba(var(--accent-rgb), 0.52);
  font-size: 0.72rem;
}

.toggle-row { gap: 0.4rem; }
.toggle-row .toggle-item { flex-shrink: 0; gap: 0.35; }

.p-row .toggle-switch {
  position: relative; width: 1.60rem; height: 0.82rem;
  background: rgba(0,0,0,0.35); border: 1px solid var(--accent-border);
  border-radius: 1rem; flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.p-row .toggle-switch::after {
  content: ''; position: absolute; left: 3px; top: 50%;
  transform: translateY(-50%);
  width: 0.50rem; height: 0.50rem;
  background: rgba(var(--accent-rgb), 0.28); border-radius: 50%;
  transition: left 0.2s, background 0.2s;
}
.p-row .toggle-cb { display: none; }
.p-row .toggle-cb:checked + .toggle-switch {
  background: var(--tog-on-track); border-color: var(--tog-on-border);
}
.p-row .toggle-cb:checked + .toggle-switch::after {
  left: calc(100% - 0.62rem);
  background: var(--tog-on-thumb);
  box-shadow: 0 0 4px var(--tog-on-glow);
}

/* ── CONTROLS PANE ─────────────────────────────────────────── */
.controls-list {
  flex: 1; overflow-y: auto;
  padding: 0.6rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.55rem;
  scrollbar-color: rgba(var(--muted-rgb), 0.10) transparent;
}
.controls-list::-webkit-scrollbar { width: 1px; }
.controls-list::-webkit-scrollbar-thumb {
  background: rgba(var(--accent-rgb), 0.05); border-radius: 1px;
}

.ctrl-group { display: flex; flex-direction: column; gap: 5px; }

.ctrl-label {
  font-size: 0.65rem; letter-spacing: 0.3px;
  color: rgba(var(--muted-rgb), 0.36);
}
.ctrl-label strong { color: rgba(var(--accent-rgb), 0.35); font-weight: 600; }

input[type="range"] {
    width: 100%;
    height: 3px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(var(--accent-rgb), 0.12);
    border-radius: 2px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: rgba(var(--accent-rgb), 0.35);
    border: 1px solid rgba(var(--accent-rgb), 0.20);
    cursor: pointer;
    transition: background 0.2s;
}
input[type="range"]::-webkit-slider-thumb:hover {
    background: rgba(var(--accent-rgb), 0.55);
}
input[type="range"]::-moz-range-thumb {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: rgba(var(--accent-rgb), 0.35);
    border: 1px solid rgba(var(--accent-rgb), 0.20);
    cursor: pointer;
}

.ctrl-select {
  width: 100%; padding: 5px 7px;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  color: rgba(var(--accent-rgb), 0.65);
  font-size: 0.72rem;
  cursor: pointer; outline: none;
  transition: border-color 0.2s;
}
.ctrl-select:focus { border-color: var(--accent-soft); }
.ctrl-select option { background: var(--bg-select-option); color: rgba(var(--accent-rgb), 0.80); }

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

.ctrl-btn {
  flex: 1; padding: 5px 8px;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  color: rgba(var(--accent-rgb), 0.50);
  font-size: 0.68rem;
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ctrl-btn:hover {
  background: rgba(var(--accent-rgb), 0.07);
  border-color: var(--accent-soft); color: var(--accent);
}
.ctrl-btn-active {
  border-color: rgba(255,195,50,0.50) !important;
  color: rgba(255,195,50,0.80) !important;
}
.ctrl-btn-danger:hover {
  border-color: rgba(255,75,75,0.55) !important;
  color: rgba(255,75,75,0.85) !important;
}

.ctrl-api-info { margin-top: 0.3rem; }
.ctrl-api-val {
  font-size: 0.60rem;
  color: rgba(var(--accent-rgb), 0.22);
  word-break: break-all;
  font-family: monospace; line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS — shared base
══════════════════════════════════════════════════════════════ */
.tool-btn {
  width: var(--btn-size); height: var(--btn-size);
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  background: rgba(0,0,0,0.28);
  color: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s, background 0.2s;
}
.tool-btn svg {
    width: calc(var(--btn-size) * 0.5);
    height: calc(var(--btn-size) * 0.5);
    pointer-events: none;
}
.tool-btn:hover {
  border-color: var(--accent-soft); color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow); background: rgba(var(--accent-rgb), 0.06);
}
.tool-btn:active   { transform: scale(0.91); }
.tool-btn.active   { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.10); }
.tool-btn:disabled { opacity: 0.27; cursor: not-allowed; transform: none; }

.mic-btn.active { animation: pulse-mic 1.4s ease-in-out infinite; }
@keyframes pulse-mic {
  0%,100% { box-shadow: 0 0 4px rgba(var(--accent-rgb), 0.18); }
  50%     { box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.58); }
}

.reload-btn.spinning svg { animation: spin 0.85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.submit-btn {
  border-color: rgba(var(--accent-rgb), 0.28);
  color:        rgba(var(--accent-rgb), 0.70);
  background:   rgba(var(--accent-rgb), 0.07);
}
.submit-btn:hover {
  background: rgba(var(--accent-rgb), 0.13);
  box-shadow: 0 0 11px rgba(var(--accent-rgb), 0.18);
}

.copy-btn,
.report-btn { width: 1.4rem; height: 1.4rem; }
.copy-btn svg,
.report-btn svg { width: 0.74rem; height: 0.74rem; }

.apply-btn {
  width: calc(var(--btn-size) * 1); height: calc(var(--btn-size) * 1);
  border-color: rgba(var(--apply-rgb), 0.32);
  color:        rgba(var(--apply-rgb), 0.68);
  background:   rgba(var(--apply-rgb), 0.06);
}
.apply-btn:hover {
  border-color: rgba(var(--apply-rgb), 0.60); color: var(--apply-color);
  box-shadow: 0 0 11px rgba(var(--apply-rgb), 0.18);
  background: rgba(var(--apply-rgb), 0.10);
}
.apply-btn.spinning svg { animation: spin 0.85s linear infinite; }

/* ══════════════════════════════════════════════════════════════
   BOTTOM BAR
══════════════════════════════════════════════════════════════ */
.toggles-bar {
  max-height: 3.5rem;
  overflow: hidden;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--gap);
  align-items: center;
  border-top: 1px solid var(--accent-border);
  padding-top: 0.28rem; padding-bottom: 0.1rem;
  z-index: 1;
}
.tbar-left {
  display: flex; flex-direction: column;
  gap: 0.22rem; justify-content: center; min-width: 0;
}
.tbar-right {
  display: flex; align-items: center;
  justify-content: flex-end;
  gap: 0.6rem; min-width: 0;
}

.active-toggles-count {
  font-size: 0.60rem; letter-spacing: 0.3px;
  color: rgba(var(--accent-rgb), 0.32); white-space: nowrap;
}

.attach-preview {
  display: flex; flex-wrap: wrap; gap: 0.25rem;
  min-height: 0; max-height: var(--tbar-chip-h); overflow-y: auto;
}
.attach-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(var(--accent-rgb), 0.05); border: 1px solid var(--accent-border);
  border-radius: 20px; padding: 2px 9px 2px 7px;
  font-size: 0.66rem; color: var(--accent-dim); white-space: nowrap;
}
.chip-remove {
  background: none; border: none; color: rgba(var(--accent-rgb), 0.36);
  cursor: pointer; font-size: 0.88rem; padding: 0; line-height: 1;
  transition: color 0.15s;
}
.chip-remove:hover { color: var(--accent); }

.toolbar {
  display: flex; align-items: center;
  gap: 0.4rem; height: var(--tbar-tool-h);
}

.tool-status {
  font-size: 0.67rem; letter-spacing: 0.3px;
  margin-left: 2px; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-ok        { color: rgba(var(--accent-rgb), 0.68); }
.status-error     { color: rgba(255,75,75,0.90); }
.status-warn      { color: rgba(255,195,50,0.76); }
.status-info      { color: rgba(var(--muted-rgb), 0.38); }
.status-listening { color: var(--accent); font-style: italic; }

/* ── PORTRAIT / RESPONSIVE ─────────────────────────────────── */
@media (orientation: portrait) {
  .panels-row   { grid-template-columns: 1fr; overflow-y: auto; }
  .review-panel { max-height: 18rem; }
  .toggles-bar  { grid-template-columns: 1fr; height: auto; padding-bottom: 0.3rem; max-height: none; }
  .tbar-right   { justify-content: flex-start; }
}

@media (max-width: 768px) {
  .panels-row   { grid-template-columns: 1fr !important; overflow-y: auto; }
  .review-panel { max-height: 18rem; }
  .toggles-bar  { grid-template-columns: 1fr; height: auto; padding-bottom: 0.3rem; max-height: none; }
  .tbar-right   { justify-content: flex-start; }
}

/* ── FOOTER ────────────────────────────────────────────────── */
footer {
  height: var(--footer-h);
  max-height: clamp(0.6rem, calc(var(--header-h) * 0.5), 2.5rem);
  flex-shrink: 0;
  background: rgba(0,0,0,0.1);
  color: rgba(var(--header-text), 0.4);
  text-align: center; letter-spacing: 1px;
  border: 1px solid var(--accent-border);
  box-shadow: 0 -2px 3px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
}
.footer-text {
  margin: 0;
  font-size: clamp(0.2rem, calc(var(--header-h) * 0.35), 0.75rem);
}

/* ============================================================
   COMPONENTS
   ============================================================ */

@layer components {

  /* ── Mid-panel layout guard ────────────────────────────────── */
  .mid-panel #outputBox {
    flex: 1 1 auto;
    min-height: 20rem;
    height: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    outline: none;
    cursor: text;
    padding: 8px 10px;
  }
  .mid-panel #outputBox:empty::before {
    content: attr(data-placeholder);
    opacity: 0.5;
    pointer-events: none;
  }

  /* ── Editor toolbar ────────────────────────────────────────── */
  .editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 4px;
    flex: 0 0 auto;
  }
  .editor-toolbar .et-btn {
    background: transparent;
    color: inherit;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    min-width: 26px;
  }
  .editor-toolbar .et-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); }
  .editor-toolbar .et-btn:active,
  .editor-toolbar .et-btn.active { background: rgba(255,255,255,0.15); }
  .editor-toolbar .et-sep { width: 1px; height: 16px; background: rgba(255,255,255,0.12); margin: 0 4px; }
  #outputBox h2 { font-size: 1.1em; font-weight: 600; margin: 0.4em 0 0.2em; }
  #outputBox ul, #outputBox ol { margin: 0.2em 0; padding-left: 1.5em; }

  /* ── Bottom references list ────────────────────────────────── */
  .ref-list {
    flex: 0 0 auto;
    margin: 8px 0 2px;
    padding: 8px 10px;
    border-top: 1px solid rgba(255,255,255,0.10);
    font-size: 0.78rem;
    line-height: 1.45;
    max-height: 14rem;
    overflow-y: auto;
  }
  .ref-list .ref-list-head {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    opacity: 0.55;
    margin-bottom: 4px;
    text-transform: uppercase;
  }
  .ref-list ol { margin: 0; padding-left: 1.6em; }
  .ref-list li { margin: 0.2em 0; }
  .ref-list .ref-list-title { font-weight: 600; }
  .ref-list .ref-list-meta { opacity: 0.7; font-size: 0.92em; }
  .ref-list a { color: rgba(var(--accent-rgb), 0.85); text-decoration: none; word-break: break-all; }
  .ref-list a:hover { text-decoration: underline; }

  /* ── Review actions row ────────────────────────────────────── */
  .review-actions { display: flex; padding: 6px; border-bottom: 1px solid rgba(255,255,255,0.08); }
  .review-actions .ctrl-btn { font-size: 12px; padding: 4px 10px; }
  .mid-panel #transparencyIndicator,
  .mid-panel #refStrip,
  .mid-panel .suggestion-bar { flex: 0 0 auto; }

  /* ── Transparency indicator ────────────────────────────────── */
  #transparencyIndicator { display: none; margin: 4px 0 2px; padding: 0 2px; }
  .transparency-bar {
    width: 100%; height: 3px; border-radius: 2px;
    background: rgba(var(--green), 0.04);
    overflow: hidden; position: relative;
  }
  .transparency-fill {
    height: 100%;
    background: rgba(var(--green), 0.15);
    border-radius: 2px;
    transition: width 0.6s ease;
  }
  .transparency-label {
    font-size: 0.62rem;
    color: rgba(var(--accent-rgb), 0.22);
    margin-top: 3px;
    letter-spacing: 0.03em;
  }

  /* ── Reference strip ───────────────────────────────────────── */
  #refStrip { display: none; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; padding: 0 2px; align-items: center; }
  .ref-strip-label { font-size: 0.60rem; color: rgba(var(--accent-rgb), 0.25); letter-spacing: 0.04em; margin-right: 2px; }
  .ref-badge {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.60rem; color: rgba(var(--green), 0.75);
    border: 1px solid rgba(var(--green), 0.25); border-radius: 3px;
    padding: 1px 5px; cursor: default;
    background: rgba(var(--green), 0.04);
    transition: border-color 0.15s, background 0.15s; user-select: none;
  }
  .ref-badge:hover { border-color: rgba(var(--green), 0.55); background: rgba(var(--green), 0.10); }
  .ref-badge:hover .ref-popup { display: block; }
  .ref-popup {
    display: none; position: absolute;
    bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.92); border: 1px solid rgba(var(--green), 0.2);
    border-radius: 4px; padding: 6px 10px;
    max-width: 260px; min-width: 160px; width: max-content;
    z-index: 100; font-size: 0.62rem; color: rgba(255,255,255,0.75);
    line-height: 1.45; white-space: normal; pointer-events: none;
  }
  .ref-popup::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: rgba(var(--green), 0.2);
  }
  .ref-popup-title { font-weight: 600; color: rgba(var(--green), 0.9); margin-bottom: 3px; display: block; }
  .ref-popup-meta { color: rgba(255,255,255,0.45); font-size: 0.58rem; }
  .ref-popup-link { color: rgba(var(--green), 0.6); text-decoration: underline; display: block; margin-top: 3px; font-size: 0.58rem; word-break: break-all; }

  /* ── Commentary reference hover spans ─────────────────────── */
  .ref-hover {
    color: rgba(var(--green), 0.75);
    border-bottom: 1px dashed rgba(var(--green), 0.35);
    cursor: default; position: relative; font-size: inherit;
  }
  .ref-hover:hover { color: rgba(var(--green), 1); }
  .ref-hover:hover::after {
    content: attr(data-tip); position: absolute;
    bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.9); border: 1px solid rgba(var(--green), 0.2);
    border-radius: 4px; padding: 6px 10px;
    max-width: 260px; min-width: 140px; width: max-content;
    z-index: 100; font-size: 0.62rem; color: rgba(255,255,255,0.75);
    line-height: 1.45; white-space: normal; pointer-events: none;
  }

  /* ── Header pulse animation ────────────────────────────────── */
  @keyframes nmmiHeaderPulse {
    0%   { color: rgba(var(--header-text), 0.22); text-shadow: 0 0 6px  rgba(var(--header-text), 0.45); }
    50%  { color: rgba(var(--header-text), 0.85); text-shadow: 0 0 22px rgba(var(--header-text), 1.0), 0 0 8px rgba(var(--header-text), 0.9); }
    100% { color: rgba(var(--header-text), 0.22); text-shadow: 0 0 6px  rgba(var(--header-text), 0.45); }
  }
  h1.header-active {
    animation: nmmiHeaderPulse 2.5s ease-in-out infinite !important;
    transition: none !important;
  }

  /* ── Header meta ───────────────────────────────────────────── */
  .header-meta {
    margin-left: auto;
    display: flex; align-items: center;
    gap: 0.75rem; font-size: 0.78rem;
    color: rgba(200,200,200,0.55); letter-spacing: 0.5px;
  }

  /* ── DOM state hooks ───────────────────────────────────────── */
  #refList { display: none; }
  #transparencyFill { width: 70%; }
  .sugg-controls { display: none; }

}

/* ============================================================
   UTILITIES
   ============================================================ */

@layer utilities {

  /* Thin scrollbars */
  * { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent; }
  *::-webkit-scrollbar { width: 6px; height: 6px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
  *::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }
  *::-webkit-scrollbar-corner { background: transparent; }

  /* Toggle switch */
  .p-row .toggle-switch,
  .toggle-switch {
    position: relative; width: 1.60rem; height: 0.82rem;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(var(--accent-rgb),0.12);
    border-radius: 1rem; flex-shrink: 0; cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
  }
  .p-row .toggle-switch::after,
  .toggle-switch::after {
    content: ''; position: absolute; left: 3px; top: 50%;
    transform: translateY(-50%);
    width: 0.50rem; height: 0.50rem;
    background: rgba(var(--accent-rgb),0.28); border-radius: 50%;
    transition: left 0.2s, background 0.2s;
  }
  .toggle-cb:checked + .toggle-switch {
    background: rgba(var(--green),0.09);
    border-color: rgba(var(--green),0.28);
  }
  .toggle-cb:checked + .toggle-switch::after {
    left: calc(100% - 0.62rem);
    background: rgba(var(--green),0.55);
    box-shadow: 0 0 4px rgba(var(--green),0.20);
  }

  /* HITL row */
  .hitl-row-inline { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
  .hitl-label-sm { font-size: 0.55rem; color: rgba(var(--accent-rgb), 0.3); line-height: 1.2; }
  .hitl-cb { display: none; }
  .hitl-cb:checked + .toggle-switch {
    background: rgba(var(--green),0.09);
    border-color: rgba(var(--green),0.28);
  }
  .hitl-cb:checked + .toggle-switch::after {
    left: calc(100% - 0.62rem);
    background: rgba(var(--green),0.55);
    box-shadow: 0 0 4px rgba(var(--green),0.20);
  }

}
