/* Colour tokens: "light table" (docs/ux-plan.md M0, UX review §4). The photos are the only saturated
   thing on screen; UI colour is kept for links, selection and decisions. WCAG contrast in the comments
   (tests/test_web_m0_css.py recomputes the ones that matter). */
:root {
  --paper: #eef0f2;        /* page */
  --surface: #ffffff;      /* cards, bars */
  --sunken: #e4e7ea;       /* image wells, placeholders */
  --ink: #16191d;          /* 15.4:1 on paper */
  --ink-2: #50565e;        /* secondary text: 6.5:1 on paper, 6.0:1 on sunken */
  --rule: #d3d7dc;         /* dividers only (decorative) */
  --edge: #7b828b;         /* input and control borders: 3.4:1 on paper, 3.9:1 on white */
  --accent: #0a6b66;       /* links, selection: 5.6:1 on paper */
  --accent-ink: #ffffff;   /* 6.4:1 on accent */
  --caution: #8a5300;      /* one-day people, "photos show both": 5.5:1 on paper */
  --stop: #a3230f;         /* errors, disabling accounts */
  --ring: #16191d;         /* focus ring, drawn with a surface halo */
  --mark: #e8a33d;         /* the face box on a photo */
  --radius: 8px;
  --r-photo: 2px;
  --r-control: 6px;
  --r-chip: 999px;
  /* The earlier names, kept as aliases: templates and other rules still use them. */
  --bg: var(--paper);
  --panel: var(--surface);
  --muted: var(--ink-2);
  --line: var(--rule);
  --ok: var(--accent);
  --warn: var(--caution);
  --bad: var(--stop);
  --focus: var(--ring);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111315;
    --surface: #191c1f;
    --sunken: #23272b;
    --ink: #eceef0;
    --ink-2: #a8afb7;
    --rule: #2c3136;
    --edge: #737b84;
    --accent: #5cc2b8;
    --accent-ink: #0a1413;
    --caution: #e7b454;
    --stop: #ff8a73;
    --ring: #ffffff;
    --mark: #e7b454;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: break-word;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -10000px; top: 8px; z-index: 100; padding: 8px 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--edge); border-radius: var(--r-control); }
.skip:focus { left: 8px; }

/* Header: wraps instead of widening the page; on narrow screens (phones, 200% zoom) the nav gets its
   own row and scrolls sideways inside itself. */
header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px;
  padding: 6px 20px; background: var(--surface); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 10;
}
header.top .brand { font-weight: 650; color: var(--ink); }
header.top nav {
  display: flex; gap: 14px; flex: 1 1 auto; min-width: 0;
  overflow-x: auto; white-space: nowrap; scrollbar-width: thin;
}
header.top nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 2px; }
header.top nav a.on { font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
header.top .who { color: var(--ink-2); display: flex; gap: 10px; align-items: center; margin-left: auto; }
@media (max-width: 760px) {
  header.top { padding: 4px 16px; }
  header.top nav { order: 3; flex-basis: 100%; }
}
main { max-width: 1320px; margin: 0 auto; padding: 18px 20px 60px; }
main:focus { outline: none; }
@media (max-width: 760px) { main { padding: 14px 16px 48px; } }
h1 { font-size: 24px; line-height: 1.2; margin: 4px 0 14px; }
h2 { font-size: 18px; line-height: 1.2; margin: 18px 0 10px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.spacer { flex: 1; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; }

/* Controls: borders at least 3:1 against the page, at least 40 px tall. */
button, .button {
  font: inherit; cursor: pointer; border-radius: var(--r-control); padding: 6px 12px; min-height: 40px;
  border: 1px solid var(--edge); background: var(--surface); color: var(--ink);
}
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.button:hover { text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--stop); border-color: var(--stop); }
button:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], input[type=number], input[type=search], select {
  font: inherit; padding: 6px 8px; min-height: 40px; max-width: 100%;
  border: 1px solid var(--edge); border-radius: var(--r-control); background: var(--surface); color: var(--ink);
}
input[type=number] { width: 7em; }
input[type=checkbox] { accent-color: var(--accent); }
/* Focus: an ink ring with a surface halo on both sides, visible on any background, photos included. */
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; box-shadow: 0 0 0 7px var(--surface); }
form.inline { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; max-width: 100%; }
kbd {
  font: 12px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--edge); border-bottom-width: 2px;
  border-radius: 4px; background: var(--paper); color: var(--ink);
}
.flash { margin: 0 0 12px; padding: 8px 12px; border-radius: var(--r-control); border: 1px solid var(--rule); background: var(--surface); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.flash.ok { border-color: var(--accent); }
.flash.error { border-color: var(--stop); color: var(--stop); }
.flash[hidden] { display: none; }
.badge { display: inline-block; font-size: 12px; padding: 0 7px; border-radius: 10px; border: 1px solid var(--edge); color: var(--ink-2); }
.badge.tentative { border-color: var(--caution); color: var(--caution); }
.badge.hidden { border-color: var(--stop); color: var(--stop); }

/* People grid */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.person-card { display: block; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; color: var(--ink); }
.person-card:hover { border-color: var(--accent); text-decoration: none; }
.person-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--sunken); }
.person-card .meta { padding: 8px 10px; }
.person-card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Photo and face grids */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
@media (max-width: 480px) { .photos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.photos a { display: block; }
.photos a img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border-radius: var(--r-control); background: var(--sunken); }
.faces { display: flex; flex-wrap: wrap; gap: 8px; }
.face { position: relative; width: 104px; }
.face a { display: block; }
.face img { width: 104px; height: 120px; object-fit: cover; border-radius: var(--r-control); display: block; background: var(--sunken); }
.face.big, .face.big img { width: 168px; }
.face.big img { height: 196px; }
.face.small, .face.small img { width: 72px; }
.face.small img { height: 84px; }
.face > input[type=checkbox] { position: absolute; top: 4px; left: 4px; }
.face .strength { height: 4px; background: var(--rule); border-radius: 2px; margin-top: 3px; }
.face .strength span { display: block; height: 4px; background: var(--accent); border-radius: 2px; }
.face .caption { font-size: 12px; color: var(--ink-2); }
.face input[type=checkbox] { width: 18px; height: 18px; }
.face.selected img { outline: 3px solid var(--accent); }

