/* Fontscope — a proofing desk for letterforms.
   Print overprint as the visual system: ink for text, cyan for the glyphs you bring,
   magenta for candidate fonts and the one primary action of each step. */
* {
  box-sizing: border-box;
}
body[data-tool="fontscope"] {
  --ui-accent: #c81e63;
  --ui-accent-hover: #a5164f;
  --fs-ink: #1c2030;
  --fs-text: #273247;
  --fs-muted: #606c80;
  --fs-line: #dce1e8;
  --fs-line-soft: #e9ecf1;
  --fs-paper: #fff;
  --fs-desk: #f3f4f7;
  --fs-dot: #d3d9e2;
  --fs-hover: #f1f3f7;
  --fs-cyan: #0a85f0;
  --fs-cyan-text: #0a6fc2;
  --fs-magenta: #c81e63;
  --fs-magenta-tint: #fcecf2;
  --fs-danger: #b42318;
  --fs-mincho: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif JP", serif;
  --fs-gothic: "Hiragino Sans", "Yu Gothic", YuGothic, "Noto Sans JP", sans-serif;
  --fs-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  margin: 0;
  color: var(--fs-text);
  background: var(--ui-background, #f6f7f9);
  font:
    13px/1.6 -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Noto Sans JP",
    sans-serif;
  font-variant-numeric: tabular-nums;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.prototype {
  align-self: center;
  margin-left: 8px;
  padding: 1px 6px;
  border: 1px solid var(--fs-line);
  border-radius: 3px;
  color: var(--fs-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.6;
}

/* Controls */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--fs-line);
  border-radius: 3px;
  background: var(--fs-paper);
  color: var(--fs-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}
button:hover:not(:disabled) {
  background: var(--fs-hover);
  border-color: #c5cdd9;
}
button:disabled {
  color: #7a8496;
  background: #f1f3f6;
  border-color: var(--fs-line-soft);
  cursor: not-allowed;
}
body[data-tool] button.primary {
  min-height: 36px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
body[data-tool] button.primary:disabled {
  color: #6f7a8c;
  background: #eceef2;
  border-color: #eceef2;
}
button.ghost {
  border-color: transparent;
  background: transparent;
}
button.ghost:hover:not(:disabled) {
  border-color: transparent;
  background: #e9ecf1;
}
button.text-button {
  min-height: 28px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--fs-cyan-text);
  font-weight: 600;
}
button.text-button:hover:not(:disabled) {
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
button.danger {
  color: var(--fs-danger);
}
input,
select,
textarea {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--fs-line);
  border-radius: 3px;
  background: var(--fs-paper);
}
select {
  min-height: 36px;
  padding: 7px 34px 7px 10px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%23515e75' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}
@media (forced-colors: active) {
  select { appearance: auto; background-image: none; }
}
input[type="checkbox"],
input[type="range"] {
  accent-color: var(--fs-ink);
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}
input[type="range"] {
  width: 100%;
  padding: 0;
  border: 0;
}
input[type="color"] {
  width: 48px;
  height: 32px;
  padding: 2px;
}
textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  font-size: 16px;
}
summary {
  cursor: pointer;
}
.full-width {
  width: 100%;
}
.hint {
  color: var(--fs-muted);
  font-size: 12px;
  line-height: 1.7;
}
.count,
.count-chip {
  color: var(--fs-muted);
  font-size: 12px;
  font-weight: 600;
}
.count-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #eceff4;
  color: var(--fs-text);
}
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--fs-line);
  border-radius: 4px;
  background: #eef0f4;
}
.segmented button {
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: #505b6e;
  font-size: 12px;
}
.segmented button:hover:not(:disabled) {
  border-color: transparent;
  background: #e2e6ec;
}
.segmented button[aria-pressed="true"],
.segmented button[aria-pressed="true"]:hover:not(:disabled) {
  border-color: var(--fs-line);
  background: var(--fs-paper);
  color: var(--fs-ink);
}

