/* Board editor (editor.js). Uses the site's colour tokens (style.css) with fallbacks; light/dark aware. */
.ae-dlg {
  --ae-lo: var(--surface-2, #f0efec);
  --ae-hi: var(--accent, #2a78d6);
  --ae-neg: #e8853a; /* orange: negative (blue = high/positive everywhere in the editor) */
  --ae-pos: var(--accent, #2a78d6);
  --ae-warn: #8a5a00;
  --ae-err: #b42318;
  --ae-sel: #f5b301;
  width: min(1040px, calc(100vw - 16px));
  max-width: none;
  max-height: calc(100dvh - 16px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border, rgba(11, 11, 11, 0.12));
  border-radius: 10px;
  background: var(--surface, #fcfcfb);
  color: var(--ink, #0b0b0b);
  font: 15px/1.4 var(--font, system-ui, sans-serif);
  box-sizing: border-box;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ae-dlg { --ae-neg: #f0a060; --ae-warn: #f7c35f; --ae-err: #ff8a80; --ae-sel: #ffd257; }
}
:root[data-theme="dark"] .ae-dlg { --ae-neg: #f0a060; --ae-warn: #f7c35f; --ae-err: #ff8a80; --ae-sel: #ffd257; }
.ae-dlg *, .ae-dlg *::before, .ae-dlg *::after { box-sizing: border-box; }
.ae-dlg::backdrop { background: rgba(0, 0, 0, 0.6); }

.ae-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border, rgba(11, 11, 11, 0.12));
  position: sticky; top: 0; background: var(--surface, #fcfcfb); z-index: 2; }
.ae-title { flex: 1; margin: 0; font-size: 1.05em; font-weight: 650; overflow-wrap: anywhere; }
.ae-body { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 18px; padding: 12px 14px 16px; }
@media (max-width: 780px) { .ae-body { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 10px; } .ae-head { padding: 8px 10px; } }
.ae-left, .ae-right { min-width: 0; }

.ae-btn { font: inherit; font-size: 0.88em; padding: 5px 10px; border: 1px solid var(--border, rgba(11, 11, 11, 0.12)); border-radius: 6px;
  background: var(--surface-2, #f0efec); color: var(--ink, #0b0b0b); cursor: pointer; }
.ae-btn:hover:not(:disabled) { border-color: var(--axis, #c3c2b7); }
.ae-btn:disabled { opacity: 0.45; cursor: default; }
.ae-close { padding: 4px 10px; }
.ae-dlg button:focus-visible, .ae-dlg input:focus-visible, .ae-dlg a:focus-visible { outline: 2px solid var(--focus, #2a78d6); outline-offset: 2px; }

/* palette */
.ae-pal { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.ae-palrow { display: grid; grid-template-columns: repeat(7, minmax(0, 44px)); gap: 4px; }
.ae-tool { aspect-ratio: 1; min-width: 0; padding: 2px; border: 1px solid var(--border, rgba(11, 11, 11, 0.12)); border-radius: 6px;
  background: var(--surface-2, #f0efec); cursor: pointer; touch-action: none; display: flex; align-items: center; justify-content: center; }
.ae-tool img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.ae-tool svg { width: 70%; height: 70%; }
.ae-ico { fill: var(--ink-2, #52514e); }
.ae-tool[aria-pressed="true"] { border: 2px solid var(--ink, #0b0b0b); background: var(--surface, #fcfcfb); box-shadow: inset 0 0 0 2px var(--ae-sel); }

/* board */
.ae-boardwrap { width: 100%; max-width: 440px; }
.ae-board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); width: 100%; aspect-ratio: 1; border-radius: 4px; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; outline-offset: 3px; }
.ae-sq { position: relative; min-width: 0; min-height: 0; }
.ae-sq.ae-l { background: var(--sq-light, #ede0c8); }
.ae-sq.ae-d { background: var(--sq-dark, #b48a64); }
.ae-sq img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.ae-coord { position: absolute; font: 600 clamp(8px, 1.9vw, 11px)/1 var(--font, system-ui, sans-serif); pointer-events: none; }
.ae-l .ae-coord { color: var(--sq-coord-light, #8a6847); }
.ae-d .ae-coord { color: var(--sq-coord-dark, #f4ead9); }
.ae-coord-net { font-style: italic; }
.ae-rank { left: 2px; top: 2px; }
.ae-file { right: 3px; bottom: 2px; }
.ae-kring::after { content: ""; position: absolute; inset: 6%; border: 3px solid #2a78d6; border-radius: 50%; pointer-events: none; }
.ae-held { box-shadow: inset 0 0 0 4px var(--ae-sel); }
.ae-held img { opacity: 0.55; }
.ae-dragsrc img { opacity: 0.25; }
.ae-over { box-shadow: inset 0 0 0 4px var(--focus, #2a78d6); }
.ae-board.ae-focus .ae-cur::before { content: ""; position: absolute; inset: 0; border: 3px dashed var(--ink, #0b0b0b); z-index: 1; pointer-events: none; }
.ae-board:focus { outline: none; }
.ae-board:focus-visible { outline: 2px solid var(--focus, #2a78d6); }
.ae-ghost { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 10; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35)); }

.ae-quick { margin: 6px 0 2px; font: 600 0.88em/1.35 var(--font, system-ui, sans-serif); color: var(--ink, #0b0b0b); font-variant-numeric: tabular-nums; }
.ae-note, .ae-keys { margin: 4px 0 8px; font-size: 0.82em; color: var(--ink-2, #52514e); }
.ae-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.ae-views { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; }
.ae-seg { border: 0; padding: 0; margin: 0; min-width: 0; }
.ae-seg legend { font-size: 0.78em; color: var(--muted, #6f6e69); padding: 0; margin-bottom: 2px; }
.ae-opts { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border, rgba(11, 11, 11, 0.12)); border-radius: 6px; overflow: hidden; }
.ae-opts button { font: inherit; font-size: 0.84em; padding: 4px 9px; border: 0; border-right: 1px solid var(--border, rgba(11, 11, 11, 0.12));
  background: var(--surface, #fcfcfb); color: var(--ink, #0b0b0b); cursor: pointer; }
.ae-opts button:last-child { border-right: 0; }
.ae-opts button[aria-pressed="true"] { background: var(--ink, #0b0b0b); color: var(--surface, #fcfcfb); }
.ae-fenrow { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.ae-fenrow label { font-size: 0.84em; color: var(--muted, #6f6e69); }
.ae-fenin { flex: 1; min-width: 0; font: 0.82em var(--mono, monospace); padding: 5px 6px; border: 1px solid var(--border, rgba(11, 11, 11, 0.12));
  border-radius: 6px; background: var(--bg, #f9f9f7); color: var(--ink, #0b0b0b); }
.ae-status { min-height: 1.2em; font-size: 0.82em; color: var(--ink-2, #52514e); }
.ae-msgs p { margin: 4px 0; font-size: 0.86em; }
.ae-err { color: var(--ae-err); }
.ae-warn { color: var(--ae-warn); }
.ae-quiet { color: var(--muted, #6f6e69); font-size: 0.86em; }
.ae-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* readout */
.ae-h3 { margin: 0 0 8px; font-size: 1em; font-weight: 650; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.ae-link { font-size: 0.85em; font-weight: 400; color: var(--link, #1c5cab); }
.ae-vrow { padding: 8px 10px; margin-bottom: 8px; border: 1px solid var(--border, rgba(11, 11, 11, 0.12)); border-radius: 8px; background: var(--bg, #f9f9f7); }
.ae-vrow.ae-vsel { border-color: var(--axis, #c3c2b7); box-shadow: inset 3px 0 0 var(--accent, #2a78d6); }
.ae-vhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.ae-vlabel { font-size: 0.86em; color: var(--ink-2, #52514e); flex: 1 1 100%; }
.ae-vnum { font-size: 1.5em; font-variant-numeric: tabular-nums; }
.ae-vpct { font-size: 0.9em; }
.ae-vdetail { font-size: 0.8em; color: var(--ink-2, #52514e); margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ae-range { display: block; width: 100%; height: auto; max-height: 56px; margin-top: 4px; }
.ae-rbin { fill: var(--muted, #6f6e69); opacity: 0.45; }
.ae-raxis { fill: var(--axis, #c3c2b7); }
.ae-rmark { fill: var(--muted, #6f6e69); opacity: 0.6; }
.ae-rval { fill: var(--mark-2, #eb6834); }
.ae-rtxt { font: 8px var(--font, system-ui, sans-serif); fill: var(--muted, #6f6e69); }
.ae-idle { padding: 8px 10px; margin-bottom: 8px; border: 1px dashed var(--axis, #c3c2b7); border-radius: 8px; }
.ae-idle p, .ae-pos p { margin: 3px 0; font-size: 0.9em; }
.ae-pos { margin: 6px 0 14px; }

/* heat strips */
.ae-strips .ae-h3 { margin-top: 4px; }
.ae-stripwrap { margin-bottom: 8px; }
.ae-slabel { font-size: 0.78em; color: var(--muted, #6f6e69); margin-bottom: 2px; }
.ae-strip { display: grid; gap: 1px; }
.ae-cell { height: 16px; min-width: 0; padding: 0; border: 0; border-radius: 2px; cursor: pointer; background: var(--ae-lo); }
.ae-cell:hover { outline: 1px solid var(--ink, #0b0b0b); }
.ae-cell.ae-on { outline: 2px solid var(--ink, #0b0b0b); outline-offset: 0; position: relative; z-index: 1; }
.ae-cell:focus-visible { outline: 2px solid var(--focus, #2a78d6); outline-offset: 1px; z-index: 2; position: relative; }
@media (max-width: 480px) { .ae-cell { height: 20px; } .ae-tools .ae-btn { padding: 5px 8px; } }

.ae-evalbox { margin: 10px 0; padding: 8px 10px; border: 1px solid var(--border, rgba(127,127,127,.3)); border-radius: 8px; }
.ae-evalbox p { margin: 0 0 4px; }
.ae-evalbox b { font-variant-numeric: tabular-nums; }

.ae-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.ae-nav button { font: inherit; font-size: 0.85em; padding: 3px 9px; border: 1px solid var(--border, rgba(127,127,127,.35)); border-radius: 6px; background: var(--surface-2, transparent); color: inherit; cursor: pointer; }

.ae-xform { align-items: center; }
.ae-xlabel { font-size: 0.85em; color: var(--ink-2, inherit); margin-right: 2px; }