/* Photo grids with a download selection (person, search, recently added) */
h3.day { font-size: 22px; font-weight: 700; line-height: 1.25; color: var(--ink); margin: 28px 0 10px; }
.photo { position: relative; }
.photo > input[type=checkbox] { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; margin: 0; cursor: pointer; }
.photo:has(input:checked) img { outline: 3px solid var(--accent); outline-offset: -3px; }
.dl-bar { position: sticky; bottom: 0; margin-top: 14px; }
ul.people-list { margin: 0; padding-left: 18px; }
ul.people-list li { margin: 3px 0; }

/* Full photo with a face box */
.photo-view { position: relative; display: inline-block; max-width: 100%; }
.photo-view img { max-width: 100%; max-height: 78vh; display: block; border-radius: var(--r-control); }
.photo-view .box { position: absolute; border: 2px solid rgba(255, 255, 255, .55); border-radius: 3px; }
.photo-view .box.focus { border: 3px solid var(--mark); box-shadow: 0 0 0 2px rgba(0, 0, 0, .45); }
.photo-view .box.hover { border: 3px solid var(--accent); box-shadow: 0 0 0 2px rgba(0, 0, 0, .45); }

/* Review */
.review-head { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.review-head a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--edge); border-radius: var(--r-chip); color: var(--ink); background: var(--surface);
}
.review-head a.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
@media (max-width: 760px) {
  .review-head { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; padding-bottom: 4px; }
}
.review-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; }
.review-card h2 { margin-top: 0; }
.review-card h2:focus { outline: none; }
.review-card h2:focus-visible { outline: 3px solid var(--ring); }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .sides { grid-template-columns: 1fr; } }
.side { border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px; min-width: 0; }
.answers { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule); }
.answers button, .answers .button { padding: 8px 14px; min-height: 44px; }
.answers button kbd { margin-left: 6px; }
.answers button.armed { background: var(--caution); border-color: var(--caution); color: var(--surface); }
.arm-note { color: var(--caution); font-weight: 600; margin: 8px 0 0; }
.img-status { color: var(--ink-2); margin: 8px 0 0; }
.undo { margin-top: 12px; }
.keys { margin-top: 14px; }
.warning { color: var(--caution); }
.context-photo { display: block; max-width: 100%; min-width: 0; }
.context-photo img { max-width: 100%; max-height: 300px; height: auto; border-radius: var(--r-control); display: block; }