/* Icons painted with masks, so scripts can rewrite button labels freely. */
:is(
  .icon-undo,
  .icon-redo,
  .icon-previous,
  .icon-next,
  .icon-arrange,
  .icon-source,
  .icon-merge,
  .icon-recrop,
  .icon-delete
)::before {
  content: "";
  display: inline-block;
  flex: none;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: transparent;
  background: transparent;
}
.icon-button:disabled {
  background: transparent;
  border-color: transparent;
  color: #9aa3b2;
}
.icon-undo {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 14 4 9l5-5'/%3E%3Cpath d='M4 9h10.5a5.5 5.5 0 0 1 0 11H11'/%3E%3C/svg%3E");
}
.icon-redo {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 14 5-5-5-5'/%3E%3Cpath d='M20 9H9.5a5.5 5.5 0 0 0 0 11H13'/%3E%3C/svg%3E");
}
.icon-previous {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E");
}
.icon-next {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
}
.icon-arrange {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linejoin='round'%3E%3Crect x='3.5' y='3.5' width='7' height='7'/%3E%3Crect x='13.5' y='3.5' width='7' height='7'/%3E%3Crect x='3.5' y='13.5' width='7' height='7'/%3E%3Crect x='13.5' y='13.5' width='7' height='7'/%3E%3C/svg%3E");
}
.icon-source {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14'/%3E%3Cpath d='M7 15h3M12 10h5M7 10h2M13 15h4'/%3E%3C/svg%3E");
}
.icon-merge {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4h6v6H4zM14 14h6v6h-6zM10 7h4a3 3 0 0 1 3 3v4'/%3E%3C/svg%3E");
}
.icon-recrop {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8V4h4M16 4h4v4M20 16v4h-4M8 20H4v-4'/%3E%3Cpath d='M9 9h6v6H9z'/%3E%3C/svg%3E");
}
.icon-delete {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3'/%3E%3C/svg%3E");
}

/* One fixed frame: a work bar with the steps and the step's single primary action,
   then the stage of the current step. */
#tool-workspace {
  padding: 0;
}
#tool-workspace .workspace {
  --work-height: max(520px, calc(100dvh - 104px));
  position: relative;
  display: flex;
  flex-direction: column;
  height: var(--work-height);
  overflow: hidden;
  border-bottom: 1px solid var(--fs-line);
  background: var(--fs-desk);
}
.workbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 57px;
  padding: 6px 12px 6px 16px;
  border-bottom: 1px solid var(--fs-line);
  background: var(--fs-paper);
}
.phase-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
}
.phase-nav button {
  gap: 8px;
  min-height: 32px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--fs-muted);
  font-size: 13px;
  font-weight: 600;
}
.phase-nav button:hover:not(:disabled) {
  background: var(--fs-hover);
  color: var(--fs-ink);
}
.phase-nav button:disabled {
  background: transparent;
  color: #6f7a8c;
  opacity: 0.7;
}
.step-number {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid #c3cad6;
  border-radius: 50%;
  background: var(--fs-paper);
  font-size: 11px;
  font-weight: 700;
  transition:
    background-color 0.2s,
    border-color 0.2s,
    color 0.2s;
}
.phase-nav .completed .step-number {
  border-color: var(--fs-ink);
  color: var(--fs-ink);
}
.phase-nav [aria-current="step"] {
  color: var(--fs-ink);
}
.phase-nav [aria-current="step"] .step-number {
  border-color: var(--fs-magenta);
  background: var(--fs-magenta);
  color: #fff;
}
.step-rule {
  width: 20px;
  height: 1px;
  background: #c3cad6;
}
.workbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
}
.phase-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}
#tool-workspace:not([data-current-phase="1"]) [data-for-phase="1"],
#tool-workspace:not([data-current-phase="2"]) [data-for-phase="2"],
#tool-workspace:not([data-current-phase="3"]) [data-for-phase="3"] {
  display: none;
}
#labels-status {
  display: grid; gap: 3px; padding: 3px 6px; min-width: 76px; height: 36px; line-height: 1.2;
  background: transparent; border: 0; color: var(--fs-ink); font-size: 12px;
}
#labels-status:disabled { opacity: 1; color: var(--fs-ink); }
#labels-progress { width: 100%; height: 5px; margin: 0; }
#labels-status[data-complete="true"] progress::-webkit-progress-value { background: #167b52; }
#cancel {
  min-height: 36px;
}
#tool-workspace [data-phase] {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* The desk: a quiet dot grid, like the paper under a loupe. */
#image-empty,
#image-stage,
#sample-board-stage,
#comparison,
.search-state {
  background-color: var(--fs-desk);
  background-image: radial-gradient(var(--fs-dot) 1px, transparent 1.2px);
  background-size: 20px 20px;
  background-position: 10px 10px;
}

