:root {
	--bg: #f6f7f9;
	--surface: #ffffff;
	--text: #1d2330;
	--muted: #5f6b7a;
	--border: #dde1e7;
	--accent: #2459c9;
	--accent-text: #ffffff;
	--ok-bg: #e7f5ec;
	--ok-text: #1d5c34;
	--error-bg: #fdecec;
	--error-text: #8c1d1d;
	--warn-bg: #fff4dd;
	--warn-text: #7a4b00;
	--due: #c0392b;
	--focus: #ffbf47;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #14171c;
		--surface: #1d2129;
		--text: #e6e9ee;
		--muted: #9aa5b4;
		--border: #313744;
		--accent: #6f9cff;
		--accent-text: #0f1218;
		--ok-bg: #173323;
		--ok-text: #a8e2bd;
		--error-bg: #3a1c1c;
		--error-text: #f3b4b4;
		--warn-bg: #3a2c12;
		--warn-text: #f5d38b;
		--due: #ef7b6f;
	}
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 1px;
}

h1 { font-size: 1.6rem; margin: 0.4rem 0 1rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h1 small, h2 small { font-size: 0.9rem; font-weight: normal; }

.topbar {
	display: flex;
	align-items: center;
	gap: 1.5rem;
	padding: 0.6rem 1rem;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	flex-wrap: wrap;
}
.topbar nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.topbar a { text-decoration: none; }
.brand { font-weight: 700; color: var(--text) !important; }
.signout { margin-left: auto; display: flex; gap: 0.6rem; align-items: baseline; }
.login { max-width: 24rem; margin: 3rem auto; }
.stack input[type=password] { width: 100%; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 1rem; }

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 1rem 1.2rem;
	margin-bottom: 1rem;
}

.heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.heading h1 { margin-bottom: 0.5rem; }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
tr.selected td { background: var(--warn-bg); }
tr.inactive td { opacity: 0.6; }
.card table { display: block; overflow-x: auto; }
@media (min-width: 700px) { .card table { display: table; } }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0 0 1rem; }
dt { color: var(--muted); }
dd { margin: 0; }

button, .button {
	display: inline-block;
	background: var(--accent);
	color: var(--accent-text);
	border: 1px solid var(--accent);
	border-radius: 6px;
	padding: 0.4rem 0.9rem;
	font: inherit;
	cursor: pointer;
	text-decoration: none;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.small { padding: 0.15rem 0.6rem; font-size: 0.85rem; }
button.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
	font: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 0.35rem 0.5rem;
	max-width: 100%;
}
textarea { width: 100%; }

form.inline { display: inline; }
.stage-picker select { font-size: 0.85rem; font-weight: 600; padding: 0.1rem 0.4rem; border-radius: 999px; vertical-align: middle; }
.stage-picker select.stage-open { color: var(--accent); }
.stage-picker select.stage-won { color: var(--ok-text); }
.stage-picker select.stage-ended { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1rem; }
.stack label { display: flex; flex-direction: column; gap: 0.25rem; }
.stack input[type=text], .stack input[type=url] { width: 100%; }
.stack > button { align-self: flex-start; }
.row { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0.5rem; }
.row label { display: flex; flex-direction: column; gap: 0.25rem; }
label.check { flex-direction: row !important; align-items: center; gap: 0.35rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.filters select { max-width: 16rem; }

.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; display: flex; gap: 1rem; align-items: center; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--error-bg); color: var(--error-text); display: block; }
.field-error, .error-text { color: var(--error-text); font-size: 0.85rem; }

.badge { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.tag { display: inline-block; font-size: 0.75rem; padding: 0.05rem 0.45rem; border-radius: 4px; background: var(--border); color: var(--text); white-space: nowrap; }
.tag.warn { background: var(--warn-bg); color: var(--warn-text); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.due { color: var(--due); }
.prewrap { white-space: pre-wrap; }
.undone { text-decoration: line-through; color: var(--muted); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: baseline; }



.link-edit { display: flex; gap: 0.4rem; margin-top: 0.4rem; flex-wrap: wrap; }
.link-edit input { flex: 1 1 16rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.flash.warn { background: var(--warn-bg); color: var(--warn-text); display: block; }
.flash.warn ul { margin: 0.3rem 0 0.6rem; }
fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.8rem; margin: 0; }
legend { color: var(--muted); font-size: 0.85rem; padding: 0 0.3rem; }
details.snapshot { border-top: 1px solid var(--border); padding: 0.5rem 0; }
details.snapshot summary { cursor: pointer; }
.description { margin-top: 0.6rem; max-width: 80ch; }
.button.bookmarklet { cursor: grab; }

.badge.stage-open { color: var(--accent); }
.badge.stage-won { color: var(--ok-text); }
.badge.stage-ended { color: var(--muted); }
.next-action { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; margin-top: 0; }
.grow { flex: 1 1 18rem; }
.log-form label.grow input { width: 100%; }
ol.timeline { list-style: none; padding: 0; margin: 1rem 0 0; }
ol.timeline li { border-left: 2px solid var(--border); padding: 0.3rem 0 0.6rem 0.9rem; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: baseline; }
ol.timeline .when { color: var(--muted); font-size: 0.85rem; min-width: 9.5rem; }
ol.timeline li > div { flex-basis: 100%; }
details summary { cursor: pointer; color: var(--accent); margin: 0.5rem 0; }
.correct-link { margin-left: auto; }
