/* ============================================================
   Officer Citation Wizard (desk/field) multi-step page.
   Structure in @layer layout, paint in @layer design. Content-named
   classes only — no legacy/appearance names, no hardcoded color.

   Every step renders through pages/_task.html, which puts it in a raised
   work surface (design-system/components/surfaces) and gives it the page
   gutter and its top and bottom padding (design-system/pages.css). Older
   rules here still read --t-* tokens; theme.css's white-card rule rebinds
   them for .officer-citation. See design-system/README.md.
   ============================================================ */

@layer layout {

	/* The wizard column: progress strip above the active step region. The
	   task page template pads the card top and bottom; the page pads its own
	   content inline, so a header's button row can reach the card's edges. */
	.officer-citation {

		/* should be a theme token */
		--p-i: var(--t-space-5);
		--gap: var(--t-space-5);
		
		/* Every header but a pane's, which the pane lays out itself. */
		& header:not(.pane > header) {

			display: flex;
			flex-direction: column;
			gap: var(--gap);

			& .button-row button, & .button-row a.button {
				padding-inline: var(--p-i);
			}

			& > *:not(.button-row) {
				padding-inline: var(--p-i);
			}

			& .title {
				font-family: var(--t-font-family-heading);
				font-size: var(--t-font-size-hero);
				font-weight: var(--t-font-weight-bold);
			}

			& .subtitle {
				font-size: var(--t-font-size-sm);
			}
		}

		& > :not(header) {
			padding-inline: var(--p-i);
		}

		& > div.content {
			gap: var(--gap);
		}
	}

	.officer-citation .citation-step[data-step="items"] {

		& .existing-items {
			list-style: none;
			display: grid;
			gap: var(--t-space-2);
			padding: 0;

			& li {
				display: grid;
				grid-template-columns: 1fr auto;
				align-items: start;
				gap: var(--t-space-2);
				padding: var(--t-space-3);
				border-radius: var(--t-radius-md);
			}

			/* Kept in the markup for the photo thumbnail to come; nothing
			   serves a draft item's photo yet, so it isn't shown. */
			& .photo {
				display: none;
			}

			& .summary {
				display: grid;
				gap: var(--t-space-1);
			}

			& .name {
				font-weight: var(--t-font-weight-semibold);
			}

			& .badges {
				display: flex;
				flex-wrap: wrap;
				gap: var(--t-space-1);
			}

			& .details {
				font-size: var(--t-font-size-sm);
			}

			& .actions {
				display: flex;
				gap: var(--t-space-1);
			}

			/* The row's form only groups its buttons for the POST. Letting
			   its parts sit in the row's grid puts the "Sending" line on a
			   row of its own under the item, so it doesn't widen the button
			   column and squeeze the item's name and price. */
			& form {
				display: contents;
			}

			& .citation-step__submit-status {
				grid-column: 1 / -1;
			}
		}

		& .running-total {
			display: grid;
			gap: var(--t-space-2);
			padding-block-start: var(--t-space-3);
			border-block-start-width: var(--t-border-width-strong);

			& dl {
				display: flex;
				align-items: center;
			}

			& dt {
				flex-grow: 1;

				&::after {
					content: ":";
				}
			}

			& dd {
				font-size: var(--t-font-size-md);
				font-weight: var(--t-font-weight-bold);
			}

			& .badges {
				display: flex;
				flex-wrap: wrap;
				gap: var(--t-space-1);
			}
		}

		/* The add/edit form keeps a readable measure on a wide screen. */
		& .evidence-form {
			inline-size: min(100%, 48rem);
			justify-self: center;
		}
	}

	/* The screening question counter ("Question 1 of 3"). */
	.question-count {
		margin: 0;
		font-size: var(--t-font-size-sm);
	}

	/* Active step shell: back/cancel control, then the step's content. */
	.citation-step-region {
		display: grid;
		min-inline-size: 0;
	}

	.citation-step {
		display: grid;
		gap: var(--mea-space-4);
		align-content: start;
		min-inline-size: 0;
	}

	/* The back button sits at the start of its step, not stretched across it. */
	.officer-citation a[rel="prev"] {
		justify-self: start;
	}

	.citation-step__title,
	.citation-step__subtitle {
		margin: 0;
	}

	/* Each step's Next fills its row. */
	.officer-citation .wizard-nav button[type="submit"] {
		flex-grow: 1;
	}

	.citation-step__actions {
		display: flex;
		flex-wrap: wrap;
		gap: var(--mea-space-3);
	}

	/* The photo control (a label pointing at the file input) fills its row,
	   as scan ID's one action. */
	.citation-step__actions .button[for] {
		flex: 1;
	}

	.citation-step__actions--stacked {
		flex-direction: column;
	}

	.citation-step__link {
		background: transparent;
	}

	.wizard-nav {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		gap: var(--mea-space-3);
		padding-block: var(--mea-space-4);
	}

	.offense-search {
		padding: 0;
	}

	.citation-offense-option {
		display: flex;
		flex-direction: row;
		align-items: center;
		gap: var(--mea-space-3);
		padding: var(--mea-space-4) 0;
		border-bottom-width: 1px;
	}

	/* Review-gated voice and vision helpers reuse the wizard's field/button language. */
	.citation-ai-tool {
		display: grid;
		gap: var(--mea-space-3);

		margin-block-end: var(--mea-space-4);
	}

	/* The HTML `hidden` attribute MUST win over the author `display` above:
	   location-picker.js hides the static-map figure and the picker by
	   setting `hidden`, but `display:grid` here (and on .citation-map) beats
	   the UA `[hidden]{display:none}` in the cascade. Without this guard both
	   maps stay visible. Same pattern as consent.css / encounters.css /
	   messages.css. */
	.citation-map[hidden],
	.citation-ai-tool[hidden] {
		display: none;
	}

	/* The no-JS dictation block (the voice and audio capture macros): a
	   title, the pre-record notice, the audio field, the attestation and the
	   actions. voice-capture.js hides it with `hidden` once the one-tap mic
	   takes over, so the guard below must beat the grid. */
	.officer-citation .dictation {
		display: grid;
		gap: var(--t-space-3);

		& h3 {
			margin: 0;
			font-family: var(--t-font-family-heading);
			font-size: var(--t-font-size-md);
			font-weight: var(--t-font-weight-bold);
		}

		&[hidden] {
			display: none;
		}
	}

	/* Under the notes box, the block needs room from the box above it. */
	.dictatable-notes-input .dictation {
		margin-block-start: var(--t-space-3);
	}

	.citation-ai-tool__header,
	.citation-ai-tool__review {
		display: grid;
		gap: var(--mea-space-2);
	}

	.citation-ai-tool__title,
	.citation-ai-tool__hint,
	.citation-ai-tool__status {
		margin: 0;
	}

	.citation-ai-tool__actions {
		display: flex;
		flex-wrap: wrap;
		gap: var(--mea-space-3);
	}

	/* Each action fills the row, two to a line when they fit. The actions
	   are button components, which render as a bare <button> with no
	   shared class, so this matches the children. */
	.citation-ai-tool__actions > * {
		flex: 1 1 12rem;
	}

	.citation-ai-tool__review .btn {
		justify-self: start;
	}

	/* Every receipt form lands back on this heading. On a phone the shell's
	   top bar stays over the page, so the heading stops below it: the seal's
	   largest height (.tenant-seal in web/static/css/web.css) and the bar's
	   padding (design-system/pages.css), with a little room after it. */
	#cit-receipt-title {
		scroll-margin-block-start: calc(96px + 3 * var(--mea-space-3));
	}

	/* Suggestion offer boxes: rows rendered in generic classes, scoped to
	   this section (same convention as the items block). The dictation box
	   is one list of suggestions, each labelled with what it is. The items
	   read from a store receipt sit in a group under their own heading. Each
	   row is its fields, prefilled for the officer to correct, then Accept
	   and Dismiss. */
	[aria-labelledby="cit-suggestions-title"],
	[aria-labelledby="cit-receipt-title"] {
		--list-gap: var(--mea-space-3);
		display: grid;
		gap: var(--list-gap);

		& > .heading {
			font-size: var(--mea-text-md);
			margin: 0;
		}

		& > .hint,
		& .suggestion-group > .hint {
			margin: 0;
		}

		& .suggestion-group {
			display: grid;
			gap: var(--mea-space-2);

			& .group-title {
				margin: 0;
			}
		}

		& .suggestion-list {
			display: grid;
			gap: var(--mea-space-2);
			margin: 0;
			padding: 0;

			& li.suggestion {
				list-style: none;
			}

			& .suggestion {
				display: grid;
				gap: var(--mea-space-2);
				border-width: 0;
				border-block-end-width: 1px;
				padding-block-end: var(--list-gap);

				&:last-child {
					border-block-end-width: 0;
				}

				/* Name across the top; quantity and price share the row
				   below, as on the form that adds an item by hand. */
				& .fields {
					display: grid;
					grid-template-columns: repeat(2, minmax(0, 1fr));
					gap: var(--mea-space-2);
					align-items: start;

					& .name {
						grid-column: 1 / -1;
					}

					/* The grid above beats the browser's own rule for
					   [hidden], so the read-only view could not hide the
					   fields without this. */
					&[hidden] {
						display: none;
					}
				}

				/* The read-only view a script shows in place of the fields:
				   a small label saying what the suggestion is, its main
				   value, and its other values, with the Edit button at the
				   top of the row's end. The label and the value give every
				   row at least the button's height, so the top leaves no gap
				   under a short suggestion. The main value is what the
				   officer scans the list for, so it is the strongest text in
				   the row. */
				& .suggestion-view {
					display: flex;
					align-items: start;
					justify-content: space-between;
					gap: var(--mea-space-2);

					/* A long unbroken value wraps, so it never pushes the
					   Edit button off a narrow screen. */
					& .values {
						min-width: 0;
						overflow-wrap: anywhere;
					}

					& .label {
						margin: 0;
						font-size: var(--mea-text-xs);
					}

					& .main {
						margin: 0;
						font-size: var(--mea-text-md);
						font-weight: var(--mea-w-semibold);
					}

					/* The Edit button's word. A phone has room only for the
					   icon, so there the word is hidden from sight but stays
					   in the button's name for a screen reader, the same way
					   .visually-hidden hides text. Where there is room it
					   shows beside the icon. */
					& .word {
						position: absolute;
						width: 1px;
						height: 1px;
						margin: -1px;
						overflow: hidden;
						clip-path: inset(50%);
						white-space: nowrap;

						@media (min-width: 48rem) {
							position: static;
							width: auto;
							height: auto;
							margin: 0;
							overflow: visible;
							clip-path: none;
						}
					}
				}

				& .actions {
					display: flex;
					gap: var(--mea-space-2);

					& .btn {
						font-size: var(--mea-text-sm);
						padding: var(--mea-space-2) var(--mea-space-4);
						min-height: 0;
					}
				}
			}
		}
	}

	/* Offense step: search → optional selection note → chip grid. */
	.offense-selected,
	.offense-hint {
		margin: 0;
	}

	.offense-grid {
		display: flex;
		flex-wrap: wrap;
		gap: var(--mea-space-2);
		min-inline-size: 0;
	}

	.offense-chip {
		display: inline-flex;
		align-items: center;
		min-height: var(--t-target-min, 44px);
		padding: var(--mea-space-2) var(--mea-space-4);
		border: 0;
		border-radius: var(--mea-radius-pill);
		cursor: pointer;
		text-align: start;
	}

	/* Location step: a coordinate map placeholder above the address field. */
	.citation-map {
		display: grid;
		place-items: center;
		gap: var(--mea-space-2);
		margin: 0;
		min-block-size: 12rem;
		padding: var(--mea-space-5);
		border-radius: var(--mea-radius-lg);
		/* The officer's natural gesture on this screen is to TAP THE MAP. On iOS
		   that selected the whole map as if it were text: a blue highlight, a
		   callout menu, and no pin. The one instinctive action on the screen did
		   nothing and looked broken.

		   Scoped to the map surface only: form fields, the address input and the
		   coordinate read-out below remain selectable, because an officer copying
		   an address is a real thing to do. */
		-webkit-user-select: none;
		user-select: none;
		-webkit-touch-callout: none;
	}

	.citation-map__pin {
		font-size: var(--mea-text-2xl);
		line-height: 1;
	}

	.citation-map__coords {
		margin: 0;
		text-align: center;
		word-break: break-word;
	}

	.dictatable-notes-input {
		position: relative;

		& .voice-mic {
			position: absolute;


			bottom: var(--mea-space-3);
			right: var(--mea-space-2);
		}

		/* An icon-only round button: the same padding on every side. Two
		   classes, to outrank the button component's inline padding. */
		& .voice-mic.primary {
			padding: var(--t-space-3);
		}
	}

	/* Evidence step: a known/unknown summary, then a grid of items + add tile. */
	.evidence-summary {
		display: flex;
		flex-wrap: wrap;
		gap: var(--mea-space-4);
		margin: 0;
		padding: var(--mea-space-3) var(--mea-space-4);
		border-radius: var(--mea-radius-md);
	}

	.evidence-summary__stat {
		display: inline-flex;
		align-items: baseline;
		gap: var(--mea-space-2);
	}

	.evidence-summary__label,
	.evidence-summary__value {
		margin: 0;
	}

	.evidence-grid {
		display: grid;
		grid-template-columns: 1fr;
		gap: var(--mea-space-3);
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.evidence-item {
		display: grid;
		grid-template-columns: auto 1fr auto;
		align-items: center;
		gap: var(--mea-space-2) var(--mea-space-3);
		padding: var(--mea-space-4);
		border-radius: var(--mea-radius-lg);
	}

	.evidence-item__label {
		grid-column: 1;
		font-weight: var(--mea-w-bold);
	}

	.evidence-item__file {
		grid-column: 2 / -1;
		min-inline-size: 0;
		word-break: break-word;
	}

	.evidence-item__value-label {
		grid-column: 1 / -1;
		margin: 0;
	}

	.evidence-item__value {
		grid-column: 1 / 3;
	}

	.evidence-item__confirm {
		grid-column: 3;
	}

	.evidence-item__status {
		grid-column: 1 / 3;
	}

	.evidence-item__ai {
		grid-column: 1 / -1;
		display: grid;
		gap: var(--mea-space-2);
		padding-block-start: var(--mea-space-2);
	}

	.evidence-item__ai-review {
		display: grid;
		gap: var(--mea-space-2);
	}

	.evidence-item__ai-status {
		margin: 0;
	}

	.evidence-item__apply-estimate {
		justify-self: start;
	}

	.evidence-item__remove {
		grid-column: 3;
		grid-row: 1;
		justify-self: end;
		align-self: start;
		inline-size: 1.75rem;
		block-size: 1.75rem;
		padding: 0;
		border: 0;
		background: transparent;
		cursor: pointer;
		border-radius: var(--mea-radius-md);
	}

	.evidence-add {
		margin: 0;
	}

	.evidence-add__control {
		display: grid;
		place-items: center;
		gap: var(--mea-space-2);
		min-block-size: 6rem;
		padding: var(--mea-space-5);
		cursor: pointer;
		border-radius: var(--mea-radius-lg);
	}

	.evidence-add__icon {
		font-size: var(--mea-text-2xl);
		line-height: 1;
	}

	.evidence-warning {
		margin: 0;
		padding: var(--mea-space-3);
		border-radius: var(--mea-radius-md);
	}

	@container (min-width: 30rem) {
		.evidence-grid {
			grid-template-columns: repeat(2, 1fr);
		}
	}

	/* Scan-ID step: a card-art illustration above the action stack. */
	.citation-id-illustration {
		display: grid;
		place-items: center;
		margin: 0;
		min-block-size: 7rem;
		border-radius: var(--mea-radius-lg);
	}

	.citation-id-illustration__icon {
		font-size: var(--mea-text-3xl);
		line-height: 1;
	}

	/* Citizen step: a responsive two-column field grid. Each field sizes to its
	   own content and pins to the top of the row; a field with a helper note
	   below its input (the phone field says why a mobile number is required)
	   stays as tall as it needs without stretching its row-mate's input. */
	.citation-form-grid {
		display: grid;
		grid-template-columns: 1fr;
		gap: var(--mea-space-4);
		align-items: start;
		min-inline-size: 0;
	}

	.citation-field--full {
		grid-column: 1 / -1;
	}

	@container (min-width: 32rem) {
		.citation-form-grid {
			grid-template-columns: repeat(2, 1fr);
		}
	}

	/* Screening questions: two large yes/no choices. */
	.citation-yn {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: var(--mea-space-3);
	}

	.citation-yn__choice {
		min-height: 4rem;
		padding: var(--mea-space-4);
		border: 0;
		border-radius: var(--mea-radius-lg);
		cursor: pointer;
	}

	/* Success screen + participant invite handoff. */
	.citation-success {
		display: grid;
		gap: var(--mea-space-4);
		justify-items: center;
		text-align: center;
		padding: var(--mea-space-6) var(--mea-space-4);
	}

	.citation-success__icon {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		inline-size: 3.5rem;
		block-size: 3.5rem;
		margin: 0;
		border-radius: var(--mea-radius-circle);
	}

	.citation-success__title,
	.citation-success__sub {
		margin: 0;
	}

	/* The referral warning is the page's h1 (officer_issue.html) but reads
	   as the callout's first line, not as a page title. */
	.citation-success .callout h1 {
		margin: 0;
		font: inherit;
	}

	.citation-eligibility {
		display: grid;
		gap: var(--mea-space-1);
		justify-items: center;
		inline-size: 100%;
		padding: var(--mea-space-4);
		border-radius: var(--mea-radius-lg);
	}

	.citation-eligibility__label,
	.citation-eligibility__outcome {
		margin: 0;
	}

	.invite-handoff {
		display: grid;
		gap: var(--mea-space-3);
		inline-size: 100%;
		padding: var(--mea-space-5);
		border-radius: var(--mea-radius-xl);
	}

	.invite-handoff__body {
		display: grid;
		gap: var(--mea-space-3);
		justify-items: center;
	}

	.invite-handoff__qr {
		display: grid;
		place-items: center;
		margin: 0;
		inline-size: 10rem;
		block-size: 10rem;
		padding: var(--mea-space-2);
		border-radius: var(--mea-radius-md);
	}

	.invite-qr-svg {
		inline-size: 100%;
		block-size: 100%;
	}

	.invite-handoff__details {
		display: grid;
		gap: var(--mea-space-1);
		justify-items: center;
		margin: 0;
	}

	.invite-handoff__label,
	.invite-handoff__code {
		margin: 0;
	}

	.invite-handoff__code {
		word-break: break-all;
	}

	.invite-handoff__link {
		text-decoration: none;
	}

	/* Report launch card on the success screen. */
	.citation-report-launch {
		display: grid;
		gap: var(--mea-space-2);
		inline-size: 100%;
		padding: var(--mea-space-5);
		border-radius: var(--mea-radius-xl);
		text-align: start;
	}

	.citation-report-launch__title,
	.citation-report-launch__hint {
		margin: 0;
	}

	.citation-report-launch .btn {
		justify-self: start;
	}

	/* Report review panel: stacked editable fields, then a checklist + actions. */
	.citation-report {
		display: grid;
		gap: var(--mea-space-4);
		align-content: start;
		min-inline-size: 0;
		text-align: start;
	}

	.citation-report__header {
		display: grid;
		gap: var(--mea-space-2);
	}

	.citation-report__title,
	.citation-report__subtitle,
	.citation-report__empty {
		margin: 0;
	}

	.citation-report__fieldset {
		display: grid;
		gap: var(--mea-space-2);
		margin: 0;
		padding: var(--mea-space-4);
		border-radius: var(--mea-radius-lg);
		min-inline-size: 0;
	}

	.citation-report__legend,
	.citation-report__group-title {
		margin: 0;
		padding-inline: var(--mea-space-1);
	}

	.citation-report__timeline,
	.citation-report__notes,
	.citation-report__evidence,
	.citation-report__checklist {
		display: grid;
		gap: var(--mea-space-2);
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.citation-report__timeline-item {
		display: grid;
		min-inline-size: 0;
	}

	.citation-report__group {
		display: grid;
		gap: var(--mea-space-2);
		padding: var(--mea-space-4);
		border-radius: var(--mea-radius-lg);
		min-inline-size: 0;
	}

	.citation-report__note {
		display: grid;
		grid-template-columns: 1fr auto;
		gap: var(--mea-space-3);
		align-items: center;
	}

	.citation-report__note-text {
		min-inline-size: 0;
		word-break: break-word;
	}

	.citation-report__evidence-item {
		word-break: break-word;
	}

	.citation-report__check {
		display: grid;
		grid-template-columns: auto 1fr;
		gap: var(--mea-space-2);
		align-items: baseline;
	}


	dialog.photo-capture {
		max-height: none;
		max-width: none;
		width: 100vw;
		/* 100vh is the LARGE viewport on iOS Safari — it excludes the browser
		   chrome, so the dialog is taller than what the officer can see and the
		   capture controls sit below the fold. A <dialog> does not scroll, so
		   they are unreachable: the founder hit a full-screen camera with no
		   controls, and could only glimpse them by pinch-zooming. dvh tracks
		   the visible viewport; vh stays as the fallback for browsers without
		   dvh support. */
		height: 100vh;
		height: 100dvh;
		max-block-size: 100dvh;
	}

	/* ── barcode scanning mode ──────────────────────────────────────────
	 *
	 * Founder, on the Safari camera experience: "the view of the camera could
	 * use a red bar for barcode scanning mode and we need copy directing the
	 * officer to scan the barcode specifically."
	 *
	 * The dialog previously opened as a bare camera rectangle with a generic
	 * message. An officer holding a licence has no way to tell it is looking
	 * for the PDF417 on the BACK — so they aim at the photo side, the scan
	 * times out, and a working feature reads as broken.
	 *
	 * The bar is an AIMING GUIDE, not decoration: it marks the band the
	 * officer should lay the barcode across. Only in barcode mode — scene and
	 * item photos share this dialog and must stay unadorned.
	 */
	.photo-capture .preview {
		position: relative;
	}

	.photo-capture .overlay {
		display: none;
	}

	.photo-capture--barcode .overlay {
		display: block;
		position: absolute;
		inset-inline: 8%;
		inset-block-start: 50%;
		block-size: 3px;
		transform: translateY(-50%);
		background: var(--mea-red);
		border-radius: var(--mea-radius-pill);
		pointer-events: none;
	}

	/* The scan has timed out. Reduced-motion users keep a static bar; everyone
	   else gets a slow sweep so a live camera never looks frozen. */
	@media (prefers-reduced-motion: no-preference) {
		.photo-capture--barcode:not(.photo-capture--scan-failed) .overlay {
			animation: mea-scan-sweep var(--mea-dur-slow, 1.6s) ease-in-out infinite alternate;
		}
	}

	@keyframes mea-scan-sweep {
		from { inset-block-start: 38%; }
		to   { inset-block-start: 62%; }
	}

	/* "Scan again" exists only once a scan has failed. Before that there is
	   nothing to retry, and an always-visible retry implies the scan is not
	   already running. */
	/* Scoped to the dialog for the same reason as the native label below: the
	   button component's own display rule sits in the same layer, and a
	   one-class rule lost to the old .btn -- "Scan again" showed while the
	   first scan was still running. */
	.photo-capture button[value="rescan"] {
		display: none;
	}

	.photo-capture.photo-capture--scan-failed button[value="rescan"] {
		display: inline-flex;
	}

	/* "Photograph front instead" needs a picture to photograph. Until the
	   first real frame (and after a failure) it is not offered: tapping it on
	   a blank preview could only fail. */
	.photo-capture:not(.photo-capture--live) button[value="capture"] {
		display: none;
	}

	/* Failed: the bar stops being an aiming guide and becomes a state signal. */
	.photo-capture--scan-failed .overlay {
		opacity: 0.35;
	}

	/* The live camera failed (refused, busy, never started, no picture). The
	   only honest way forward is the phone's own camera: nothing may be
	   photographed from a dead preview, and no bar may claim a scan is
	   running. Shared by every photo dialog, barcode or not. */
	/* Scoped to the dialog: the label is also a button component, whose
	   display rule sits in the same layer, so a weaker rule here would lose
	   to it -- the old .btn did, showing the fallback when nothing failed. */
	.photo-capture [data-native-capture] {
		display: none;
	}

	.photo-capture.photo-capture--camera-error [data-native-capture] {
		display: inline-flex;
		/* The action row stretches its buttons; this is a label, so it must
		   ask for the same, or it collapses to a wrapped circle on a phone. */
		flex: 1 1 auto;
	}

	.photo-capture--camera-error .overlay,
	.photo-capture--camera-error button[value="capture"],
	.photo-capture.photo-capture--camera-error button[value="rescan"] {
		display: none;
	}

	/* The photo is on its way: no second tap can send it twice. */
	.photo-capture--sending .actions {
		visibility: hidden;
	}

	/* The photo being sent, in place of the released camera (dialog) or
	   under the controls (phone-camera path), with a spinner beside the
	   "Sending the photo" line. Structure here; colours in @layer design. */
	.photo-capture .preview [data-sent-photo] {
		max-inline-size: 100%;
		max-block-size: 100%;
		margin: auto;
		object-fit: contain;
	}

	/* Without script, sending is the step after photographing: its own row
	   under the photo control. Dimmed while the form has no photo -- dimmed,
	   not disabled, so pressing it anyway gets the browser's "select a file"
	   prompt -- and a ready callout once a photo is attached. */
	.officer-citation [data-send-photo-row] {
		flex-basis: 100%;
		display: grid;
		gap: var(--t-space-2);
		margin-block-start: var(--t-space-4);

		&[hidden] {
			display: none;
		}
	}

	/* Two attributes, to outrank the callout's own display rule. */
	.officer-citation [data-send-photo-row] [data-photo-ready] {
		display: none;
	}

	.officer-citation form:valid [data-send-photo-row] [data-photo-ready] {
		display: grid;
	}

	form:invalid [data-send-photo] {
		opacity: 0.5;
	}

	.officer-citation [data-scan-sending] {
		display: grid;
		gap: var(--t-space-2);
		justify-items: center;
		/* It sits in the controls' row; take the whole row so it centres. */
		inline-size: 100%;

		/* The display rule above would otherwise beat the hidden attribute. */
		&[hidden] {
			display: none;
		}

		& [data-sent-photo] {
			max-inline-size: 100%;
			max-block-size: 40vh;
			border-radius: var(--t-radius-md);
		}
	}

	/* The space beside the busy indicator before "Sending the photo", in the
	   dialog and on the page. */
	.officer-citation :is(.photo-capture, [data-scan-sending]) .busy-indicator {
		margin-inline-end: var(--t-space-2);
	}

	.id-scan {
		flex-grow: 1;
		flex-basis: auto;
		display: grid;
		gap: var(--mea-space-2);
	}

	.citation-report__check-icon {
		font-weight: var(--mea-w-bold);
	}

	/* Read-only finalized report view. */
	.citation-report-view {
		display: grid;
		gap: var(--mea-space-4);
		align-content: start;
		min-inline-size: 0;
		text-align: start;
	}

	.citation-report-view__header {
		display: grid;
		gap: var(--mea-space-2);
	}

	.citation-report-view__badge,
	.citation-report-view__title,
	.citation-report-view__group-title,
	.citation-report-view__narrative {
		margin: 0;
	}

	.citation-report-view__badge {
		justify-self: start;
		padding: var(--mea-space-1) var(--mea-space-3);
		border-radius: var(--mea-radius-pill);
	}

	.citation-report-view__group {
		display: grid;
		gap: var(--mea-space-2);
	}

	.citation-report-view__timeline {
		display: grid;
		gap: var(--mea-space-1);
		margin: 0;
		padding-inline-start: var(--mea-space-5);
	}

	.citation-report-view__narrative {
		white-space: pre-wrap;
		word-break: break-word;
	}

	[aria-labelledby="cit-items-title"] {
		--list-gap: var(--mea-space-3);
		& > .heading {
			font-size: var(--mea-text-md);
		}

		& > .item-list {
			display: grid;
			gap: var(--list-gap);

			& li.item {
				list-style: none;
			}

			& .item {
				display: grid;
				gap: var(--mea-space-2);
				border-width: 0;
				border-block-end-width: 1px;
				&:last-child {
					border-block-end-width: 0;
				}

				padding-block-end: var(--list-gap);

				& .name {
					  font-size: var(--mea-text-sm);
				}
				& .estimate {
					font-size: var(--mea-text-xs);
				}
				& .details {
					display: flex;
					align-items: center;
					gap: var(--mea-space-2);

					& div.photo {
						padding: var(--mea-space-1);
						align-content: center;
						aspect-ratio: 1;
						display: grid;
						justify-content: center;
					}
					& .photo {
						align-self: center;
					}

					& dl {
						flex-grow: 1;
						display: grid;
						gap: var(--mea-space-1);
						& > div {
							display: flex;
							
							& > dt {
								flex-grow: 1;
							}
						}

						& .total {
							& dd {
								font-weight: var(--mea-w-semibold);
							}
						}
					}

				}

				& .actions {
					gap: var(--mea-space-2);

					& .btn {
					    font-size: var(--mea-text-sm);
						padding: var(--mea-space-1);
						min-height: 0;
					}
				}
			}
		}

		& #grand-total {
			display: flex;
			border-width: 0;
			border-block-start-width: 2px;
			padding-block-start: var(--list-gap);
			font-weight: var(--mea-w-bold);
			align-items: center;

			& dt::after {
				content: ":";
			}
			& dt {
				flex-grow: 1;
			}

			& dd {
				font-size: var(--mea-text-md);
			}
		}

	}

	details:has(#add-evidence-item-form-heading) {
		margin-block: var(--mea-space-8);

		& summary {
			list-style: none;

			padding: var(--mea-space-3) var(--mea-space-5);
			padding-inline-start: 0;
			font-size: var(--mea-text-md);
			font-weight: var(--mea-w-bold);

			& h4 {
				display: inline-block;
			}

			&::after {
				content: "▼";
			}
		}

		border-width: 0;

		&[open] {
			border-width: 1px;
			padding: var(--mea-space-4);
			padding-block-start: 0;

			& summary::after {
				content: "▲"
			}
		}

	}

	.citation-age-details {

		& .detail {
			display: flex;
			align-items: center;
			min-block-size: 3lh;
			border-width: 0;

			& + .detail {
				border-block-start-width: 1px;
			}

			& dt {
				flex-grow: 1;
				flex-shrink: 0;
			}

			&[data-detail="age"] dd {
				font-size: 1.5em;
			}

		}

	}
}

