/* Plot45 — Sketch (E2) · the experiment-diagram canvas room.
   Shares site.css tokens + the unified chrome (light header · ink navigate-spine
   · paper work area). The canvas itself is an always-light paper sheet (like the
   graph's plot area) so ink strokes stay visible and exports read the same in
   either theme; only the surrounding chrome follows the theme. */

:root {
  --sk-paper: #fcfcfb;      /* the drawing sheet — light in both themes */
  --sk-grid: rgba(20, 24, 28, 0.05);
  --sk-grid-lg: rgba(20, 24, 28, 0.10);
  --sk-fill: #ffffff;
  --sk-sel: #1f5fd0;        /* selection accent (data-blue, not chrome yellow) */
}

/* ── layout: header (56) + [ink rail][palette][stage][inspector] ───────────── */
/* The rail is 64px — the Workbench rail's width (one building, one grammar). */
.sk-app {
  display: grid;
  grid-template-columns: 64px 216px minmax(0, 1fr) 272px;
  height: calc(100vh - var(--nav-height, 56px));
  min-height: 0;
  background: var(--bg-subtle);
}

/* ink navigate-spine (one building) */
.sk-rail {
  display: flex; flex-direction: column; align-items: stretch;
  background: var(--ink-spine-bg); border-right: 1px solid var(--ink-spine-line);
  padding: 10px 0;
}
.sk-rail__item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 2px; border: none; background: none; cursor: pointer;
  color: var(--ink-spine-text); font: inherit; font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.01em; text-decoration: none; text-align: center;
}
.sk-rail__item:hover { background: var(--ink-spine-hover); color: var(--ink-spine-text-strong); }
/* Active marker: a 3px yellow bar on the outer (left) edge — absolute, like the
   Workbench rail's ::after, so it never offsets the centred label. */
.sk-rail__item.is-active {
  color: var(--ink-spine-text-strong); background: var(--ink-spine-active);
}
.sk-rail__item.is-active::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--ink-spine-marker);
}
.sk-rail__item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.sk-rail__item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ink-spine-marker); }
.sk-rail__sep { height: 1px; margin: 8px 12px; background: var(--ink-spine-line); }

/* palette (paper) */
.sk-palette {
  background: var(--panel); border-right: 1px solid var(--line-strong);
  overflow-y: auto; padding: 12px 12px 28px;
}
.sk-pal__title {
  margin: 16px 2px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.sk-pal__title:first-child { margin-top: 2px; }
.sk-pal__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sk-tile {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 9px 4px 7px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); background: var(--bg); cursor: pointer;
  color: var(--text); font: inherit;
}
.sk-tile:hover { border-color: var(--sk-sel); background: var(--bg-subtle); }
.sk-tile:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.sk-tile__art { width: 100%; height: 40px; display: flex; align-items: center; justify-content: center; color: var(--text); }
.sk-tile__art svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.sk-tile__name { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.15; }

/* stage */
.sk-stagewrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sk-toolbar {
  display: flex; align-items: center; gap: 14px; height: 46px; flex: none;
  padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line-strong);
}
.sk-toolbar__group { display: flex; align-items: center; gap: 4px; }
.sk-toolbar__title { font-size: 12px; font-weight: 650; color: var(--muted); margin-right: auto; }
.sk-tbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 1px solid transparent; border-radius: var(--radius);
  background: none; color: var(--text); cursor: pointer;
  /* site.css's global `button` padding (10px 16px) exceeds the 30px border-box
     and crushes the icon svg to 0 width — icon buttons size by the box alone */
  padding: 0;
}
.sk-tbtn:hover { background: var(--bg-subtle); border-color: var(--line-strong); }
.sk-tbtn:disabled { opacity: 0.35; cursor: default; }
.sk-tbtn:disabled:hover { background: none; border-color: transparent; color: var(--text); }
.sk-tbtn:focus-visible { outline: none; box-shadow: var(--focus); }
.sk-tbtn svg { width: 16px; height: 16px; }
.sk-tbtn--danger:hover { color: var(--danger); border-color: var(--danger); }
.sk-btn {
  font: inherit; font-size: var(--fs-body); font-weight: 600; padding: 6px 12px;
  border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--text); cursor: pointer;
}
.sk-btn:hover { background: var(--bg-subtle); }
.sk-btn--primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.sk-btn--ghost { background: none; }
.sk-btn:focus-visible { outline: none; box-shadow: var(--focus); }

