/* An office application for a drawing, not a dev tool.
 *
 * THE DRAWING IS THE HERO. Every colour here is chosen to lose against it. The
 * class colours are the estimator's own — they arrive from the project file and
 * run to #00c8ff, #ff8a3d, #e05fa8 — so the interface has to be near-neutral or
 * it competes with the markup it exists to show. That is also why the accent is
 * dark and quiet rather than another bright hue: it has to be a colour no
 * legend swatch will ever be.
 *
 * RADIUS MEANS SOMETHING. Zero on the furniture — bars, panel, the drawing
 * area — because those are structure and run to the edges. Four on things you
 * act on. Six, with a shadow, on things that float above the sheet: a modal, a
 * popover, the read-out over the drawing. It is a signal about elevation, not a
 * decoration applied evenly.
 *
 * TWO FACES, BOTH ALREADY ON THE MACHINE. Nothing here may fetch a font: this
 * frontend has no runtime network dependency and that is deliberate (see the
 * README). Segoe UI carries the interface and every number, with tabular
 * figures so columns of quantities line up. Constantia carries the few real
 * headings — a transitional serif made for reading documents on screen, and
 * what this application produces is a document.
 */

:root {
  /* Surfaces, lightest to the desk. */
  --bg: #ffffff;        /* fields, and anything recessed */
  --panel: #f1f3f5;     /* the chrome: bars, the left panel, the rail */
  --card: #ffffff;      /* controls: buttons, and only buttons */
  --desk: #e4e8eb;      /* behind the drawing, where it shows */
  --line: #d8dde2;

  /* Ink. A blue-slate rather than a tinted black, and darker than a light
   * theme's first instinct: #8996a3 on this panel is 2.5:1, which is a colour
   * for a mock-up and not for a tool somebody reads all day. */
  --ink: #1b2733;      /* ~13:1 on the panel */
  --dim: #47586a;      /* ~7:1  — secondary text and every icon */
  --faint: #6a7a89;    /* ~4.2:1 — the quietest thing allowed to carry words */

  /* Drafting ink: active, selected, primary. Deep and low-chroma on purpose —
   * every legend colour is bright, so this is the one region left. */
  --accent: #1b4965;
  --on-accent: #ffffff;

  --ok: #1c7c54;
  --warn: #a8620a;
  --bad: #b3261e;

  --r: 4px;             /* things you act on */
  --r-float: 6px;       /* things that float above the sheet */
  --shadow: 0 1px 2px rgba(24, 39, 55, 0.06), 0 4px 14px rgba(24, 39, 55, 0.10);
  --shadow-lift: 0 2px 6px rgba(24, 39, 55, 0.10), 0 12px 32px rgba(24, 39, 55, 0.16);

  /* One face for the interface and every number in it. There was a `--mono`
   * here and fifty rules asked for it; tabular figures do the aligning a
   * monospace was there for, so the second family went and the name went with
   * it rather than becoming untrue. */
  --ui: "Segoe UI", "Segoe UI Variable Text", system-ui, -apple-system, sans-serif;
  --doc: Constantia, Cambria, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute only sets `display: none` at the UA level, so any rule
 * of ours that sets `display` beats it. That is how "reading project…" stayed
 * painted across the sheet after loading finished: `.stage-hint` is a flex
 * centring box. Fix it once, here, rather than per component. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--panel);
  color: var(--ink);
  font: 13px/1.45 var(--ui);
  /* A takeoff is a column of quantities. Figures that do not line up are the
   * one typographic failure this interface cannot afford. */
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* The status bar's read-outs: one size smaller than the interface, and figures
 * that hold their column while the cursor moves. Called `.mono` when a
 * monospace was doing that job. */
.readout { font-size: 11.5px; font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.grow { flex: 1; }

kbd {
  font-family: var(--ui);
  font-size: 10px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  padding: 0 3px;
  color: var(--ink);
}

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
  flex-wrap: wrap;
}

/* The one place the serif is a wordmark rather than a heading. */
.brand { font-family: var(--doc); font-size: 16px; letter-spacing: 0.01em; }
.brand .dim { color: var(--faint); }

.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; flex: none; }

.field { display: flex; align-items: center; gap: 6px; }
.field > span {
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--faint);
}
.field input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 12px;
  padding: 5px 7px;
  min-width: 22ch;
}
.field.narrow input { min-width: 6ch; width: 6ch; }
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--dim);
  cursor: pointer;
}
.toggle input { accent-color: var(--accent); margin: 0; }

button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  font: inherit;
  padding: 5px 11px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--dim); background: var(--panel); }
