/* plylab: one stylesheet, light and dark from the same tokens. */

:root {
	--bg: #f7f7f5;
	--surface: #ffffff;
	--surface-2: #f0f0ec;
	--ink: #1c1c1a;
	--ink-2: #4a4a46;
	--muted: #6b6b66;
	--line: #dcdcd6;
	--accent: #1f5fae;
	--accent-ink: #ffffff;
	--accent-soft: #e6eef8;
	--ok: #1d7a46;
	--ok-soft: #e3f3ea;
	--bad: #b3261e;
	--bad-soft: #fbe9e7;
	--warn-soft: #fdf5dc;
	--hi: #fff6d6;
	--radius: 6px;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
	--sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #151614;
		--surface: #1d1e1c;
		--surface-2: #262724;
		--ink: #ecece8;
		--ink-2: #c4c4bf;
		--muted: #9a9a94;
		--line: #363733;
		--accent: #7fb0ec;
		--accent-ink: #0d1a2b;
		--accent-soft: #1c2a3d;
		--ok: #6fcf97;
		--ok-soft: #173325;
		--bad: #f28b82;
		--bad-soft: #3b1f1d;
		--warn-soft: #3a3320;
		--hi: #3a3420;
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--bg: #151614;
	--surface: #1d1e1c;
	--surface-2: #262724;
	--ink: #ecece8;
	--ink-2: #c4c4bf;
	--muted: #9a9a94;
	--line: #363733;
	--accent: #7fb0ec;
	--accent-ink: #0d1a2b;
	--accent-soft: #1c2a3d;
	--ok: #6fcf97;
	--ok-soft: #173325;
	--bad: #f28b82;
	--bad-soft: #3b1f1d;
	--warn-soft: #3a3320;
	--hi: #3a3420;
	color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 16px/1.5 var(--sans);
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 1.6em 0 0.6em; }
h1 { font-size: 1.75rem; margin-top: 1rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.25em; }

main {
	max-width: 1100px;
	margin: 0 auto;
	padding: 1rem 16px 4rem;
}

/* the menu */
header.top {
	background: var(--surface);
	border-bottom: 1px solid var(--line);
}
header.top nav {
	max-width: 1100px;
	margin: 0 auto;
	padding: 0.5rem 16px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 1rem;
	min-height: 3.25rem;
}
header.top nav a { color: var(--ink-2); text-decoration: none; }
header.top nav a:hover { color: var(--ink); text-decoration: underline; }
header.top nav a.brand { color: var(--ink); font-weight: 700; letter-spacing: 0.01em; margin-right: 0.5rem; }
header.top nav a.button { color: var(--ink); }
header.top .spacer { flex: 1; }
#clerk-org, #clerk-user { display: inline-flex; align-items: center; min-height: 2rem; }

/* text */
.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 46rem; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0; }
.crumbs { margin: 0.5rem 0 0; font-size: 0.9rem; color: var(--muted); }
small { font-size: 0.8rem; }

.note, .errors {
	border-radius: var(--radius);
	padding: 0.75rem 1rem;
	margin: 1rem 0;
	border: 1px solid var(--line);
	background: var(--warn-soft);
}
.errors { background: var(--bad-soft); border-color: var(--bad); }
.errors p:first-child, .note p:first-child { margin-top: 0; }
.errors ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.note pre, .errors pre { margin: 0.25rem 0 0; white-space: pre-wrap; }

pre, code { font-family: var(--mono); font-size: 0.875rem; }
pre {
	background: var(--surface-2);
	border-radius: var(--radius);
	padding: 0.75rem;
	overflow-x: auto;
}

/* buttons */
button, .button {
	font: inherit;
	font-size: 0.95rem;
	display: inline-block;
	padding: 0.45rem 0.9rem;
	border-radius: var(--radius);
	border: 1px solid var(--line);
	background: var(--surface);
	color: var(--ink);
	text-decoration: none;
	cursor: pointer;
	line-height: 1.3;
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary, .button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-ink);
	font-weight: 600;
}
button.primary:hover, .button.primary:hover { filter: brightness(1.08); }
button:focus-visible, .button:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible, summary:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* the hidden default button of a form (Enter runs it) */
.default-submit {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* home, dashboard */
.hero { padding: 1.5rem 0 0.5rem; }
.hero h1 { font-size: 2.1rem; margin-bottom: 0.4em; }
.hero p:last-child { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 0.75rem;
	margin: 1rem 0;
}
.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 1rem;
}
.card h2 { font-size: 1.05rem; margin: 0 0 0.4em; }
.card p { margin: 0; color: var(--ink-2); font-size: 0.95rem; }
a.card.link { color: inherit; text-decoration: none; }
a.card.link:hover { border-color: var(--accent); }
a.card.link h3 { color: var(--accent); }
.card.off { opacity: 0.7; }
ul.recent { padding-left: 1.1rem; }
ul.recent li { margin: 0.3rem 0; }