/* Step 1 — choose an image. */
#image-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 32px 16px;
}
.picker-specimen {
  display: grid;
  place-items: center;
}
.specimen-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 168px;
  height: 168px;
  border: 1px solid #c9d0db;
  background:
    linear-gradient(#c9d0db, #c9d0db) 50% 0 / 1px 100% no-repeat,
    linear-gradient(#c9d0db, #c9d0db) 0 50% / 100% 1px no-repeat,
    var(--fs-paper);
}
.specimen-cell::before,
.specimen-cell::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed #dde2ea;
}
.specimen-cell::after {
  inset: auto -9px -9px auto;
  width: 18px;
  height: 18px;
  border: 1px solid var(--fs-ink);
  border-radius: 50%;
  background:
    linear-gradient(var(--fs-ink), var(--fs-ink)) 50% -4px / 1px calc(100% + 8px) no-repeat,
    linear-gradient(var(--fs-ink), var(--fs-ink)) -4px 50% / calc(100% + 8px) 1px no-repeat;
}
.specimen-glyph {
  grid-area: 1 / 1;
  z-index: 1;
  font-size: 120px;
  line-height: 1;
  mix-blend-mode: multiply;
}
.specimen-original {
  color: var(--fs-cyan);
  font-family: var(--fs-mincho);
  font-weight: 600;
}
.specimen-candidate {
  color: var(--fs-magenta);
  font-family: var(--fs-gothic);
  font-weight: 700;
  transform: translate(3px, -2px);
  opacity: 0.92;
}
.picker-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
#sample {
  margin-top: 8px;
}

/* Step 1 — trim the image. */
#editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.canvas-bar {
  position: relative;
  z-index: 4;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--fs-line);
  background: var(--fs-paper);
}
.canvas-bar .segmented {
  margin-right: 4px;
}
.bar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}
#image-meta {
  overflow: hidden;
  color: var(--fs-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crop-details {
  position: relative;
}
.crop-details summary {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}
.crop-details summary::-webkit-details-marker {
  display: none;
}
.crop-details summary:hover,
.crop-details[open] summary {
  background: #e9ecf1;
}
.crop-fields {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  grid-template-columns: repeat(2, 104px);
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--fs-line);
  border-radius: 4px;
  background: var(--fs-paper);
  box-shadow: 0 12px 32px -12px #1c203040;
}
.crop-fields label {
  display: grid;
  gap: 2px;
  color: var(--fs-muted);
  font-size: 12px;
}
.crop-fields button {
  grid-column: 1 / -1;
}
#image-stage {
  flex: 1;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-height: 0;
  padding: 24px;
  overflow: hidden;
}
#source {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  outline: 1px solid #1c20301a;
  touch-action: none;
  cursor: crosshair;
}
.stage-note {
  flex: none;
  padding: 8px 16px;
  border-top: 1px solid var(--fs-line);
  background: var(--fs-paper);
  color: var(--fs-muted);
  font-size: 12px;
}

