* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  padding: clamp(0.5rem, 3vw, 2rem);
}
.app-header {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}
h1 {
  text-align: center;
  color: #f0c040;
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  letter-spacing: 0.3px;
}
.header-rule {
  border: none;
  border-top: 1px solid #0f3460;
  margin: 0;
  width: 100%;
}
.app-header .controls { justify-content: center; }

.container { max-width: 1100px; margin: 0 auto; }

.site-disclaimer {
  background: #12192f;
  border: 1px solid #0f3460;
  border-left: 3px solid #f0c040;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #9aa0b5;
  text-align: center;
}
.site-disclaimer i { color: #f0c040; margin-right: 0.35rem; }

.panel {
  background: #16213e;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #0f3460;
}
.panel h2 { color: #f0c040; font-size: 1.1rem; margin-bottom: 1rem; }

.grid-wrapper { overflow-x: auto; margin-bottom: 1rem; }

/* One box model shared by both Xerox views. Every data cell is an .xbox of
   fixed size (dot + gap), so the table's footprint is identical whether we draw
   round dots (Dots view) or square grid cells (Grid view). border-spacing is 0;
   the gap lives *inside* each box as transparent padding around the round dot. */
:root {
  --xdot: clamp(28px, 4.5vw, 52px);
  --xgap: clamp(3px, 0.7vw, 8px);
  --xcell: calc(var(--xdot) + var(--xgap));
}
table.mic-grid {
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 auto;
}
.xbox {
  width: var(--xcell);
  height: var(--xcell);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
table.mic-grid th {
  font-size: clamp(0.55rem, 1.2vw, 0.75rem);
  color: #888;
  padding: 3px 4px;
  text-align: center;
  font-weight: normal;
}
table.mic-grid th.col-label {
  color: #f0c040;
  font-weight: bold;
  font-size: clamp(0.6rem, 1.4vw, 0.85rem);
}
table.mic-grid th.row-label {
  color: #f0c040;
  font-weight: bold;
  padding-right: clamp(4px, 1vw, 10px);
  font-size: clamp(0.6rem, 1.4vw, 0.85rem);
}
table.mic-grid td { padding: 0; }

.col-info {
  font-size: clamp(0.5rem, 1.1vw, 0.65rem);
  color: #f0c040;
  text-align: center;
  max-width: 64px;
  word-wrap: break-word;
  font-weight: bold;
}
.col-info.unused { color: #444; font-weight: normal; }

.dot {
  width: var(--xdot);
  height: var(--xdot);
  border-radius: 50%;
  border: 2px solid #335;
  background: #1a1a2e;
  cursor: pointer;
  transition: all 0.15s;
  display: block;
  margin: 0 auto;
}
.dot.active {
  background: #f0c040;
  border-color: #f0c040;
  box-shadow: 0 0 10px rgba(240, 192, 64, 0.5);
}
.dot:hover { border-color: #f0c040; }

.dot.parity-dot { border-width: 3px; }
.dot.parity-dot.active {
  background: #f0c040;
  border-color: #f0c040;
  box-shadow: 0 0 10px rgba(240, 192, 64, 0.5);
}
.dot.parity-dot.parity-good {
  border-color: #4caf50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}
.dot.parity-dot.parity-good.active {
  background: #f0c040;
  border-color: #4caf50;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}
.dot.parity-dot.parity-bad {
  border-color: #e94560;
  box-shadow: 0 0 8px rgba(233, 69, 96, 0.3);
}
.dot.parity-dot.parity-bad.active {
  background: #f0c040;
  border-color: #e94560;
  box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}
.dot.parity-dot:hover { border-color: #f0c040; }

.dot.unused-dot { opacity: 0.55; }

/* Grid view: same table, but each cell fills its box as a square grid cell
   (like the Python tool) instead of a round dot. The .xbox stays the same size,
   so the footprint is identical to the Dots view. Thick lines mark the parity
   row/column boundaries. */
.mic-grid--grid .xbox { padding: 0; }
.mic-grid--grid .dot {
  width: 100%;
  height: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  background: #12121e;
  opacity: 1;
  /* Thin cell lines as inset shadows (top + left) — no corner miter, and
     !important so they win over the dots-view parity glow rules in this view. */
  box-shadow: inset 1px 0 0 0 #2b2b44, inset 0 1px 0 0 #2b2b44 !important;
}
.mic-grid--grid .dot:hover { background: #23233a; }
.mic-grid--grid .dot.unused-dot { background: #0b0b12; }
/* Thick parity-boundary lines, white listed first so it stays solid through
   the corners and crossings. */
.mic-grid--grid .dot.xkt { box-shadow: inset 0 3px 0 0 #c8ccda, inset 1px 0 0 0 #2b2b44 !important; }
.mic-grid--grid .dot.xkl { box-shadow: inset 3px 0 0 0 #c8ccda, inset 0 1px 0 0 #2b2b44 !important; }
.mic-grid--grid .dot.xkt.xkl { box-shadow: inset 3px 0 0 0 #c8ccda, inset 0 3px 0 0 #c8ccda !important; }
/* Filled always wins the background, regardless of parity/unused classes. */
.mic-grid--grid .dot.active,
.mic-grid--grid .dot.active:hover { background: #f0c040; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.top-bar h2 { margin-bottom: 0; }

.controls { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }

button {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-primary { background: #f0c040; color: #1a1a2e; }
.btn-primary:hover { background: #d4a830; }
.btn-secondary { background: #0f3460; color: #e0e0e0; }
.btn-secondary:hover { background: #1a4a7a; }
.btn-danger { background: #e94560; color: #fff; }
.btn-danger:hover { background: #c73e54; }

input[type="file"] { display: none; }
.file-label {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  background: #0f3460;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
  display: inline-block;
}
.file-label:hover { background: #1a4a7a; }

/* Decoded info bar below grid */
.decoded-bar {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: baseline;
  padding: 0.75rem 1rem;
  background: #0f3460;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  min-height: 2.5rem;
}
.decoded-field { display: flex; align-items: baseline; gap: 0.4rem; }
.decoded-label { font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
.decoded-value { font-size: 1.1rem; font-weight: bold; color: #f0c040; }
.decoded-value .invalid { color: #e94560; }
.ref-val { font-family: monospace; color: #f0c040; white-space: nowrap; }
.ref-val .invalid { color: #e94560; }
.ref-arrow, .ref-note { color: #888; }

/* Konica Minolta: sample-file dropdown + its metadata line. */
.konica-select {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid #1a4a7a;
  font-size: 0.9rem;
  cursor: pointer;
}
/* Reserved-height status line (no layout shift when text appears/clears). */
.konica-status-line {
  min-height: 1.15rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #888;
}
.ksample-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: #aaa;
}
.ksample-meta:empty { display: none; }
.ksample-key { color: #f0c040; margin-right: 0.25rem; }

/* Konica Minolta: Old/New code toggle. */
.konica-mode {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.konica-mode-label { color: #888; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
.konica-toggle {
  display: inline-flex;
  border: 1px solid #0f3460;
  border-radius: 8px;
  overflow: hidden;
}
.konica-toggle-btn {
  padding: 0.4rem 1.1rem;
  background: #0f3460;
  color: #e0e0e0;
  border: none;
  border-radius: 0;
  font-size: 0.9rem;
}
.konica-toggle-btn.active { background: #f0c040; color: #1a1a2e; }
.konica-toggle-btn:not(.active):hover { background: #1a4a7a; }
.konica-mode-hint { font-size: 0.8rem; }
.konica-view-row { margin: 0.25rem 0 0.75rem; }

/* Konica Minolta: one real 16x24 dot grid with block rectangles drawn on top. */
.konica-help { color: #888; font-size: 0.85rem; margin-bottom: 1rem; }
.konica-board-wrap { padding: 8px 4px 6px; }
.konica-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  grid-template-rows: repeat(16, 1fr);
  gap: 3px;
  place-items: center;
  width: 100%;
  aspect-ratio: 24 / 16; /* keep cells square so dots stay round */
}
.kdot {
  width: 68%;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #2a2a44;
  background: #1a1a2e;
  cursor: pointer;
  transition: all 0.12s;
}
.kdot:hover { border-color: #f0c040; }
.kdot.active { background: #f0c040; border-color: #f0c040; box-shadow: 0 0 6px rgba(240,192,64,0.55); }
/* Locked registration marker — always colored yellow, not clickable. */
.kdot-marker {
  background: #f5d000;
  border-color: #f5d000;
  box-shadow: 0 0 6px rgba(245,208,0,0.6);
  cursor: default;
}
/* Unfillable positions — same size as real dots but with a dotted outline. */
.kdot-empty {
  background: transparent;
  border-style: dotted;
  border-color: #4a4a6a;
  cursor: default;
}
.kdot-empty:hover { border-color: #4a4a6a; }

/* Grid view: a tight square-cell grid (like the Python tool) with thin cell
   lines and thick lines outlining each block. Overrides the dot-board layout. */
.konica-board.konica-board--grid {
  gap: 0;
  place-items: stretch;
}
.kcell {
  width: 100%;
  height: 100%;
  padding: 0;
  background: #14142400;
  box-sizing: border-box;
  border-radius: 0;   /* fillable cells are <button>s; kill the global 6px round */
  /* Thin cell lines as inset shadows (top + left). Shadows stack without the
     diagonal miter that borders draw at corners, so lines join cleanly. */
  box-shadow: inset 1px 0 0 0 #2b2b44, inset 0 1px 0 0 #2b2b44;
}
/* Same grid coloring as the Xerox grid: normal fillable cells sit a shade
   above the board, filled cells go yellow. */
.kcell-fill { background: #12121e; cursor: pointer; }
.kcell-fill:hover { background: #23233a; }
.kcell-fill.filled { background: #f0c040; }
.kcell-fill.filled:hover { background: #f0c040; }
/* Off-block cells can't hold a dot — same "unused" look as the Xerox grid,
   here meaning "can't use this position". */
.kcell-off { background: #0b0b12; cursor: default; }
/* Fixed thick grid lines (above certain rows / left of certain columns). The
   thick white line is listed first so it paints on top of the thin dark line,
   staying solid and unbroken through every corner and crossing. */
.kcell.kt { box-shadow: inset 0 3px 0 0 #c8ccda, inset 1px 0 0 0 #2b2b44; }
.kcell.kl { box-shadow: inset 3px 0 0 0 #c8ccda, inset 0 1px 0 0 #2b2b44; }
.kcell.kt.kl { box-shadow: inset 3px 0 0 0 #c8ccda, inset 0 3px 0 0 #c8ccda; }

/* Aesthetic overlay: rectangles stretch across their grid tracks, clicks pass through. */
.krect {
  place-self: stretch;
  position: relative;
  pointer-events: none;
  border: 2px solid #3a3a5c;
  border-radius: 5px;
  z-index: 2;
}
/* Field-category colors, shared by board rectangles, mini-blocks and legend
   chips. New-code fields: serial/brand/region/submodel/batchnum/checksum.
   Old-code fields: model/time/parity. Both: constant/spacer. */
.krect-serial,   .kblock.kblock-serial,   .kscol-serial   { --kcat: #e6a94d; }
.krect-brand,    .kblock.kblock-brand,    .kscol-brand    { --kcat: #b98ce0; }
.krect-region,   .kblock.kblock-region,   .kscol-region   { --kcat: #4fb8ac; }
.krect-submodel, .kblock.kblock-submodel, .kscol-submodel { --kcat: #e086b0; }
.krect-batchnum, .kblock.kblock-batchnum, .kscol-batchnum { --kcat: #6cc06c; }
.krect-checksum, .kblock.kblock-checksum { --kcat: #e0705a; }
.krect-model,    .kblock.kblock-model    { --kcat: #e08a5a; }
.krect-time,     .kblock.kblock-time     { --kcat: #5aa9e0; }
.krect-parity,   .kblock.kblock-parity   { --kcat: #9a8ce6; }
.krect-constant, .kblock.kblock-constant { --kcat: #8a92a0; }
.krect-spacer,   .kblock.kblock-spacer   { --kcat: #565a6e; }
/* Both the rectangle border and the box-ID number take the field color. */
.krect-serial, .krect-brand, .krect-region, .krect-submodel, .krect-batchnum,
.krect-checksum, .krect-model, .krect-time, .krect-parity, .krect-constant, .krect-spacer,
.kblock.kblock-serial, .kblock.kblock-brand, .kblock.kblock-region, .kblock.kblock-submodel,
.kblock.kblock-batchnum, .kblock.kblock-checksum, .kblock.kblock-model, .kblock.kblock-time,
.kblock.kblock-parity, .kblock.kblock-constant, .kblock.kblock-spacer { border-color: var(--kcat); }
.kblock[class*="kblock-"] .kblock-id { color: var(--kcat, #888); }

.kchip.kfield-serial   { border-color: #e6a94d; color: #e6a94d; }
.kchip.kfield-brand    { border-color: #b98ce0; color: #b98ce0; }
.kchip.kfield-region   { border-color: #4fb8ac; color: #4fb8ac; }
.kchip.kfield-submodel { border-color: #e086b0; color: #e086b0; }
.kchip.kfield-batchnum { border-color: #6cc06c; color: #6cc06c; }
.kchip.kfield-checksum { border-color: #e0705a; color: #e0705a; }
.kchip.kfield-model    { border-color: #e08a5a; color: #e08a5a; }
.kchip.kfield-time     { border-color: #5aa9e0; color: #5aa9e0; }
.kchip.kfield-parity   { border-color: #9a8ce6; color: #9a8ce6; }
.kchip.kfield-constant { border-color: #8a92a0; color: #9aa3b2; }
.kchip.kfield-spacer   { border-color: #565a6e; color: #7a7f96; }

.konica-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  margin-top: 0.75rem;
}

.krect-label {
  position: absolute;
  top: -9px;
  left: -1px;
  padding: 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  color: var(--kcat, #888);
  background: #16213e;
}

.kchip {
  display: inline-block;
  padding: 0.1em 0.5em;
  border-radius: 4px;
  border: 1px solid;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  color: #e0e0e0;
  background: transparent;
  cursor: pointer;
  transition: opacity 0.12s;
}
.kchip:hover { opacity: 0.8; }
/* Toggled off: color removed, chip shown as a muted dashed outline. */
.kchip.kchip-off {
  border-style: dashed;
  border-color: #3a3a5c;
  color: #666;
}

/* Read-only "blocks by field" view: the 30 blocks grouped into decoded fields. */
.konica-blocks {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* The full serial number on one row, field by field, in serial order. */
.kserial-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.4rem;
  padding: 0.6rem 0.5rem 0.5rem;
  border: 1px solid #26264a;
  border-radius: 6px;
  background: #141428;
}
.kscol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  padding: 0 0.35rem;
  border-left: 3px solid var(--kcat, #3a3a5c);
}
.kscol:first-child { border-left: none; }
.kscol-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--kcat, #888);
  white-space: nowrap;
}
.kscol-boxes { display: flex; gap: 5px; margin-top: auto; }
.kscol-value {
  margin-top: 0.1rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--kcat, #f0c040);
  white-space: nowrap;
}
.kscol-meaning {
  font-size: 0.66rem;
  line-height: 1.25;
  color: #9aa3b2;
  text-align: center;
  max-width: 13ch;
  min-height: 1.65rem;
}
.kscol-meaning.empty::before { content: "\2014"; color: #4a4f63; }

/* One decoded field: a header (name + resolved value) over its parts. */
.kfield {
  border: 1px solid #26264a;
  border-left: 3px solid #3a3a5c;
  border-radius: 6px;
  padding: 0.5rem 0.7rem 0.55rem;
  background: #141428;
}
.kfield-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.kfield-title { font-size: 0.85rem; font-weight: 600; color: #e6e6ee; }
.kfield-result {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: #f0c040;
  text-align: right;
}
.kfield-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.15rem;
  align-items: flex-start;
}
/* A part = the boxes that combine into one value, plus its translation. */
.kpart { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kpart-boxes { display: flex; gap: 5px; }
.kpart-conv {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: #cfd3e0;
  white-space: nowrap;
}
.kconv-key { color: #9aa3b2; }
.kconv-out { color: #f0c040; font-weight: 700; }
.kconv-split { color: #7f8497; }
.kconv-inc { color: #5a5f74; }
.kpart-label {
  font-size: 0.6rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #7f8497;
}
.kfield-note {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: #7a7f96;
}

/* Warning note: probably decoding with the wrong scheme (e.g. a new-code
   pattern shown under the old decoder). */
.kfield-warn {
  margin: 0.5rem 0;
  padding: 0.45rem 0.6rem;
  background: #2a1e12;
  border: 1px solid #5a4020;
  border-left: 3px solid #f0c040;
  border-radius: 4px;
  color: #d8b878;
  font-size: 0.78rem;
}

/* Field accent colors, matching the legend / board rectangles. */
.kfield-box-serial   { border-left-color: #e6a94d; }
.kfield-box-brand    { border-left-color: #b98ce0; }
.kfield-box-region   { border-left-color: #4fb8ac; }
.kfield-box-submodel { border-left-color: #e086b0; }
.kfield-box-batchnum { border-left-color: #6cc06c; }
.kfield-box-checksum { border-left-color: #e0705a; }
.kfield-box-model    { border-left-color: #e08a5a; }
.kfield-box-time     { border-left-color: #5aa9e0; }
.kfield-box-parity   { border-left-color: #9a8ce6; }
.kfield-box-constant { border-left-color: #8a92a0; }
.kfield-box-spacer   { border-left-color: #565a6e; }
.kblock {
  border: 1px solid #3a3a5c;
  border-radius: 5px;
  padding: 5px 4px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.kblock-id {
  font-size: 0.95rem;
  font-weight: 700;
  color: #888;
  line-height: 1;
}
.kblock-cells {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
}
.kblock-cell {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #555577;
  background: #000000;
}
.kblock-cell.filled {
  background: #f0c040;
  border-color: #f0c040;
  box-shadow: 0 0 4px rgba(240, 192, 64, 0.55);
}
.kblock-digit {
  font-size: 0.95rem;
  font-weight: bold;
  color: #f0c040;
  line-height: 1;
}
.kblock-digit.empty { color: #555; }

.konica-subhead { color: #f0c040; font-size: 0.95rem; margin: 1rem 0 0.5rem; }
.konica-models { list-style: none; padding: 0; }
.konica-models li { padding: 0.15rem 0; color: #e0e0e0; }
.konica-models li.muted { color: #888; }
.konica-note { font-size: 0.8rem; margin-bottom: 0.75rem; }
.muted { color: #888; }
#konica-results code { color: #f0c040; }

.parity-live {
  font-size: 0.85rem;
  min-height: 1.2em;
}
.parity-ok { color: #4caf50; }
.parity-err { color: #e94560; }

/* Checksum (Parity) rows: summed boxes (full mini-blocks) = sum, mod 6 = x,
   then the actual check box, then the pass/fail mark. */
.kck-item { padding: 0.5rem 0 !important; }
.kck-label {
  display: block;
  color: #8a93b5;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}
.kck-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.kck-sum {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}
.kck-op { color: #8a93b5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.kck-total { font-weight: 700; color: #f0c040; font-size: 1.05rem; }
.kck-exp { color: #e0e0e0; font-size: 0.9rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.kck-exp b { color: #f0c040; }
.kck-arrow { color: #8a93b5; }

/* Constant boxes, shown as a check: each mini-block with its pass/fail mark. */
.kconst {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
/* Expected value + pass/fail mark, sitting under each constant box. */
.kconst-exp {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: #8a93b5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.kconst-note {
  font-size: 0.8rem;
  line-height: 1.4;
  padding-top: 0.2rem !important;
}

/* Column reference table */
table.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.ref-table th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  color: #f0c040;
  border-bottom: 1px solid #0f3460;
  font-weight: 600;
}
table.ref-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #0a1e3d;
}
table.ref-table td:first-child {
  color: #f0c040;
  font-weight: bold;
  white-space: nowrap;
}
table.ref-table tr.unused-row td { color: #555; }

/* Top-level decoder selector: a centered segmented switch. */
.decoder-switch {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 2rem;
  border: 1px solid #0f3460;
  border-radius: 10px;
  overflow: hidden;
  flex-wrap: wrap;
}
.decoder-btn {
  padding: 0.6rem 1.6rem;
  border: none;
  border-radius: 0;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 1rem;
  font-weight: 600;
}
.decoder-btn.active { background: #f0c040; color: #1a1a2e; }
.decoder-btn:not(.active):hover { background: #1a4a7a; }

/* Tab bar — now used for the Dots/Grid (Blocks/Grid) view tabs on each page. */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid #0f3460;
}
.tab-btn {
  padding: 0.6rem 1.5rem;
  border: 1px solid #1a4a7a;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  margin-right: 0.25rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  background: #0f3460;
  color: #e0e0e0;
  transition: all 0.15s;
}
.tab-btn.active {
  background: #f0c040;
  color: #1a1a2e;
  border-color: #f0c040;
}
.tab-btn:not(.active):hover { background: #1a4a7a; }
.tab-btn.tab-right { margin-left: auto; }

/* Calendar styles */
.cal-year-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.cal-year-header .year-label {
  font-size: 1.3rem;
  font-weight: 700;
  color: #f0c040;
  min-width: 80px;
  text-align: center;
}
.cal-year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.cal-month-card {
  background: #0f3460;
  border-radius: 8px;
  padding: 0.75rem;
}
.cal-month-title {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #f0c040;
  margin-bottom: 0.5rem;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-grid .cal-dow {
  text-align: center;
  font-size: 0.6rem;
  color: #888;
  padding: 0.15rem 0;
  font-weight: 600;
}
.cal-grid .cal-day {
  text-align: center;
  padding: 0.3rem 0.1rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #555;
  min-height: 24px;
}
.cal-grid .cal-day.has-prints {
  background: rgba(240, 192, 64, 0.25);
  color: #e0e0e0;
  cursor: pointer;
  font-weight: 600;
}
.cal-grid .cal-day.has-prints:hover {
  background: rgba(240, 192, 64, 0.4);
}
.cal-grid .cal-day.selected {
  background: #f0c040;
  color: #1a1a2e;
}
.cal-status {
  font-size: 0.85rem;
  color: #888;
  margin-top: 0.75rem;
}
.cal-status .count { color: #f0c040; font-weight: 600; }
.cal-status .errors { color: #e94560; }

/* --- Decode cypher help button + modal ---------------------------------- */
.h2-help { display: flex; align-items: center; gap: 0.5rem; }
.help-btn {
  padding: 0; width: 1.5rem; height: 1.5rem; line-height: 1; border-radius: 50%;
  background: transparent; color: #6f7aa0; border: none; cursor: pointer;
  font-size: 1rem; transition: color 0.15s, transform 0.15s;
}
.help-btn:hover { color: #f0c040; transform: scale(1.1); }
.help-btn:focus-visible { outline: 2px solid #f0c040; outline-offset: 2px; }

.kmodal { position: fixed; inset: 0; z-index: 1000; display: flex;
  align-items: center; justify-content: center; padding: 1.25rem; }
.kmodal[hidden] { display: none; }
.kmodal-backdrop { position: absolute; inset: 0; background: rgba(8, 8, 18, 0.72);
  backdrop-filter: blur(2px); }
.kmodal-box {
  position: relative; width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  background: #16213e; border: 1px solid #0f3460; border-radius: 14px;
  padding: 1.5rem; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  animation: kmodal-in 0.16s ease-out;
}
@keyframes kmodal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .kmodal-box { animation: none; } }
.kmodal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.kmodal-head h3 { margin: 0; color: #f0c040; font-size: 1.1rem; }
.kmodal-close {
  padding: 0; width: 2rem; height: 2rem; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: #9aa0b8; font-size: 1.05rem; transition: background 0.15s, color 0.15s;
}
.kmodal-close:hover { background: #0f3460; color: #fff; }
.kmodal-close:focus-visible { outline: 2px solid #f0c040; outline-offset: 1px; }
.kmodal-sub { margin: 0.5rem 0 1.1rem; color: #b6bcd0; font-size: 0.86rem; line-height: 1.5; }
.kmodal-sub em { color: #f0c040; font-style: normal; }

.kcy-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.kcy-cell {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 0.4rem 0.2rem; border: 1px solid #0f3460; border-radius: 8px;
  background: #12121e; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
.kcy-key { font-size: 0.85rem; font-weight: 600; color: #8a93b5; font-variant-numeric: tabular-nums; }
.kcy-char { font-size: 1.4rem; font-weight: 700; }
.kcy-cell.letter .kcy-char { color: #e6a94d; }
.kcy-cell.digit  .kcy-char { color: #4fb8ac; }

.kcy-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-top: 1.1rem;
  font-size: 0.76rem; color: #9aa0b8; }
.kcy-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.kcy-swatch { width: 0.7rem; height: 0.7rem; border-radius: 3px; }
.kcy-swatch.letter { background: #e6a94d; }
.kcy-swatch.digit  { background: #4fb8ac; }

.kcy-batch { margin-top: 1.1rem; padding-top: 0.9rem; border-top: 1px solid #0f3460; }
.kcy-batch h4 { font-size: 0.82rem; color: #6cc06c; letter-spacing: 0.02em; margin-bottom: 0.35rem; }
.kcy-batch .kmodal-sub { margin-bottom: 0.7rem; }
.kcy-bn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.kcy-cell.bn { padding: 0.3rem 0.45rem; min-width: 2.1rem; }
.kcy-cell.bn .kcy-char { font-size: 1.1rem; color: #6cc06c; }
.kcy-bn-conv {
  margin-left: 0.4rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem; color: #9aa0b8;
}
.kcy-bn-conv b { color: #6cc06c; }