@layer design {

	.officer-citation header .subtitle {
		color: var(--c-surface-text-color-muted);
	}

	.officer-citation .citation-step[data-step="items"] {

		& .existing-items {
			& .details {
				color: var(--c-surface-text-color-muted);
			}
		}

		& .running-total {
			border-block-start-style: solid;
			border-block-start-color: var(--t-border);
		}

	}

	[aria-labelledby="cit-items-title"] {
		& > .heading {
			color: var(--t-text-muted);
		}
		& > .item-list {
			& .item {
				border-color: var(--t-border);
				border-style: solid;

				&[data-no-photo] {
					& .photo {
						background-color: var(--t-warning-bg);
						color: var(--t-warning-text);
					}
				}

				& .estimate {
					color: var(--t-text-muted);
				}

			}
		}

		& #grand-total {
			border-style: solid;
			border-color: var(--t-border);

			& dd {
				color: var(--mea-blue);
			}
		}
	}
	[aria-labelledby="cit-suggestions-title"],
	[aria-labelledby="cit-receipt-title"] {
		& > .heading {
			color: var(--t-text-muted);
		}

		& .suggestion-list {
			& .suggestion {
				border-color: var(--t-border);
				border-style: solid;

				& .suggestion-view .label {
					color: var(--t-text-muted);
				}
			}
		}
	}
	details:has(#add-evidence-item-form-heading) {
		&[open] {
			border-style: solid;
			border-color: var(--t-border);
		}
	}


	.question-count {
		color: var(--c-surface-text-color-muted);
	}

	/* Step shell. */
	.citation-step__title {
		font-family: var(--mea-font-citizen);
		font-size: var(--mea-text-hero);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
	}

	.citation-step__subtitle {
		font-size: var(--mea-text-sm);
		color: var(--t-text-secondary);
	}

	.citation-step__link {
		color: var(--t-link);
		font-weight: var(--mea-w-semibold);
	}

	.citation-step__link:hover {
		color: var(--t-link-hover);
	}

	.offense-search {
		border: none;
	}

	.wizard-step {
		background-color: var(--t-card-bg);

		&>fieldset:invalid~.wizard-nav .next,
		&>input:invalid~.wizard-nav .next {
			pointer-events: none;
			opacity: 40%;
		}
	}

	.citation-offense-option {
		border-color: var(--t-border);
		border-bottom-style: solid;
		font-weight: var(--mea-w-semibold);

		&>input[type="radio"]:checked~span {
			color: var(--t-accent)
		}
	}

	.citation-ai-tool__title {
		font-family: var(--mea-font-citizen);
		font-size: var(--mea-text-md);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
	}

	.citation-ai-tool__hint,
	.citation-ai-tool__status {
		font-size: var(--mea-text-sm);
		color: var(--t-text-secondary);
	}

	.citation-ai-tool__status--error {
		color: var(--t-error-text);
		font-weight: var(--mea-w-semibold);
	}

	.citation-ai-tool__status--success,
	.citation-ai-tool__status--applied {
		color: var(--t-success-text);
		font-weight: var(--mea-w-semibold);
	}

	.citation-ai-tool__review {
		padding-block-start: var(--mea-space-3);
		border-block-start: 1px solid var(--t-border);
	}

	/* Offense selection + chips. .is-active is toggled by the controller. */
	.offense-selected {
		font-size: var(--mea-text-md);
		color: var(--t-text-secondary);
	}

	.offense-selected__label {
		color: var(--t-text-muted);
	}

	.offense-hint {
		font-size: var(--mea-text-md);
		color: var(--t-text-muted);
	}

	.offense-chip {
		background: var(--t-bg-recessed);
		color: var(--t-text);
		font-size: var(--mea-text-md);
		font-weight: var(--mea-w-semibold);
		transition: background var(--mea-dur-fast), color var(--mea-dur-fast);
	}

	.offense-chip:hover {
		background: var(--t-bg-active);
	}

	.offense-chip.is-active {
		background: var(--t-accent);
		color: var(--t-accent-text);
	}

	/* Location map placeholder. */
	.citation-map {
		background: var(--t-bg-recessed);
		color: var(--t-text);
		border: 1px solid var(--t-border);
	}

	.citation-map__pin {
		color: var(--t-accent);
	}

	.citation-map__coords {
		font-size: var(--mea-text-sm);
		color: var(--t-text-secondary);
	}

	/* Evidence summary + items. */
	.evidence-summary {
		background: var(--t-bg-recessed);
		color: var(--t-text);
	}

	.evidence-summary__label {
		font-size: var(--mea-text-sm);
		color: var(--t-text-muted);
	}

	.evidence-summary__value {
		font-size: var(--mea-text-md);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
	}

	.evidence-item {
		background: var(--t-bg-recessed);
		color: var(--t-text);
		border: 1px solid var(--t-border);
	}

	.evidence-item__label {
		font-size: var(--mea-text-sm);
		color: var(--t-text-muted);
	}

	.evidence-item__file {
		font-size: var(--mea-text-md);
		color: var(--t-text);
	}

	.evidence-item__value-label {
		font-size: var(--mea-text-sm);
		color: var(--t-text-muted);
	}

	.evidence-item__status {
		font-size: var(--mea-text-sm);
		color: var(--t-text-muted);
	}

	.evidence-item__status--confirmed {
		color: var(--t-success-text);
		font-weight: var(--mea-w-semibold);
	}

	.evidence-item__ai {
		border-block-start: 1px solid var(--t-border);
	}

	.evidence-item__ai-status {
		font-size: var(--mea-text-sm);
		color: var(--t-text-secondary);
	}

	.evidence-item__ai-status--error {
		color: var(--t-error-text);
		font-weight: var(--mea-w-semibold);
	}

	.evidence-item__remove {
		color: var(--t-text-muted);
		font-size: var(--mea-text-lg);
		transition: background var(--mea-dur-fast), color var(--mea-dur-fast);
	}

	.evidence-item__remove:hover {
		background: var(--t-error);
		color: var(--t-accent-text);
	}

	.evidence-add__control {
		background: var(--t-bg-recessed);
		color: var(--t-text-secondary);
		border: 1px dashed var(--t-border);
		font-weight: var(--mea-w-semibold);
	}

	.evidence-add__control:hover {
		border-color: var(--t-border-focus);
		color: var(--t-text);
	}

	.evidence-add__icon {
		color: var(--t-text-muted);
	}

	.evidence-warning {
		background: var(--t-warning-bg);
		color: var(--t-warning-text);
		font-size: var(--mea-text-sm);
		font-weight: var(--mea-w-semibold);
	}

	/* Scan-ID illustration. */
	.citation-id-illustration {
		background: var(--t-bg-recessed);
	}

	.citation-id-illustration__icon {
		color: var(--t-accent);
	}

	/* Success + invite handoff. */
	.citation-success__icon {
		background: var(--t-success);
		color: var(--t-accent-text);
		font-size: var(--mea-text-2xl);
		font-weight: var(--mea-w-bold);
	}

	.citation-success__title {
		font-family: var(--mea-font-citizen);
		font-size: var(--mea-text-2xl);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
	}

	.citation-success__sub {
		font-size: var(--mea-text-md);
		color: var(--t-text-secondary);
	}

	.citation-eligibility {
		background: var(--t-bg-recessed);
		color: var(--t-text);
		border: 1px solid var(--t-border);
	}

	.citation-eligibility__label {
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-semibold);
		color: var(--t-text-muted);
		text-transform: uppercase;
		letter-spacing: var(--mea-ls-wide);
	}

	.citation-eligibility__outcome {
		font-size: var(--mea-text-lg);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
	}

	/* Dark fills: white text on the mid green/red reads below 4.5:1. */
	.citation-eligibility--eligible {
		background: var(--mea-green-dark);
		border-color: var(--mea-green-dark);
	}

	.citation-eligibility--eligible .citation-eligibility__label,
	.citation-eligibility--eligible .citation-eligibility__outcome {
		color: var(--t-accent-text);
	}

	.citation-eligibility--ineligible,
	.citation-eligibility--error {
		background: var(--mea-red-dark);
		border-color: var(--mea-red-dark);
	}

	.citation-eligibility--ineligible .citation-eligibility__label,
	.citation-eligibility--ineligible .citation-eligibility__outcome,
	.citation-eligibility--error .citation-eligibility__label,
	.citation-eligibility--error .citation-eligibility__outcome {
		color: var(--t-accent-text);
	}

	.invite-handoff {
		background: var(--t-card-bg);
		border: 1px solid var(--t-card-border);
		box-shadow: var(--mea-shadow-sm);
	}

	.invite-handoff__qr {
		background: var(--mea-white);
	}

	.invite-handoff__label {
		font-size: var(--mea-text-sm);
		font-weight: var(--mea-w-semibold);
		color: var(--t-text-secondary);
	}

	.invite-handoff__code {
		font-family: var(--mea-font-mono);
		font-size: var(--mea-text-xl);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
		letter-spacing: var(--mea-ls-wide);
	}

	.invite-handoff__link {
		color: var(--t-link);
		font-weight: var(--mea-w-semibold);
	}

	.invite-handoff__link:hover {
		color: var(--t-link-hover);
	}

	/* Report launch card. */
	.citation-report-launch {
		background: var(--t-bg-recessed);
		color: var(--t-text);
		border: 1px solid var(--t-border);
	}

	.citation-report-launch__title {
		font-family: var(--mea-font-citizen);
		font-size: var(--mea-text-md);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
	}

	.citation-report-launch__hint {
		font-size: var(--mea-text-sm);
		color: var(--t-text-secondary);
	}

	/* Report review panel. */
	.citation-report__title {
		font-family: var(--mea-font-citizen);
		font-size: var(--mea-text-2xl);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
	}

	.citation-report__subtitle {
		font-size: var(--mea-text-md);
		color: var(--t-text-secondary);
	}

	.citation-report__fieldset,
	.citation-report__group {
		background: var(--t-bg-recessed);
		color: var(--t-text);
		border: 1px solid var(--t-border);
	}

	.citation-report__legend,
	.citation-report__group-title {
		font-size: var(--mea-text-sm);
		font-weight: var(--mea-w-semibold);
		color: var(--t-text-muted);
		text-transform: uppercase;
		letter-spacing: var(--mea-ls-wide);
	}

	.citation-report__empty,
	.citation-report__evidence-item {
		font-size: var(--mea-text-sm);
		color: var(--t-text-secondary);
	}

	.citation-report__empty--ok {
		color: var(--t-success-text);
		font-weight: var(--mea-w-semibold);
	}

	.citation-report__note-text {
		font-size: var(--mea-text-sm);
		color: var(--t-text);
	}

	.citation-report__check {
		font-size: var(--mea-text-sm);
		color: var(--t-text-secondary);
	}

	.citation-report__check--ok {
		color: var(--t-success-text);
	}

	.citation-report__check--ok .citation-report__check-icon {
		color: var(--t-success-text);
	}

	.citation-report__check--todo .citation-report__check-icon {
		color: var(--t-text-muted);
	}

	/* Finalized report view. */
	.citation-report-view__badge {
		background: var(--t-success);
		color: var(--t-accent-text);
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-bold);
		text-transform: uppercase;
		letter-spacing: var(--mea-ls-wide);
	}

	.citation-report-view__title {
		font-family: var(--mea-font-citizen);
		font-size: var(--mea-text-2xl);
		font-weight: var(--mea-w-bold);
		color: var(--t-text);
	}

	.citation-report-view__group-title {
		font-size: var(--mea-text-sm);
		font-weight: var(--mea-w-semibold);
		color: var(--t-text-muted);
		text-transform: uppercase;
		letter-spacing: var(--mea-ls-wide);
	}

	.citation-report-view__narrative {
		font-size: var(--mea-text-md);
		color: var(--t-text);
	}

	.citation-age-details {

		& .detail {
			border-style: solid;
			border-color: var(--t-border);

			& dd {
				font-weight: var(--mea-w-semibold);
			}
			&[data-detail="age"] dd {
				font-weight: var(--mea-w-bold);
			}
		}

	}
}