/* Step 2 — the character desk. */
.notice {
  flex: none;
  padding: 8px 16px;
  border-bottom: 1px solid #ecd9a8;
  background: #fff8e6;
  color: #74560f;
  font-size: 12px;
}
#sample-workbench {
  flex: 1;
  min-height: 0;
}
.editing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  height: 100%;
  min-height: 0;
}
.canvas-column {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
#samples-title {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  font-size: 13px;
  font-weight: 700;
}
.canvas-bar .ghost {
  font-size: 13px;
}
.history-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
#sample-zoom {
  width: 88px;
  margin-left: 6px;
  border-color: transparent;
  background-color: transparent;
  font-size: 12px;
  font-weight: 600;
}
#sample-zoom:hover {
  background-color: #e9ecf1;
}
.canvas-overlay {
  position: absolute;
  top: 52px;
  left: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--fs-line);
  border-radius: 6px;
  background: var(--fs-paper);
  box-shadow: 0 8px 24px -12px #1c203038;
  font-size: 13px;
}
#source-banner {
  right: 12px;
  justify-content: space-between;
  font-weight: 600;
}
#source-caption {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#source-banner button {
  min-height: 30px;
}
.canvas-overlay-tools {
  top: 100px;
}
.canvas-overlay-tools label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fs-muted);
  font-size: 12px;
}
.canvas-overlay-tools select,
.canvas-overlay-tools button {
  min-height: 30px;
}
#sample-board-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-start;
  min-height: 0;
  padding: 88px 32px 32px;
  overflow: auto;
}
#sample-board {
  display: block;
  flex-shrink: 0;
  margin: 0;
  outline: none;
  touch-action: none;
}
#sample-board:focus-visible {
  outline: 2px solid var(--fs-cyan);
  outline-offset: 10px;
}
.canvas-column:has(#source-banner:not([hidden])) #sample-board {
  box-shadow: 0 0 0 1px #1c20301f;
}
.tool-row {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 8px 12px;
  border-top: 1px solid var(--fs-line);
  background: var(--fs-paper);
}
.canvas-hint {
  position: absolute;
  left: 16px;
  max-width: calc(50% - 130px);
  overflow: hidden;
  color: var(--fs-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.floating-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--fs-line);
  border-radius: 8px;
  background: var(--fs-paper);
  box-shadow: 0 6px 20px -10px #1c203040;
}
.floating-tools .segmented {
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
}
.floating-tools button,
.multi-select {
  display: grid;
  place-items: center;
  width: 40px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--fs-ink);
  background: transparent;
  cursor: pointer;
}
.floating-tools button:hover:not(:disabled),
.multi-select:hover {
  background: var(--fs-hover);
}
.floating-tools button[aria-pressed="true"],
.floating-tools button[aria-pressed="true"]:hover:not(:disabled) {
  color: #fff;
  background: var(--fs-ink);
}
.floating-tools svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.multi-select {
  position: relative;
  margin-left: 2px;
  border-left: 1px solid var(--fs-line-soft);
  border-radius: 0 5px 5px 0;
}
.multi-select input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.multi-select:has(input:checked) {
  color: #fff;
  background: var(--fs-ink);
}
.multi-select:has(input:focus-visible) {
  outline: 3px solid var(--ui-accent);
  outline-offset: 2px;
}

/* The recognised character, edited right next to its glyph. */
.character-editor {
  position: absolute;
  z-index: 3;
  padding: 5px;
  border: 1px solid #c9d0db;
  border-radius: 6px;
  background: var(--fs-paper);
  box-shadow: 0 12px 28px -14px #1c203059;
}
.character-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.character-input-row label {
  flex: 1;
  min-width: 0;
}
#object-character {
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--fs-line);
  background: #f7f8fa;
  color: var(--fs-ink);
  font-size: 22px;
  font-weight: 600;
  text-align: center;
}
#object-character:focus {
  border-color: var(--fs-cyan);
  outline: 2px solid #0a85f033;
  outline-offset: 0;
  background: var(--fs-paper);
}
#object-character[aria-invalid="true"] {
  border-color: var(--fs-danger);
  background: #fff5f4;
}
#object-character::placeholder {
  color: #9aa3b2;
}
.character-input-row .icon-button {
  width: 32px;
  min-height: 36px;
  color: var(--fs-text);
}
.character-input-row .icon-button:hover:not(:disabled) {
  background: var(--fs-hover);
}
.character-input-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding: 0 2px;
  color: var(--fs-muted);
  font-size: 12px;
  line-height: 1.5;
}
.character-input-status label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fs-text);
  white-space: nowrap;
}

/* Inspector */
.inspector {
  min-width: 0;
  overflow: auto;
  border-left: 1px solid var(--fs-line);
  background: var(--fs-paper);
}
.inspector-section {
  padding: 16px;
  border-bottom: 1px solid var(--fs-line-soft);
}
#inspector-title {
  margin-bottom: 8px;
  color: var(--fs-ink);
  font-size: 14px;
  font-weight: 700;
}
.inspector-actions {
  display: grid;
  gap: 2px;
  margin: 0 -8px;
}
.inspector-actions .action {
  justify-content: flex-start;
  gap: 10px;
  min-height: 36px;
  padding: 6px 8px;
  border-color: transparent;
  background: transparent;
  font-weight: 600;
}
.inspector-actions .action:hover:not(:disabled) {
  border-color: transparent;
  background: var(--fs-hover);
}
.inspector-actions .action[aria-pressed="true"] {
  background: #e7f2fe;
  color: var(--fs-cyan-text);
}
.recognition-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--fs-line-soft);
}
#ocr-status {
  color: var(--fs-muted);
  font-size: 12px;
}
.inspector details > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -16px;
  padding: 14px 16px;
  color: var(--fs-ink);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}
