/* Tokens from DESIGN.md. */
:root {
	color-scheme: light dark;
	--page: #fbfaf7;
	--raised: #ffffff;
	--hover: #f1efe9;
	--ink: #1f1f1f;
	--muted: #6b6b6b;
	--checked: #9a9a9a;
	--accent: #2f55c8;
	--on-accent: #ffffff;
	--error: #b3261e;
	--offline: #8a5a00;
	--divider: rgba(0, 0, 0, 0.08);
	--field: rgba(0, 0, 0, 0.24);
	--scrim: rgba(0, 0, 0, 0.4);
	--shadow-1: 0 1px 2px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
	--shadow-2: 0 8px 24px rgba(0, 0, 0, 0.18);
	--gutter: 1rem;
}

@media (prefers-color-scheme: dark) {
	:root {
		--page: #1c1c1e;
		--raised: #2a2a2d;
		--hover: #323236;
		--ink: #ececec;
		--muted: #a0a0a5;
		--checked: #76767b;
		--accent: #7f9cf0;
		--on-accent: #10131c;
		--error: #f2b8b5;
		--offline: #e0b060;
		--divider: rgba(255, 255, 255, 0.08);
		--field: rgba(255, 255, 255, 0.24);
	}
}

@media (min-width: 40rem) {
	:root { --gutter: 1.5rem; }
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--page);
	color: var(--ink);
	font: 400 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	accent-color: var(--accent);
}

a { color: var(--accent); }

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

[hidden] { display: none !important; }

/* Layout */

.page {
	max-width: 40rem;
	margin: 0 auto;
	padding: 0.5rem var(--gutter) 3rem;
}

.page--narrow {
	max-width: 28rem;
	padding-top: 1.5rem;
}

.app-bar {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	max-width: 40rem;
	min-height: 3.5rem;
	margin: 0 auto;
	padding: 0 var(--gutter);
}

.app-bar__brand { font-weight: 600; }

.app-bar__back {
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	margin-left: -0.75rem;
	color: var(--ink);
	font-size: 1.375rem;
	text-decoration: none;
	border-radius: 0.5rem;
}

.page-foot {
	max-width: 40rem;
	margin: 0 auto;
	padding: 1rem var(--gutter) 2rem;
	color: var(--muted);
	font-size: 0.875rem;
	border-top: 1px solid var(--divider);
}

/* Buttons */

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

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.75rem;
	padding: 0.625rem 1rem;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	border: 0;
	border-radius: 0.5rem;
	cursor: pointer;
}

.button--primary { background: var(--accent); color: var(--on-accent); }
.button--primary:hover { background: color-mix(in srgb, var(--accent) 92%, black); }
.button--quiet { background: transparent; color: var(--accent); }
.button--quiet:hover { background: var(--hover); }
.button--danger { background: var(--error); color: var(--page); }

/* Sign-in forms */

form { display: grid; gap: 0.5rem; margin-block: 1rem; }
.page-foot form { display: block; margin: 0.5rem 0 0; }

input[type="email"], input[inputmode="numeric"] {
	padding: 0.6rem 0.75rem;
	font-size: 1.0625rem;
	background: var(--raised);
	border: 1px solid var(--field);
	border-radius: 0.375rem;
}

form > button[type="submit"]:not(.button) {
	min-height: 2.75rem;
	padding: 0.625rem 1rem;
	font-weight: 600;
	background: var(--accent);
	color: var(--on-accent);
	border: 0;
	border-radius: 0.5rem;
	cursor: pointer;
}

.error { color: var(--error); }

/* Index */

.index-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-block: 0.5rem 1rem;
}

.index-head h1 { margin: 0; font-size: 1.375rem; font-weight: 600; letter-spacing: -0.01em; }

.index-list { margin: 0; padding: 0; list-style: none; }
.index-list li { border-bottom: 1px solid var(--divider); }

.index-list__row {
	display: flex;
	align-items: center;
	gap: 1rem;
	min-height: 3rem;
	padding: 0.75rem 0;
	color: var(--ink);
	text-decoration: none;
}

.index-list__row:hover { background: var(--hover); }