button:disabled { opacity: 0.45; cursor: default; }
/* Filled, and one per context. An outlined primary beside outlined everything
 * else is not a primary — it is a button with a coloured edge. */
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
button.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 86%, #000);
  border-color: color-mix(in srgb, var(--accent) 86%, #000);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- progress ---------- */

.progress {
  position: relative;
  height: 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.progress.idle .progress-fill { border-right-color: transparent; }
.progress-fill {
  height: 100%;
  width: 0;
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  border-right: 1px solid var(--accent);
  transition: width 0.25s linear;
}
.progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding-left: 12px;
  font-family: var(--ui);
  font-size: 11px;
  color: var(--dim);
}

/* ---------- layout ---------- */

main { flex: 1; display: flex; min-height: 0; }

.panel {
  width: 320px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;

  /* A default scrollbar is 15 px of grey down the side of a 320 px panel. */
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.panel::-webkit-scrollbar { width: 7px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
.panel:hover::-webkit-scrollbar-thumb { background: var(--faint); }

/* A section of the panel, not a card. One continuous surface divided by
 * hairlines: a column of separate rounded boxes would read as a dashboard, and
 * this is a list of work with a drawing beside it. */
.card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 {
  margin: 0;
  font-family: var(--doc);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
}
.count { font-family: var(--ui); font-size: 12px; color: var(--accent); }

.card .empty { margin: 0; padding: 10px; color: var(--dim); }
.card .hint {
  margin: 0;
  padding: 7px 10px;
  font-size: 11.5px;
  color: var(--faint);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.card code { font-family: var(--ui); color: var(--ink); }

#doc-info dl, #timings {
  margin: 0;
  padding: 8px 10px;
  display: grid;
  /* `minmax(0, …)` on both: a grid track's default minimum is the content's
   * own minimum width, so one unbroken forty-character filename — which is
   * what an exported sheet is usually called — widens the whole panel and
   * pushes the sidebar out rather than wrapping. */
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 3px 10px;
  font-family: var(--ui);
  font-size: 11.5px;
}
#doc-info dt, #timings dt { color: var(--faint); white-space: nowrap; }
#doc-info dd, #timings dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  /* Break inside a word when there is nowhere else to break. `break-word`
   * would not: it only breaks words that overflow *after* normal wrapping has
   * been tried, and a single word has nothing to try. */
  overflow-wrap: anywhere;
}

#classes { list-style: none; margin: 0; padding: 0; }
#classes li {
  display: grid;
  /* Six columns for six children: swatch, thumbnail, name, count, rename,
   * remove. It was four once, and the remove button fell onto a second row of
   * the implicit grid — which reads as a layout bug rather than a missing
   * column, and is why it was chased in the button's own styles first. Add a
   * child, add a column. */
  grid-template-columns: 14px 34px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  cursor: pointer;
}
#classes li:last-child { border-bottom: none; }
/* The radius arrives with the hover, not before it. Thirty conditions want to
 * read as a list; the corner is the signal that this row is now the thing under
 * your hand. */
#classes li:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: var(--r);
}
#classes li.off { opacity: 0.35; }
#classes li.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: var(--r);
}
#classes li.active .name { color: var(--accent); }
#classes .swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(32, 43, 54, 0.22);
  cursor: pointer;
}
#classes li.off .swatch { background: transparent !important; border-style: dashed; }
#classes .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
#classes .n {
  font-family: var(--ui);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}
#classes li.hit .n { color: var(--ok); }

/* A condition section: the heading that groups Count, Linear and Area, which is
 * how the estimator's other program lays them out. It shares the list with the
 * rows it heads rather than nesting a second <ul>, so one flat list is what
 * scrolls — at the price that `#classes li` stopped meaning "a condition". It
 * means "a row of this list", and a condition is `li.cond`. */
#classes li.group {
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  gap: 7px;
  padding: 7px 10px 6px;
  background: color-mix(in srgb, var(--line) 50%, transparent);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
}
#classes li.group:first-child { border-top: none; }
#classes li.group:hover { background: color-mix(in srgb, var(--line) 75%, transparent); }
/* 11px and `--dim`, not 9px and `--faint`. At the first size the triangle came
 * out as a dot: folded and unfolded looked identical, which is the one thing
 * this glyph is for. Checked on a crop rather than on the whole panel, where
 * twelve pixels of anything looks like twelve pixels of anything else. */
#classes .fold {
  /* Segoe UI draws these small triangles at a size that reads as a dash. */
  font-size: 13px;
  color: var(--dim);
  text-align: center;
  line-height: 1;
}
#classes li.group:hover .fold { color: var(--ink); }
#classes .group-name {
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 600;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#classes .group-total {
  font-family: var(--ui);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
/* The eye is a group's own control, so it gets a hit area of its own rather
 * than inheriting the row's — clicking it must not also fold the section. */
#classes .group-eye {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1;
  color: var(--dim);
  cursor: pointer;
}
#classes .group-eye:hover { color: var(--ink); }
#classes .group-eye:focus-visible { outline: 1px solid var(--accent); }

/* A crop of the class's own template. Names in these projects run to fifty
 * characters of Latin binomial, so the picture is what actually identifies a
 * row.
 *
 * No frame. On a dark panel the white crop needed an edge to stop it glowing;
 * on a light one the edge is thirty boxes down a column, and the crop is
 * already white against a grey panel. */