.inspector details > summary::-webkit-details-marker {
  display: none;
}
.inspector details > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.6px solid var(--fs-muted);
  border-bottom: 1.6px solid var(--fs-muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s var(--fs-ease);
}
.inspector details[open] > summary::after {
  transform: translateY(2px) rotate(225deg);
}
.inspector details > summary:hover {
  background: #f7f8fa;
}
.inspector details[open] > summary {
  margin-bottom: 8px;
}
#clean-tools .hint {
  margin-bottom: 12px;
}
#brush-control {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--fs-muted);
  font-size: 12px;
}
.subheading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 8px;
}
.subheading h3 {
  font-size: 12px;
}
#ink-label {
  color: var(--fs-muted);
  font-size: 12px;
}
.mask-stage {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  padding: 8px;
  border: 1px solid var(--fs-line);
  border-radius: 3px;
}
#mask-preview {
  max-width: 100%;
  max-height: 96px;
}
.adjustment-fields {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}
.adjustment-fields > label {
  position: relative;
  display: grid;
  gap: 6px;
  color: var(--fs-muted);
  font-size: 12px;
}
.adjustment-fields output {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--fs-text);
}
.color-field,
.rotation-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-field button,
.rotation-field button {
  flex-shrink: 0;
  min-height: 30px;
  font-size: 12px;
}
.transcription {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--fs-line-soft);
}
.transcription > summary {
  font-size: 13px;
  font-weight: 600;
}
.transcription label {
  display: block;
  margin: 12px 0 6px;
  color: var(--fs-muted);
  font-size: 12px;
}
.transcription button {
  width: 100%;
  margin-top: 8px;
}
#sample-generation {
  margin-top: 16px;
}
#sample-generation .hint + .hint {
  margin-top: 4px;
}
.library-content {
  display: grid;
  gap: 8px;
}
#catalog {
  max-height: 96px;
  overflow: auto;
  color: var(--fs-muted);
  font-size: 12px;
  line-height: 1.8;
}

/* Step 3 — results. */
.search-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  text-align: center;
}
/* Live specimen: the user's glyphs overprinted with the font being compared. */
.search-specimen,
.search-font {
  display: none;
}
[data-state="searching"] > .search-specimen {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 660px;
  margin-bottom: 20px;
}
[data-state="searching"] > .search-font {
  display: block;
  min-height: 1.4em;
  margin-bottom: 4px;
  color: var(--fs-ink);
  font-size: 22px;
  line-height: 1.4;
}
.glyph-cell {
  width: 112px;
  height: 112px;
  border: 1px solid #c9d0db;
  background:
    linear-gradient(#e1e5eb, #e1e5eb) 50% 0 / 1px 100% no-repeat,
    linear-gradient(#e1e5eb, #e1e5eb) 0 50% / 100% 1px no-repeat,
    var(--fs-paper);
}
#results-empty-title {
  color: var(--fs-ink);
  font-size: 16px;
}
#results-empty-description {
  max-width: 440px;
  color: var(--fs-muted);
  font-size: 13px;
}
progress {
  width: min(320px, 80%);
  height: 4px;
  margin-top: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 2px;
  background: #e1e5eb;
  accent-color: var(--fs-magenta);
  -webkit-appearance: none;
  appearance: none;
}
progress::-webkit-progress-bar {
  background: #e1e5eb;
}
progress::-webkit-progress-value {
  background: var(--fs-magenta);
  transition: width 0.3s var(--fs-ease);
}
progress::-moz-progress-bar {
  background: var(--fs-magenta);
}
#results-content {
  flex: 1;
  display: flex;
  min-height: 0;
}
.results-layout {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

/* The comparison: the chosen font, then each glyph overprinted on its proof cell. */
#comparison {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.comparison-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--fs-line);
  background: var(--fs-paper);
}
.comparison-title {
  min-width: 0;
}
.comparison-rank {
  color: var(--fs-magenta);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
#comparison-name {
  margin: 2px 0 4px;
  color: var(--fs-ink);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.comparison-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  color: var(--fs-muted);
  font-size: 12px;
}
#comparison-source,
.font-source {
  color: var(--fs-cyan-text);
  font-weight: 600;
  text-decoration: none;
}
#comparison-source:hover,
.font-source:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
#overlay {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 32px 24px;
  overflow: auto;
}
.comparison-header,
.comparison-footer {
  flex: none;
}
.comparison-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}
.glyph-figure {
  margin: 0;
}
#overlay .glyph-cell {
  display: block;
  width: 168px;
  height: 168px;
}
.glyph-figure figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px;
}
.glyph-character {
  color: var(--fs-ink);
  font-size: 15px;
  font-weight: 600;
}
.glyph-rotation {
  color: var(--fs-muted);
  font-size: 11px;
  font-weight: 400;
}
.glyph-score {
  color: var(--fs-muted);
  font-size: 12px;
  font-weight: 600;
}
.comparison-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 12px 24px;
  border-top: 1px solid var(--fs-line);
  background: var(--fs-paper);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--fs-text);
  font-size: 12px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend span::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.legend-original::before {
  background: var(--fs-cyan);
}
.legend-candidate::before {
  background: var(--fs-magenta);
}
.legend-overlap::before {
  background: var(--fs-ink);
}
.ranking-note {
  color: var(--fs-muted);
  font-size: 12px;
}

