:root {
  --bg: #FBFBFA; --surface: #FFFFFF; --text: #2F3437; --muted: #787774; --line: #EAEAEA;
  --accent: #26282B; --on-accent: #FFFFFF; /* near-black means "press this", so the only colour on screen is a status */
  --stage: #1C1C1B; /* behind every photo, in both themes: paper and ink read best against dark */
  --serif: 'Iowan Old Style', 'Palatino Linotype', Charter, Georgia, serif;
  --sans: -apple-system, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  --display: var(--sans); /* headings and big numbers; the serif is kept for the journals' own words */
  --gray-bg: #F1F1EF; --gray: #5F5E5B; --yellow-bg: #FBF3DB; --yellow: #956400; --blue-bg: #E1F3FE; --blue: #1F6C9F;
  --purple-bg: #F0EBF8; --purple: #6940A5; --green-bg: #EDF3EC; --green: #346538; --red-bg: #FDEBEC; --red: #9F2F2D;
  /* Stats bar fills: each status keeps its badge hue, stepped to pass the dataviz validator (CVD + contrast). */
  --m-done: #56A05A; --m-review: #1798EB; --m-transcribe: #734FA9; --m-crop-verify: #8A5F17; --m-crop: #D29F0E; --m-fix: #C42A2F; --m-todo: #9B9A97;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191918; --surface: #222221; --text: #E6E5E1; --muted: #9B9A97; --line: #333331; --accent: #E9E8E4; --on-accent: #1A1A19; --stage: #111110;
    --gray-bg: #2C2C2A; --gray: #B5B4B0; --yellow-bg: #3A3220; --yellow: #E3B45A; --blue-bg: #1D3240; --blue: #7DBDE8;
    --purple-bg: #2F2740; --purple: #B79BE3; --green-bg: #22301F; --green: #8BC283; --red-bg: #3D2223; --red: #EE8F8B;
    --m-done: #417A44; --m-review: #4082B7; --m-transcribe: #8C51D8; --m-crop-verify: #845700; --m-crop: #B18926; --m-fix: #CB3E3D; --m-todo: #5F5E5B;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 var(--sans); }
a { color: inherit; }
img { max-width: 100%; display: block; }

/* The app bar: the place you're in is marked; your claims and Sign out sit at the far end. */
body { display: grid; grid-template: auto minmax(0, 1fr) / minmax(0, 1fr); min-height: 100dvh; }
.skip-link { position: absolute; left: -999rem; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; z-index: 3; padding: 0.5rem 0.75rem; background: var(--surface); border-radius: 6px; }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 0 1.5rem; min-height: 3.5rem; padding: 0 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line); }
header .home { font: 600 1.2rem/1.1 var(--serif); letter-spacing: -0.02em; text-decoration: none; }
header nav { display: flex; gap: 0.25rem; }
header nav a { padding: 0.4rem 0.75rem; border-radius: 6px; color: var(--muted); text-decoration: none; white-space: nowrap; }
header nav a:hover { color: var(--text); background: var(--gray-bg); }
header nav a[aria-current] { color: var(--text); font-weight: 600; background: var(--gray-bg); }
.me { display: flex; align-items: center; gap: 1.25rem; margin-left: auto; font-size: 0.95rem; white-space: nowrap; }
.me a { color: var(--muted); text-decoration: none; }
.me a:hover { color: var(--text); }
.me .who { color: var(--muted); }
@media (max-width: 1000px) { .me .who { display: none; } }
/* Phones: the name and your things on one line, then one nav line that scrolls sideways and fades at the edge to show there's more. */
@media (max-width: 760px) {
  header { padding: 0 1rem; }
  header .home, .me { display: flex; align-items: center; min-height: 2.75rem; }
  header nav { order: 3; width: calc(100% + 2rem); margin: 0 -1rem; padding: 0 0.5rem 0.4rem; overflow-x: auto; scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 calc(100% - 2.5rem), transparent); }
  body.work header nav { display: none; } /* a workspace has its own Back, and the name still goes home */
}