.thumb {
  border-radius: 3px;
  width: 34px;
  height: 26px;
  background: #fff;
  border: 1px solid transparent;
  object-fit: contain;
  image-rendering: auto;
  display: block;
}
/* Except the one that has nothing to show, where the frame *is* the message. */
.thumb.missing {
  background: transparent;
  border: 1px dashed var(--line);
}

#templates { list-style: none; margin: 0; padding: 0; }
#templates li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  cursor: pointer;
}
#templates li:last-child { border-bottom: none; }
#templates li:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
#templates li.excluded { opacity: 0.42; }
#templates li.excluded .t-name { text-decoration: line-through; }
#templates li.selected { background: color-mix(in srgb, var(--accent) 18%, transparent); }
#templates .t-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
#templates .t-meta {
  display: block;
  font-family: var(--ui);
  font-size: 10px;
  color: var(--faint);
}
#templates .t-drop {
  background: none;
  border: 1px solid transparent;
  color: var(--faint);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
}
#templates li:hover .t-drop { color: var(--bad); border-color: var(--line); }

.drop-hint {
  position: absolute;
  inset: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, rgba(7, 9, 11, 0.72));
  color: var(--accent);
  font-family: var(--ui);
  font-size: 15px;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* ---------- the library ---------- */

/* The bar's project button. Wider than a command because it carries a name,
 * and truncating is right: the tail of "Combined ASMEP_L_Part1-9e482d" is not
 * what tells two drawings apart. */
.project-open {
  font-family: var(--ui);
  font-size: 11.5px;
  max-width: 26ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  color: var(--ink);
}
.project-open:hover { border-color: var(--accent); color: var(--accent); }

.lib-filter {
  border-radius: var(--r);
  flex: 1;
  min-width: 0;
  max-width: 28ch;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 11.5px;
  padding: 3px 7px;
}
.lib-filter:focus-visible { outline: none; border-color: var(--accent); }

.lib-list {
  padding: 4px 0;
  overflow-y: auto;
}

/* One row per drawing: the picture, what it is, and what is in it. A grid and
 * not a flex row, so the names line up down the sheet however wide the badges
 * turn out to be. */
/* A file list, and it has to read as one. Nine identical bordered boxes in a
 * column is a dashboard of cards — it was what this looked like, and on a light
 * ground it was unmistakable. Transparent rows on one surface, divided by
 * hairlines, and the corner and the ground arrive together when the row becomes
 * the thing under your hand. */
.lib-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  text-align: left;
  cursor: pointer;
}
.lib-row:last-child { border-bottom: none; }
/* Row and its remove, side by side. The row keeps the whole width it had and
 * the × sits over its right edge, so the list does not reflow when one appears
 * and a stray click on the way down the list opens a drawing rather than
 * deleting one. */
.lib-item { position: relative; }
.lib-del,
.lib-rename {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  font-size: 15px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--faint);
  opacity: 0;
  cursor: pointer;
}
/* The rename sits inboard of the remove, so the destructive one stays at the
 * edge where it was and the hand does not learn a new place for it. */
.lib-rename { right: 32px; font-size: 13px; }

/* Shown on hover and on keyboard focus. Always-visible on nine rows is nine
 * invitations to delete something while looking for something to open. */
.lib-item:hover .lib-del,
.lib-item:hover .lib-rename,
.lib-del:focus-visible,
.lib-rename:focus-visible { opacity: 1; }
.lib-del:hover { color: var(--bad); border-color: var(--bad); }
.lib-rename:hover { color: var(--ink); border-color: var(--line); }
.lib-del:disabled { opacity: 0.4; }
.lib-row:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: var(--r);
}
/* The one that is open is marked on its edge rather than boxed: an outline
 * round one row of nine puts a rectangle back into a list. */
.lib-row.on {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: var(--r);
  box-shadow: inset 2px 0 0 var(--accent);
}
.lib-row.on .lib-name { color: var(--accent); }

.lib-thumb {
  border-radius: 3px;
  width: 68px;
  height: 48px;
  background: #fff;
  border: 1px solid var(--line);
  object-fit: contain;
  display: block;
}