/* Candidates: each row is one button, set in its own face. */
.results-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--fs-line);
  background: var(--fs-paper);
}
.results-heading {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--fs-line-soft);
}
#results-title {
  color: var(--fs-ink);
  font-size: 14px;
}
#results {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}
.font-card {
  border-bottom: 1px solid var(--fs-line-soft);
}
.font-pick {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  justify-items: stretch;
  gap: 2px;
  width: 100%;
  min-height: 0;
  padding: 14px 20px 14px 20px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fs-text);
  text-align: left;
  white-space: normal;
}
.font-pick:hover:not(:disabled) {
  border: 0;
  background: #f7f8fa;
}
.font-pick::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--fs-magenta);
  transform: scaleY(0);
  transition: transform 0.25s var(--fs-ease);
}
.font-pick[aria-pressed="true"],
.font-pick[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--fs-magenta-tint);
}
.font-pick[aria-pressed="true"]::before {
  transform: scaleY(1);
}
.font-pick-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.rank {
  color: var(--fs-muted);
  font-size: 12px;
  font-weight: 700;
}
.font-pick[aria-pressed="true"] .rank {
  color: var(--fs-magenta);
}
.font-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--fs-ink);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.score {
  color: var(--fs-ink);
  font-size: 15px;
  font-weight: 700;
}
.font-sample {
  overflow: hidden;
  padding-left: 26px;
  color: var(--fs-ink);
  font-size: 30px;
  letter-spacing: 0.06em;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-pick-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 26px;
  color: var(--fs-muted);
  font-size: 12px;
}
.score-bar {
  position: relative;
  flex: 1;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: #e6e9ee;
}
.score-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--fs-ink);
  transform: scaleX(var(--score, 0));
  transform-origin: left;
}
.font-pick[aria-pressed="true"] .score-bar::after {
  background: var(--fs-magenta);
}
.results-footer {
  flex: none;
  padding: 12px 20px;
  border-top: 1px solid var(--fs-line-soft);
  color: var(--fs-muted);
  font-size: 12px;
}

/* Status: a transient note over the desk, always available to assistive technology. */
.toast {
  position: absolute;
  bottom: 76px;
  left: 50%;
  z-index: 10;
  max-width: min(560px, calc(100% - 32px));
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--fs-ink);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition:
    opacity 0.2s,
    transform 0.25s var(--fs-ease);
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
/* Clear of each step's bottom bar. */
#tool-workspace[data-current-phase="1"] .toast {
  bottom: 56px;
}
#tool-workspace[data-current-phase="3"] .toast {
  bottom: 64px;
}
.drag-over::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 20;
  border: 2px dashed var(--fs-magenta);
  border-radius: 6px;
  background: #c81e630d;
  pointer-events: none;
}