/* Officer evidence valuation: the captured photo rendered inline via the
   same-origin relay route (/officer-evidence/{id}/image/{eid}). Bounded so a
   large capture never blows out the pane it sits in; the pane body spaces it. */
@layer layout {
	.officer-citation .evidence-photo {
		display: block;
		max-inline-size: 100%;
		block-size: auto;
		max-block-size: 22rem;
		border-radius: var(--t-radius-md);
	}
}

/* Wizard steps built from components (time, offense, location, notes,
   screening). The components paint themselves; this places them. */
@layer layout {
	.officer-citation .citation-step {
		& .time-of-day {
			display: grid;
			gap: var(--t-space-2);
		}

		/* A list of plain choices reads as rows split by a rule. */
		& fieldset.field .choice:not(.answer) {
			padding-block: var(--t-space-3);
			border-block-end-width: var(--t-border-width-interactive);
		}

		& fieldset.field:has(.choice) legend {
			margin-block-end: var(--t-space-2);
			font-size: var(--t-font-size-lg);
		}

		& .offense-group .choice {
			font-size: var(--t-font-size-sm);

			& .name {
				font-weight: var(--t-font-weight-semibold);
			}

			& .code {
				font-size: var(--t-font-size-xs);
			}
		}

		& fieldset.yes-no {
			gap: var(--t-space-4);
		}
	}

	/* Screening steps show the question as the visible <h2>; the legend
	   repeats it so screen readers name the yes/no group. Moved off-screen,
	   not display:none, which would hide it from assistive tech too. `left`
	   (not inset-inline-start) so RTL can't push it into a horizontal scroll. */
	.officer-citation .citation-step[data-step="screen"] fieldset.yes-no > legend {
		position: absolute;
		left: -10000px;
	}
}

@layer design {
	.officer-citation .citation-step {
		& fieldset.field .choice:not(.answer) {
			border-block-end-style: solid;
			border-block-end-color: var(--t-border);
		}

		& .offense-group .choice .code {
			color: var(--c-surface-text-color-muted);
		}
	}
}