.lib-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-name {
  color: var(--ink);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-meta, .lib-work {
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The work in it, in the colour the counts use everywhere else. This is the
 * line somebody is actually reading. */
.lib-work { color: var(--ok); }

.lib-kind {
  font-family: var(--ui);
  font-size: 9.5px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  color: var(--faint);
}
.lib-kind.project { border-color: var(--accent); color: var(--accent); }

.lib-empty { margin: 18px 10px; color: var(--dim); }

/* ---------- the help sheet ---------- */

/* One sheet of paper over the app, and a modal on purpose — the only one here.
 * Everything else in this interface refuses to be a modal because the drawing
 * behind it is the thing you are deciding about. This is the opposite: nobody
 * reads the shortcut for "add a corner" while adding one, and covering the sheet
 * is what lets the answer be laid out wide enough to scan. */
.help {
  position: fixed;
  inset: 0;
  /* Above the drop hint at 5 and below the toast at 10: a message about what
   * just happened still has to reach someone who is reading the manual. */
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(32, 43, 54, 0.28);
}

.help-sheet {
  border-radius: var(--r-float);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  width: min(980px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.help-head h2 {
  margin: 0;
  font-family: var(--doc);
  font-size: 17px;
  font-weight: 400;
  color: var(--ink);
}
.help-head button {
  font-family: var(--ui);
  font-size: 10.5px;
  padding: 3px 10px;
}

/* Sections flow into as many columns as fit, and are never split across one:
 * a group of rows read as a group, and half of "fixing one you already drew" at
 * the foot of a column is worse than a shorter column. */
.help-body {
  padding: 14px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 4px 26px;
  align-items: start;
}
.help-body section { break-inside: avoid; margin-bottom: 14px; }
.help-body h3 {
  margin: 0 0 8px;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.help-body dl {
  margin: 0;
  display: grid;
  /* The chips column is as wide as its widest row and no wider, so the sentences
   * all start at the same place and the eye runs down one edge. */
  grid-template-columns: max-content 1fr;
  gap: 5px 10px;
  align-items: baseline;
}
.help-body dt { white-space: nowrap; }
.help-body dt kbd + kbd { margin-left: 3px; }
.help-body dd { margin: 0; color: var(--dim); }

.help-note {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 12px;
  border-left: 1px solid var(--line);
  padding-left: 8px;
}

/* Round, so it does not read as one more command in a row of commands. */
.help-open {
  font-family: var(--ui);
  font-weight: 600;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  color: var(--dim);
}
.help-open:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- tool rail ---------- */

/* A dock of its own between the panel and the sheet, rather than a strip inside
 * either. The tools outlived three homes in the top bar and the Classes card,
 * and both of those are lists of *nouns* — a document, a page, a class. A tool
 * is a verb and it now has somewhere that only holds verbs.
 *
 * Vertical, because the top bar is already full and horizontal space is what the
 * drawing wants; 66 px of width buys a permanent, labelled home for six tools. */
.toolrail {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 7px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  scrollbar-width: none;
}
.toolrail::-webkit-scrollbar { width: 0; }

.tool {
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 52px;
  padding: 6px 0 5px;
  /* Not the button chrome: six bordered boxes stacked in a 66 px column read as
   * a fence, and the armed one has to be the thing that stands out. */
  background: transparent;
  border: 1px solid transparent;
  color: var(--dim);
}
.tool svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool > span {
  font-family: var(--ui);
  font-size: 8.5px;
  line-height: 1;
}
.tool:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line);
  background: var(--card);
}
.tool:disabled { opacity: 0.32; }
/* `button.armed` is a border and a tint, which is enough on a bar button and not
 * enough here — at this size the border is most of the control. The icon and the
 * word carry it instead.
 *
 * The hover case is spelled out because it has to outrank `.tool:hover`, which
 * is one pseudo-class heavier than a lone `.tool.armed`. Without it the tool you
 * just pressed goes grey while the cursor is still sitting on it — you press a
 * tool and it reports that nothing happened. */
.tool.armed,
.tool.armed:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, #fff);
}
.tool-sep {
  height: 1px;
  flex: none;
  background: var(--line);
  margin: 5px 6px;
}

/* ---------- viewer ---------- */

.viewer { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--desk);
  /* The sharp buffer fills itself white to the window's edges — see the fill in
   * `renderWindow` — so this shows only in the gaps. The frame is what makes
   * the drawing read as a surface: an inset hairline rather than a shadow
   * around a sheet, because the canvas is the size of the window and not of the
   * sheet, and rebuilding the renderer for a decoration is not a trade worth
   * making. */
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: grab;
  outline: none;
  touch-action: none;
}
.stage.panning { cursor: grabbing; }
.stage.picking { cursor: pointer; }
/* After `picking`, and deliberately: a corner handle sitting over a detection
 * box is a handle first — the detection is still one click away, and the handle
 * is five pixels wide. */
.stage.editing { cursor: move; }
.stage:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.stage > canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  image-rendering: auto;
}
.stage > canvas#page-back { visibility: hidden; }

/* Explicit stacking, all of it. Giving only the canvases a z-index lifted them
 * above every later sibling with `z-index: auto` — the box overlay, the HUD and
 * the snap panel all went behind the sheet, and Playwright reported the canvas
 * "intercepts pointer events" on a button click. Layers are numbered here so
 * that cannot happen again by omission. */
.stage > canvas#page-backdrop { z-index: 1; }   /* soft whole-sheet underlay */
.stage > canvas#page,
.stage > canvas#page-back      { z-index: 2; }  /* the sharp buffer */
.stage > svg#overlay           { z-index: 3; }  /* boxes */
.stage > .stage-hint,
.stage > .hud,
.stage > .snap-panel,
.stage > .minimap,
.stage > .scalebar             { z-index: 4; }  /* controls */
/* Over all of it: the review grid replaces the drawing rather than sitting on
 * it. Under the modals at 8 and the toast at 10, which still have to reach
 * somebody who is looking at crops. */
.stage > .review               { z-index: 6; }

.stage > svg#overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}
.stage-hint {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-family: var(--ui);
}

/* ---------- the review grid ---------- */