.index-list__title {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	font-size: 1.0625rem;
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.index-list__owner {
	flex: 0 1 auto;
	min-width: 0;
	max-width: 45%;
	overflow: hidden;
	color: var(--muted);
	font-size: 0.875rem;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.index-list__title--untitled { color: var(--muted); font-weight: 400; }
.index-list__count { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.index-empty { color: var(--muted); }

/* List */

.status {
	flex: 1;
	margin: 0;
	color: var(--muted);
	font-size: 0.875rem;
	text-align: center;
}

.status[data-state="offline"] { color: var(--offline); }
.status[data-state="error"], .status[data-state="signedout"] { color: var(--error); }

.list-title {
	width: 100%;
	margin-block: 0.5rem;
	padding: 0.5rem 0;
	font-size: 1.375rem;
	font-weight: 600;
	letter-spacing: -0.01em;
	background: transparent;
	border: 0;
}

.list-title:focus-visible { outline: none; }

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

.item, .add-row {
	display: flex;
	align-items: flex-start;
	gap: 0.25rem;
	min-height: 3rem;
	border-bottom: 1px solid var(--divider);
}

.item__check {
	flex: none;
	width: 1.375rem;
	height: 1.375rem;
	/* The margin widens the tap area to 48 px across the row's height. */
	margin: 0.8125rem;
	cursor: pointer;
}

.item__text {
	flex: 1;
	min-width: 0;
	padding: 0.75rem 0;
	font-size: 1.0625rem;
	line-height: 1.45;
	background: transparent;
	border: 0;
	resize: none;
	overflow: hidden;
}

.item__text:focus-visible { outline: none; }

.item__delete {
	flex: none;
	width: 2.75rem;
	height: 3rem;
	color: var(--muted);
	font-size: 1.25rem;
	background: none;
	border: 0;
	border-radius: 0.5rem;
	cursor: pointer;
	opacity: 0;
}

.item:hover .item__delete, .item:focus-within .item__delete { opacity: 1; }

@media (hover: none) {
	.item__delete { opacity: 1; }
}

.item--checked .item__text {
	color: var(--checked);
	text-decoration: line-through;
}

.add-row__plus {
	flex: none;
	width: 3rem;
	padding: 0.75rem 0;
	color: var(--muted);
	font-size: 1.25rem;
	line-height: 1.2;
	text-align: center;
}

.missing { color: var(--muted); }

/* Confirm dialog */

.confirm {
	max-width: min(24rem, calc(100vw - 2rem));
	padding: 1.5rem;
	color: var(--ink);
	background: var(--raised);
	border: 0;
	border-radius: 0.5rem;
	box-shadow: var(--shadow-2);
}

.confirm::backdrop { background: var(--scrim); }
.confirm h2 { margin: 0 0 0.5rem; font-size: 1.0625rem; font-weight: 600; }
.confirm p { margin: 0; color: var(--muted); }
.confirm__actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin: 1.5rem 0 0; }

/* Sharing */

.shared-by { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.875rem; }

.index-shared { margin-top: 2rem; }
.index-shared__heading { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.875rem; font-weight: 400; }

.share { width: min(28rem, calc(100vw - 2rem)); max-width: none; }
.share__people { margin: 1rem 0 0; padding: 0; list-style: none; }

.share__person {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	border-bottom: 1px solid var(--divider);
}

.share__person span { overflow-wrap: anywhere; }
.share__add { grid-template-columns: 1fr auto; align-items: end; }
.share__add label { grid-column: 1 / -1; font-size: 0.875rem; color: var(--muted); }

.share__add input {
	min-height: 2.75rem;
	padding: 0.6rem 0.75rem;
	font-size: 1.0625rem;
	background: var(--page);
	border: 1px solid var(--field);
	border-radius: 0.375rem;
}

.options { display: grid; gap: 0.5rem; margin: 1rem 0 0; padding: 0; border: 0; }
.options legend { margin-bottom: 0.25rem; color: var(--muted); font-size: 0.875rem; }
.options label { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; }
.options input { width: 1.375rem; height: 1.375rem; margin: 0; }
.options__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0; }

.share__note { min-height: 1.4em; margin: 0; font-size: 0.875rem; }
.share__note[data-state="error"] { color: var(--error); }

@media (prefers-reduced-motion: no-preference) {
	.item__delete { transition: opacity 150ms; }
}