main { width: 100%; max-width: 46rem; min-width: 0; margin: 0 auto; padding: 2rem 1rem 6rem; }
main:has(.reading) { max-width: 80rem; }
main:has(.dash) { max-width: 74rem; }
h1 { font: 650 2rem/1.15 var(--display); letter-spacing: -0.03em; margin: 0.25rem 0 1.5rem; }
.muted, .crumbs { color: var(--muted); }
.crumbs { margin: 0; font-size: 0.95rem; }
.crumbs a { text-decoration: none; }

.prose { font: 1.2rem/1.65 var(--serif); }
.prose h1, .prose h2 { font-family: var(--serif); letter-spacing: -0.02em; line-height: 1.2; }
.prose h2 { font-size: 1.5rem; font-weight: 500; margin-top: 2.5rem; }

.search { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.search input { flex: 1; min-width: 0; font: inherit; padding: 0.7rem 0.9rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
/* Buttons: primary = filled accent, secondary = tinted accent with a border, danger = red outline. Links stay links. */
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: 0.55rem 1.1rem;
  font: 500 1rem/1.2 var(--sans); white-space: nowrap; text-decoration: none; cursor: pointer;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--on-accent);
  transition: background-color 150ms, border-color 150ms, transform 100ms; }
button:hover, .button:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
button:active, .button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.secondary { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--surface)); }
button.secondary:hover { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
button.danger { background: transparent; color: var(--red); border-color: var(--red); }
button.danger:hover { background: var(--red-bg); }

.authors { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.75rem; }
.card { display: flex; flex-direction: column; gap: 0.25rem; padding: 1.5rem; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; transition: box-shadow 200ms; }
.card:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); }
.card strong { font: 600 1.6rem/1.15 var(--display); letter-spacing: -0.02em; }

.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-bottom: 1px solid var(--line); }
.entries li > a { flex: 1; display: flex; flex-direction: column; padding: 0.85rem 0; text-decoration: none; min-width: 0; }
.entries li > a:hover > span:first-child { text-decoration: underline; }
.entries .muted { font-size: 0.9rem; }
.snippet { color: var(--muted); font: 0.98rem/1.5 var(--serif); margin-top: 0.25rem; }
mark { background: var(--yellow-bg); color: inherit; border-radius: 2px; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 9999px; white-space: nowrap;
  font: 600 0.68rem/1.4 var(--sans); text-transform: uppercase; letter-spacing: 0.05em; background: var(--gray-bg); color: var(--gray); }
h1 .badge { font-size: 0.9rem; vertical-align: middle; }
/* Claim lists: the pill sits after the title and wraps with it as one piece. */
.claim-list li > a .badge, .entries li > a .badge { vertical-align: 0.1em; }
.s-crop, .s-crop-verify { background: var(--yellow-bg); color: var(--yellow); }
.s-transcribe { background: var(--purple-bg); color: var(--purple); }
.s-review { background: var(--blue-bg); color: var(--blue); }
.s-done { background: var(--green-bg); color: var(--green); }
.s-fix { background: var(--red-bg); color: var(--red); }

.meta, .tags, .chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.chip { padding: 0.2rem 0.65rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; font-size: 0.9rem; }
/* Tags are pills (full radius); buttons and chips keep 6-8px corners. */
.tag { padding: 0.2rem 0.75rem; border-radius: 999px; background: var(--gray-bg); color: var(--text); text-decoration: none; font-size: 0.9rem; }
.tag:hover { background: color-mix(in srgb, var(--gray-bg) 80%, var(--text)); }
.tag small { color: var(--muted); }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chips { margin: -0.5rem 0 1.5rem; }
/* Sort and years sit at the end of the chips row, chip-sized; on a phone they wrap to their own line. */
.refine { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-left: auto; }
.refine select, .refine input { font: 0.9rem/1.4 var(--sans); color: var(--text); background: var(--surface);
  padding: 0.2rem 0.5rem; border: 1px solid var(--line); border-radius: 6px; }
.refine input { width: 4.5rem; font-variant-numeric: tabular-nums; }
.refine input::placeholder { color: var(--muted); }
.years { display: flex; align-items: center; gap: 0.3rem; color: var(--muted); }
@media (max-width: 600px) { .refine { margin-left: 0; } }