/* Every detection of one class, where the drawing usually is. Not a modal: it
 * is the main area doing a different job, so it fills the stage and has no
 * shadow and no corner — the same reasoning that keeps the panel square. */
.review {
  position: absolute;
  inset: 0;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.review-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.review-head h2 {
  margin: 0;
  font-family: var(--doc);
  font-size: 17px;
  font-weight: 400;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.review-meta { color: var(--dim); font-size: 12px; white-space: nowrap; }

.review-control {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
}
.review-control input { width: 110px; }
.review-control output { min-width: 3ch; color: var(--ink); }

/* Reflows to the width it is given, which is the point of putting it here: a
 * class with two hundred detections in a side panel is a letterbox. */
.review-grid {
  --tile: 128px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
  /* The row height is stated, not derived. The tile used to carry
   * `aspect-ratio: 1` and let the row follow, but with flexible columns the
   * browser will not size an automatic row from a ratio — it sizes the row from
   * the tile's *content*, which here is the score label. One row of tiles looked
   * right; a class of 206 got thirty 16 px rows with 146 px tiles overlapping
   * down them, and the grid read as a stack of sliced strips. */
  grid-auto-rows: var(--tile);
  gap: 10px;
  align-content: start;
}

/* Sized by its cell — the column for width, `grid-auto-rows` for height. It
 * keeps no aspect-ratio of its own: that is what collapsed the rows. */
.review-tile {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  cursor: pointer;
  overflow: hidden;
}
.review-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.review-tile:hover { border-color: var(--dim); }
.review-tile.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.review-tile.broken { background: var(--desk); }

/* The score, on the crop. It is the number that decides whether a match is
 * worth a second look, so it belongs on the picture and not in a tooltip. */
.review-score {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 1px 5px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border-top-right-radius: var(--r);
}

.review-empty { margin: 24px 14px; color: var(--dim); max-width: 60ch; }

/* ---------- HUD, minimap, scale bar ---------- */

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  max-width: 46ch;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 7px 10px;
  font-family: var(--ui);
  font-size: 11.5px;
  line-height: 1.55;
  pointer-events: none;
}
.hud { pointer-events: auto; }
.hud-actions {
  display: flex;
  gap: 6px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}
.hud-actions button { padding: 3px 9px; font-size: 12px; }
#hud-delete { border-color: var(--bad); color: var(--bad); }

.hud .hud-name {
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud .hud-meta { color: var(--dim); }
.hud .hud-how {
  margin-top: 5px;
  color: var(--faint);
  font-family: var(--ui);
  font-size: 10.5px;
}

/* ---------- template mode ---------- */

.pill {
  font-family: var(--ui);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border: 1px solid var(--line);
  color: var(--dim);
  white-space: nowrap;
}
.pill.warm { border-color: var(--ok); color: var(--ok); }
.pill.loading { border-color: var(--warn); color: var(--warn); }
.pill.cold { border-color: var(--line); color: var(--faint); }
.pill.failed { border-color: var(--bad); color: var(--bad); }
.pill.cold-cache { border-color: var(--warn); color: var(--warn); }

/* Armed is the accent, everywhere. It used to be green, which said "good"
 * where the claim is "this is what the next click does". */
button.armed {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, #fff);
}

.stage.template { cursor: crosshair; }

.pager { display: flex; align-items: center; gap: 2px; }
.pager button {
  font-family: var(--ui);
  min-width: 26px;
  padding: 4px 6px;
  font-size: 15px;
  line-height: 1;
}
.page-label {
  font-family: var(--ui);
  font-size: 11.5px;
  min-width: 6ch;
  text-align: center;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.snap-preview-wrap {
  background: #fff;
  border: 1px solid var(--line);
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#snap-preview { width: 100%; height: 100%; display: block; }

.snap-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20rem;
  background: color-mix(in srgb, var(--card) 96%, transparent);
  border: 1px solid var(--ok);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}
.snap-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--ui);
  font-size: 11.5px;
}
.snap-head strong { color: var(--ok); font-weight: 600; }
.snap-row { display: grid; grid-template-columns: 4.5rem 1fr; align-items: center; gap: 8px; }
.snap-row > span {
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--faint);
}
.snap-row select, .snap-row input {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  min-width: 0;
}
/* The ranked classes. Laid out on the same 4.5rem label column as the rows
 * below, so "looks like" and "goes to" line up and read as one decision. */
.snap-suggest { display: grid; grid-template-columns: 4.5rem 1fr; gap: 8px; }
.snap-suggest-label {
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--faint);
  padding-top: 4px;
}
.snap-suggest-row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.suggest {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  text-align: left;
  cursor: pointer;
}
.suggest:hover { border-color: var(--ok); }
/* The picked one carries the same green the panel's own border does: the chip
 * and the dropdown are one control, so agreeing with it must be visible. */
.suggest.chosen { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--bg)); }
.suggest-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-score {
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
/* Below what a run would accept. Still shown — three weak rows say "nothing
 * here looks like it", and an empty row says the ranking never arrived. */
.suggest.weak { opacity: 0.55; }
.suggest.weak:hover { opacity: 1; }

.snap-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.snap-note {
  margin: 0;
  font-family: var(--ui);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--faint);
}

