@font-face { font-family: "Caveat"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/caveat-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/caveat-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Kalam"; font-style: normal; font-weight: 300; font-display: swap; src: url("fonts/kalam-latin-300-normal.woff2") format("woff2"); }
@font-face { font-family: "Kalam"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/kalam-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Kalam"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/kalam-latin-700-normal.woff2") format("woff2"); }
/* Layout: a zoological field notebook. Squared paper (true 5 mm squares) with a red margin, a clear school ruler above the
   specimen and a clear inch ruler below, the specimen's index card clipped on with its size on a Post-it, then coloured
   index tabs to filter by group and a shelf of taped index cards, each stamped with its group. One deliberate light look. */
:root {
  --paper: #f5f3ec;
  --grid: #dfe4dc;
  --margin: #d98c7a;
  --card: #fffdf7;
  --ink: #2b2a26;
  --muted: #6f6a5c;
  --accent: #ad5834;      /* red pen: highlights, item A (4.9:1 on the cards) */
  --second: #2f6b4f;      /* green pen: item B */
  --postit: #f6df6e;
  --wood: rgba(226, 238, 236, 0.42);   /* clear acetate school ruler */
  --wood-edge: #9fb7b4;
  --wood-ink: #26302f;
  --clip: #8d9496;
  --font-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --font-body: "Kalam", "Segoe Print", "Comic Neue", cursive;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;  /* plain and quick to scan, for long pick lists */
  --font-latin: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --cell: 19px;           /* 5 mm at the current scale, set by script */
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; color: var(--ink); font-family: var(--font-body); font-size: 15px; display: flex; flex-direction: column; overflow: hidden;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell); }
body::after { content: ""; position: fixed; top: 0; bottom: 0; left: max(44px, calc(env(safe-area-inset-left, 0px) + 30px)); width: 2px; background: var(--margin); opacity: 0.6; pointer-events: none; z-index: 0; }
.gutter { padding-left: max(60px, calc(env(safe-area-inset-left, 0px) + 46px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px dashed var(--accent); outline-offset: 3px; }

/* header */
.top { position: relative; z-index: 3; display: flex; align-items: center; gap: 8px 22px; flex-wrap: wrap; padding-block: 10px 4px; }
.brand { position: relative; margin: 0 auto 0 0; font-family: var(--font-hand); font-weight: 700; font-size: 2.6rem; line-height: 1; }
.brand .bname { position: relative; display: inline-block; }
.brand svg { position: absolute; left: -4px; bottom: -9px; width: calc(100% + 8px); height: 12px; }
.brand small { font-family: var(--font-body); font-weight: 300; font-size: 0.95rem; color: var(--muted); margin-left: 14px; }
.tabs { display: flex; gap: 6px; }
.tabs button { position: relative; border: 0; background: transparent; padding: 4px 12px; font-family: var(--font-hand); font-size: 1.6rem; line-height: 1.1; color: var(--muted); min-height: 44px; }
.tabs button svg { position: absolute; inset: -2px -10px; width: calc(100% + 20px); height: calc(100% + 4px); opacity: 0; pointer-events: none; }
.tabs button[aria-pressed="true"] { color: var(--ink); }
.tabs button[aria-pressed="true"] svg { opacity: 1; }
.calbtn { display: flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 6px 2px; font-size: 0.92rem; color: var(--muted); min-height: 44px; }
.calbtn:hover { color: var(--ink); }
.calbtn:not(.ok) { color: var(--accent); font-weight: 700; font-size: 0.98rem; }
.calbtn:not(.ok) #calstatus { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.calbtn:not(.ok) .dot { background: color-mix(in srgb, var(--accent) 22%, transparent); animation: calpulse 2.4s ease-in-out 3; }
@keyframes calpulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent); } }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); flex: none; }
.calbtn.ok .dot { border-color: var(--second); background: color-mix(in srgb, var(--second) 25%, transparent); }

/* stage */
.stage { position: relative; z-index: 1; flex: 1 1 auto; min-height: 180px; overflow: hidden; }
.ruler { position: absolute; height: 56px; pointer-events: none; z-index: 3; left: max(52px, calc(env(safe-area-inset-left, 0px) + 38px)); right: 10px; border-radius: 3px; }
.ruler.cm { top: 6px; border-radius: 9px; border: 1.2px solid var(--wood-edge); --tick: var(--wood-ink); --muted: var(--wood-ink);
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.78), rgba(232, 241, 240, 0.38) 18%, rgba(214, 230, 228, 0.3) 82%, rgba(185, 207, 204, 0.55));
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.95), inset 0 -1px 0 rgba(120, 150, 147, 0.25), 0 3px 8px rgba(40, 60, 58, 0.12);
  -webkit-backdrop-filter: blur(0.6px); backdrop-filter: blur(0.6px); }
.ruler.cm::after { content: ""; position: absolute; right: 13px; top: 50%; width: 13px; height: 13px; margin-top: -7.5px; border-radius: 50%;
  background: var(--paper); border: 1.2px solid var(--wood-edge); box-shadow: inset 0 1px 2px rgba(40, 60, 58, 0.2); }
