/* ---------- Tokens ---------- */
:root {
	--brand: #b45309;
	--on-brand: #ffffff;
	--ink-light: #b45309;
	--brand-ink: var(--ink-light, var(--brand));

	--bg: #ffffff;
	--fg: #0a0a0a;
	--soft: #3a3a3a;
	--line: #e8e8e8;
	--hover: #f5f5f5;

	--t-xs: 13px;
	--t-sm: 16px;
	--t-md: 20px;
	--t-lg: 40px;
	--t-xl: clamp(64px, 14vw, 112px);

	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0a0a0a;
		--fg: #f4f4f4;
		--soft: #c4c4c4;
		--line: #222222;
		--hover: #141414;
		--brand-ink: var(--brand);
	}
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

[hidden] {
	/* biome-ignore lint/complexity/noImportantStyles: required for hidden attribute */
	display: none !important;
}

html,
body {
	background: var(--bg);
	color: var(--fg);
}

body {
	font:
		500 var(--t-sm) / 1.4 system-ui,
		-apple-system,
		"Segoe UI",
		sans-serif;
	-webkit-font-smoothing: antialiased;
	padding: 32px 24px 120px;
}

main {
	max-width: 680px;
	margin: 0 auto;
}

main.wide {
	max-width: 960px;
}

.split {
	display: grid;
	grid-template-columns: 220px minmax(0, 1fr);
	gap: 32px;
	align-items: start;
}

.split > * {
	min-width: 0;
}

.table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--t-xs);
	font-variant-numeric: tabular-nums;
}

.table th,
.table td {
	text-align: left;
	padding: 10px 12px 10px 0;
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}

.table th {
	font-weight: 700;
	color: var(--soft);
}

a {
	color: inherit;
	text-decoration: none;
}

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

ol,
ul {
	list-style: none;
}

.num {
	font-variant-numeric: tabular-nums;
}

/* ---------- Hero ---------- */
.hero {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px;
}

.brandline {
	font-size: var(--t-xs);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

h1 {
	font-size: var(--t-xl);
	line-height: 0.9;
	font-weight: 800;
	letter-spacing: -0.045em;
	color: var(--brand-ink);
	margin-top: 8px;
}

.count {
	font-size: var(--t-md);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	margin-bottom: 8px;
	text-align: right;
	white-space: nowrap;
}

.count small {
	display: block;
	font-size: var(--t-xs);
	font-weight: 500;
	color: var(--soft);
}

/* ---------- Forms ---------- */
label {
	display: block;
	font-size: var(--t-xs);
	font-weight: 700;
	color: var(--soft);
	margin-bottom: 20px;
}

label input,
label select,
label textarea {
	display: block;
	width: 100%;
	margin-top: 6px;
	font: inherit;
	font-size: var(--t-sm);
	font-weight: 500;
	color: var(--fg);
	background: var(--bg);
	border: 0;
	border-bottom: 1.5px solid var(--line);
	border-radius: 0;
	padding: 8px 0;
	outline: none;
}

label select {
	cursor: pointer;
}

label textarea {
	resize: vertical;
	min-height: 88px;
}

label input:focus,
label select:focus,
label textarea:focus {
	border-bottom-color: var(--brand);
}

label input::placeholder,
label textarea::placeholder {
	color: var(--fg);
	opacity: 0.28;
}

.checkbox-label {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: var(--t-xs);
	font-weight: 700;
	color: var(--fg);
	cursor: pointer;
	padding: 4px 0;
	margin-bottom: 20px;
	-webkit-tap-highlight-color: transparent;
}

input[type="checkbox"] {
	width: 18px;
	height: 18px;
	margin: 0;
	padding: 0;
	border: 0;
	accent-color: var(--brand);
	flex-shrink: 0;
	cursor: pointer;
}

details {
	margin-bottom: 20px;
}

summary {
	font-size: var(--t-xs);
	font-weight: 700;
	color: var(--soft);
	cursor: pointer;
	padding: 4px 0;
	-webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
	summary:hover {
		color: var(--fg);
	}
}

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

details[open] > summary {
	margin-bottom: 16px;
}

/* ---------- Toolbar ---------- */
.toolbar {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-top: 40px;
	padding-bottom: 16px;
	border-bottom: 2px solid var(--fg);
}

.toolbar input {
	flex: 1;
	font:
		700 var(--t-md) / 1.2 system-ui,
		-apple-system,
		"Segoe UI",
		sans-serif;
	color: var(--fg);
	background: none;
	border: 0;
	outline: none;
	min-width: 0;
}

.toolbar input::placeholder {
	color: var(--fg);
	opacity: 0.28;
}

.edit-btn {
	font-size: var(--t-sm);
	font-weight: 700;
	color: var(--soft);
	padding: 8px 12px;
	white-space: nowrap;
}

@media (hover: hover) {
	.edit-btn:hover {
		color: var(--fg);
	}
}

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

.edit-btn[aria-pressed="true"] {
	color: var(--brand-ink);
}

.add {
	background: var(--brand);
	color: var(--on-brand);
	font-weight: 700;
	padding: 8px 16px;
	border-radius: 999px;
	white-space: nowrap;
}

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

/* ---------- List ---------- */
li.item {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 20px;
	padding: 18px 12px;
	margin: 0 -12px;
	border-bottom: 1px solid var(--line);
	cursor: pointer;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
	li.item:hover {
		background: var(--hover);
	}
}

li.item:focus-visible,
li.item.is-selected {
	background: var(--hover);
	box-shadow: inset 4px 0 0 var(--brand);
}

.meta {
	min-width: 0;
}

.item-title {
	font-size: var(--t-md);
	font-weight: 700;
	letter-spacing: -0.01em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.item-sub {
	font-size: var(--t-xs);
	color: var(--soft);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-top: 2px;
}

.metric {
	grid-column: 2;
	grid-row: 1;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	font-size: var(--t-lg);
	font-weight: 700;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
	line-height: 1;
	padding: 6px 8px;
	border-radius: 8px;
	color: var(--fg);
	white-space: nowrap;
}

@media (hover: hover) {
	.metric:hover {
		color: var(--brand-ink);
	}

	li.item:has(.metric:hover) {
		background: transparent;
	}
}

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

.metric small {
	font-size: var(--t-xs);
	font-weight: 500;
	color: var(--soft);
}

.metric::after {
	content: "↗";
	font-size: var(--t-lg);
	font-weight: 500;
	line-height: 1;
	color: var(--brand-ink);
}

.row-actions {
	grid-column: 2;
	grid-row: 1;
	justify-self: end;
	display: none;
	flex-wrap: wrap;
	justify-content: flex-end;
	align-items: center;
	gap: 8px;
}

.row-actions form {
	display: contents;
}

.pill-btn {
	font-size: var(--t-xs);
	font-weight: 700;
	color: var(--soft);
	background: var(--hover);
	padding: 6px 12px;
	border-radius: 999px;
	border: 1px solid var(--line);
	white-space: nowrap;
}

@media (hover: hover) {
	.pill-btn:not(:disabled):hover {
		color: var(--fg);
		border-color: var(--fg);
	}
}

.pill-btn:disabled {
	opacity: 0.35;
	cursor: default;
}

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

ol.editing li.item {
	cursor: default;
}

ol.editing .metric {
	visibility: hidden;
	pointer-events: none;
}

ol.editing .row-actions {
	display: flex;
}

.empty {
	display: block;
	padding: 48px 0;
	font-size: var(--t-md);
	font-weight: 700;
	text-align: center;
	cursor: default;
	color: var(--soft);
}

/* ---------- Start Page Grid ---------- */
.nav-group {
	margin-top: 32px;
}

.nav-group-title {
	font-size: var(--t-xs);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--soft);
	border-bottom: 1px solid var(--line);
	padding-bottom: 6px;
	margin-bottom: 12px;
}

.nav-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 4px 16px;
}

