/* Colours by role; the editing dialogs reuse these. Boxes are tinted by gender (light blue / light pink).
   Gold (--line-out, --frame-out, --badge) marks only people outside the line: a dashed frame and a badge.
   The owner's font (adwa-assalaf) has no @font-face here: it is licensed, served only with a session, and
   main.js loads it with the Font Loading API after the tree loads. It has one weight, so nothing is bold. */
:root {
	color-scheme: light;
	--bg: #ffffff;
	--surface: #ffffff;
	--surface-raised: #eef2f9;
	--text: #1b2a4a;
	--text-strong: #0d2146;
	--muted: #5f6e8e;
	--rule: #e6eaf2;
	--guide: #c9d2e3;
	--control: #1c3a70;
	--on-control: #ffffff;
	--input-border: #9fb0cc;
	--focus: #1c3a70;
	--error: #b42318;
	--line-in: #8ea5c9;
	--line-out: #b8902f;
	--frame-out: #a67c1f;
	--male: #dcebff;
	--male-frame: #8fb8ee;
	--female: #ffe0ec;
	--female-frame: #f2a3c0;
	--box-text: #0d2146;
	--box-sub: #3d4f73;
	--box-shadow: 0 1px 2px rgba(13, 33, 70, 0.12);
	--badge: #8f6d1f;
	--badge-text: #ffffff;
	--side-area: rgba(184, 144, 47, 0.07);
	--shadow: 0 8px 24px rgba(13, 33, 70, 0.16);
	--backdrop: rgba(13, 33, 70, 0.45);
	--radius: 10px;
	--font: 'adwa-assalaf', system-ui, 'Geeza Pro', Tahoma, sans-serif;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

/* One weight only: headings and labels lose the browser's bold, and no bold is ever faked. */
* {
	font-weight: 400;
}

html {
	height: 100%;
	font-synthesis: none;
}

body {
	margin: 0;
	min-height: 100%;
	display: flex;
	flex-direction: column;
	height: 100dvh;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 1.1rem;
	line-height: 1.5;
}

button,
input,
select {
	font: inherit;
	color: inherit;
}

:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

[hidden] {
	display: none !important;
}

/* Header: rows that wrap, in DOM (and Tab) order: titles and switch, search, actions. */
.site-header {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 16px;
	align-items: center;
	padding: 14px 20px 12px;
	border-bottom: 1px solid var(--rule);
	background: var(--bg);
}

.bar {
	flex: 1 1 36rem;
	display: flex;
	align-items: center;
	gap: 8px 16px;
	min-width: 0;
}

.titles {
	flex: 1;
	min-width: 15rem;
}

/* On wide screens the menu's contents sit in the header's rows; the ☰ button and short count are for phones. */
.menu-panel {
	display: contents;
}

.menu-button,
.count-short,
.menu-count {
	display: none;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* View switch: a native radio group drawn as segments */
.view-switch {
	display: flex;
	flex: none;
	border: 1.5px solid var(--control);
	border-radius: var(--radius);
	overflow: hidden;
}

.view-switch label {
	position: relative;
	display: flex;
}

.view-switch input {
	position: absolute;
	inset: 0;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.view-switch span {
	display: flex;
	align-items: center;
	min-height: 38px;
	padding: 4px 12px;
	font-size: 1rem;
	color: var(--control);
	cursor: pointer;
}

.view-switch label + label span {
	border-inline-start: 1px solid var(--control);
}

.view-switch input:not(:checked) + span:hover {
	background: var(--surface-raised);
}

.view-switch input:checked + span {
	background: var(--control);
	color: var(--on-control);
}

.view-switch input:focus-visible + span {
	outline: 3px solid var(--focus);
	outline-offset: -4px;
}

.view-switch input:checked:focus-visible + span {
	outline-color: var(--on-control);
}

h1 {
	margin: 0;
	font-size: 1.875rem;
	color: var(--text-strong);
	letter-spacing: 0.3px;
}

.lineage {
	margin: 2px 0 0;
	font-size: 0.95rem;
	color: var(--muted);
}

.family-count {
	margin-top: 4px;
	font-size: 1rem;
	color: var(--text);
}

.actions {
	flex: 0 1 auto;
	margin-inline-start: auto;
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.locked-note {
	padding: 2px 10px;
	border: 1px solid var(--muted);
	border-radius: 999px;
	font-size: 0.95rem;
	color: var(--muted);
}

.control {
	min-height: 40px;
	padding: 6px 14px;
	border: 1.5px solid var(--control);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--control);
	cursor: pointer;
}

.control:hover:not(:disabled) {
	background: var(--surface-raised);
}

.control:disabled,
.control[aria-disabled='true'] {
	opacity: 0.5;
	cursor: default;
}

.control.primary {
	background: var(--control);
	color: var(--on-control);
}

.control.primary:hover:not(:disabled) {
	background: var(--text-strong);
}

/* Search */
.search {
	flex: 1 1 16rem;
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 10px;
	max-width: 420px;
}

.search label {
	font-size: 1rem;
	color: var(--muted);
}

.search input {
	flex: 1;
	min-width: 0;
	min-height: 40px;
	padding: 6px 12px;
	border: 1.5px solid var(--input-border);
	border-radius: var(--radius);
	background: var(--surface);
}

.search input:focus {
	border-color: var(--control);
}

.search-status {
	flex-basis: 100%;
	margin: 0;
	font-size: 0.92rem;
	color: var(--muted);
	min-height: 1em;
}

.search-status:empty {
	display: none;
}

.search-results {
	position: absolute;
	inset-inline: 0;
	top: 100%;
	z-index: 5;
	margin: 4px 0 0;
	padding: 4px;
	list-style: none;
	max-height: 50vh;
	overflow-y: auto;
	background: var(--surface);
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.search-results button {
	display: block;
	width: 100%;
	min-height: 40px;
	padding: 6px 10px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	text-align: start;
	cursor: pointer;
}

.search-results button:hover {
	background: var(--surface-raised);
}

.page-error {
	margin: 12px 20px 0;
	padding: 10px 14px;
	border: 1.5px solid var(--error);
	border-radius: var(--radius);
	color: var(--error);
}

/* Diagram */
.diagram {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.zoom {
	position: absolute;
	inset-block-end: 14px;
	inset-inline-start: 14px;
	z-index: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	max-width: calc(100% - 28px);
}

.zoom-error {
	flex-basis: 100%;
	margin: 0;
	padding: 6px 10px;
	border: 1.5px solid var(--error);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--error);
}

.zoom .control {
	box-shadow: var(--shadow);
}

.canvas {
	flex: 1;
	min-height: 0;
	overflow: auto;
	outline: none;
	overscroll-behavior: contain;
	/* One finger scrolls natively; two fingers are the view's own pinch zoom (pinch.js). */
	touch-action: pan-x pan-y;
}

/* The picture: its paper colour is set from treepic-draw.js. */
.canvas.picture svg {
	display: block;
	margin: 0 auto;
}

.sizer {
	position: relative;
	margin: 0 auto;
}

.stage {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: 0 0;
}

.stage ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.lines {
	position: absolute;
	top: 0;
	left: 0;
	pointer-events: none;
	overflow: visible;
}

.lines .link,
.lines .marriage {
	fill: none;
	stroke: var(--line-in);
	stroke-width: 1.5;
}

.lines .link.outside {
	stroke: var(--line-out);
	stroke-dasharray: 5 4;
}

.lines .marriage.former {
	stroke-opacity: 0.5;
}

.lines .side-area {
	fill: var(--side-area);
	stroke: var(--line-out);
	stroke-width: 1.5;
	stroke-dasharray: 6 4;
}

.empty {
	margin: 40px 20px;
	color: var(--muted);
	direction: rtl;
}

/* Person boxes */
.person {
	position: absolute;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1px;
	padding: 4px 8px;
	border: 1.5px solid var(--frame);
	border-radius: var(--radius);
	background: var(--fill);
	color: var(--box-text);
	direction: rtl;
	text-align: center;
	line-height: 1.25;
	cursor: pointer;
	box-shadow: var(--box-shadow);
}

/* Gender colours the whole box; the in-line / outside marking is the frame (solid tint vs gold dashes + badge). */
.person.male {
	--fill: var(--male);
	--frame: var(--male-frame);
}

.person.female {
	--fill: var(--female);
	--frame: var(--female-frame);
}

.person.outside {
	border: 3px dashed var(--frame-out);
}

.person .name,
.person .meta,
.person .badge {
	max-width: 100%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.person .name {
	font-size: 1.08rem;
}

/* Room for the dots under letters such as ي: the clip box reaches below the tight line box
   without changing the layout height. */
.person .name,
.person .meta {
	padding-block-end: 0.3em;
	margin-block-end: -0.3em;
}

/* A lady from another family: her full name on up to two lines. */
.person .name.two-lines {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	white-space: normal;
	overflow-wrap: anywhere;
	line-height: 1.65;
	padding-block-end: 0;
	margin-block-end: 0;
}

.person .meta {
	font-size: 0.8rem;
	color: var(--box-sub);
}

.person .badge {
	padding: 0 8px;
	border-radius: 999px;
	background: var(--badge);
	color: var(--badge-text);
	font-size: 0.8rem;
	line-height: 1.7;
}

.person.former {
	opacity: 0.72;
}

.person.former.in-line {
	border-style: dotted;
}

.person .link-mark {
	position: absolute;
	top: 3px;
	inset-inline-end: 4px;
	width: 14px;
	height: 14px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.6;
	stroke-linecap: round;
}

.person:hover {
	filter: brightness(0.95);
}

.person:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 3px;
}

.person.found {
	outline: 3px solid var(--focus);
	outline-offset: 3px;
	box-shadow: 0 0 0 7px rgba(28, 58, 112, 0.16), 0 0 18px rgba(28, 58, 112, 0.35);
}

/* Fold control under a box that has children */
.toggle {
	position: absolute;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 3px;
	min-width: 22px;
	height: 22px;
	padding: 0 4px;
	transform: translateX(-50%);
	border: 1.5px solid var(--control);
	border-radius: 999px;
	background: var(--surface);
	color: var(--control);
	font: 0.8rem/1 var(--font);
	direction: rtl;
	cursor: pointer;
}

.toggle.collapsed {
	padding: 0 7px;
}

.toggle .chevron,
.fold .chevron {
	width: 12px;
	height: 12px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.toggle.collapsed .chevron,
.fold.collapsed .chevron {
	transform: rotate(90deg);
}

.toggle:hover {
	background: var(--surface-raised);
}

.toggle:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

@media (pointer: coarse) {
	.toggle {
		min-width: 28px;
		height: 28px;
	}
}

/* List view */
.list-view {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 8px 12px 32px;
	outline: none;
}

.list-view ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.lrow {
	display: flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 4px 0;
	border-bottom: 1px solid var(--rule);
}

/* The person and spouse chips; they wrap between the fold control and the branch size. */
.lrow .who {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.list-view .person {
	position: relative;
	flex-direction: row;
	flex-wrap: wrap;
	gap: 0 8px;
	min-height: 36px;
	max-width: 100%;
	padding-block: 5px;
	padding-inline-end: 10px;
	box-shadow: none;
	text-align: start;
}

.list-view .person .name {
	font-size: 1.2rem;
	white-space: normal;
	overflow-wrap: anywhere;
}

.list-view .person .meta {
	font-size: 0.92rem;
}

.list-view .person .badge {
	font-size: 0.86rem;
}

.list-view .person.linked {
	padding-inline-end: 24px;
}

.list-view .person .link-mark {
	top: 50%;
	margin-top: -7px;
}

.fold,
.fold-space {
	flex: none;
	width: 32px;
	height: 32px;
}

.fold {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 1.5px solid var(--control);
	border-radius: 999px;
	background: var(--surface);
	color: var(--control);
	cursor: pointer;
}

.fold:hover {
	background: var(--surface-raised);
}

.list-view .size {
	flex: none;
	font-size: 0.98rem;
	color: var(--muted);
	white-space: nowrap;
}

.kids {
	margin-inline-start: 15px;
	padding-inline-start: 10px;
	border-inline-start: 2px solid var(--guide);
}

/* A daughter's children from another family: the same frame and tint as the diagram's side area. */
.kids.outside {
	margin-block: 2px 6px;
	padding: 2px 8px;
	border: 1.5px dashed var(--line-out);
	border-radius: var(--radius);
	background: var(--side-area);
}

.group-label {
	margin: 6px 0 0;
	font-size: 0.98rem;
	color: var(--muted);
}

@media (pointer: coarse) {
	.list-view .person {
		min-height: 44px;
	}

	.fold,
	.fold-space {
		width: 44px;
		height: 44px;
	}
}

/* Dialogs */
.dialog {
	width: min(420px, calc(100vw - 32px));
	padding: 22px 22px 18px;
	border: 1px solid var(--rule);
	border-radius: 14px;
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 20px 50px rgba(13, 33, 70, 0.25);
}

.dialog::backdrop {
	background: var(--backdrop);
	backdrop-filter: blur(3px);
}

.dialog h2 {
	margin: 0 0 6px;
	font-size: 1.45rem;
	color: var(--text-strong);
}

.dialog .hint {
	margin: 0 0 16px;
	font-size: 1.03rem;
	color: var(--muted);
}

.dialog label {
	display: block;
	margin-bottom: 6px;
	color: var(--text-strong);
}

.dialog input {
	width: 100%;
	min-height: 44px;
	padding: 8px 12px;
	border: 1.5px solid var(--input-border);
	border-radius: var(--radius);
	background: var(--surface);
}

.dialog input:focus,
.dialog select:focus {
	border-color: var(--control);
}

.dialog input[aria-invalid='true'] {
	border-color: var(--error);
}

.form-error {
	min-height: 1.5em;
	margin: 8px 0 0;
	font-size: 1rem;
	color: var(--error);
}

.field-error {
	min-height: 0;
	margin-top: 4px;
}

.dialog-actions {
	display: flex;
	justify-content: flex-start;
	gap: 8px;
	margin-top: 8px;
}

/* Household and history dialogs */
.dialog.sheet {
	width: min(560px, calc(100vw - 32px));
	max-height: calc(100dvh - 32px);
	overflow-y: auto;
}

.dialog-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 8px;
}

.dialog-head h2 {
	margin: 0;
	min-width: 0;
	overflow-wrap: anywhere;
}

.dialog h3 {
	margin: 16px 0 6px;
	font-size: 1.15rem;
	color: var(--text-strong);
}

.dialog .locked-note {
	display: inline-block;
	margin: 4px 0 8px;
}

.form-status {
	margin: 0;
	font-size: 1rem;
	color: var(--muted);
}

.form-status:empty,
#household-error:empty,
#history-error:empty {
	display: none;
}

.crumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 2px 4px;
	margin: 0 0 10px;
	padding: 0;
	list-style: none;
	font-size: 0.95rem;
	color: var(--muted);
}

.crumbs li:not(:last-child)::after {
	content: '›';
	margin-inline-start: 4px;
}

.crumbs [aria-current] {
	color: var(--text-strong);
}

.crumb {
	min-height: 32px;
	padding: 2px 4px;
	border: 0;
	background: none;
	color: var(--control);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.person.chip {
	position: relative;
	min-width: 112px;
	max-width: 100%;
	min-height: 48px;
	padding-block: 4px;
	padding-inline-end: 12px;
	box-shadow: none;
}

.person.chip.self {
	cursor: default;
}

.self-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
}

.self-row .hint {
	margin: 0;
}

.relations {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	margin: 12px 0 0;
}

.relations div {
	display: flex;
	align-items: center;
	gap: 8px;
}

.relations dt {
	color: var(--muted);
	font-size: 1rem;
}

.relations dd {
	margin: 0;
}

/* Birth date and contact details under the person */
.details {
	display: grid;
	gap: 4px;
	margin: 10px 0 0;
}

.details div {
	display: flex;
	flex-wrap: wrap;
	gap: 0 8px;
}

.details dt {
	color: var(--muted);
}

.details dd {
	margin: 0;
	min-width: 0;
	overflow-wrap: anywhere;
}

.details a {
	color: var(--control);
	text-underline-offset: 3px;
}

/* Date rows in the edit form: a legend and the date button */
.date-row {
	margin-top: 4px;
}

.date-row .auto-hint {
	min-height: 0;
	margin: 4px 0 8px;
	font-size: 0.95rem;
}

.relations .full-name {
	color: var(--text);
	overflow-wrap: anywhere;
}

/* The edit form's sections: native <details>, the <summary> is the label */
.form-section {
	margin: 0 0 12px;
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	background: var(--surface);
}

.form-section > summary {
	min-height: 44px;
	padding: 10px 12px;
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--text-strong);
	cursor: pointer;
	list-style: none;
}

.form-section > summary::-webkit-details-marker {
	display: none;
}

.form-section > summary::before {
	content: '';
	width: 0;
	height: 0;
	border-block: 5px solid transparent;
	border-inline-start: 6px solid var(--muted);
}

.form-section[open] > summary::before {
	transform: rotate(-90deg);
}

.form-section > summary:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
	border-radius: var(--radius);
}

.section-body {
	padding: 0 12px 4px;
}

/* A date row: one button that opens the wheel picker */
.date-button {
	width: 100%;
	justify-content: flex-start;
	text-align: start;
}

/* The wheel date picker */
.wheel-dialog {
	width: min(420px, calc(100vw - 32px));
}

.dialog .wheel-title {
	margin: 0 0 12px;
	font-size: 1.15rem;
}

.wheels {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1.2fr);
	gap: 8px;
	margin-bottom: 8px;
}