/* Tables: on narrow screens a wide table scrolls inside itself, never the page. */
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
table.list th, table.list td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.list th { font-weight: 600; font-size: 14px; color: var(--ink-2); }
@media (max-width: 760px) { table.list { display: block; overflow-x: auto; } }
.pager { display: flex; gap: 10px; align-items: center; margin: 16px 0; }
.pager a { display: inline-flex; align-items: center; min-height: 40px; }
.login { max-width: 360px; margin: 10vh auto; }
.login label { display: block; margin: 10px 0 4px; }
.login input { width: 100%; }
pre.json { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; margin: 0; color: var(--ink-2); }

/* --- M1: person page, cover picker, about --- */
/* Person page head: the cover with its "Change cover" button, then the name and the details. */
.person-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.person-cover { display: flex; flex-direction: column; gap: 8px; width: 168px; }
.person-cover .cover-change { text-align: center; display: block; }
.person-info { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 6px; }
.person-name h1 { margin: 4px 0 2px; }
.person-name .name-edit { color: var(--ink); }
.person-name .name-edit:hover { text-decoration: none; }
.person-name .name-edit .name-edit-hint { font-weight: 400; color: var(--accent); margin-left: 6px; }
.person-name .name-edit:hover .name-edit-hint, .person-name .name-edit:focus-visible .name-edit-hint { text-decoration: underline; }
.name-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.name-form input[type=text] { font-size: 18px; min-width: 0; width: 22em; max-width: 100%; }
.name-form .small { flex-basis: 100%; }
details.person-edit > summary { cursor: pointer; color: var(--accent); width: max-content; }
details.person-edit[open] > summary { margin-bottom: 8px; }
details.person-edit input[type=number] { width: 7em; }

/* Sort links: the active one is marked (not only by colour). */
.sort-links a.on, .sort-links a[aria-current] { font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* Cover picker (Faces page, mode=cover): whole-tile buttons, the current cover ringed. */
.now-showing { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 4px 0 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.now-showing .face.big img { height: 186px; }
.now-showing .now-label { font-weight: 600; font-size: 17px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); gap: 10px; }
.pick { position: relative; display: block; width: 100%; padding: 4px; border: 2px solid transparent; border-radius: var(--radius);
  background: var(--panel); cursor: pointer; text-align: left; }
.pick img { display: block; width: 100%; aspect-ratio: 6 / 7; object-fit: cover; border-radius: 6px; background: var(--line); }
.pick:hover { border-color: var(--accent); }
.pick:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.pick.current, .pick:disabled { opacity: 1; cursor: default; border-color: var(--ok); }
.pick .strength { display: block; height: 4px; background: var(--line); border-radius: 2px; margin-top: 4px; }
.pick .strength span { display: block; height: 4px; background: var(--accent); border-radius: 2px; }
.pick-now { position: absolute; top: 8px; left: 8px; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 10px;
  background: var(--ok); color: var(--panel); }

/* About: text and files. */
section.about { margin: 8px 0 4px; max-width: 900px; }
section.about h2 { margin: 10px 0 6px; }
section.about h3 { font-size: 15px; margin: 12px 0 6px; }
.about-head { gap: 8px; }
.about-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 4px; }
.about-merged { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; margin: 10px 0; }
.about-form textarea { width: 100%; min-height: 8em; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink); }
.about-form textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.about-form .row { margin-top: 6px; }
details.add-file > summary { list-style: none; }
details.add-file > summary::-webkit-details-marker { display: none; }
details.add-file[open] > summary { margin-bottom: 8px; }
.upload-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.upload-form input[type=file] { max-width: 100%; }
table.files td { vertical-align: middle; }
table.files .file-name { overflow-wrap: anywhere; }
table.files .file-actions { white-space: nowrap; text-align: right; }
table.files .file-actions a + a, table.files .file-actions a + form { margin-left: 10px; }
.danger-link { color: var(--bad); }
.confirm-delete { flex-wrap: wrap; }
@media (max-width: 600px) {
  .person-cover { width: 100%; flex-direction: row; align-items: flex-end; }
  table.files .file-actions { white-space: normal; text-align: left; }
}