.nav-item {
	min-width: 0;
}

.nav-link {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 2px;
	padding: 10px 12px;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
	.nav-link:hover {
		background: var(--hover);
	}
}

.nav-link:focus-visible,
.nav-link.is-selected {
	background: var(--hover);
	box-shadow: inset 4px 0 0 var(--brand);
}

.nav-title {
	font-size: var(--t-sm);
	font-weight: 700;
	color: var(--fg);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.nav-host {
	font-size: var(--t-xs);
	font-weight: 500;
	color: var(--soft);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---------- Auth & Actions ---------- */
.login-form {
	margin-top: 48px;
}

.error {
	font-size: var(--t-xs);
	font-weight: 700;
	color: var(--brand-ink);
}

.error:not(:empty) {
	margin-bottom: 16px;
}

.actions {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 20px;
	margin-top: 12px;
}

.actions .cancel {
	font-weight: 700;
	color: var(--soft);
}

.actions .save,
.actions .primary {
	background: var(--brand);
	color: var(--on-brand);
	font-weight: 700;
	padding: 8px 20px;
	border-radius: 999px;
}

.actions .cancel:focus-visible,
.actions .save:focus-visible,
.actions .primary:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}

/* ---------- Dialog ---------- */
dialog {
	margin: auto;
	border: 0;
	border-radius: 12px;
	background: var(--bg);
	color: var(--fg);
	padding: 32px;
	width: min(440px, calc(100vw - 32px));
}

dialog::backdrop {
	background: rgb(0 0 0 / 0.4);
}

dialog h2 {
	font-size: var(--t-lg);
	font-weight: 800;
	letter-spacing: -0.03em;
	line-height: 1;
	margin-bottom: 24px;
}

.dlg-note {
	font-size: var(--t-sm);
	color: var(--soft);
	margin-bottom: 24px;
}

/* ---------- Toast ---------- */
.toast {
	position: fixed;
	left: 50%;
	bottom: 64px;
	transform: translate(-50%, 12px);
	background: var(--fg);
	color: var(--bg);
	font-size: var(--t-xs);
	font-weight: 700;
	padding: 10px 18px;
	border-radius: 999px;
	opacity: 0;
	pointer-events: none;
	transition:
		opacity 0.15s,
		transform 0.15s;
}

.toast.show {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ---------- Footer ---------- */
.footer-bar {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 16px;
	margin-top: 48px;
}

.logout-btn {
	font-size: var(--t-xs);
	font-weight: 700;
	color: var(--soft);
}

@media (hover: hover) {
	.logout-btn:hover {
		color: var(--fg);
	}
}

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

/* ---------- Media Queries ---------- */
@media (pointer: coarse) {
	.add,
	.edit-btn,
	.pill-btn,
	.metric,
	.logout-btn,
	.actions .cancel,
	.actions .save,
	.actions .primary {
		min-height: 44px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	.nav-link {
		min-height: 44px;
	}
}

@media (max-width: 720px) {
	.split {
		grid-template-columns: 1fr;
		gap: 24px;
	}
}

@media (max-width: 520px) {
	body {
		padding: 24px 16px 120px;
	}

	:root {
		--t-lg: 30px;
		--t-md: 18px;
	}

	li.item {
		gap: 14px;
	}

	dialog {
		padding: 24px;
	}
}