.scan { display: block; margin: 0 -1rem 1.5rem; background: var(--surface); }
.scan img { margin: 0 auto; }
@media (min-width: 900px) {
  .reading { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3rem; align-items: start; }
  .scan { margin: 0; position: sticky; top: 1rem; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
  .scan img { max-height: calc(100vh - 2rem); width: auto; }
}

.pager { color: var(--muted); white-space: nowrap; }
.pager a { color: var(--text); padding: 0.5rem 0; }
p.pager { white-space: normal; } /* the search pager carries a count, so it may wrap on a phone */

.notice { padding: 0.75rem 1rem; border-radius: 6px; background: var(--blue-bg); color: var(--blue); }
.notice.bad { background: var(--red-bg); color: var(--red); }
textarea, .panel input, .tag-edit input[name=add], .notes input { width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.7rem 0.9rem; }
textarea { font: 1.15rem/1.6 var(--serif); resize: vertical; }
.tag-edit { border: 0; padding: 0; margin: 1.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-edit legend { color: var(--muted); margin-bottom: 0.5rem; }
.tag-edit legend { padding: 0; }
/* A pill is a checkbox: the × unticks it (removed on save), tapping again puts it back. Works without JS. */
.pill { position: relative; display: inline-flex; align-items: center; gap: 0.2rem; min-height: 2.25rem; padding: 0 0.3rem 0 0.8rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--surface)); border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface)); color: var(--accent); font-size: 0.95rem; user-select: none; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.pill::after { content: '×'; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 999px; font-size: 1.15rem; line-height: 1; }
.pill:hover::after { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.pill:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill:has(input:not(:checked)) { background: transparent; border-style: dashed; border-color: var(--line); color: var(--muted); }
.pill:has(input:not(:checked)) span { text-decoration: line-through; }
.pill:has(input:not(:checked))::after { content: '↺'; font-size: 1rem; }
/* The review editor's status choice: two boxes tinted like their status pills (.s-review, .s-done set the colours).
   The picked one gets a full-strength border; side by side, stacked on phones. */
.status-pick { border: 0; padding: 0; margin: 1.5rem 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.75rem; }
.status-pick legend { color: var(--muted); padding: 0; margin-bottom: 0.5rem; }
.status-pick label { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.8rem 1rem; border-radius: 8px; cursor: pointer;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent); font-size: 0.95rem; line-height: 1.45;
  transition: border-color 150ms, box-shadow 150ms; }
.status-pick label:has(:checked) { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.status-pick label:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.status-pick .s-review input { accent-color: var(--blue); }
.status-pick .s-done input { accent-color: var(--green); }
.status-pick input { width: 1.1rem; height: 1.1rem; margin: 0.15rem 0 0; flex: none; }
.status-pick strong { display: block; font-weight: 600; }
/* Every entry screen: all actions in one sticky bar at the bottom, primary first, Report a problem set apart at the end. */
.bar { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem -1rem 0;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.bar .danger { margin-left: auto; }
@media (max-width: 400px) { .bar button { padding-inline: 0.8rem; } } /* Save, Cancel and Report a problem fit one row on a phone */
/* Every flyout is one .panel (index.mjs panel()): a native popover from the right edge, the whole screen on a phone, so it
   never moves the work. Plain block flow from the top: a stretched grid spread a short form down a tall iPad screen. */
.panel { inset: 0 0 0 auto; width: min(30rem, 100vw); height: 100dvh; max-height: none; margin: 0; overflow: auto;
  padding: 0 1.5rem calc(2rem + env(safe-area-inset-bottom)); color: var(--text); background: var(--surface);
  border: 0; border-left: 1px solid var(--line); box-shadow: 0 8px 28px rgba(25, 25, 24, 0.14); }
.panel::backdrop { background: rgba(25, 25, 24, 0.25); }
.panel-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(1rem + env(safe-area-inset-top)) 0 0.75rem; background: var(--surface); }
.panel-head h2 { margin: 0; }
.panel label { display: grid; gap: 0.4rem; margin-bottom: 0.75rem; }
.panel .prose { font-size: 1.05rem; }
.panel > p { font-size: 0.95rem; }
.bar p { margin: 0; align-self: center; }
/* A refusal's one line sits on its own row above the buttons; the full error stays at the top of the page. */
.bar p.bad { flex-basis: 100%; color: var(--red); }
/* Wrappers live.js swaps; no box of their own, so an empty one adds no gap to the nav. */
div[data-live], span[data-live] { display: contents; }
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.25rem 1rem; }
.top a { text-decoration: none; }