/* --- M1b: "Could be the same person" on the person page (web/similar.py) --- */
section.similar { margin: 8px 0 4px; max-width: 900px; }
section.similar h2 { margin: 14px 0 8px; }
.similar-row { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 10px; }
.similar-row .similar-head { gap: 6px 12px; }
.similar-row .faces { margin: 8px 0 4px; }
.similar-row .warning { margin: 6px 0; }
.similar-row .flash { margin: 8px 0; }
.similar-row .match { display: inline-flex; align-items: center; gap: 6px; }
.similar-row .strength { display: inline-block; width: 96px; height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.similar-row .strength span { display: block; height: 6px; background: var(--accent); }
.similar-row.done { color: var(--ink-2); padding: 8px 14px; }
.badge.question { border-color: var(--accent); color: var(--accent); }
.similar-actions { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-top: 8px; }
.similar-actions .warning, .similar-actions .arm-note { flex-basis: 100%; margin: 0; }
.similar-actions button.armed { background: var(--caution); border-color: var(--caution); color: var(--surface); }
button.link-button { background: none; border-color: transparent; color: var(--accent); padding: 6px 4px; }
button.link-button:hover { text-decoration: underline; }

/* --- M3: person photos --- */
/* Person page: photo tiles (web/photos.py, templates/_photo_macros.html). The frame fills the
   tile with a ring at the face; the person's face is a small inset in the bottom corner away from
   the ring. When the photo isn't on this server, the face fills the tile with a note. "×6" when the
   tile stands for photos taken moments apart; the checkbox selects all of them. */
.bursts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
@media (max-width: 600px) { .bursts { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; } }
.burst { position: relative; padding: 4px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.burst:hover { border-color: var(--accent); }
.burst:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.burst > a { position: relative; display: block; color: var(--ink); }
.burst > a:hover { text-decoration: none; }
.burst-frame { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--r-photo); background: var(--sunken); }
.burst-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.burst-face { position: absolute; bottom: 6px; width: 28%; max-width: 88px; aspect-ratio: 5 / 6; object-fit: cover;
  border: 2px solid var(--surface); border-radius: var(--r-photo); background: var(--sunken); box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.burst.inset-left .burst-face { left: 6px; }
.burst.inset-right .burst-face { right: 6px; }
.burst.no-photo .burst-face { position: static; width: 100%; max-width: none; aspect-ratio: 16 / 9; object-fit: contain;
  border: 0; box-shadow: none; }
.burst-frame.none { aspect-ratio: auto; margin-top: 4px; padding: 2px 6px; text-align: center; font-size: 12px; line-height: 1.25;
  color: var(--ink-2); background: none; }
.burst-n { position: absolute; top: 8px; right: 8px; padding: 1px 8px; border-radius: var(--r-chip); font-size: 13px; font-weight: 600;
  background: rgba(0, 0, 0, .72); color: #fff; pointer-events: none; }
.burst > input[type=checkbox] { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; margin: 0; cursor: pointer; }
/* A ring around a face on a 16:9 photo tile, centred on the face box (--l/--t/--w/--h in % of the
   photo) and at least 16 px wide: a face is about 2% of the frame's width. */
.ring { position: absolute; left: calc(var(--l) + var(--w) / 2); top: calc(var(--t) + var(--h) / 2);
  width: max(calc(var(--w) * 2), 16px); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  border: 2px solid var(--mark); box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(0, 0, 0, .6); pointer-events: none; }
/* Search results: rings on the named people; a photo that isn't on this server shows the face. */
.photos a { position: relative; }
.photo.stand-in a img { object-fit: contain; }
.tile-note { position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: var(--r-control);
  font-size: 12px; text-align: center; color: var(--ink-2); background: var(--surface); }
/* Photo page: previous / next through a person's photos, the photos of the same moment, and the
   face when the photo itself isn't on this server. */
.photo-nav { margin: 0 0 10px; }
.photo-steps { display: inline-flex; gap: 10px; align-items: center; margin-left: auto; }
@media (max-width: 600px) { .photo-steps { flex-basis: 100%; justify-content: space-between; } }
.photo-missing { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.photo-view .photo-missing img { width: 240px; aspect-ratio: 5 / 6; object-fit: cover; border-radius: var(--r-photo); background: var(--sunken); }
.burst-strip h2 { font-size: 16px; }
.strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; }
.strip a { flex: none; display: block; padding: 2px; border: 2px solid transparent; border-radius: var(--r-control); }
.strip a.on { border-color: var(--accent); }
.strip img { display: block; width: 72px; height: 86px; object-fit: cover; border-radius: var(--r-photo); background: var(--sunken); }

/* --- M2: naming --- */
/* Name people (/name): cards with the cover (six faces on hover or focus) and a name field. */
.naming-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 6px; font-weight: 600; }
.naming-progress progress { width: 160px; height: 10px; accent-color: var(--accent); }
.naming-help { margin: 0 0 8px; max-width: 75ch; }
.naming-filter { margin-bottom: 4px; }
.naming-hint { margin: 0 0 14px; }
.naming-empty, .people-empty { margin: 8px 0; max-width: 75ch; }
.naming-empty p, .people-empty p { margin: 4px 0; }
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 12px; }
@media (max-width: 420px) { .name-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.name-card { display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); overflow: hidden; }
.name-card:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.name-card.conflict { border-color: var(--caution); box-shadow: 0 0 0 1px var(--caution); }
.name-card.error { border-color: var(--stop); box-shadow: 0 0 0 1px var(--stop); }
.name-card.saved { border-color: var(--accent); }
.name-card[aria-busy="true"] .nc-input { color: var(--ink-2); }
.nc-look { position: relative; display: block; aspect-ratio: 6 / 7; background: var(--sunken); }
.nc-look:focus-visible { outline-offset: -3px; }
.nc-cover { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Three faces a row, rows sharing the height; two or four faces two a row. */
.nc-samples { position: absolute; inset: 0; display: none; grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr; gap: 2px; background: var(--sunken); }
.nc-samples[data-n="2"], .nc-samples[data-n="4"] { grid-template-columns: repeat(2, 1fr); }
.nc-samples img { display: block; width: 100%; height: 100%; object-fit: cover; }
.name-card:hover .nc-samples, .name-card:focus-within .nc-samples { display: grid; }
.nc-body { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 10px; min-width: 0; }
.nc-head { display: flex; flex-direction: column; min-width: 0; }
.nc-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-card.saved .nc-label { font-size: 18px; color: var(--accent); }
.nc-form { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.nc-form .nc-input { flex: 1 1 90px; min-width: 0; width: 100%; }
.nc-save { flex: none; padding: 6px 8px; }
.nc-note { font-size: 14px; margin: 0; color: var(--ink); }
.nc-note p { margin: 0 0 4px; }
.name-card.conflict .nc-note > p:first-child { color: var(--caution); font-weight: 600; }
.nc-note.error { color: var(--stop); }
.nc-hint { color: var(--ink-2); }
.nc-saved { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.nc-done { font-weight: 600; color: var(--accent); }
.nc-undo button { padding: 4px 10px; }

/* Person typeahead: a listbox under the field (search, People, "Merge into..."). */
.suggest-wrap { position: relative; display: inline-block; max-width: 100%; }
.suggest-wrap > input { max-width: 100%; }
.suggest { position: absolute; z-index: 20; left: 0; top: calc(100% + 4px); min-width: 100%; width: 18rem;
  max-width: calc(100vw - 32px); max-height: 60vh; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-control);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.suggest[hidden] { display: none; }
@media (max-width: 600px) { .suggest { right: 0; width: auto; min-width: 0; } }  /* as wide as the field */
.suggest a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 3px 8px; color: var(--ink);
  border-radius: 4px; }
.suggest a:hover { text-decoration: none; background: var(--sunken); }
.suggest [aria-selected="true"] a { background: var(--accent); color: var(--accent-ink); }
.suggest [aria-selected="true"] .muted { color: inherit; }
.suggest img, .merge-preview img { flex: none; width: 32px; height: 38px; object-fit: cover; border-radius: 4px;
  background: var(--sunken); }
.suggest-text { display: flex; flex-direction: column; min-width: 0; }
.suggest-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.merge-preview { display: inline-flex; align-items: center; gap: 8px; }
.merge-preview[hidden] { display: none; }
.merge-preview .suggest-text { flex-direction: row; gap: 6px; flex-wrap: wrap; }

/* --- Fragment absorption: approving a batch its control cards alone blocked (web/absorb.py) --- */
.panel.override { margin: 16px 0; max-width: 900px; border-color: var(--caution); }
.panel.override h2 { margin: 0 0 8px; }
.panel.override ul { margin: 4px 0 10px; padding-left: 20px; }
.override-form { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.override-form textarea { width: 100%; min-height: 5em; font: inherit; padding: 8px; border: 1px solid var(--edge);
  border-radius: var(--r-control); background: var(--surface); color: var(--ink); }
.override-accept { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.override-note { overflow-wrap: anywhere; }