@media (max-width: 1199px) {
  #overlay .glyph-cell {
    width: 128px;
    height: 128px;
  }
}
/* Mid-size desks keep the shared header on one line; the purpose returns on wide screens. */
@media (min-width: 701px) and (max-width: 1139px) {
  body[data-tool="fontscope"] > header .brand-tagline {
    display: none;
  }
}
@media (max-width: 1000px) {
  .editing-layout {
    grid-template-columns: minmax(0, 1fr) 248px;
  }
  .results-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

/* Phones: the steps and the primary action share one bar; tools stay reachable
   under the canvas, and the properties sit below it. */
@media (max-width: 700px) {
  #tool-workspace .workspace {
    --work-height: max(560px, calc(100dvh - 100px));
  }
  .workbar {
    gap: 8px;
    padding: 6px 8px;
  }
  .phase-nav {
    gap: 0;
  }
  #labels-status { font-size: 11px; min-width: 72px; padding-inline: 2px; margin-right: auto; }
  .phase-nav button {
    gap: 5px;
    padding: 4px 5px;
    font-size: 12px;
  }
  .step-rule {
    width: 8px;
  }
  body[data-tool] .workbar button.primary {
    padding-inline: 12px;
  }
  .canvas-bar {
    gap: 2px;
    padding: 4px 4px 4px 8px;
  }
  .canvas-bar .ghost {
    padding-inline: 8px;
  }
  .bar-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #editor .canvas-bar {
    flex-wrap: wrap;
  }
  #image-meta,
  .crop-details {
    display: none;
  }
  #image-stage {
    padding: 12px;
  }
  .editing-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 38%);
  }
  .inspector {
    border-top: 1px solid var(--fs-line);
    border-left: 0;
  }
  .inspector-actions {
    grid-template-columns: 1fr 1fr;
  }
  #sample-board-stage {
    padding: 80px 16px 24px;
  }
  .tool-row {
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    padding: 6px 8px;
  }
  .canvas-hint {
    position: static;
    order: 2;
    max-width: 100%;
  }
  #tool-workspace[data-current-phase] .toast {
    bottom: auto;
    top: 104px;
    width: max-content;
    max-width: calc(100% - 24px);
  }
  #tool-workspace[data-current-phase="3"] .toast {
    top: auto;
    bottom: 12px;
  }
  .results-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .glyph-cell {
    width: 76px;
    height: 76px;
  }
  .comparison-header,
  #overlay,
  .comparison-footer {
    padding-inline: 16px;
  }
  .comparison-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding-block: 12px;
  }
  #comparison-name {
    font-size: 24px;
  }
  #overlay {
    flex: none;
    justify-content: flex-start;
    padding-block: 16px;
    overflow-x: auto;
  }
  .comparison-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 12px;
  }
  #overlay .glyph-cell {
    width: 96px;
    height: 96px;
  }
  .comparison-footer {
    padding-block: 8px;
  }
  .ranking-note {
    display: none;
  }
  .results-panel {
    border-top: 1px solid var(--fs-line);
    border-left: 0;
  }
  .results-heading {
    padding: 10px 16px 8px;
  }
  .font-pick {
    padding: 10px 16px;
  }
  .font-sample {
    font-size: 24px;
  }
}
/* Motion: short and purposeful. Steps fade in, results rise in order, and the start
   screen's two plates slide into register once. All of it stops for reduced motion. */
@keyframes fs-fade {
  from {
    opacity: 0;
  }
}
@keyframes fs-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes fs-grow {
  from {
    transform: scaleX(0);
  }
}
@keyframes fs-register {
  from {
    opacity: 0;
    transform: translate(22px, -16px);
  }
  55% {
    opacity: 0.92;
  }
}
#tool-workspace [data-phase]:not([hidden]) {
  animation: fs-fade 0.22s ease-out;
}
.specimen-original {
  animation: fs-fade 0.5s ease-out both;
}
.specimen-candidate {
  animation: fs-register 1.3s 0.2s var(--fs-ease) both;
}
.specimen-cell::after {
  animation: fs-fade 0.5s 1.1s ease-out both;
}
.font-card {
  animation: fs-rise 0.4s var(--fs-ease) both;
  animation-delay: calc(var(--order, 0) * 40ms);
}
.score-bar::after {
  animation: fs-grow 0.7s var(--fs-ease) both;
  animation-delay: calc(var(--order, 0) * 40ms + 150ms);
}
#overlay .glyph-figure {
  animation: fs-fade 0.2s ease-out both;
}
.font-pick:focus-visible {
  outline-offset: -3px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* Explanation: supplementary notes under the steps, grouped like the other canvas tools. */
.tool-about .fontscope-shortcuts {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 2fr;
  margin-top: 12px;
  font-size: 14px;
}
.fontscope-shortcuts dt,
.fontscope-shortcuts dd {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border);
}
.fontscope-shortcuts dt {
  padding-left: 0;
  color: var(--ui-text);
  font-weight: 600;
}

