/* experimental letters — "Pastilla ácida".
   Warm paper #f3f2ee, ink #111, one acid accent #e4ff4f (pink #ff48b0
   only in the credits and for cutting). Everything is a pill: chips on a
   translucent ink background, black when active; outlined pills for
   secondary actions; Courier Prime for numbers, codes and small labels. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #f3f2ee;          /* page */
  --surface: #ffffff;     /* cards, fields */
  --fg: #111111;          /* ink */
  --muted: #67645e;       /* ≥ 4.5:1 on paper, white, chips and acid */
  --line: #d9d6cf;
  --chip: rgba(17, 17, 17, 0.07);
  --chip-hover: rgba(17, 17, 17, 0.12);
  --acid: #e4ff4f;
  --acid-soft: #f6ffc4;
  --pink: #ff48b0;
  --pink-ink: #c8177f;    /* pink dark enough for text */
  --ok: #40994d;
  --sans: "Familjen Grotesk", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: "Courier Prime", ui-monospace, "SF Mono", Menlo, monospace;
  --shadow: 0 1px 2px rgba(17, 17, 17, 0.04), 0 10px 30px rgba(17, 17, 17, 0.06);
  --gutter: 24px;
  --test-h: 233px;        /* test bar with its margin; see .app */
}
body:has(#testbar.collapsed) { --test-h: 82px; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--mono); }

/* Small uppercase labels: "ESTADO", "MINÚSCULAS", "TODA LA FUENTE". */
.label, .zone-left h2 {
  display: block;
  font-family: var(--mono); font-weight: 400; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}

/* ---------- Buttons ---------- */
button {
  font: inherit;
  font-weight: 500;
  color: var(--fg);
  background: var(--chip);
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
button:hover:not(:disabled) { background: var(--chip-hover); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}
button:disabled { opacity: 0.35; cursor: default; }
button.primary { background: var(--fg); color: #fff; padding: 0 16px 0 12px; }
button.primary:hover:not(:disabled) { background: #2b2b2b; }
dialog button.primary { padding: 0 18px; }
/* Outlined pill: secondary actions. */
button.ghost { background: transparent; border-color: var(--fg); font-weight: 400; min-height: 34px; padding: 0 13px; }
button.ghost:hover:not(:disabled) { background: var(--chip); }
button.ghost.active { background: var(--fg); color: #fff; }
button.danger { color: var(--pink-ink); border-color: currentColor; }
button.small { min-height: 28px; padding: 0 11px; font-size: 12.5px; }
button.wide { width: 100%; }
button.square { width: 32px; min-height: 32px; padding: 0; }
button.link {
  background: none; border: 0; border-radius: 0; min-height: 0; padding: 0;
  font-weight: 400; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}
button.link:hover:not(:disabled) { background: none; color: var(--pink-ink); }
.icon-btn { width: 36px; height: 36px; min-height: 0; padding: 0; flex: none; }
.icon-btn img { display: block; }
.icon-btn.active { background: var(--fg); color: var(--acid); }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Chips inside a pill group (sizes, master). */
.chip { min-height: 36px; padding: 0 14px; background: transparent; }
.chip.active { background: var(--fg); color: #fff; }
.segmented { display: inline-flex; align-items: center; gap: 2px; }

/* ---------- Fields ---------- */
select, input[type="text"], input[type="number"], textarea {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 18px;
  min-height: 36px;
  padding: 0 14px;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 30px;
  background: var(--surface) url("img/flecha.svg") no-repeat right 12px center / 12px 12px;
  cursor: pointer;
}
input[type="number"] {
  width: 100px; text-align: center; font-family: var(--mono); font-size: 14px;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"]:disabled, select:disabled { color: var(--muted); background-color: var(--chip); }
input[type="checkbox"] { accent-color: var(--fg); width: 16px; height: 16px; margin: 0; }
input[type="color"] { width: 36px; height: 28px; border: 1px solid var(--line); border-radius: 14px; padding: 2px; background: var(--surface); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 10px; }

/* Sliders: hairline rail, black filled part (--fill, set by main.js), black knob. */
input[type="range"] {
  --fill: 0%;
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; border-radius: 1px;
  background: linear-gradient(to right, var(--fg) var(--fill), var(--line) var(--fill));
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--fg); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px;
  border-radius: 50%; background: var(--fg); border: 0;
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--fg); border: 0; }
input[type="range"]:disabled { opacity: 0.35; cursor: default; }

/* ---------- Header ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand picker actions" "history history history";
  align-items: center;
  column-gap: 24px;
  row-gap: 4px;
  padding: 24px var(--gutter) 12px;
  background: linear-gradient(to bottom, var(--acid), var(--bg));
}
/* The wordmark: "EXPERIMENTAL LETTERS" set in Letritas, as outlines. Sized
   by its width, so it keeps its place in the top bar. Its box keeps the room
   the earlier drawing had (as tall as a 7.5th of its width, letters 8/461 of
   the width from the top), which sets the height of the top bar. */
.brand {
  --wm-w: 461px; grid-area: brand; margin: 0; line-height: 0; width: var(--wm-w);
  height: calc(var(--wm-w) / 7.5); padding-top: calc(var(--wm-w) * 8 / 461);
}
.wordmark { display: block; width: var(--wm-w); height: auto; pointer-events: none; }
.font-picker {
  grid-area: picker; justify-self: center;
  display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%;
  min-height: 36px; padding: 0 18px 0 6px; border-radius: 18px; background: var(--chip);
}
#fontSelect {
  min-width: 0; max-width: 240px; min-height: 30px; padding: 0 26px 0 12px;
  font-weight: 600; background-color: transparent; background-position: right 8px center;
  text-overflow: ellipsis;
}
#fontSelect:hover { background-color: var(--chip); }
.font-style { white-space: nowrap; }
.font-style:empty { display: none; }
.save-status {
  display: flex; align-items: center; gap: 6px; margin-left: 14px; flex: none;
  font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap;
}
.save-status:empty { display: none; }
.save-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.save-status.failed { color: var(--pink-ink); }
.save-status.failed::before { background: var(--pink); }
.top-actions { grid-area: actions; display: flex; align-items: center; gap: 8px; }
.history { grid-area: history; display: flex; gap: 6px; }
.history .icon-btn:disabled { opacity: 0.45; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 316px;
  column-gap: 0;
  /* Leaves room for the test bar, so the test text is on screen with the
     grid (down to 560px; below that the page scrolls). */
  height: max(560px, calc(100vh - 160px - var(--test-h)));
  padding: 12px var(--gutter) 0;
}
.zone { min-height: 0; overflow: auto; scrollbar-width: thin; }
.zone-left { padding: 0 2px 20px 0; }
.zone-center { margin-left: 12px; border-left: 1px solid var(--line); padding: 0 0 4px 23px; }
.zone-right { padding: 0 2px 20px 0; margin-left: 20px; }
.app.letters-hidden { grid-template-columns: 0 minmax(0, 1fr) 316px; }
.app.letters-hidden .zone-left { visibility: hidden; padding: 0; }
.app.letters-hidden .zone-center { margin-left: 0; border-left: 0; padding-left: 0; }

/* ---------- Letters: filters and character map ---------- */
.guide-btn { width: 100%; margin-bottom: 14px; background: var(--acid); }
.guide-btn:hover:not(:disabled) { background: #d6f23c; }
/* "¿Por dónde empiezo?": the steps, each with its letters. */
dialog.guide { max-width: 600px; }
.guide-steps { margin: 18px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 14px; }
.guide-steps li::marker { font-family: var(--mono); color: var(--muted); }
.guide-steps p { margin: 2px 0 6px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.guide-chars { display: flex; flex-wrap: wrap; gap: 4px; }
.guide-char { min-width: 34px; min-height: 34px; padding: 0 8px; font-size: 17px; background: var(--bg); position: relative; overflow: hidden; }
.guide-char.drawn::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--acid); }
.guide-char.next { box-shadow: inset 0 0 0 2px var(--fg); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters + .label { margin: 16px 0 8px; }
/* Kinds of characters (short labels: ABC, abc, 123, !?&) and states: one
   pill each, on a single row. */
.filters.kinds, .filters.states {
  flex-wrap: nowrap; gap: 1px; padding: 4px;
  background: linear-gradient(var(--chip), var(--chip)), var(--surface); border-radius: 22px;
}
.filter { flex: 1 1 auto; min-width: 0; min-height: 32px; padding: 0 6px; font-size: 14px; font-weight: 600; background: transparent; }
.filter[data-filter="digits"] { font-family: var(--mono); font-weight: 700; }
.filter:hover:not(:disabled) { background: var(--surface); }
.filter.active, .filter.active:hover:not(:disabled) { background: var(--fg); color: #fff; box-shadow: none; }
.state { flex: 1 1 auto; min-width: 0; min-height: 30px; padding: 0 6px; font-size: 13.5px; font-weight: 400; background: transparent; border-color: transparent; }
.state:hover:not(:disabled) { background: var(--surface); }
.state.active, .state.active:hover:not(:disabled) { background: var(--acid); }
#stateFilters { padding-bottom: 6px; border-bottom: 1px solid var(--line); }

.zone-left h2 { display: flex; justify-content: space-between; margin: 14px 0 10px; }
.cm-count { color: var(--fg); text-transform: none; }
.cm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px 9px; }
.cm-cell {
  position: relative;
  aspect-ratio: 44 / 52;
  min-height: 0;
  padding: 6px 5px;
  background: var(--surface);
  border: 0;
  border-radius: 12px;
  overflow: hidden;
}
.cm-cell:hover:not(:disabled) { background: var(--surface); box-shadow: inset 0 0 0 1px var(--fg); }
.cm-cell svg { display: block; width: 100%; height: 100%; }
/* The thumbnail's paper is the tile itself. */
.cm-cell svg > rect:first-child { fill: transparent; }
.cm-label { display: none; }
.cm-cell.empty svg { visibility: hidden; }
.cm-cell.empty .cm-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 19px; color: var(--muted);
}
/* Drawn letters: the acid bar along the bottom. */
.cm-cell:not(.empty)::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--acid); }
.cm-cell.as-capital:not(.active) svg { opacity: 0.3; }
.cm-cell.active, .cm-cell.active:hover:not(:disabled) { background: var(--fg); box-shadow: none; }
.cm-cell.active::after { display: none; }
.cm-cell.active svg [fill]:not([fill="none"]):not(rect:first-child) { fill: var(--acid); }
.cm-cell.active.empty .cm-label { color: var(--acid); }
.cm-cell.filtered, .cm-group.filtered { display: none; }
.own-dot { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--pink); }
.comp-mark { position: absolute; top: 5px; left: 5px; width: 6px; height: 6px; border: 1.5px solid var(--muted); border-radius: 1px; }
.grid-mark { position: absolute; bottom: 9px; right: 5px; width: 6px; height: 6px; background: var(--fg); border-radius: 1px; }
.node-mark { position: absolute; bottom: 9px; left: 5px; width: 6px; height: 6px; border: 1.5px solid var(--fg); background: #fff; }
.cm-cell.active .grid-mark { background: var(--acid); }
.bold-mark { position: absolute; top: 5px; right: 13px; width: 6px; height: 6px; border-radius: 50%; background: #d23b48; }

.drafts { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.drafts summary {
  cursor: pointer; list-style: none; display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.drafts summary::after { content: "+"; font-family: var(--sans); font-size: 18px; line-height: 1; color: var(--fg); }
.drafts[open] summary::after { content: "−"; }
.drafts summary::-webkit-details-marker { display: none; }
.hint { margin: 8px 0 10px; color: var(--muted); font-size: 12.5px; }
#gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.thumb { position: relative; cursor: pointer; }
.thumb svg { display: block; width: 100%; height: auto; border-radius: 12px; }
.thumb:hover svg { box-shadow: 0 0 0 1px var(--fg); }

/* ---------- Center: toolbar, tool options, board ---------- */
.zone-center { position: relative; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.tools-pill, .master-switch {
  display: inline-flex; gap: 1px; padding: 4px; background: var(--chip); border-radius: 22px;
}
.tools-pill .tool { min-height: 36px; padding: 0 12px; gap: 5px; background: transparent; }
.tools-pill .tool:hover:not(:disabled) { background: var(--chip); }
.tools-pill .tool.active { background: var(--fg); color: #fff; }
.tool kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tool.active kbd { color: var(--acid); }
.master-switch .chip { color: var(--muted); }
.master-switch .chip:hover:not(:disabled) { background: var(--chip); color: var(--fg); }
.master-switch .chip.active { background: var(--acid); color: var(--fg); }
.master-switch #masterBold.active { background: var(--fg); color: #fff; }
.bold-status { font-size: 12px; padding: 3px 9px; white-space: nowrap; border-radius: 999px; background: var(--surface); }
.bold-status.ok { color: #2f7a3b; background: #eaf7ec; }
.bold-status.bad { color: #b4232f; background: #fff0f1; }
.bold-status.auto { color: var(--muted); }
.bad-list { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.bad-list button { min-height: 28px; padding: 0 11px; font-size: 13px; color: #b4232f; background: #fff0f1; }
body.master-bold .regular-only { display: none !important; }
body.master-bold .board-card { box-shadow: 0 0 0 2px var(--fg); }

/* Options of the active tool: a vertical pill to the left of the board. */
.work { flex: 1; min-height: 0; display: flex; gap: 10px; }
.work .board-card { min-width: 0; }
.context-bar {
  display: none; flex-direction: column; align-items: center; align-self: flex-start;
  flex: none; max-height: 100%; overflow-y: auto; scrollbar-width: none;
  padding: 4px; background: var(--chip); border-radius: 22px;
}
.context-bar::-webkit-scrollbar { display: none; }
.context-bar:has(.tool-group:not([hidden])) { display: flex; }
.tool-group { display: grid; grid-template-columns: repeat(2, 32px); gap: 2px; padding: 5px 0; }
.tool-group:not([hidden]) ~ .tool-group:not([hidden]) { border-top: 1px solid var(--line); }
.tool-group[hidden] { display: none; }
.tool-group .wide-cell, .tool-group .grid-gap { grid-column: span 2; }
.tool-group .grid-gap { height: 2px; }
.context-bar .icon-btn { width: 32px; height: 32px; background: transparent; }
.context-bar .icon-btn:hover:not(:disabled) { background: var(--chip); }
.context-bar .icon-btn.active { background: var(--fg); color: var(--acid); }
.context-bar .bold-status { font-size: 10.5px; line-height: 1.25; white-space: normal; padding: 4px 3px; text-align: center; border-radius: 10px; cursor: help; }
.context-bar .field { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); }
.context-bar .field input { width: 62px; min-height: 28px; padding: 0 4px; font-size: 12px; }
.ico.pf { stroke-width: 1.3; }
.ico.pf .fill { fill: currentColor; fill-opacity: .35; }
.corner-radius { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; font-size: 10.5px; color: var(--muted); }
.corner-radius input[type="range"] { writing-mode: vertical-lr; direction: rtl; width: 16px; height: 120px; }
.corner-radius input[type="range"]::-webkit-slider-runnable-track { width: 2px; height: auto; background: linear-gradient(to top, var(--fg) var(--fill), var(--line) var(--fill)); }
.corner-radius input[type="range"]::-webkit-slider-thumb { margin-top: 0; margin-left: -7px; }
.corner-radius output { font-family: var(--mono); color: var(--fg); font-size: 12px; }

/* The title and the tool hints sit above the board, in the layout: a hint
   makes the board smaller instead of covering the letter. */
.board-card {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 24px;
  overflow: hidden;
}
.board-wrap { position: relative; order: 2; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px 24px 64px; }
#board { width: 100%; height: 100%; touch-action: none; cursor: crosshair; user-select: none; }
#board text { font-family: var(--mono); }
#board .metric-label.draggable { cursor: ns-resize; }
#board .sb-label { cursor: ew-resize; }
#board[data-tool="select"], #board[data-tool="nodes"] { cursor: default; }
#board[data-tool="corner"] { cursor: pointer; }
#board[data-tool="piece"], #board.drawing-shape { cursor: crosshair; }
#board.adding-node { cursor: copy; }
#board.pan-ready, #board.pan-ready * { cursor: grab; }
#board.panning, #board.panning * { cursor: grabbing; }

.board-title { order: 0; flex: none; display: flex; align-items: baseline; gap: 8px; padding: 18px 24px 0; pointer-events: none; }
#boardChar { font-size: 32px; line-height: 1; }
#boardInfo { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
/* Hints of the active tool, under the title (only while one is showing). */
.board-hints {
  order: 1; flex: none; display: flex; flex-direction: column; gap: 4px;
  padding: 8px 24px 0; pointer-events: none;
}
.board-hints:not(:has(.hint-inline:not([hidden]):not(:empty))) { display: none; }
.board-hints .hint-inline { align-self: flex-start; max-width: 520px; padding: 3px 10px; border-radius: 12px; background: var(--bg); }
.board-hints .hint-inline:empty { display: none; }
.hint-inline { font-size: 12.5px; color: var(--muted); }

/* View options: a pill floating at the bottom center of the board. */
.view-tools {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2;
  max-width: calc(100% - 32px); overflow-x: auto; scrollbar-width: none;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: color-mix(in srgb, #ededea 94%, transparent);
  border-radius: 20px;
}
.view-tools::-webkit-scrollbar { display: none; }
.view-tools > * { flex: none; }
.view-tools button { min-height: 32px; padding: 0 14px; font-size: 13px; font-weight: 400; background: transparent; }
.view-tools button.square { width: 36px; padding: 0; }
.view-tools button:hover:not(:disabled) { background: var(--chip); }
.view-tools button.active { background: var(--fg); color: #fff; }
.view-tools label.inline { display: flex; align-items: center; gap: 2px; padding-left: 14px; font-size: 13px; }
.view-tools select {
  field-sizing: content; min-height: 32px; max-width: 130px; padding: 0 24px 0 2px; font-size: 13px;
  background-color: transparent; background-position: right 8px center; border-radius: 16px;
}
.view-tools select:hover { background-color: var(--chip); }
#mirrorAxis { padding-left: 10px; }
#mirrorAxis:disabled { display: none; }
#zoomLevel {
  min-width: 62px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; background: var(--surface); border-radius: 16px; font-size: 13px; font-variant-numeric: tabular-nums;
}

/* First-visit tip: a banner above the work area, so it never covers the grid. */
.tip {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
  padding: 10px 12px 10px 18px; background: var(--fg); color: #fff;
  border-radius: 20px; font-size: 13.5px;
}
.tip span { flex: 1 1 280px; }
.tip strong { color: var(--acid); font-weight: 600; }
.tip button { background: var(--acid); color: var(--fg); }
.tip button:hover:not(:disabled) { background: #d6f23c; }

.toast {
  position: absolute; left: 50%; bottom: 68px; transform: translateX(-50%); z-index: 3;
  max-width: min(90%, 520px);
  background: var(--fg); color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 13.5px; box-shadow: var(--shadow); pointer-events: none;
}

/* ---------- Right: the letter ---------- */
/* Tabs: "Esta letra" and "Toda la fuente". */
.panel-tabs {
  position: sticky; top: 0; z-index: 2;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 4px; margin-bottom: 16px;
  background: linear-gradient(var(--chip), var(--chip)), var(--bg); border-radius: 22px;
}
.panel-tabs .chip { color: var(--muted); }
.panel-tabs .chip:hover:not(:disabled) { background: var(--chip); color: var(--fg); }
.panel-tabs .chip.active, .panel-tabs .chip.active:hover:not(:disabled) { background: var(--fg); color: #fff; }
.panel-intro { margin: 0 0 12px; }
.glyph-card {
  display: flex; align-items: center; gap: 0;
  height: 120px; padding: 16px 22px; margin-bottom: 20px;
  background: var(--acid); border-radius: 24px;
}
.glyph-thumb { width: 44px; height: 88px; flex: none; }
.glyph-thumb > rect:first-child { fill: transparent; }
.glyph-char { min-width: 54px; margin: 0 16px 0 30px; font-size: 64px; line-height: 1; letter-spacing: -0.02em; text-align: center; }
.glyph-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; align-self: flex-start; padding-top: 14px; }
.glyph-meta strong { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.glyph-meta small { font-family: var(--mono); font-size: 13px; }

.fields { padding-bottom: 20px; }
label.range-row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; row-gap: 12px; margin: 0 0 24px; font-weight: 500; font-size: 15px; }
label.range-row input[type="range"] { grid-column: 1 / -1; }
label.range-row output { font-family: var(--mono); font-weight: 400; font-size: 14px; font-variant-numeric: tabular-nums; }
#colsOut::after { content: " col"; }
label.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
label.row > span { display: flex; align-items: center; gap: 8px; }
.fields label.row { font-weight: 500; font-size: 15px; }
label.row input[type="text"] { width: 160px; }
label.row select { max-width: 170px; }
label.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
/* Number with its unit inside the pill: "50 u". */
.unit { position: relative; display: inline-flex; }
.unit input[type="number"] { padding: 0 40px 0 14px; text-align: right; }
.unit i { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); font-style: normal; font-family: var(--mono); pointer-events: none; }
.info { margin: 8px 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.info.mono { font-size: 12.5px; }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.buttons.inline { display: flex; flex-wrap: wrap; margin: 14px 0 12px; }
.buttons.end { display: flex; justify-content: flex-end; }
.colors { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin-top: 6px; }

/* Accordion rows: a hairline, the title and a "+". */
.sections { border-top: 1px solid var(--line); margin-bottom: 20px; }
.section { border-bottom: 1px solid var(--line); }
.section > summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  min-height: 38px; font-size: 15px;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after { content: "+"; font-size: 18px; line-height: 1; }
.section[open] > summary::after { content: "−"; }
.section > summary:hover { color: var(--pink-ink); }
.section-body { padding: 2px 0 16px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.25); }
.rows-editor { margin: 12px 0 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.rows-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 500; margin-bottom: 4px; }
.rows-head strong { font-family: var(--mono); font-size: 12.5px; font-weight: 400; color: var(--muted); }
.zone-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; }
.zone-row > span { display: flex; align-items: center; gap: 8px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper input { width: 52px; padding: 0 4px; }
.stepper .icon-btn { width: 32px; height: 32px; }
.glyph-curve { margin: 0 0 12px; padding: 12px; background: var(--bg); border-radius: 16px; font-size: 12.5px; }
.glyph-curve > span { display: block; color: var(--muted); margin-bottom: 8px; }
.glyph-curve label.range-row { margin-bottom: 12px; font-size: 14px; }
.glyph-curve button { width: 100%; }
.badge { display: inline-block; font-family: var(--mono); font-size: 11px; padding: 1px 7px; border-radius: 8px; background: var(--acid); color: var(--fg); font-weight: 400; }
.component { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.component label { display: flex; align-items: center; gap: 3px; margin: 0; font-size: 12px; color: var(--muted); }
.component input[type="number"] { width: 52px; min-height: 30px; padding: 0 4px; }
.comp-name { width: 34px; min-height: 30px; padding: 0; font-size: 16px; }
.comp-center, .comp-remove { margin-left: auto; width: 30px; min-height: 30px; padding: 0; }
.comp-center + .comp-remove { margin-left: 0; }
.component.selected .comp-name { background: var(--fg); color: var(--acid); }
.component-erase { margin: -2px 0 8px; }
.component-erased { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: -2px 0 8px; font-size: 12.5px; color: var(--muted); }
.component-erased button { min-height: 28px; padding: 0 11px; font-size: 12.5px; }
.alt-list { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 6px; }
.alt-list:empty { display: none; }
.alt-chip { min-width: 36px; min-height: 30px; padding: 0 10px; font-size: 13px; background: var(--surface); }
.alt-chip.active { background: var(--fg); color: var(--acid); }
.add-component { display: flex; gap: 6px; margin: 8px 0; }
.add-component select { flex: 1; min-width: 0; }
.piece-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.piece-label { flex: 1; justify-content: flex-start; min-height: 30px; font-size: 12.5px; padding: 0 12px; font-weight: 400; background: var(--surface); }
.piece-row.active .piece-label { background: var(--fg); color: var(--acid); }
.piece-row .icon-btn { width: 30px; height: 30px; }

/* ---------- Test bar ---------- */
.testbar {
  margin: 20px var(--gutter) 12px;
  background: var(--surface);
  border-radius: 24px;
  padding: 18px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.testbar.collapsed { padding-top: 14px; padding-bottom: 14px; }
.testbar.collapsed .test-controls > :not(#toggleTest):not(.test-title),
.testbar.collapsed .test-view, .testbar.collapsed .test-foot { display: none; }
.testbar.collapsed .test-title { cursor: pointer; }
.test-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.test-title { font-size: 30px; font-weight: 500; letter-spacing: -0.01em; line-height: 1; margin-right: 8px; }
#testText {
  flex: 0 1 320px; min-width: 140px; min-height: 38px; max-height: 120px; resize: vertical;
  padding: 9px 18px; border-radius: 19px; background: var(--bg); font-size: 15px; line-height: 1.3;
}
.select-pill {
  position: relative; display: inline-flex; align-items: center;
  border: 1px solid var(--fg); border-radius: 18px; min-height: 36px;
}
.select-pill img { position: absolute; left: 9px; pointer-events: none; }
.select-pill select { field-sizing: content; min-height: 34px; max-width: 170px; padding: 0 14px 0 34px; background: transparent; }
.sizes { gap: 4px; }
.sizes .chip { width: 36px; padding: 0; background: var(--bg); }
.sizes .chip:hover:not(:disabled) { background: var(--chip-hover); }
.sizes .chip.active { background: var(--fg); color: #fff; }
.test-weight { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.test-weight input { width: 110px; }
.test-weight output { min-width: 64px; font-family: var(--mono); font-size: 13px; font-weight: 400; font-variant-numeric: tabular-nums; }
.kern {
  display: flex; align-items: center; gap: 4px;
  min-height: 36px; padding: 0 4px 0 14px; border: 1px solid var(--fg); border-radius: 18px;
}
/* No pair chosen: just "Kerning − +", faded. */
.kern:has(#kernValue:disabled) { opacity: 0.35; padding-right: 8px; }
.kern:has(#kernValue:disabled) :is(.kern-pair, .kern-sides, .kern-scope, #kernValue, #kernClear) { display: none; }
/* Each letter of the pair with the group of the side that kerns: the
   right group of the first letter and the left group of the second. */
.kern-sides { display: inline-flex; align-items: center; gap: 2px; }
.kern-sides:not([hidden]) + .kern-scope { margin-left: 4px; }
.kern-side { display: inline-flex; align-items: center; gap: 3px; padding: 0 2px; }
.kern-side strong { min-width: 14px; text-align: center; font-weight: 600; font-size: 15px; }
.kern-side + .kern-side { padding-left: 6px; border-left: 1px solid var(--line); }
.kern .kern-group { min-height: 24px; padding: 0 7px; font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--fg); background: var(--bg); }
.kern .kern-group.none { color: var(--muted); font-style: italic; }
.kern-legend { font-family: var(--mono); }
.kern-legend::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 3px; border-radius: 2px; vertical-align: 0; }
.kern-legend.group::before { background: var(--fg); }
.kern-legend.exception::before { background: #ff52a9; }
.kern-legend.pair::before { background: var(--fg); opacity: 0.45; }
.kern-label { margin-right: 2px; }
.kern-pair { min-width: 24px; text-align: center; font-weight: 600; }
.kern button { background: transparent; }
.kern button:hover:not(:disabled) { background: var(--chip); }
.kern button:disabled { opacity: 1; }
#kernValue { width: 64px; min-height: 28px; padding: 0 4px; background: var(--bg); }
#kernValue:disabled { background: transparent; }
#toggleTest { margin-left: auto; background: var(--bg); }
#toggleTest .chev { transition: transform .2s ease; transform-origin: 12px 12.5px; }
.testbar.collapsed #toggleTest .chev { transform: scaleY(-1); }
.test-view { overflow: auto; min-height: 60px; max-height: 32vh; border-radius: 16px; cursor: text; outline: none; }
.test-view:focus-visible { box-shadow: inset 0 0 0 1px var(--fg); }
.test-view svg { display: block; }
.test-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.counter { display: inline-flex; align-items: center; min-height: 28px; padding: 0 14px; border-radius: 14px; background: var(--acid); font-family: var(--mono); font-size: 13px; }
.counter:empty { display: none; }
.test-hint { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.kern-list { display: flex; flex-wrap: wrap; gap: 4px; font-size: 12.5px; color: var(--muted); }
.kern-chip { min-height: 26px; padding: 0 10px; font-size: 12.5px; font-family: var(--mono); font-weight: 400; font-variant-numeric: tabular-nums; }
.kern-chip.active { background: var(--fg); color: #fff; }
.kern-chip.group { box-shadow: inset 0 0 0 1px var(--fg); }
.kern-chip.exception::before { content: "≠ "; }
.kern-scope { min-height: 26px; padding: 0 10px; font-size: 12.5px; font-family: var(--mono); font-weight: 400; white-space: nowrap; box-shadow: inset 0 0 0 1px var(--fg); }
.kern-scope.exception { background: var(--acid) !important; box-shadow: none; }
.kern-scope.pair { box-shadow: none; color: var(--muted); }

/* ---------- Ribbon and credits ---------- */
.ribbon { overflow: hidden; background: var(--acid); border-top: 1px solid var(--fg); height: 32px; display: flex; align-items: center; }
.ribbon-track { display: flex; flex: none; animation: ribbon 40s linear infinite; }
.ribbon-track span {
  flex: none; white-space: pre; font-family: var(--mono); font-weight: 700; font-size: 13px;
  letter-spacing: 0.06em; text-transform: uppercase;
}
@keyframes ribbon { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ribbon-track { animation: none; } }

.credits {
  display: flex; align-items: flex-start; gap: 12px 36px;
  padding: 12px 28px 14px; background: var(--fg); color: #f3f2ee;
  font-family: var(--mono); font-size: 12px;
}
.credits p { margin: 2px 0 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.credits em { font-family: "Instrument Serif", Georgia, serif; font-style: italic; font-size: 14px; color: var(--pink); }
.credit-brand { display: flex; flex: none; align-items: flex-start; gap: 10px; margin-right: 24px; }
.credit-brand img { margin-top: 8px; }
.credit-brand span { display: flex; flex-direction: column; gap: 2px; }
.credit-brand strong { font-weight: 600; font-size: 17px; color: #f3f2ee; }
.credit-brand em { color: var(--acid); font-size: 15px; }
.credit-link { flex: none; margin-left: auto; margin-top: 2px; color: var(--acid); text-decoration: none; }
.credit-link:hover { text-decoration: underline; }

/* ---------- Dialogs ---------- */
dialog {
  border: 0;
  border-radius: 24px;
  padding: 24px;
  max-width: 440px;
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 24px 70px rgba(17, 17, 17, 0.25);
}
dialog::backdrop { background: rgba(17, 17, 17, 0.35); }
dialog h3 { margin: 0 0 12px; font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
dialog h4 { margin: 20px 0 10px; font-family: var(--mono); font-weight: 400; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
dialog p { margin: 0 0 14px; line-height: 1.5; }
dialog label.row { margin: 10px 0; }
dialog input[type="text"], dialog select { background-color: var(--bg); }
dialog input[type="text"] { width: 220px; }
dialog .buttons { margin-top: 20px; display: flex; justify-content: flex-end; }
dialog.help { max-width: 540px; }
dialog.dingbats { max-width: 560px; }
.dingbat-picker { max-height: 46vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.dingbat-picker h4:first-child { margin-top: 0; }
.dingbat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.dingbat-opt { min-height: 38px; padding: 0; font-size: 20px; line-height: 1; background: var(--bg); border-color: transparent; }
.dingbat-opt[aria-pressed="true"] { background: var(--fg); color: var(--acid); }
.dingbat-opt.have, .dingbat-opt.have:disabled { background: var(--acid); color: var(--fg); opacity: 1; }
#addDingbats { margin-top: 14px; }
.filter[data-filter="dingbats"] { font-weight: 400; }
.steps { margin: 0; padding-left: 20px; line-height: 1.6; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; font-size: 13px; }
.shortcuts dt { font-family: var(--mono); white-space: nowrap; }
.shortcuts dd { margin: 0; }

/* The tools bar, the board and the right column move up beside the history
   buttons (menu, undo, redo), which stay above the letters: the board gets
   that row's height. With the letters hidden, the tools bar stays below the
   buttons so it doesn't cover them. */
@media (min-width: 901px) {
  :root { --history-row: 60px; } /* the buttons (36px) and the space around them */
  .zone-center, .zone-right { margin-top: calc(-1 * var(--history-row)); }
  .app.letters-hidden .zone-center { margin-top: 0; }
}

/* ---------- Smaller screens ---------- */
@media (max-width: 1280px) {
  .app { grid-template-columns: 232px minmax(0, 1fr) 290px; }
  .tool kbd { display: none; }
  .tools-pill .tool { padding: 0 11px; }
  .brand { --wm-w: 330px; }
}

@media (max-width: 1100px) {
  .topbar { grid-template-columns: auto 1fr; grid-template-areas: "brand actions" "picker picker" "history history"; row-gap: 12px; }
  .top-actions { justify-self: end; }
  .font-picker { justify-self: start; }
  .view-tools label.inline { font-size: 0; gap: 0; padding-left: 4px; }
}

@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .brand { --wm-w: 255px; }
  .topbar { grid-template-columns: minmax(0, 1fr); grid-template-areas: "brand" "actions" "picker" "history"; }
  .top-actions { justify-self: start; flex-wrap: wrap; }
  .font-picker { flex-wrap: wrap; }
  .toolbar > * { max-width: 100%; }
  .tools-pill { overflow-x: auto; scrollbar-width: none; }
  .tools-pill .tool { flex: none; }
  .app, .app.letters-hidden { grid-template-columns: minmax(0, 1fr); height: auto; row-gap: 20px; }
  .zone { overflow: visible; }
  .zone-center { order: -1; height: 82vh; margin: 0; border: 0; padding: 0; }
  .zone-right { margin: 0; }
  .app.letters-hidden .zone-left { display: none; }
  .save-status { display: none; }
  .work { flex-direction: column; }
  .context-bar { flex-direction: row; flex-wrap: wrap; align-self: stretch; }
  .tool-group { display: flex; flex-wrap: wrap; align-items: center; padding: 0 6px; }
  .tool-group:not([hidden]) ~ .tool-group:not([hidden]) { border-top: 0; border-left: 1px solid var(--line); }
  .corner-radius { flex-direction: row; }
  .corner-radius input[type="range"] { writing-mode: horizontal-tb; direction: ltr; width: 110px; height: 16px; }
  .test-hint { margin-left: 0; }
  .credits { flex-wrap: wrap; }
  .credit-link { margin-left: 0; }
}
