:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1b1f24; --muted: #5b6573; --border: #d5dae1;
  --accent: #0b6e4f; --accent-text: #ffffff; --danger: #b3261e; --info: #1d4f91;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --surface: #1d2127; --text: #e8ebef; --muted: #9aa5b3; --border: #343b45;
    --accent: #3fb68b; --accent-text: #0b1410; --danger: #ff8a80; --info: #8ab4f8;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
footer { max-width: 760px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: 0.85rem; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; margin-top: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-top: 16px; }
.card.narrow { max-width: 380px; margin: 12vh auto 0; }
.bar { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.bar .muted { flex: 1; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 0.9rem; }
.grid .field { margin-bottom: 0; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); min-height: 40px; width: 100%; }
button { font: inherit; padding: 9px 16px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-text); cursor: pointer; min-height: 40px; }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: 0.55; cursor: progress; }
button.link { background: transparent; color: var(--text); text-align: left; padding: 6px 8px; width: 100%; border-radius: 6px; }
button.link.active { background: var(--bg); font-weight: 600; outline: 2px solid var(--accent); }
.list { list-style: none; padding: 0; margin: 0 0 8px; }
.list li + li { margin-top: 4px; }
.status { min-height: 1.5em; margin: 8px 0; }
.status.error { color: var(--danger); }
.status.info { color: var(--info); }
.result { margin-top: 12px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dt { color: var(--muted); } dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.preview { width: 100%; max-height: 220px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.preview[hidden] { display: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.multi { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin: 0; min-width: 0; font-size: 0.9rem; }
.multi legend { padding: 0 4px; }
.check { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.check input { width: auto; min-height: 0; }

input[type="search"] { margin-bottom: 8px; }
details.more { margin-top: 12px; }
details.more > summary { cursor: pointer; padding: 6px 0; font-weight: 600; }
details.more[open] > summary { margin-bottom: 8px; }
.card .list button.link { white-space: normal; }
@media (max-width: 480px) { main { padding: 10px; } .card { padding: 12px; } dl { grid-template-columns: 1fr; gap: 0; } dd { margin-bottom: 8px; } }

.qr { display: block; margin: 12px auto; width: 200px; height: 200px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 6px; }
.secret { font: 600 1rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; user-select: all; text-align: center; letter-spacing: 0.05em; }

/* Touch-friendly sizing (phones and tablets): 16px text stops iOS Safari zooming the page when a
   field is tapped, and 44px targets are comfortable for a finger (Apple and WCAG guidance). */
input, select { font-size: 1rem; min-height: 44px; }
button { min-height: 44px; }
button.link { min-height: 44px; }
details.more > summary { min-height: 44px; padding: 10px 0; } /* padding, not flex, so the expand arrow stays */
.check { min-height: 44px; gap: 10px; padding: 0 4px; }
.check input { width: 22px; height: 22px; flex: none; }

[hidden] { display: none !important; }
.bar button { white-space: nowrap; }

.bar { flex-wrap: wrap; }
.report-link { margin: 24px 0 8px; }
.report-link button.link { width: auto; color: var(--muted); text-decoration: underline; }
textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
.capture { min-width: 0; margin-bottom: 8px; }
.capture-label { margin: 0 0 6px; font-weight: 600; }
.capture-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.capture-select { flex: 1; min-width: 160px; }
.capture-panel { border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-top: 8px; }
.capture-video { width: 100%; max-height: 60vh; background: #000; border-radius: 6px; display: block; }
.capture-panel[hidden] { display: none; }

/* Crop dialog and the photo tray (several close-up photos per case) */
.crop-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 12px; }
.crop-box { background: var(--surface); color: var(--text); border-radius: 10px; padding: 12px; max-width: 96vw; max-height: 96vh; overflow: auto; }
.crop-help { margin: 0 0 8px; font-size: 0.9rem; color: var(--muted); }
.crop-canvas { display: block; max-width: 100%; touch-action: none; user-select: none; border-radius: 4px; background: #000; margin: 0 auto; }
.tray-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 8px 0; }
.tray-item { margin: 0; border: 1px solid var(--border); border-radius: 8px; padding: 8px; min-width: 0; }
.tray-item .preview { width: 100%; max-height: 160px; object-fit: contain; background: var(--bg); }
.suggestion { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }

/* User app: burst capture (about 12 pictures, three get selected) and the result list */
.burst-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 8px 0; }
.thumb { background: var(--bg); color: var(--text); border: 2px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.thumb-open { padding: 0; border: 0; border-radius: 0; background: none; min-height: 0; line-height: 0; cursor: zoom-in; }
.thumb-open img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.thumb-use { margin: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; min-height: 44px; font-size: 0.9rem; background: var(--bg); color: var(--muted); }
.thumb.selected { border-color: var(--accent); outline: 2px solid var(--accent); }
.thumb.selected .thumb-use { color: var(--text); font-weight: 600; }

/* Capture mode (automatic or manual) and the pictures taken by hand */
.mode-box { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 8px; padding: 6px 10px 8px; }
.mode-box legend { padding: 0 6px; font-weight: 600; }
.mode-option { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 6px 0; cursor: pointer; }
.mode-option input { width: 22px; height: 22px; flex: none; margin-top: 2px; }
.manual-box[hidden] { display: none; }
.manual-strip { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.strip-img { width: 72px; height: auto; border-radius: 4px; border: 1px solid var(--border); background: #000; }

/* Enlarged picture viewer */
.viewer { position: fixed; inset: 0; z-index: 1100; background: rgba(0, 0, 0, 0.92); color: #fff; display: flex; flex-direction: column; }
.viewer-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; background: rgba(0, 0, 0, 0.6); }
.viewer-count { margin-right: auto; font-weight: 600; }
.viewer-stage { flex: 1; min-height: 0; overflow: auto; display: flex; touch-action: none; user-select: none; }
.viewer-stage.zoomed { touch-action: auto; }
.viewer-img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; -webkit-user-drag: none; }
.viewer-stage.zoomed .viewer-img { max-width: none; max-height: none; width: auto; height: auto; cursor: grab; }
.viewer-stage.zoomed .viewer-img.dragging { cursor: grabbing; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 72px; font-size: 2.2rem; line-height: 1; padding: 0; border-radius: 8px; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; }
.viewer-prev { left: 8px; }
.viewer-next { right: 8px; }
.viewer-nav[hidden] { display: none; }
dl.results dd { font-weight: 600; }
.viewer button.secondary { color: #fff; border-color: rgba(255, 255, 255, 0.55); }
.viewer button:disabled { opacity: 0.7; }