/* status */
.status {
	display: inline-block;
	font-size: 0.75rem;
	font-weight: 600;
	padding: 0.1rem 0.5rem;
	border-radius: 999px;
	vertical-align: middle;
	white-space: nowrap;
}
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
h1 .status { font-size: 0.8rem; margin-left: 0.4rem; }

/* tables */
.table-wrap { overflow-x: auto; max-width: 100%; }
table {
	border-collapse: collapse;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	font-size: 0.925rem;
}
th, td {
	padding: 0.4rem 0.65rem;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: middle;
}
thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.hi th, tr.hi td { background: var(--hi); }
table.data td {
	font-family: var(--mono);
	font-size: 0.82rem;
	text-align: right;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}
table.data thead th { text-align: right; font-family: var(--mono); font-size: 0.82rem; }
table.plans th[scope="row"] { white-space: nowrap; }

/* result */
dl.summary {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 0;
	margin: 0;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
}
dl.summary div {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.4rem 0.75rem;
	border-bottom: 1px solid var(--line);
}
dl.summary dt { color: var(--ink-2); }
dl.summary div:last-child { border-bottom: 0; }
dl.summary dd { margin: 0; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 0.9rem; text-align: right; }

.plots {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr));
	gap: 0.75rem;
}
.plots figure {
	margin: 0;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 0.5rem;
}
.plots img { width: 100%; height: auto; max-height: 560px; object-fit: contain; display: block; }
.plots figcaption { font-size: 0.85rem; padding: 0.25rem 0.25rem 0; }

details.table, details.fieldset {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	margin: 0.75rem 0;
}
details.table > summary, details.fieldset > summary {
	cursor: pointer;
	padding: 0.6rem 1rem;
	font-weight: 600;
}
details.table > .table-wrap, details.table > p, details.table > pre { margin: 0 1rem 1rem; }
details.table > .table-wrap table { border-radius: 0; }
details.fieldset > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
details.fieldset > :last-child { margin-bottom: 1rem; }
pre.nml { white-space: pre-wrap; }

/* forms */
form.analysis { max-width: 900px; }
fieldset {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	margin: 0.75rem 0;
	padding: 0.5rem 1rem 1rem;
	min-width: 0;
}
legend { font-weight: 600; padding: 0 0.25rem; }
label { display: inline-flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; color: var(--ink-2); }
input, select {
	font: inherit;
	font-size: 0.95rem;
	color: var(--ink);
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 4px;
	padding: 0.35rem 0.5rem;
	max-width: 100%;
}
input[inputmode="decimal"] { font-variant-numeric: tabular-nums; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
select { height: 2.25rem; }
input:not([type="checkbox"]) { height: 2.25rem; }
.grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 0.6rem 0.75rem;
}
.grid input { width: 100%; }
table.plies { margin: 0.75rem 0; }
table.plies td { padding: 0.25rem 0.4rem; }
table.plies input, table.plies select { width: 100%; min-width: 5.5rem; }
.checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; margin: 0.25rem 0 0.75rem; }
.checks label, label.check { flex-direction: row; align-items: center; gap: 0.4rem; color: var(--ink); font-size: 0.95rem; }
.checks label.disabled { color: var(--muted); }

@media (max-width: 600px) {
	h1 { font-size: 1.5rem; }
	.hero h1 { font-size: 1.7rem; }
	header.top nav { gap: 0.25rem 0.75rem; }
	.row > label, .row > button { width: 100%; }
	.row input, .row select { width: 100%; }
	.plots { grid-template-columns: 1fr; }
	table.plies input, table.plies select { min-width: 3.5rem; }
	table.plies td, table.plies th { padding: 0.25rem; }
}