/* the two hairlines around the selected row */
.wheels::before {
	content: '';
	position: absolute;
	inset-inline: 0;
	top: calc(50% - 20px);
	height: 40px;
	border-block: 1px solid var(--guide);
	pointer-events: none;
}

.wheel {
	height: 200px;
	padding-block: 80px;
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-snap-type: y mandatory;
	scrollbar-width: none;
	text-align: center;
	border-radius: var(--radius);
	-webkit-mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
	mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
}

.wheel::-webkit-scrollbar {
	display: none;
}

.wheel:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

.wheel-item {
	height: 40px;
	line-height: 40px;
	scroll-snap-align: center;
	color: var(--muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
	user-select: none;
}

.wheel-item[aria-selected='true'] {
	color: var(--text-strong);
}

/* The mobile number: a fixed +966 attached to the input */
.phone-input {
	display: flex;
	align-items: stretch;
}

.phone-input .phone-prefix {
	display: flex;
	align-items: center;
	padding: 0 10px;
	border: 1.5px solid var(--input-border);
	border-inline-end: 0;
	border-start-start-radius: var(--radius);
	border-end-start-radius: var(--radius);
	background: var(--surface-raised);
	color: var(--text-strong);
}

.phone-input input {
	min-width: 0;
	border-start-start-radius: 0;
	border-end-start-radius: 0;
}

/* Other information in the overview: the text on its own lines, line breaks kept */
.details .notes {
	display: block;
}

.details .notes dd {
	white-space: pre-line;
}

/* A marriage's contract date, under the spouse's chip */
.row .contract {
	order: 1;
	flex-basis: 100%;
	margin: 0;
	color: var(--muted);
}

.rows {
	display: grid;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.row-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.row-actions .field.check {
	margin: 0;
}

.household-actions {
	margin-top: 18px;
	padding-top: 12px;
	border-top: 1px solid var(--rule);
}

.dialog-actions.wrap {
	flex-wrap: wrap;
}

.household-actions .hint {
	margin: 6px 0 0;
}

/* Form fields */
.field {
	margin: 0 0 12px;
}

.dialog select {
	width: 100%;
	min-height: 44px;
	padding: 8px 12px;
	border: 1.5px solid var(--input-border);
	border-radius: var(--radius);
	background: var(--surface);
}

.dialog fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.dialog legend {
	margin-bottom: 6px;
	padding: 0;
	color: var(--text-strong);
}

.check {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 40px;
}

.dialog .check label {
	margin: 0;
	color: var(--text);
}

.dialog input[type='checkbox'],
.dialog input[type='radio'] {
	flex: none;
	width: 22px;
	min-height: 0;
	height: 22px;
	margin: 0;
	padding: 0;
	accent-color: var(--control);
}

.dialog input[role='switch'] {
	appearance: none;
	width: 44px;
	height: 26px;
	border: 1.5px solid var(--control);
	border-radius: 999px;
	background: var(--surface);
	position: relative;
	cursor: pointer;
}

.dialog input[role='switch']::before {
	content: '';
	position: absolute;
	top: 3px;
	inset-inline-start: 3px;
	width: 17px;
	height: 17px;
	border-radius: 50%;
	background: var(--muted);
}

.dialog input[role='switch']:checked {
	background: var(--control);
}

.dialog input[role='switch']:checked::before {
	inset-inline-start: auto;
	inset-inline-end: 3px;
	background: var(--on-control);
}

.dialog input[role='switch']:disabled {
	opacity: 0.5;
	cursor: default;
}

.choices .check {
	min-height: 44px;
}

.picks {
	max-height: 40vh;
	overflow-y: auto;
}

.house-form .hint[role='status'] {
	margin: 0 0 6px;
}

/* History */
#history-lock .field {
	margin: 4px 0 8px;
}

.history-list {
	display: grid;
	gap: 0;
	margin: 8px 0;
	padding: 0;
	list-style: none;
}

.change {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 4px 12px;
	padding: 10px 0;
	border-bottom: 1px solid var(--rule);
}

.change p {
	margin: 0;
	flex-basis: 100%;
}

.change .what {
	flex: 1 1 60%;
	overflow-wrap: anywhere;
}

.change .meta {
	order: 3;
	font-size: 0.92rem;
	color: var(--muted);
}

.change.undone .what {
	color: var(--muted);
	text-decoration: line-through;
}

.change .note {
	text-decoration: none;
	display: inline-block;
}

/* Contact form and the owner's messages */
.dialog textarea {
	display: block;
	width: 100%;
	min-height: 8rem;
	padding: 8px 12px;
	border: 1.5px solid var(--input-border);
	border-radius: var(--radius);
	background: var(--surface);
	color: inherit;
	font: inherit;
	resize: vertical;
}

.dialog textarea:focus {
	border-color: var(--control);
}

.dialog textarea[aria-invalid='true'] {
	border-color: var(--error);
}

#contact-form input {
	margin-bottom: 14px;
}