.minimap {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  line-height: 0;
  cursor: crosshair;
  box-shadow: var(--shadow);
}
.minimap canvas { display: block; background: #fff; }
.minimap-view {
  position: absolute;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  pointer-events: none;
}

.scalebar {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--dim);
  pointer-events: none;
  user-select: none;
}
.scalebar-line {
  border-left: 1px solid currentColor;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  height: 6px;
  position: relative;
}
.scalebar-line span {
  position: absolute;
  left: 0;
  bottom: 8px;
  white-space: nowrap;
}

/* ---------- status bar ---------- */

.statusbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  min-height: 30px;
}
select#doc-list {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 11.5px;
  padding: 5px 6px;
  max-width: 16ch;
}

.zoom { display: flex; align-items: center; gap: 2px; }
.zoom button { font-family: var(--ui); min-width: 30px; padding: 3px 7px; }
.zoom-level {
  font-family: var(--ui);
  font-size: 11.5px;
  min-width: 6ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 70ch;
  background: var(--card);
  border: 1px solid var(--bad);
  color: var(--ink);
  padding: 9px 14px;
  font-family: var(--ui);
  font-size: 12px;
  z-index: 10;
}
.toast.ok { border-color: var(--ok); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}


/* The geometry row in the document panel.

   It replaced a `geometry: NOT CACHED · minutes` definition line. That line was
   accurate and useless: it named a cost without saying what the cost buys or
   how to pay it, and geometry is no longer started automatically, so there has
   to be something to press. */