.sk-stage-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 22px;
  display: flex; align-items: flex-start; justify-content: center; }
#skStage {
  width: 100%; max-width: 1280px; height: auto; aspect-ratio: 1280 / 860;
  border: 1px solid var(--line-strong); box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  background: var(--sk-paper); touch-action: none;
}
.sk-obj { cursor: move; }
.sk-hit { cursor: move; }
.sk-selbox { stroke: var(--sk-sel); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; vector-effect: non-scaling-stroke; }
.sk-handle { fill: #fff; stroke: var(--sk-sel); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sk-handle--rot { cursor: grab; }
.sk-handle--nw, .sk-handle--se { cursor: nwse-resize; }
.sk-handle--ne, .sk-handle--sw { cursor: nesw-resize; }
.sk-handle--n, .sk-handle--s { cursor: ns-resize; }
.sk-handle--e, .sk-handle--w { cursor: ew-resize; }
.sk-handle--end { cursor: move; }
.sk-text { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.sk-emptyhint { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 22px; fill: #9aa0a6; pointer-events: none; }

/* inspector (paper) */
.sk-inspector { background: var(--panel); border-left: 1px solid var(--line-strong);
  overflow-y: auto; padding: 14px 14px 28px; }
.sk-inspector__empty { font-size: var(--fs-caption); line-height: 1.55; color: var(--muted); margin: 4px 2px; }
.sk-field { margin-bottom: 14px; }
.sk-field--num { margin-bottom: 0; }
.sk-flabel { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sk-fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.sk-input {
  width: 100%; font: inherit; font-size: var(--fs-body); color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 7px 9px;
}
.sk-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sk-range { width: 100%; accent-color: var(--sk-sel); }
.sk-rangewrap { display: flex; align-items: center; gap: 9px; }
.sk-rangeval {
  flex: none; min-width: 38px; text-align: right;
  font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--muted);
}
.sk-swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.sk-swatch {
  width: 24px; height: 24px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  cursor: pointer; padding: 0;
}
.sk-swatch.is-on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--sk-sel); }
.sk-swatch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

/* read-only (a teacher viewing a student's sketch, E2b) */
.sk-ribbon {
  display: flex; align-items: center; gap: 6px; flex: none;
  padding: 9px 14px; font-size: var(--fs-caption); color: var(--text);
  background: var(--warning-soft); border-bottom: 1px solid var(--warning);
}
.sk-ribbon strong { font-weight: 650; }
.sk-readonly .sk-palette, .sk-readonly .sk-inspector { opacity: 0.55; pointer-events: none; }
.sk-readonly .sk-toolbar .sk-tbtn { opacity: 0.35; pointer-events: none; }
.sk-readonly .sk-obj, .sk-readonly .sk-hit { cursor: default; }

/* narrow: stack the palette/inspector under a scrollable stage (basic reflow) */
@media (max-width: 900px) {
  .sk-app { grid-template-columns: 64px 1fr; grid-auto-rows: auto; height: auto; }
  .sk-palette { grid-column: 1 / -1; grid-row: 2; max-height: 220px; }
  .sk-stagewrap { grid-column: 1 / -1; grid-row: 3; }
  .sk-inspector { grid-column: 1 / -1; grid-row: 4; border-left: none; border-top: 1px solid var(--line-strong); }
  .sk-stage-scroll { min-height: 60vh; }
}

/* tile B: the rail's top = symbol categories; bottom register = File·Save·Apps */
.sk-rail__cats { display: flex; flex-direction: column; }
.sk-rail__spring { flex: 1; }
.sk-rail__catprev svg, .sk-rail__item > svg {
  width: 18px; height: 18px; display: block; margin: 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
}
.sk-rail__item.is-active { color: var(--ink-spine-text-strong); background: var(--ink-spine-active); }
.sk-rail__item.is-active::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--ink-spine-marker);
}
.sk-rail__item[hidden] { display: none; }

/* the lasso marquee (tile E) */
.sk-marquee {
  stroke: var(--sk-sel); stroke-width: 1; stroke-dasharray: 4 3;
  fill: rgba(31, 95, 208, 0.06); vector-effect: non-scaling-stroke;
  pointer-events: none;
}