.contact-sender {
	margin: 0 0 14px;
	color: var(--text-strong);
}

#contact-error:empty,
#inbox-error:empty {
	display: none;
}

.unread-count {
	display: inline-block;
	min-width: 1.6em;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--control);
	color: var(--on-control);
	text-align: center;
}

.message {
	padding: 10px 0 10px;
	padding-inline-start: 10px;
	border-bottom: 1px solid var(--rule);
	border-inline-start: 4px solid transparent;
}

.message.unread {
	border-inline-start-color: var(--control);
	background: var(--surface-raised);
}

.message p {
	margin: 0 0 6px;
}

.message .meta,
.message .reply,
.message .note {
	font-size: 0.92rem;
	color: var(--muted);
}

.message .text {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	color: var(--text-strong);
}

.message .tag {
	display: inline-block;
	margin-inline-start: 8px;
	padding: 0 8px;
	border: 1px solid var(--control);
	border-radius: 999px;
	color: var(--control);
}

.message-actions .field {
	margin: 0;
}

.message-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

/* Phones: one compact bar; the rest of the header opens from ☰. */
@media (max-width: 719.98px) {
	.site-header {
		display: block;
		position: relative;
		padding: 8px 12px;
	}

	.bar {
		gap: 8px;
	}

	h1 {
		font-size: 1.45rem;
		line-height: 1.3;
	}

	.titles {
		min-width: 0;
	}

	.titles .lineage {
		display: none;
	}

	.count-short {
		display: block;
		margin: 0;
		font-size: 0.92rem;
		color: var(--muted);
		white-space: nowrap;
	}

	.view-switch span {
		padding: 4px 9px;
	}

	.menu-button {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		flex: none;
		min-width: 44px;
		min-height: 40px;
		padding: 4px 10px;
		font-size: 1.1rem;
	}

	.menu-panel {
		display: none;
	}

	.menu-panel.open {
		position: absolute;
		inset-inline: 0;
		top: 100%;
		z-index: 20;
		display: flex;
		flex-direction: column;
		gap: 14px;
		max-height: calc(100dvh - 64px);
		overflow-y: auto;
		padding: 14px 16px 18px;
		background: var(--surface);
		border-bottom: 1px solid var(--rule);
		box-shadow: 0 16px 32px rgba(13, 33, 70, 0.16);
	}

	.menu-panel .search {
		max-width: none;
	}

	.menu-panel .search-results {
		position: static;
		max-height: none;
		box-shadow: none;
	}

	.menu-count {
		display: block;
		margin: 0;
		color: var(--text-strong);
	}

	.menu-panel > * {
		flex: none;
	}

	.actions {
		justify-content: flex-start;
		margin-inline-start: 0;
	}
}

@media (max-width: 719.98px) and (pointer: coarse) {
	.view-switch span,
	.menu-button {
		min-height: 44px;
	}
}

@media (max-width: 640px) {
	.dialog.sheet {
		width: 100%;
		max-width: 100%;
		max-height: 92dvh;
		margin: auto 0 0;
		border-inline: 0;
		border-bottom: 0;
		border-radius: 14px 14px 0 0;
		padding: 16px 16px 20px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.person {
		transition: filter 0.15s;
	}
}