.geom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.geom-label { color: var(--dim); line-height: 1.45; }
.geom-row.ok .geom-label { color: var(--ok, #7ee081); }
.geom-row.busy .geom-label { color: var(--accent, #00c8ff); }
.geom-build {
  flex: none;
  padding: 3px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.geom-build:disabled { opacity: 0.5; cursor: default; }

/* The page field. It replaced a static `7/13` label: stepping is right for the
   next sheet and useless for the thirteenth, which was twelve clicks away. */
.page-input {
  width: 3.2em;
  text-align: center;
  font-family: var(--ui);
  font-size: 12px;
  padding: 2px 4px;
}
.page-input:disabled { opacity: 0.6; }
.page-count {
  font-family: var(--ui);
  font-size: 12px;
  color: var(--dim);
  margin-left: 2px;
}

/* Remove / restore a class, in its row. Sits at the end so it never displaces
   the name, and only shows on hover: a destructive control that is always
   visible invites the accident it enables. */
.class-act {
  flex: none;
  margin-left: 6px;
  padding: 0 5px;
  border: none;
  background: none;
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}
#classes li:hover .class-act,
#classes li.gone .class-act { opacity: 1; }
.class-act:hover { color: var(--ink, #e6edf3); }
.class-act:focus-visible { opacity: 1; outline: 1px solid var(--accent); }
#classes li.gone { opacity: 0.45; }
#classes li.gone .name { text-decoration: line-through; }

/* The legend proposal: a strip under the Classes heading, shown only while
 * there is something to accept. Deliberately not a modal — the boxes it is
 * describing are on the drawing behind it, and the whole point is to look at
 * them before agreeing. */
.legend-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--ok, #3fb950) 12%, transparent);
  font-family: var(--ui);
  font-size: 11.5px;
}
.legend-bar span { flex: 1; min-width: 0; }
.legend-bar button { padding: 3px 10px; font-size: 11px; }

/* The legend bar is the one that grew. One slider fits on a row in a sidebar
 * this narrow; three do not — laid out as a row they pushed the count into a
 * three-line column and cut the last slider off the edge. So this one stacks:
 * the count and the buttons on their own lines, each slider a labelled row
 * underneath, which is also the order they are used in. */
#legend-bar {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 6px;
}
#legend-bar > span { flex: none; }
#legend-bar .legend-split {
  display: grid;
  grid-template-columns: 3.6rem 1fr;
  align-items: center;
  gap: 6px;
}
#legend-bar .legend-split input { width: 100%; min-width: 0; }
/* The two buttons share the last row rather than taking one each. */
#legend-bar .legend-actions { display: flex; gap: 6px; flex: none; }
#legend-bar .legend-split select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  padding: 2px 4px;
  min-width: 0;
  width: 100%;
}

.legend-split { display: flex; align-items: center; gap: 5px; }
.legend-split > span {
  font-size: 10px;
  color: var(--faint);
}
.legend-split input { width: 90px; }
/* The totals switch: two states, always both visible, so which one you are
 * looking at needs no memory. */
.totals {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  font-family: var(--ui);
  font-size: 11px;
}
.scope {
  border-radius: var(--r);
  padding: 2px 8px;
  font-size: 10.5px;
  color: var(--dim);
}
.scope.on {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.scope-total {
  margin-left: auto;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.chip { border-radius: var(--r); }

/* The count mode: two buttons in the status bar, the same switch shape as the
 * totals below the class list. */
.count-mode { display: flex; gap: 3px; }

/* The count-box mode. Same shape as the scale chip beside it — a read-out that
 * is the control — and the same green for "armed" the rail uses, because it is
 * the same claim: this is what the next thing you do will do. */
.chip.count-chip {
  font-family: var(--ui);
  font-size: 10.5px;
  border-color: var(--line);
  color: var(--dim);
}
.chip.count-chip:hover { color: var(--ink); border-color: var(--faint); }
.chip.count-chip.armed {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, #fff);
}

/* The scale chip: a read-out that is also the way to correct it.
 *
 * Amber when the sheet states no scale — the one state that stops measurement
 * working at all, so it is the one state that asks for attention. Calm when it
 * was read from the sheet, since that is the ordinary case and it needs no more
 * than to be legible. Accented when a person set it by hand, because a value
 * that disagrees with what is printed should look different from one that does
 * not. */
.chip.scale-chip {
  font-family: var(--ui);
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  white-space: nowrap;
}
.chip.scale-chip:hover { color: var(--ink); border-color: var(--dim); }
.chip.scale-chip.unset { border-color: var(--warn); color: var(--warn); }
.chip.scale-chip.manual { border-color: var(--accent); color: var(--accent); }
.chip.scale-chip.armed {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, #fff);
}

/* A condition that is drawn rather than detected. The slot that holds a symbol
 * crop for a counted class holds a glyph for these, so the two kinds are
 * distinguishable in a list of thirty without reading a word. */
.thumb.kind {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 13px;
  line-height: 1;
}
/* An area condition's fill, in the slot a count uses for its symbol crop. The
 * swatch fills the slot: at 34x26 a bordered picture inside a bordered button
 * is two frames around 24 pixels of hatch. */
.thumb.kind.area.fill {
  padding: 0;
  background: var(--bg);
  overflow: hidden;
  cursor: pointer;
}
.thumb.kind.area.fill svg { width: 100%; height: 100%; display: block; }
.thumb.kind.area.fill:hover { border-color: var(--accent); }
.thumb.kind.area.fill:focus-visible { outline: 1px solid var(--accent); }

/* The fill picker. Fixed, because it is anchored to a row in a list that
 * scrolls and it must not scroll away from the swatch that opened it. */
.fill-picker {
  border-radius: var(--r-float);
  position: fixed;
  z-index: 9;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  box-shadow: var(--shadow-lift);
}
.fill-option {
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 7px 3px 3px;
  background: none;
  border: 1px solid transparent;
  color: var(--dim);
  font-family: var(--ui);
  font-size: 10.5px;
  white-space: nowrap;
  cursor: pointer;
}
.fill-option svg { flex: none; display: block; background: var(--bg); }
.fill-option:hover { color: var(--ink); background: var(--panel); border-color: var(--line); }
.fill-option.on { color: var(--ok); border-color: var(--ok); }

#classes li.drawing { border-left: 2px solid var(--ok); }
#classes li.drawing .name { color: var(--ok); }

/* The + that adds a condition. Pushed to the right so the heading keeps the
 * left edge, and sized down: adding a condition is a real act but not the one
 * this card is mostly for. */
.head-add {
  font-family: var(--ui);
  font-size: 13px;
  line-height: 1;
  padding: 1px 8px 3px;
  margin-left: auto;
  margin-right: 8px;
  color: var(--dim);
}
.head-add:hover { color: var(--accent); border-color: var(--accent); }

/* The kind toggle gets a row of its own. Alongside the field it left about
 * fifty pixels for the name, so typing "Decomposed granite" showed "anite" —
 * the panel is 310 px wide and five controls do not fit across it. `!important`
 * because `.legend-bar span { flex: 1 }` is right for the legend summary and
 * wrong for two buttons. */
#condition-bar { flex-wrap: wrap; row-gap: 6px; }
.cond-kind {
  flex: 1 0 100% !important;
  display: flex;
  gap: 3px;
}

#condition-name {
  border-radius: var(--r);
  flex: 1 1 12ch;
  min-width: 10ch;
  font-family: var(--ui);
  font-size: 12px;
  padding: 4px 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
}
#condition-name:focus { outline: none; border-color: var(--accent); }

/* The sheet rail. Two columns per row — the picture and the two facts about it —
 * because at 40 px the numbers must not be under the thumbnail where they would
 * be read as part of it. */
.sheets {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheets li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border: 1px solid transparent;
  cursor: pointer;
}
.sheets li:hover { background: var(--card); }
.sheets li.here { border-color: var(--accent); background: var(--card); }
.sheets li.done .sheet-no { color: var(--ok); }
.sheet-thumb {
  /* Fixed box, letterboxed picture. A set mixes a portrait cover sheet with
   * landscape plans, and rows that changed height with the orientation made the
   * column of numbers beside them jump about. */
  width: 46px;
  height: 32px;
  flex: none;
  object-fit: contain;
  object-position: center;
  background: var(--bg);
  border: 1px solid var(--line);
  /* White paper on a dark panel is a row of small lamps. Dimmed to sit in the
   * list rather than shout from it, and lit for the two rows anybody is
   * actually looking at. */
  opacity: 0.62;
  transition: opacity 140ms ease-out;
}
.sheets li:hover .sheet-thumb,
.sheets li.here .sheet-thumb { opacity: 1; }
.sheet-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sheet-no { font-family: var(--ui); font-size: 12px; color: var(--ink); }
.sheet-work { font-family: var(--ui); font-size: 10.5px; color: var(--dim); }

/* The name the drawing gives itself. Clipped rather than wrapped: the useful
 * half of `Thomas_Hardscape Details-L1.51` is the front of it, and a row that
 * grows to two lines when one sheet has a long name makes the column of
 * thumbnails beside it jump — the same reason the pictures are letterboxed. */
.sheet-name {
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheets li.here .sheet-name { color: var(--ink); }

/* The star. Quiet until it is on, because most rows are not kept and a column
 * of lit stars says nothing. */
.sheet-star {
  flex: none;
  border: none;
  background: none;
  padding: 2px 4px;
  font-size: 13px;
  line-height: 1;
  color: var(--faint);
  cursor: pointer;
}
.sheets li:hover .sheet-star { color: var(--dim); }
.sheet-star.on, .sheets li:hover .sheet-star.on { color: var(--accent); }

/* An empty view explains itself rather than showing nothing. */
.sheets-empty {
  display: block;
  padding: 8px 6px;
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--faint);
  cursor: default;
}
.sheets-empty:hover { background: none; }

/* A template belonging to another sheet of the same set. Dimmed, because it is
 * not on the drawing in front of you; listed, because a run here uses it and a
 * count with no visible reason is worse than a row that explains itself. */
.templates li.elsewhere { opacity: 0.66; }
.templates li.elsewhere .t-meta { color: var(--accent); }

/* The row that is only in a filtered rail because you are standing on it. It
 * has to be visible — the pager and the list must agree about where you are —
 * and it must not read as a member, or the filter looks wrong. */
.sheets li.passing { opacity: 0.55; }
.sheets li.passing .sheet-no::after {
  content: ' · not in this view';
  color: var(--faint);
  font-size: 9.5px;
}

/* The three views sit under the rail's own head, in the switch shape the
 * totals under the class list already use. */
.sheet-views { margin: 0 0 6px; }


/* ------------------------------------------------------------- accounts -- */

/* The two chips in the bar. Same weight as `help`, because who you are is a
 * standing fact and not an action the drawing is waiting on. */
.chip-btn { font-family: var(--ui); font-size: 11px; }

/* The door. Opaque, and over everything: with accounts on there is nothing
 * behind it worth seeing, and a login that lets the empty app show through
 * reads as a page that failed to load. */
.signin {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.signin-sheet {
  width: min(22rem, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.signin-sheet h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.signin-row { display: grid; grid-template-columns: 5rem 1fr; align-items: center; gap: 8px; }
.signin-row > span { font-family: var(--ui); font-size: 10.5px; color: var(--faint); }
.signin-row input {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  padding: 5px 6px;
  min-width: 0;
}
.signin-error:empty { display: none; }
.signin-error {
  margin: 0;
  font-family: var(--ui);
  font-size: 10.5px;
  color: var(--bad);
  line-height: 1.45;
}

/* Whose drawing this is. One line in the library row, under the counts. */
.lib-owner { font-family: var(--ui); font-size: 10px; color: var(--faint); }

.owner-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.owner-row > span { font-family: var(--ui); font-size: 10.5px; color: var(--faint); }
.owner-row select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 11.5px;
  padding: 3px 5px;
  min-width: 0;
}

.admin-body { display: flex; flex-direction: column; gap: 20px; padding: 4px 2px 2px; }
.admin-section h3 { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; }
.admin-new { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.admin-new input, .admin-new select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  min-width: 0;
}
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
/* A disabled account stays on the list and stops looking live. Removing it
 * would make "disabled" and "deleted" the same thing on screen, and they are
 * very much not: one is reversible. */
.admin-list li.off { opacity: 0.5; }
.admin-name { font-weight: 600; min-width: 8rem; }
.admin-badge {
  font-family: var(--ui);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ok);
  border: 1px solid var(--ok);
  border-radius: 2px;
  padding: 0 3px;
}
.admin-groups { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.admin-groups label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--ui);
  font-size: 11px;
  color: var(--faint);
}
.admin-list button.danger { color: var(--bad); }


/* A class name being corrected. Sized to the row it replaces so the list does
 * not jump when one of thirty goes into edit. */
.name-edit {
  width: 100%;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--ok);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  padding: 1px 3px;
}



/* The rename, shown on hover and on keyboard focus. Always visible on thirty
 * rows is thirty invitations to edit a name while looking for a count; hidden
 * entirely is what it was, and a tooltip is the same as not existing. */
.class-act.rename { opacity: 0; font-size: 11px; }
#classes li:hover .class-act.rename,
.class-act.rename:focus-visible { opacity: 1; }
.class-act.rename:hover { color: var(--ink); }