/* Export keeps the editing workspace intact beneath a dismissible proof. */
#glyph-export-dialog {
  width: min(900px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 1px solid #c3cad6;
  border-radius: 8px;
  padding: 20px;
  color: #1c2030;
  background: #fff;
}
#glyph-export-dialog::backdrop {
  background: #1c203066;
}
.glyph-export-header,
.glyph-export-options,
#glyph-downloads {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.glyph-export-header {
  justify-content: space-between;
}
.glyph-smoothing {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}
#glyph-export-dialog h2 {
  font-size: 18px;
  margin: 0;
}
#glyph-export-status {
  font-size: 13px;
  margin: 12px 0;
}
#glyph-proof {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
#glyph-proof figure {
  margin: 0;
  padding: 8px;
  border: 1px solid #dce1e8;
}
#glyph-proof canvas {
  width: 100%;
  height: 140px;
  object-fit: contain;
}
#glyph-proof figcaption {
  font-size: 12px;
  margin-top: 6px;
}
#glyph-duplicates {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.glyph-save {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid #c81e63;
  border-radius: 3px;
  color: #9c174d;
  text-decoration: none;
}
@media (max-width: 700px) {
  #tool-workspace[data-current-phase="1"] .phase-nav button:not([aria-current="step"]) .step-label,
  #tool-workspace[data-current-phase="3"] .phase-nav button:not([aria-current="step"]) .step-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .phase-action {
    gap: 6px;
  }
  [data-glyph-export],
  #search,
  #cancel,
  #samples-next {
    padding-inline: 8px;
    font-size: 12px;
  }
  #glyph-export-dialog {
    padding: 12px;
  }
}

.rotation-preference {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-block: 8px;
  color: var(--fs-text);
  font-size: 12px;
}
.rotation-preference input {
  flex: none;
  margin-top: 2px;
}
#retry-rotation {
  width: 100%;
  margin-block: 4px 8px;
  font-size: 12px;
  white-space: normal;
}
#rotation-search-status,
.rotation-settings {
  color: var(--fs-muted);
  font-size: 12px;
}
.rotation-settings {
  margin-bottom: 8px;
}

/* Keep the action row in a stable place on narrow workspaces. */
@media (max-width: 1000px) {
  .workbar { flex-wrap: wrap; gap: 4px; min-height: 100px; }
  .workbar-actions { flex-basis: 100%; min-height: 44px; }
  .phase-action { width: 100%; }
}
[data-glyph-export] {
  display: grid;
  grid-template-rows: 15px 15px;
  gap: 1px;
  height: 44px;
  min-height: 44px;
  padding: 5px 10px;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.35;
  color: #fff;
  background: #0864af;
  border-color: #0864af;
}
[data-glyph-export]:hover:not(:disabled) {
  color: #fff;
  background: #075493;
  border-color: #075493;
}
@media (max-width: 700px) {
  [data-glyph-export] { padding-inline: 6px; font-size: 11px; }
}
.floating-tools .sample-touch-menu {
  display: none;
}
@media (hover: none) and (pointer: coarse) {
  .floating-tools .sample-touch-menu {
    display: inline-flex;
  }
}
#sample-context-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 4px;
  min-width: 160px;
  border: 1px solid var(--fs-line);
  border-radius: 6px;
  background: var(--fs-paper);
  color: var(--fs-ink);
  box-shadow: 0 4px 16px #17203326;
}
#sample-context-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  text-align: left;
}

#samples-next, #search, #cancel, #image-next { min-height: 44px; }

.font-source {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin: 0 20px 8px;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

[data-glyph-export] span { line-height: 15px; }