.jobs { display: grid; gap: 1.25rem; margin-top: 2rem; }
.job { display: grid; grid-template-rows: 1fr auto; gap: 0.5rem; }
.job > .muted { font-size: 0.95rem; justify-self: start; }
.job .card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.25rem 1.5rem; }
.job .card .muted { grid-column: 1; }
.job .count { grid-column: 2; grid-row: 1 / 3; font: 650 2.75rem/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.card.idle { color: var(--muted); background: transparent; }
.card.idle .count { font: 0.95rem/1.4 var(--sans); letter-spacing: 0; }
.card:active { transform: scale(0.99); }

/* Stats: stacked 100% bars, 2px surface gaps between segments, rounded data end (dataviz mark specs). */
h2 { font: 600 1.3rem/1.25 var(--display); letter-spacing: -0.02em; margin: 3rem 0 1rem; }
h2 .muted { font: 0.95rem/1.4 var(--sans); letter-spacing: 0; margin-left: 0.5rem; }
.meter { display: flex; gap: 2px; height: 12px; min-width: 5rem; }
.meter > * { min-width: 3px; }
.meter > :last-child { border-radius: 0 4px 4px 0; }
.meter a:hover { opacity: 0.8; }
.overall .meter { height: 20px; }
.headline { font-size: 1.15rem; margin: 0 0 0.75rem; }
.headline strong { font: 650 2.5rem/1 var(--display); letter-spacing: -0.03em; margin-right: 0.25rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; list-style: none; margin: 0.75rem 0 0; padding: 0; color: var(--muted); font-size: 0.9rem; }
.legend a { color: inherit; text-decoration: none; }
.legend a:hover { text-decoration: underline; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.4rem; }
.m-done { background: var(--m-done); }
.m-review { background: var(--m-review); }
.m-transcribe { background: var(--m-transcribe); }
.m-crop-verify { background: var(--m-crop-verify); }
.m-crop { background: var(--m-crop); }
.m-fix { background: var(--m-fix); }
.m-todo { background: var(--m-todo); }

.progress { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.progress th, .progress td { padding: 0.55rem 0; text-align: right; white-space: nowrap; }
.progress th + th, .progress td, .progress th + td { padding-left: 1rem; }
.progress th:first-child { text-align: left; font-weight: 500; }
.progress th[scope=row] a { text-decoration: none; }
.progress th[scope=row] a:hover { text-decoration: underline; }
.progress thead th { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.progress td:nth-child(2) { width: 100%; }
.progress tbody tr { border-top: 1px solid var(--line); }
.progress small { display: block; color: var(--red); font-size: 0.8rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.wide { display: none; }
@media (min-width: 720px) {
  main:has(.progress) { max-width: 60rem; }
  .wide { display: table-cell; }
  .progress .narrow { display: none; }
}
.not-started { margin-top: 1rem; color: var(--muted); }
.not-started summary { cursor: pointer; }
.not-started p { line-height: 1.8; }

/* Home: the numbers first. Search, then tiles: overall progress beside the three jobs, each author's shelf of years,
   your claims and the latest changes. One column on a phone. */
.dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.dash .search { margin: 0; }
.tile { margin: 0; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.tile h2, section.tile > h2:first-child { margin: 0 0 0.75rem; font: 600 1.05rem/1.3 var(--sans); letter-spacing: 0; }
.tile h2 a { text-decoration: none; }
.tile h2 a:hover { text-decoration: underline; }
.tile h2 .muted { margin-left: 0.5rem; font-weight: 400; font-size: 0.9rem; }
.total .big { margin: 0; font-size: 1.15rem; }
.total .big strong { margin-right: 0.2rem; font: 650 3.5rem/1 var(--sans); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.total .muted { margin: 0.35rem 0 1rem; }
.total .meter { height: 14px; }
.total dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem 1.5rem; margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.total dt { color: var(--muted); font-size: 0.85rem; }
.total dd { margin: 0; font: 600 1.4rem/1.3 var(--sans); font-variant-numeric: tabular-nums; }
.job-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0 1rem; min-height: 4rem; padding: 0.5rem 0;
  border-top: 1px solid var(--line); text-decoration: none; }
.job-row span { display: grid; }
.job-row small { color: var(--muted); font-size: 0.85rem; line-height: 1.35; }
.job-row b { font: 600 1.4rem/1 var(--sans); font-variant-numeric: tabular-nums; }
.job-row em { padding: 0.45rem 0.9rem; border-radius: 6px; background: var(--accent); color: var(--on-accent); font: 600 0.9rem/1.2 var(--sans); }
.job-row:hover em { background: color-mix(in srgb, var(--accent) 85%, var(--surface)); }
.job-row.idle { color: var(--muted); }
.job-row.idle em { grid-column: 2 / -1; padding: 0; background: none; color: var(--muted); font-weight: 400; }
.jobs-tile .more { margin: 0.5rem 0 0; font-size: 0.9rem; }
.more a { color: var(--muted); }
.shelf-years { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.75rem, 1fr)); gap: 0.4rem; }
.year { display: grid; align-content: start; gap: 0.3rem; padding: 0.45rem 0.5rem; border: 1px solid var(--line); border-radius: 6px;
  min-width: 0; text-decoration: none; font-size: 0.85rem; line-height: 1.3; font-variant-numeric: tabular-nums; transition: border-color 150ms; }
.year:hover { border-color: var(--muted); }
.year.notebook { grid-column: span 2; }
.year span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.year small { color: var(--muted); font-size: 0.75rem; }
.year .meter { height: 6px; min-width: 0; }
.year.none { border-style: dashed; color: var(--muted); }
.year.none span { font-weight: 400; }
.dash .welcome { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.95rem; }
.dash .welcome p { margin: 0; }
@media (min-width: 900px) {
  .dash { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .dash .search, .shelf, .dash .welcome, .dash:not(:has(.claim-list)) .recent { grid-column: 1 / -1; }
}
.overall { margin-top: 2.5rem; }
.authors { margin: 2.5rem 0 0; }
.authors .card { gap: 0.4rem; padding: 1rem 1.1rem; }
.authors .meter { margin-top: 0.5rem; height: 8px; }

.changes { list-style: none; margin: 0; padding: 0; }
.changes li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.changes time { white-space: nowrap; font-size: 0.9rem; }

/* Workspaces (crop, check a crop, the text editors) fill the window like an app instead of scrolling. The picture gets all
   the room that's left; tools and actions sit in a panel beside it on a wide screen, under it on a narrow one. */
body.work main { max-width: none; padding: 0; }
.ws { display: grid; grid-template: "head" auto "msg" auto "main" minmax(0, 1fr) "side" auto "bar" auto / minmax(0, 1fr); }
.ws-edit { display: block; } /* narrow: the text editors scroll like a page */
.ws-edit > form { display: contents; }
.ws-head { grid-area: head; display: flex; align-items: center; gap: 0.75rem; min-height: 3rem; padding: 0.35rem 1rem; border-bottom: 1px solid var(--line); }
.ws-head h1 { min-width: 0; margin: 0; font: 600 1.05rem/1.2 var(--display); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-head .back { padding: 0.4rem 0; color: var(--muted); text-decoration: none; white-space: nowrap; }
.ws-head .back:hover { color: var(--text); }
.ws-head .badge { flex: none; }
.skip { margin-left: auto; padding: 0.35rem 0.9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-weight: 500; text-decoration: none; white-space: nowrap; }
.skip:hover { border-color: var(--muted); }
@media (max-width: 480px) { .ws-head .w { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } }
.ws-msg { grid-area: msg; padding: 0.75rem 1rem 0; }
.ws-msg .notice { margin: 0 0 0.75rem; }
.ws-main { grid-area: main; min-width: 0; min-height: 0; }
.ws-scan { grid-area: scan; }
.ws-scan .scan { margin: 0; }
.ws-text { grid-area: text; padding: 1rem; }
.ws-text textarea { display: block; }
.ws-side { grid-area: side; min-height: 0; max-height: 45dvh; padding: 0.75rem 1rem; overflow: auto; }
.ws-edit .ws-side { max-height: none; }
.ws-side > * { margin: 0; }
.ws-side > * + * { margin-top: 1rem; }
.hint { color: var(--muted); font-size: 0.95rem; }
.ws .bar { grid-area: bar; margin: 0; }
.ws-crop .bar, .ws-verify .bar { position: static; }
.ws .bar > button:not(.secondary, .danger) { flex: 1; }
.zoomer { display: none; }
@media (min-height: 520px) {
  body.work { height: 100dvh; }
  body.work main { min-height: 0; overflow: hidden; }
  .ws { height: 100%; }
}
@media (max-width: 899px) {
  body.work-wide { height: auto; }
  body.work-wide main { overflow: visible; }
  body.work-wide .ws { height: auto; }
}
@media (max-height: 519px) { .ws-crop .ws-main, .ws-verify .ws-main { height: 85dvh; } } /* a phone on its side: scroll, the picture nearly a screen tall */
.ws-head .hint { order: 9; flex-basis: 100%; margin: 0 0 0.35rem; }
.ws-head { flex-wrap: wrap; }
.how-btn { gap: 0.3em; min-height: 2.25rem; margin-left: auto; padding: 0.3rem 0.8rem; }
.ws-head .skip { margin-left: 0; }
.ws-head .badge + .skip { margin-left: auto; }
@media (max-width: 899px) { .ws-head h1 { flex: 1 1 0; } }
@media (max-width: 480px) { .ws-head .badge { display: none; } }
.ws-crop .ws-side { max-height: none; overflow: visible; }
@media (min-width: 900px) {
  .ws-head { flex-wrap: nowrap; }
  .ws-head h1 { flex: none; max-width: 40%; }
  .ws .ws-head .hint { order: 0; display: block; flex: 1; min-width: 0; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ws-head .hint + .how-btn { margin-left: 0; }
  .ws-crop { grid-template: "head head" auto "msg msg" auto "main main" minmax(0, 1fr) "side bar" auto / minmax(0, 1fr) auto; }
  .ws-verify { grid-template: "head" auto "msg" auto "main" minmax(0, 1fr) "bar" auto / minmax(0, 1fr); }
  .ws-edit { display: grid; grid-template: "head head" auto "msg msg" auto "scan text" minmax(0, 1fr) "scan side" auto "bar bar" auto / minmax(0, 1fr) minmax(0, 1fr); }
  .ws-edit.no-scan { grid-template: "head" auto "msg" auto "text" minmax(0, 1fr) "side" auto "bar" auto / minmax(0, 1fr); }
  .ws-side, .ws .bar { background: var(--surface); border-top: 1px solid var(--line); }
  .ws-crop .ws-side { display: flex; align-items: center; padding: 0.6rem 1rem; }
  .ws-edit .ws-side { max-height: 34dvh; padding: 1rem 1.25rem; }
  /* the primary action sits at the far right, where desktop apps put it; Report a problem is set apart at the far left */
  .ws .bar { position: static; flex-direction: row-reverse; align-items: center; padding: 0.6rem 1rem; }
  .ws .bar > button:not(.secondary, .danger) { flex: none; min-width: 9rem; }
  .ws .bar .danger { margin: 0 auto 0 0; }
  .ws-crop .bar .danger { margin: 0; }
  .ws-text { display: flex; flex-direction: column; gap: 0.75rem; min-height: 0; padding: 1rem 1.25rem; overflow: auto; }
  .ws-text textarea[name=body] { flex: 1; min-height: 10rem; resize: none; }
  .ws-scan { position: relative; min-height: 0; background: var(--stage); }
  .ws-scan .scroller { height: 100%; overflow: auto; }
  .ws-scan .scan { position: static; width: calc(var(--z) * 100%); border: 0; border-radius: 0; background: none; }
  .ws-scan .scan img { width: 100%; max-height: none; }
  .zoomer { position: absolute; right: 1rem; bottom: 1rem; display: flex; gap: 0.35rem; }
  .zoomer button { width: 2.75rem; padding: 0; background: var(--surface); font-size: 1.35rem; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4); }
}
.crop-view { display: grid; place-items: center; height: 100%; min-height: 0; overflow: hidden;
  background: var(--stage); touch-action: none; user-select: none; -webkit-user-select: none; }
#stage { position: relative; }
.clip { position: absolute; inset: 0; overflow: hidden; background: #FFFFFF; } /* the white the server fills rotated corners with */
.clip img { position: absolute; max-width: none; transform-origin: center; pointer-events: none; -webkit-user-drag: none; }
.box { position: absolute; box-shadow: 0 0 0 9999px rgba(25, 25, 24, 0.6); outline: 1px solid rgba(255, 255, 255, 0.9);
  background: linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px) 0 0 / 100% 33.333%,
    linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px) 0 0 / 33.333% 100%; }
.straightening .box { background: linear-gradient(rgba(31, 108, 159, 0.75) 1px, transparent 1px) 0 0 / 100% 22px; }
.handle { position: absolute; width: 48px; height: 48px; margin: -24px 0 0 -24px; touch-action: none; cursor: grab;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.7)); }
.handle::after { content: ''; position: absolute; width: 18px; height: 18px; border: 0 solid #FFFFFF; }
.handle.nw::after { left: 22px; top: 22px; border-width: 4px 0 0 4px; }
.handle.ne::after { right: 22px; top: 22px; border-width: 4px 4px 0 0; }
.handle.sw::after { left: 22px; bottom: 22px; border-width: 0 0 4px 4px; }
.handle.se::after { right: 22px; bottom: 22px; border-width: 0 4px 4px 0; }
.straighten { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.25rem 0.6rem; }
.straighten input { width: 100%; height: 2.25rem; accent-color: var(--accent); }
.straighten output { grid-column: 1 / -1; grid-row: 1; justify-self: center; font-variant-numeric: tabular-nums; font-weight: 500; }
.straighten .secondary { padding: 0.55rem 0.8rem; font-variant-numeric: tabular-nums; }
.straighten .turn { grid-row: 1; grid-column: 1; }
.straighten .reset { grid-row: 1; grid-column: 3; }
@media (min-width: 900px) {
  /* In the toolbar the straighten tools run in one line. */
  .straighten { flex: 1; grid-template: "turn minus slider plus angle reset" auto / auto auto minmax(8rem, 24rem) auto 4rem auto; gap: 0.5rem; }
  .straighten output { grid-area: angle; justify-self: start; }
  .straighten #slider { grid-area: slider; }
  .straighten #minus { grid-area: minus; }
  .straighten #plus { grid-area: plus; }
  .straighten .turn { grid-area: turn; }
  .straighten .reset { grid-area: reset; justify-self: start; }
}
.loupe { position: fixed; z-index: 2; width: 132px; height: 132px; border-radius: 50%; overflow: hidden;
  border: 3px solid #FFFFFF; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); pointer-events: none; background: #FFFFFF; }
.loupe > div { position: absolute; left: -3px; top: -3px; }
.loupe::after { content: ''; position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border: 2px solid var(--red); border-radius: 50%; }
/* Check a crop: the server's real output, as big as the room allows. */
.cropped { position: relative; margin: 0; background: var(--stage); }
.cropped a { position: absolute; inset: 1rem; }
.cropped img { width: 100%; height: 100%; object-fit: contain; }
[hidden] { display: none !important; }

/* "Working on" menu in the header: your claims, with Renew and Let go. */
button.claims { min-height: 0; padding: 0; border: 0; background: none; color: var(--text); font: inherit; }
.claims .count { display: inline-block; min-width: 1.4em; margin-left: 0.25rem; padding: 0 0.4em; border-radius: 9999px;
  text-align: center; font: 600 0.8rem/1.6 var(--sans); background: var(--yellow-bg); color: var(--yellow); }
.claim-list { list-style: none; margin: 0; padding: 0; }
.claim-list li { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0.15rem 0.75rem; padding: 0.65rem 0; border-top: 1px solid var(--line); }
.claim-list li > a { color: var(--text); font-weight: 500; }
.claim-list li > .muted { font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.claim-actions { grid-column: 1 / -1; display: flex; gap: 0.5rem; }
.claim-actions button, .entries form button { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.release-all { padding-top: 0.65rem; border-top: 1px solid var(--line); }
.release-all button { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
main > .claim-list, main > .release-all { max-width: 32rem; } /* the limit screen */
.entries li form { flex: none; }
button.claims:hover { background: none; }

/* Page viewer: full screen, a top bar (hint above Close) clear of the image, then the image area; zoom.js transforms the image box. */
dialog.zoom { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #111110; overflow: hidden; touch-action: none; }
dialog.zoom[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
dialog.zoom::backdrop { background: #111110; }
dialog.zoom form { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem;
  padding: calc(0.75rem + env(safe-area-inset-top)) 0.75rem 0.75rem; }
dialog.zoom p { margin: 0; color: #D6D5D1; font-size: 0.95rem; }
dialog.zoom div { overflow: hidden; }
dialog.zoom img { width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
body:has(dialog.zoom[open]) { overflow: hidden; }
.scan, .cropped a { cursor: zoom-in; }

/* /admin overview: one card per area, its number big. */
.admin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.75rem; margin-top: 1.5rem; }
.admin-cards .card strong { font-variant-numeric: tabular-nums; }
.admin-cards .bad, .admin-cards strong .bad { color: var(--red); }
/* Fix queue: where each was reported from sits at the row's end. */
.fixes .from { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
/* Fix editor's note fields: label above input. */
.notes { border: 0; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 1rem; }
.notes legend { padding: 0; color: var(--muted); margin-bottom: 0.5rem; }
.notes label { display: grid; gap: 0.35rem; font-weight: 500; }
.notes label .muted { font-weight: 400; font-size: 0.85rem; }

/* /admin/ai transcription mode and settings */
.modes { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1rem 0; }
.transcription-settings { display: grid; justify-items: start; gap: 0.75rem; margin-bottom: 1rem; }
.transcription-settings fieldset { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; border: 0; padding: 0; margin: 0; }
.transcription-settings legend { padding: 0; margin-bottom: 0.25rem; font-weight: 500; }
.do-now { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 1rem 0; }
.transcription-settings input, .do-now input { font: inherit; color: var(--text); background: var(--surface); margin-left: 0.4rem;
  border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.6rem; }
.transcription-settings input[type=number], .do-now input { width: 7rem; }

.job-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0; font-size: 0.95rem; }
.names { columns: 15rem; column-gap: 2rem; padding-left: 1.1rem; }
.names li { break-inside: avoid; margin-bottom: 0.25rem; }
section[id] { scroll-margin-top: 1rem; }

/* Entry history: one card per commit. ins/del carry their meaning by line style and hidden words, not just tint. */
.meta .history-link { margin-left: auto; font-size: 0.9rem; color: var(--muted); }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.history li { padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.history li > p, .history .diff { margin: 0.5rem 0 0; }
.history .who { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.25rem 1rem; margin: 0; }
.history .who time { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.history .who .badge, .history .moved .badge { vertical-align: 0.1em; }
.history .moved { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); }
.history .tags { color: var(--muted); font-size: 0.95rem; }
.diff { font: 1.05rem/1.6 var(--serif); }
.diff p { margin: 0 0 0.4rem; overflow-wrap: anywhere; }
.diff .gap { color: var(--muted); margin: 0; }
details.diff summary { color: var(--accent); cursor: pointer; font: 0.95rem/1.6 var(--sans); }
details.diff[open] summary { margin-bottom: 0.5rem; }
ins { background: var(--green-bg); color: var(--green); text-decoration: underline 2px; text-underline-offset: 0.2em; border-radius: 2px; }
del { background: var(--red-bg); color: var(--red); text-decoration: line-through 1.5px; border-radius: 2px; }
del.tag { background: var(--red-bg); color: var(--red); }
ins::before, del::before { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
ins::before { content: ' inserted: '; }
del::before { content: ' deleted: '; }

/* The welcome page: just the name and a big Sign in button. */
.welcome { max-width: 36rem; padding-top: 18vh; text-align: center; }
.welcome h1 { font: 600 2.4rem/1.15 var(--serif); letter-spacing: -0.02em; margin-bottom: 2rem; }
.welcome .notice { margin-bottom: 1.5rem; }
.welcome .sign-in { min-height: 3.75rem; padding: 0.9rem 2.5rem; font-size: 1.3rem; border-radius: 10px; }