.ruler svg { display: block; width: 100%; height: 100%; }
.pan { position: absolute; inset: 68px 0 0 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: none; }
.pan::-webkit-scrollbar { display: none; }
.board { position: relative; min-width: 100%; min-height: 100%; width: max-content; display: flex; }
.board > .row, .board > .overlay { margin: auto; }
.specimen { position: relative; flex: none; }
.specimen img { position: absolute; left: 0; top: 0; display: block; max-width: none; user-select: none; -webkit-user-drag: none; filter: drop-shadow(0 6px 5px rgba(40, 30, 10, 0.22)); }
.specimen svg.dim { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.specimen .ph { position: absolute; inset: 0; }
.row { display: flex; align-items: flex-end; }
.overlay { position: relative; }
.overlay .specimen { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.overlay .specimen.b img { opacity: 0.62; }
.hint { position: absolute; z-index: 4; left: max(60px, calc(env(safe-area-inset-left, 0px) + 46px)); transform: rotate(-1deg); bottom: 8px; max-width: calc(100% - 260px); white-space: normal; line-height: 1.05; font-family: var(--font-hand); font-size: 1.3rem; color: var(--accent); pointer-events: none; }
.tiny-ring { position: absolute; border: 2px solid var(--accent); border-radius: 50%; pointer-events: none; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 4; width: 52px; min-height: 52px; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; padding: 0; }
.nav small { font-family: var(--font-hand); font-size: 1.05rem; line-height: 1; }
.nav:disabled { visibility: hidden; }
.nav:hover { color: var(--accent); }
.nav.prev { left: max(56px, calc(env(safe-area-inset-left, 0px) + 42px)); }
.nav.next { right: max(8px, env(safe-area-inset-right, 0px)); }
.nav svg { width: 30px; height: 30px; }

/* dock */
.dock { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px 22px; padding-block: 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
.dockmain { min-width: 0; }
.dockside { min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.dock .tray { grid-column: 1 / -1; }
.dock.folded .tray { display: none; }
#i-fold svg { transition: transform 0.2s; }
.dock.folded #i-fold svg { transform: rotate(180deg); }
@media (min-width: 1000px) {
  .dock { grid-template-columns: minmax(0, 600px) minmax(0, 1fr); align-items: end; }
}
.labelrow { display: flex; align-items: flex-start; gap: 18px; }
.idcard { position: relative; flex: 0 1 600px; min-width: 0; background: var(--card); box-shadow: 0 6px 16px rgba(40, 30, 10, 0.16); padding: 12px 18px 10px; transform: rotate(-0.6deg); }
/* an index card: name above a red rule, the note on blue lines, then the measurement as a filed detail */
.idcard .fact { --lh: 26px; margin: 2px -18px 2px; padding: 0 18px 0 18px; font-size: 0.97rem; line-height: var(--lh); font-weight: 400; color: #33312b; max-width: none;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--lh) - 1px), rgba(118, 155, 196, 0.42) calc(var(--lh) - 1px), rgba(118, 155, 196, 0.42) var(--lh));
  background-position: 0 -3px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.idcard h2 { margin: 0; font-family: var(--font-hand); font-weight: 700; font-size: 2.3rem; line-height: 1; padding-right: 110px; }
.idcard .sci { display: block; margin: 3px -18px 0; padding: 0 18px 5px; font-family: var(--font-latin); font-style: italic; font-size: 1rem; color: #6a4630; letter-spacing: 0.01em;
  border-bottom: 1.5px solid rgba(217, 140, 122, 0.85); }
.stamp { position: absolute; right: 60px; top: 12px; transform: rotate(-9deg); font-family: var(--font-body); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--g, var(--muted)); border: 2px solid var(--g, var(--muted)); border-radius: 6px; padding: 1px 7px; white-space: nowrap; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--g, var(--muted)) 35%, transparent); }
.sub { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: baseline; font-size: 0.92rem; color: #3f3c35; margin-top: 6px; }
.sub .mlabel { font-family: var(--font-body); font-weight: 700; font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-right: 4px; vertical-align: 1px; }
.sub button { border: 0; background: transparent; padding: 0; font-family: var(--font-hand); font-size: 1.3rem; color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.about { position: absolute; z-index: 12; left: 24px; bottom: calc(100% - 4px); width: min(420px, calc(100vw - 60px)); max-height: 50vh; overflow: auto; background: var(--postit); box-shadow: 2px 10px 22px rgba(60, 50, 10, 0.25); transform: rotate(-1.5deg); padding: 16px 18px 12px; font-size: 0.88rem; color: #3f3a22; line-height: 1.45; }
.about::before { content: ""; position: absolute; left: 50%; top: -10px; width: 70px; height: 20px; margin-left: -35px; background: rgba(255, 255, 255, 0.55); transform: rotate(-3deg); }
.about h4 { margin: 0 0 4px; font-family: var(--font-hand); font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.about .x { position: absolute; right: 6px; top: 4px; border: 0; background: transparent; font-size: 1.2rem; color: #6f6a5c; width: 36px; height: 36px; }
.about p { margin: 0 0 4px; }
.about .fact { color: var(--ink); font-weight: 300; }
.about ul { margin: 0; padding-left: 18px; }
.fixlink, .linkish { border: 0; background: transparent; padding: 4px 0; margin-top: 6px; font-family: var(--font-hand); font-size: 1.25rem; color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.about .fulltext { display: none; }
.rec { color: var(--accent); }
a { color: var(--ink); text-decoration-color: var(--accent); text-underline-offset: 2px; }

/* shelf header: count, active filter, and three icon tools */
.shelfhead { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; position: relative; }
.shelfhead .sum { font-family: var(--font-hand); font-size: 1.35rem; color: var(--muted); }
.shelfhead .sum button { border: 0; background: transparent; padding: 0 4px; font: inherit; color: var(--accent); }
.icons { margin-left: auto; display: flex; gap: 2px; }
.ico { width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink); display: grid; place-items: center; border-radius: 50%; position: relative; }
.ico svg { width: 26px; height: 26px; }
.ico:hover, .ico[aria-expanded="true"] { color: var(--accent); }
.ico.on::after { content: ""; position: absolute; right: 8px; top: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.pop { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 10; width: min(300px, calc(100vw - 40px)); background: var(--card); box-shadow: 0 10px 26px rgba(40, 30, 10, 0.22); padding: 14px 16px; transform: rotate(-0.8deg); }
.pop h4 { margin: 0 0 6px; font-family: var(--font-hand); font-size: 1.5rem; font-weight: 700; }
.pop input[type="search"] { width: 100%; border: 0; border-bottom: 1.5px solid var(--muted); background: transparent; padding: 4px 2px; font-size: 1rem; font-family: var(--font-body); }
.opts { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.opts button { border: 0; background: transparent; padding: 4px 2px; font-size: 0.98rem; color: var(--ink); min-height: 32px; text-align: left; }
.opts button[aria-pressed="true"] { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.opts.grid { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.opts .gs { color: var(--g); border: 1.5px solid var(--g); border-radius: 5px; padding: 1px 8px; font-weight: 700; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; transform: rotate(-3deg); min-height: 30px; }
.resetall { margin-top: 10px; border: 0; background: transparent; padding: 4px 0; font-family: var(--font-hand); font-size: 1.25rem; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.opts .gs[aria-pressed="true"] { background: var(--g); color: #fff; text-decoration: none; }

.tray { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x proximity; padding: 8px 6px 10px; cursor: grab;
  scrollbar-width: auto; scrollbar-color: #7d776a rgba(111, 106, 92, 0.2); }
.tray::-webkit-scrollbar { height: 12px; }
.tray::-webkit-scrollbar-track { background: rgba(111, 106, 92, 0.2); border-radius: 6px; }
.tray::-webkit-scrollbar-thumb { background: #7d776a; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
.tray::-webkit-scrollbar-thumb:hover { background-color: var(--ink); }
.tray.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.tray.dragging .card { pointer-events: none; }
.traywrap { position: relative; grid-column: 1 / -1; min-width: 0; }
.dock.folded .traywrap { display: none; }
.trayarrow { position: absolute; z-index: 3; top: calc(50% - 26px); width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  background: var(--card); color: var(--accent); box-shadow: 0 3px 10px rgba(40, 30, 10, 0.25); transition: opacity 0.2s, color 0.2s; }
.trayarrow svg { width: 24px; height: 24px; }
.trayarrow.l { left: -6px; } .trayarrow.r { right: -6px; }
.trayarrow:disabled { color: #b9b4a8; box-shadow: 0 1px 4px rgba(40, 30, 10, 0.12); opacity: 0.55; cursor: default; }
.traywrap.noscroll .trayarrow { display: none; }
.traywrap::before, .traywrap::after { content: ""; position: absolute; top: 0; bottom: 14px; width: 46px; z-index: 2; pointer-events: none; }
.traywrap::before { left: -2px; background: linear-gradient(to right, var(--paper), transparent); }
.traywrap::after { right: -2px; background: linear-gradient(to left, var(--paper), transparent); }
.traywrap.noscroll::before, .traywrap.noscroll::after, .traywrap.atstart::before, .traywrap.atend::after { opacity: 0; }
.traywrap::before, .traywrap::after { transition: opacity 0.2s; }
.card.is-a { outline: 2.5px solid var(--accent); outline-offset: -5px; }
.card.is-b, .dock.cmpmode .card[aria-current="true"] { outline: 2.5px solid var(--second); outline-offset: -5px; }
.dock.cmpmode .shelfhead .sum::after { content: " · tap a card to change the green one"; font-size: 1.1rem; color: var(--second); }
.card { --g: var(--muted); position: relative; flex: 0 0 132px; width: 132px; min-width: 0; height: 112px; scroll-snap-align: start; border: 0; background: var(--card); box-shadow: 0 4px 10px rgba(40, 30, 10, 0.14); padding: 14px 9px 7px; text-align: left; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; transition: transform 0.15s; }
.card:nth-child(3n) { transform: rotate(-2deg); }
.card:nth-child(3n+1) { transform: rotate(1.5deg); }
.card:nth-child(3n+2) { transform: rotate(-0.5deg); }
.card:hover { transform: rotate(0) translateY(-3px); }
.card .cstamp { position: absolute; right: 6px; top: 12px; transform: rotate(-12deg); font-weight: 700; font-size: 0.55rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--g); border: 1.5px solid var(--g); border-radius: 4px; padding: 0 4px; background: var(--card); }
.card[aria-current="true"] { outline: 2px solid var(--accent); outline-offset: -5px; }
.card .thumb { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.card .thumb img { max-height: 42px; max-width: 100%; width: auto; height: auto; -webkit-user-drag: none; user-select: none; }
.card .thumb svg { width: 100%; height: 40px; }
.card b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; max-width: 100%; font-family: var(--font-hand); font-weight: 700; font-size: 1.15rem; line-height: 1; overflow: hidden; }
.card span.sz { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { font-family: var(--font-hand); font-size: 1.4rem; color: var(--muted); padding: 14px 4px; }

/* compare controls */
.cmp { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: center; background: var(--card); box-shadow: 0 6px 16px rgba(40, 30, 10, 0.14); padding: 4px 14px 6px; transform: rotate(-0.4deg); }
.back { flex: 0 0 auto; border: 0; background: transparent; padding: 0 6px 0 0; text-align: left; font-family: var(--font-hand); font-size: 1.3rem; white-space: nowrap; color: var(--accent); min-height: 36px; }
.back:hover { text-decoration: underline; text-underline-offset: 4px; }
.pick { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 180px; }
.pick i { width: 14px; height: 14px; border-radius: 50%; flex: none; }
#presets { flex: 1; min-width: 0; border: 0; border-bottom: 1.5px solid var(--muted); background: transparent; padding: 4px 2px; font-family: var(--font-hand); font-size: 1.25rem; border-radius: 0; }
.pickbtn { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; border: 0; border-bottom: 1.5px solid var(--muted); background: transparent; padding: 6px 2px 4px; min-height: 40px; text-align: left; font-family: var(--font-ui); }
.pickbtn:hover, .pickbtn[aria-expanded="true"] { border-bottom-color: var(--ink); }
.pickbtn .pname { font-weight: 600; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pickbtn .psize { color: var(--muted); font-size: 0.82rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pickbtn .caret { width: 18px; height: 18px; margin-left: auto; flex: none; align-self: center; color: var(--muted); }
.cmp { position: relative; }
.pop.picker { left: 0; right: auto; bottom: calc(100% + 8px); width: min(460px, calc(100vw - 40px)); max-height: min(64vh, 560px); display: flex; flex-direction: column; gap: 8px; transform: none; padding: 12px 12px 10px; font-family: var(--font-ui); }
.picker .phead { display: flex; align-items: center; justify-content: space-between; }
.picker h4 { margin: 0; font-size: 1.35rem; }
.picker.for-b h4 { color: var(--second); }
.picker:not(.for-b) h4 { color: var(--accent); }
.picker .x { border: 0; background: transparent; width: 36px; height: 36px; font-size: 1.3rem; color: var(--muted); }
.psearch { display: flex; align-items: center; gap: 8px; border: 1.5px solid #a39d8f; border-radius: 9px; padding: 4px 10px; background: #fff; }
.psearch:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(173, 88, 52, 0.15); }
.psearch svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.pop .psearch input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; padding: 6px 0; font-family: var(--font-ui); font-size: 1rem; color: var(--ink); }
.plist { overflow: auto; min-height: 120px; flex: 1 1 auto; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px; }
.pg { border-bottom: 1px solid #ebe7dc; }
.pgh { width: 100%; display: flex; align-items: center; gap: 9px; border: 0; background: transparent; padding: 9px 4px; font-family: var(--font-ui); font-weight: 650; font-size: 0.95rem; color: var(--g); text-align: left; min-height: 40px; }
.pgh:hover { background: color-mix(in srgb, var(--g) 7%, transparent); }
.pgdot { width: 10px; height: 10px; border-radius: 50%; background: var(--g); flex: none; }
.pgn { margin-left: auto; font-weight: 400; font-size: 0.82rem; color: var(--muted); }
.pgh svg { width: 18px; height: 18px; color: var(--muted); transition: transform 0.15s; flex: none; }
.pgh[aria-expanded="false"] svg { transform: rotate(-90deg); }
.pgl { padding: 0 0 6px; }
.pit { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; background: transparent; padding: 6px 8px 6px 23px; border-radius: 6px; text-align: left; font-family: var(--font-ui); font-size: 0.95rem; color: var(--ink); min-height: 40px; }
.pit:hover, .pit:focus-visible { background: rgba(173, 88, 52, 0.08); }
.picker.for-b .pit:hover, .picker.for-b .pit:focus-visible { background: rgba(47, 107, 79, 0.09); }
.pit[aria-current="true"] { background: rgba(173, 88, 52, 0.14); font-weight: 650; }
.picker.for-b .pit[aria-current="true"] { background: rgba(47, 107, 79, 0.15); }
.pit:disabled { opacity: 0.4; cursor: default; }
.pit .pn { min-width: 0; }
.pit .pn small { display: block; font-family: var(--font-latin); font-style: italic; font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.pit .pz { flex: none; color: var(--muted); font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.pnone { color: var(--muted); padding: 10px 4px; margin: 0; }
.ptip { margin: 0; font-size: 0.8rem; color: var(--muted); }
.swap { border: 0; background: transparent; color: var(--muted); width: 40px; height: 40px; padding: 0; font-size: 1.3rem; }
.swap:hover { color: var(--accent); }
.cmpbar { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; width: 100%; }
.ratio { flex: 1 1 100%; font-size: 0.86rem; color: var(--muted); line-height: 1.25; }
.ratio b { font-family: var(--font-hand); font-weight: 700; font-size: 1.4rem; color: var(--accent); margin-right: 4px; }
.ratio small { margin-left: 6px; font-size: 0.8rem; }
.tabs.small button { font-size: 1.25rem; min-height: 36px; padding: 2px 10px; }
#presets { flex: 0 1 220px; font-size: 1.15rem; color: var(--muted); }
.lu-strip { gap: 4px 14px; }
.lu-what { font-family: var(--font-hand); font-size: 1.35rem; }
.lu-strip .linkish { margin: 0; }

/* modal */
.field { display: flex; flex-direction: column; gap: 2px; font-size: 0.9rem; color: var(--muted); }
.field input, .field textarea { border: 0; border-bottom: 1.5px solid var(--muted); background: transparent; padding: 4px 2px; font-family: var(--font-body); font-size: 1rem; color: var(--ink); resize: vertical; }
.field input[readonly] { border-bottom-style: dashed; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(40, 35, 25, 0.45); display: grid; place-items: center; padding: 16px; }
.sheet { position: relative; width: min(540px, 100%); max-height: 100%; overflow: auto; background: var(--card); padding: 22px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.sheet h3 { margin: 0; font-family: var(--font-hand); font-weight: 700; font-size: 2.2rem; line-height: 1; }
.sheet p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.cardzone { display: grid; place-items: center; min-height: 120px; padding: 8px 0; overflow: hidden; }
#card, #checkshape { position: relative; }
#card svg, #checkshape svg { display: block; overflow: visible; }
.shapelabel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 0.78rem; color: var(--muted); white-space: nowrap; pointer-events: none; }
.srow { display: flex; gap: 8px; align-items: center; }
.srow input[type="range"] { flex: 1; accent-color: var(--accent); }
.step { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--muted); background: transparent; font-size: 1.2rem; padding: 0; }
.or { font-family: var(--font-hand); font-weight: 700; font-size: 1.7rem; line-height: 1; color: var(--ink); border-top: 1.5px dashed #cfcabd; padding-top: 12px; margin-top: 2px; }
.calwith { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.cwlabel { font-family: var(--font-hand); font-weight: 700; font-size: 1.4rem; margin-right: 2px; }
.cw { display: inline-flex; align-items: center; gap: 9px; border: 2px solid #b5ae9f; border-radius: 10px; background: #fff; padding: 7px 16px 7px 12px; min-height: 48px; font-size: 1.02rem; color: var(--muted); }
.cw svg { width: 30px; height: 24px; flex: none; }
.cw:hover { border-color: var(--ink); color: var(--ink); }
.cw[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, #fff); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent); }
.altrow { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 4px 10px; align-items: start; }
.altlabel { font-weight: 700; padding-top: 9px; }
.altbody { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.altbody .srow { flex-wrap: wrap; }
.altbody p { font-size: 0.84rem; }
#c-ruler[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, #fff); font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent); }
.actions .spacer { flex: 1; }
.btn.grey { background: #e9e6dd; border-color: #e9e6dd; color: var(--ink); }
.btn.grey:hover { border-color: #cfcabd; }
@media (max-width: 520px) { .altrow { grid-template-columns: 1fr; } .altlabel { padding-top: 0; } .actions .spacer { display: none; } .actions #reset-cal { margin-right: auto; } }
#diag { width: 90px; border: 0; border-bottom: 1.5px solid var(--muted); padding: 4px; background: transparent; }
.btn { border: 1.5px solid var(--ink); background: transparent; border-radius: 4px; padding: 6px 14px; font-weight: 400; min-height: 40px; }
.btn.primary { background: var(--ink); color: var(--card); }
.btn.quiet { border-color: transparent; color: var(--muted); }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.err { color: var(--accent); font-size: 0.85rem; }

/* setup tool */
.setup { position: fixed; inset: 0; z-index: 30; background: var(--paper); overflow: auto; padding-block: 18px; }
.setup h3 { font-family: var(--font-hand); font-weight: 700; font-size: 2.2rem; margin: 0 0 6px; }
.setup .canvasbox { position: relative; display: inline-block; max-width: 100%; background: var(--card); margin: 10px 0; cursor: crosshair; box-shadow: 0 4px 10px rgba(40, 30, 10, 0.12); }
.setup .canvasbox img { display: block; max-width: 100%; height: auto; }
.setup .canvasbox svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.setup textarea { width: 100%; max-width: 760px; height: 110px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; border: 1px solid var(--grid); background: var(--card); padding: 10px; }
.setup .srow { flex-wrap: wrap; }

/* stage extras: scale stamp, tools, measuring, first-visit note */
.scalestamp { position: relative; align-self: center; margin: 0 8px 0 4px; transform: rotate(-3deg); font-family: var(--font-body); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); border: 2px solid var(--accent); border-radius: 6px; padding: 2px 8px; pointer-events: none; background: color-mix(in srgb, var(--paper) 80%, transparent); }
.scalestamp.true { color: var(--second); border-color: var(--second); }
.tools { position: absolute; z-index: 5; right: max(8px, env(safe-area-inset-right, 0px)); bottom: 6px; display: flex; gap: 0; background: color-mix(in srgb, var(--paper) 85%, transparent); border-radius: 22px; }
.tools .ico[aria-pressed="true"] { color: var(--accent); }
.tools .ico[aria-pressed="true"]::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 16px; height: 2px; margin-left: -8px; background: var(--accent); border-radius: 2px; }
.objpop { right: 0; bottom: calc(100% + 8px); width: 230px; }
.objpop .small { margin: 8px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.35; }
.pan.measuring { cursor: crosshair; }
.mlayer { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 3; }
.mread { position: absolute; z-index: 5; left: 50%; top: 74px; transform: translateX(-50%) rotate(-1deg); background: var(--postit); box-shadow: 2px 6px 14px rgba(60, 50, 10, 0.22); padding: 4px 14px; font-family: var(--font-hand); font-size: 1.45rem; white-space: nowrap; }
.lu { flex: none; display: flex; flex-direction: column; align-items: flex-start; }
.lu .luname { font-family: var(--font-hand); font-weight: 700; font-size: 1.1rem; line-height: 1; color: var(--g, var(--ink)); max-width: 150px; margin-top: 10px; }
.lu .luname small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 0.72rem; color: var(--muted); }
.objlink { position: absolute; left: 0; bottom: -6px; font-family: var(--font-hand); font-size: 1.1rem; white-space: nowrap; color: var(--accent); }
.calnote { position: fixed; z-index: 15; right: max(14px, env(safe-area-inset-right, 0px)); top: 64px; width: min(300px, calc(100vw - 28px)); background: var(--postit); box-shadow: 2px 10px 22px rgba(60, 50, 10, 0.28); transform: rotate(1.5deg); padding: 16px 16px 12px; font-size: 0.9rem; line-height: 1.4; color: #3f3a22; }
.calnote::before { content: ""; position: absolute; left: 50%; top: -10px; width: 70px; height: 20px; margin-left: -35px; background: rgba(255, 255, 255, 0.55); transform: rotate(-3deg); }
.calnote b { display: block; font-family: var(--font-hand); font-size: 1.5rem; line-height: 1.05; color: var(--ink); }
.calnote p { margin: 6px 0 10px; }
.calnote .btn { min-height: 38px; }
.calnote .btn.primary { background: var(--ink); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.printcap { display: none; }

/* size scrubber: every specimen on one log scale */
.scrub { position: relative; height: 34px; margin: 0 4px; cursor: pointer; touch-action: none; border-radius: 4px; }
.scrub svg { display: block; width: 100%; height: 100%; overflow: visible; }
.scrub:focus-visible { outline-offset: 1px; }

@media (max-height: 820px) and (min-width: 701px) {
  .idcard { padding: 8px 16px 6px; }
  .idcard h2 { font-size: 1.95rem; }
  .idcard .fact { -webkit-line-clamp: 2; margin-top: 3px; font-size: 0.9rem; line-height: 1.35; }
  .stamp { top: 8px; }
  .card { height: 92px; flex-basis: 120px; width: 120px; padding-top: 10px; }
  .card .thumb img { max-height: 32px; }
  .card .thumb svg { height: 30px; }
  .card b { font-size: 1.05rem; }
  .tray { padding-block: 6px 6px; gap: 12px; }
  .top { padding-block: 6px 2px; }
  .brand { font-size: 2.2rem; }
  .tabs button { min-height: 40px; font-size: 1.45rem; }
}
@media (max-height: 680px) and (min-width: 701px) {
  .idcard .fact { display: none; }
  .card { height: 78px; }
  .card .thumb { display: none; }
}

@media (max-width: 700px) {
  .gutter { padding-left: max(30px, calc(env(safe-area-inset-left, 0px) + 22px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  body::after { left: max(18px, calc(env(safe-area-inset-left, 0px) + 10px)); }
  .ruler { left: 24px; right: 6px; }
  .brand { font-size: 2rem; }
  .brand small { display: none; }
  .top { flex-wrap: nowrap; gap: 6px; }
  .tabs button { font-size: 1.35rem; padding-inline: 8px; }
  #calstatus { display: none; }
  .calbtn .short { display: inline; }
  .idcard h2 { font-size: 1.8rem; padding-right: 0; }
  .stamp { right: 10px; top: auto; bottom: 10px; }
  .labelrow { gap: 10px; }
  .shelfhead { flex-wrap: nowrap; }
  .shelfhead .sum { font-size: 1.1rem; min-width: 0; }
  .ico { width: 40px; }
  .card { flex-basis: 112px; width: 112px; height: 100px; }
  .idcard .fact { -webkit-line-clamp: 2; font-size: 0.88rem; }
  .pop, .about, .objpop { position: fixed; left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); top: auto; width: auto; max-height: 62vh; overflow: auto; transform: none; z-index: 25; box-shadow: 0 -6px 30px rgba(40, 30, 10, 0.3); }
  .about { padding-top: 20px; }
  .about .fulltext { display: block; color: var(--ink); font-weight: 300; margin-bottom: 8px; }
  .opts button { min-height: 40px; }
  .scalestamp { font-size: 0.66rem; margin: 0 4px 0 2px; padding: 1px 6px; }
  .hint { left: 28px; max-width: calc(100% - 200px); font-size: 1.1rem; }
  .tools .ico { width: 40px; height: 40px; }
  .scrub { height: 30px; }
  .calnote { top: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); transform: none; }
  .modal { padding: 8px; }
  .sheet { padding: 16px; }
  .nav { display: none; }
}
.calbtn .short { display: none; }
@media (max-width: 700px) { .calbtn .short { display: inline; } .brand { white-space: nowrap; font-size: 1.7rem; } .brand svg { display: none; } }
@media (max-width: 430px) { .calbtn .short { display: none; } .calbtn { padding-inline: 6px; } .dot { width: 18px; height: 18px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* print at actual size: CSS px are exactly 1/96 inch on paper */
@media print {
  @page { margin: 10mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  body::after, .top, .dock, .nav, .tools, .hint, .mread, .calnote, .modal, .setup, .scalestamp { display: none !important; }
  .stage { overflow: visible; flex: none; }
  .ruler { position: relative; left: 0; right: auto; top: 0; width: 680px; box-shadow: none; border: 1px solid var(--wood-edge); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pan { position: relative; inset: auto; overflow: visible; }
  .board { display: block; min-height: 0; }
  .board > * { display: inline-flex; }
  .specimen img { filter: none; }
  .printcap { display: block; font-size: 10pt; color: #333; margin: 4mm 0; line-height: 1.4; }
  .printcap b { font-family: var(--font-hand); font-size: 20pt; display: block; color: #000; }
}
@media (max-width: 430px) {
  .brand { font-size: 1.45rem; }
  .tabs { gap: 0; }
  .top > .tabs button { font-size: 1.15rem; padding-inline: 5px; white-space: nowrap; }
  .tabs button svg { inset: -2px -4px; width: calc(100% + 8px); }
}
@media (max-width: 700px) {
  .cmp:not(.lu-strip) { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 0 6px; padding: 2px 10px 4px; }
  .cmp .back { grid-column: 1 / 3; grid-row: 1; font-size: 1.15rem; min-height: 32px; }
  .cmp #presets { grid-column: 3; grid-row: 1; font-size: 1rem; }
  .cmp .pick { grid-row: 2; }
  .cmp .pick select { font-size: 1.05rem; }
  .cmp .swap { grid-row: 2; grid-column: 2; width: 32px; height: 32px; }
  .cmp .tabs.small { grid-column: 1 / -1; grid-row: 3; }
  .cmp .tabs.small button { font-size: 1.1rem; min-height: 30px; }
  .cmp .ratio { grid-column: 1 / -1; grid-row: 4; font-size: 0.8rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .cmp .ratio b { font-size: 1.2rem; }
  .pick { flex: none; }
  .lu-what { font-size: 1.1rem; }
}

/* the stage runs on under the dock and fades out, rather than stopping at a hard edge */
.stage { margin-bottom: calc(-1 * var(--dockh, 0px)); }
.pan { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--dockh, 0px) + 4px), transparent calc(100% - var(--dockh, 0px) + 120px));
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--dockh, 0px) + 4px), transparent calc(100% - var(--dockh, 0px) + 120px)); }
.board { padding-bottom: var(--dockh, 0px); }
.hint { bottom: calc(var(--dockh, 0px) + 8px); }
.tools { bottom: calc(var(--dockh, 0px) + 6px); }
.nav { top: calc((100% - var(--dockh, 0px) + 68px) / 2); }
.dock { pointer-events: none; }
.dock > * { pointer-events: auto; }
@media print { .stage { margin-bottom: 0; } .pan { -webkit-mask-image: none; mask-image: none; } .board { padding-bottom: 0; } }
@media (max-width: 700px) {
  .cmp { transform: none; }
  .pop.picker { position: fixed; left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); top: auto; width: auto; max-height: 78vh; z-index: 25; box-shadow: 0 -6px 30px rgba(40, 30, 10, 0.3); }
  .pickbtn .psize { display: none; }
  .dock.cmpmode .shelfhead .sum::after { content: " · tap to change green"; font-size: 0.95rem; }
  .trayarrow { width: 34px; height: 34px; }
  .trayarrow svg { width: 20px; height: 20px; }
  .tray::-webkit-scrollbar { height: 8px; }
}
@media (max-width: 700px) {
  .tools .scalestamp { position: absolute; right: 8px; bottom: calc(100% + 4px); margin: 0; }
  .cwlabel { flex: 1 0 100%; font-size: 1.25rem; }
  .cw { min-height: 42px; padding: 5px 12px 5px 10px; font-size: 0.95rem; }
  .cw svg { width: 26px; height: 20px; }
}
/* line-up scroll bar */
.luscroll { position: absolute; z-index: 5; left: max(60px, calc(env(safe-area-inset-left, 0px) + 46px)); right: 24px; bottom: calc(var(--dockh, 0px) + 58px); display: flex; align-items: center; gap: 10px; }
.luscroll .lend { font-family: var(--font-hand); font-size: 1.15rem; color: var(--muted); white-space: nowrap; }
.ltrack { position: relative; flex: 1; height: 18px; border-radius: 9px; background: rgba(111, 106, 92, 0.22); box-shadow: inset 0 1px 3px rgba(40, 30, 10, 0.18); cursor: pointer; touch-action: none; }
.lthumb { position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 7px; background: var(--accent); box-shadow: 0 1px 3px rgba(40, 30, 10, 0.3); cursor: grab; }
.ltrack:active .lthumb { cursor: grabbing; }
.card .sz { white-space: nowrap; }
.card .thumb { overflow: hidden; }
@media (max-width: 700px) { .luscroll { left: 26px; right: 10px; bottom: calc(var(--dockh, 0px) + 84px); } .luscroll .lend { display: none; } .ltrack { height: 22px; } }
@media print { .luscroll { display: none !important; } }
/* header icons: about, donate, language */
.hicons { position: relative; display: flex; align-items: center; gap: 0; margin-left: -8px; }
.hico { height: 40px; min-width: 36px; border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 3px; padding: 0 5px; border-radius: 20px; }
.hico svg { width: 22px; height: 22px; }
.hico:hover, .hico[aria-expanded="true"] { color: var(--accent); }
.hico .caret { width: 14px; height: 14px; }
.hico.more { display: none; }
.flag { display: inline-flex; width: 24px; height: 16px; flex: none; border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px rgba(40, 30, 10, 0.25); vertical-align: -3px; }
.flag svg { width: 100%; height: 100%; display: block; }
.pop.hpop { top: calc(100% + 6px); bottom: auto; right: 0; width: 260px; transform: rotate(0.6deg); z-index: 12; }
.langs { display: flex; flex-direction: column; }
.langs button { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 6px 6px; min-height: 38px; border-radius: 6px; text-align: left; font-family: var(--font-ui); font-size: 0.95rem; color: var(--ink); }
.langs button:hover { background: rgba(173, 88, 52, 0.08); }
.langs button[aria-pressed="true"] { font-weight: 650; background: rgba(173, 88, 52, 0.12); }
.langs .lnat { color: var(--muted); font-size: 0.85rem; }
.langs .soon { margin-left: auto; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.hpop .small { margin: 8px 0 0; font-size: 0.85rem; color: var(--accent); line-height: 1.35; }
.sheet.info { gap: 10px; }
.sheet.info .x { position: absolute; right: 8px; top: 8px; width: 40px; height: 40px; border: 0; background: transparent; font-size: 1.4rem; color: var(--muted); }
.sheet.info .lead { color: var(--ink); font-size: 1rem; line-height: 1.55; }
.sheet.info .links { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sheet.info .links li { display: flex; flex-direction: column; border-left: 3px solid var(--accent); padding-left: 10px; }
.sheet.info .links a { font-family: var(--font-hand); font-weight: 700; font-size: 1.45rem; line-height: 1.1; }
.sheet.info .links span { font-size: 0.85rem; color: var(--muted); }
.actions.start { justify-content: flex-start; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
a.btn[aria-disabled="true"] { opacity: 0.55; cursor: default; }
@media (max-width: 700px) {
  .hicons { margin-left: 0; }
  .hico:not(.more) { display: none; }
  .hico.more { display: inline-flex; min-width: 30px; padding: 0 2px; }
}
@media (max-width: 700px) {
  .pop.hpop { position: fixed; top: auto; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); width: auto; transform: none; z-index: 25; }
  #morepop { padding-bottom: 18px; }
  #morepop .opts button { font-family: var(--font-hand); font-size: 1.5rem; min-height: 46px; display: flex; align-items: center; gap: 8px; }
}
