/* =============================================================== tokens */

:root {
	--font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

	/* dark is the default look */
	--bg: #070c11;
	--surface: #0e1620;
	--surface-2: #151f2a;
	--surface-3: #1b2734;
	--line: #223140;
	--line-soft: #18222d;

	--text: #e8eef4;
	--text-dim: #91a3b2;
	--text-faint: #67788a;

	--accent: #00a884;
	--accent-strong: #00c79c;
	--accent-ink: #04120e;
	--accent-tint: rgba(0, 168, 132, 0.14);
	--accent-edge: rgba(0, 168, 132, 0.42);

	--danger: #ff6d7e;
	--danger-tint: rgba(255, 109, 126, 0.12);
	--danger-edge: rgba(255, 109, 126, 0.38);
	--warn: #f0b232;

	--glow-a: rgba(0, 168, 132, 0.2);
	--glow-b: rgba(30, 92, 140, 0.18);

	--r-sm: 8px;
	--r-md: 12px;
	--r-lg: 18px;
	--shadow: 0 18px 44px -18px rgba(0, 0, 0, 0.7);
	--shadow-soft: 0 2px 10px -4px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: light) {
	:root {
		--bg: #eef2f5;
		--surface: #ffffff;
		--surface-2: #f4f7f9;
		--surface-3: #eaeff3;
		--line: #dde4ea;
		--line-soft: #e8edf1;

		--text: #0e1a22;
		--text-dim: #5d707e;
		--text-faint: #8496a3;

		--accent: #00a884;
		--accent-strong: #018264;
		--accent-ink: #ffffff;
		--accent-tint: rgba(0, 168, 132, 0.1);
		--accent-edge: rgba(0, 168, 132, 0.38);

		--danger: #d43f52;
		--danger-tint: rgba(212, 63, 82, 0.08);
		--danger-edge: rgba(212, 63, 82, 0.3);
		--warn: #b57611;

		--glow-a: rgba(0, 168, 132, 0.16);
		--glow-b: rgba(30, 92, 140, 0.1);

		--shadow: 0 18px 40px -22px rgba(14, 26, 34, 0.28);
		--shadow-soft: 0 1px 3px rgba(14, 26, 34, 0.07);
	}
}

/* =============================================================== base */

* {
	box-sizing: border-box;
}

/* The UA rule for [hidden] is display:none, which any author `display`
   declaration beats — several elements here set one, so pin it down. */
[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	min-height: 100vh;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.55 var(--font);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

.backdrop {
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background:
		radial-gradient(900px 520px at 18% -8%, var(--glow-a), transparent 62%),
		radial-gradient(760px 460px at 88% 4%, var(--glow-b), transparent 60%);
}

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

/* =============================================================== layout */

.shell {
	width: min(1120px, 100% - 40px);
	margin: 0 auto;
	padding: 32px 0 96px;
}

/* Sidebar of bots beside the panel for the one being looked at. */
.workspace {
	display: grid;
	grid-template-columns: 248px minmax(0, 1fr);
	gap: 24px;
	align-items: start;
	margin-top: 24px;
}

@media (max-width: 860px) {
	.workspace {
		grid-template-columns: minmax(0, 1fr);
	}
}

.col-main {
	display: flex;
	flex-direction: column;
	gap: 20px;
	min-width: 0;
}

/* =============================================================== topbar */

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	padding-bottom: 22px;
	margin-bottom: 22px;
	border-bottom: 1px solid var(--line-soft);
}

.brand {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

.brand-mark {
	flex: none;
	width: 42px;
	height: 42px;
	display: grid;
	place-items: center;
	border-radius: var(--r-md);
	color: #fff;
	background: linear-gradient(150deg, var(--accent-strong), var(--accent) 55%, #00805f);
	box-shadow: 0 8px 20px -8px rgba(0, 168, 132, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.brand-mark svg {
	width: 23px;
	height: 23px;
}

.brand-text {
	min-width: 0;
}

.topbar h1 {
	margin: 0;
	font-size: 20px;
	font-weight: 640;
	letter-spacing: -0.35px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.brand-sub {
	margin: 1px 0 0;
	color: var(--text-dim);
	font-size: 13px;
}

/* status pill — app.js rewrites className to `pill pill-<tone>`,
   so everything visual has to live on those two classes. */
.pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 14px 7px 12px;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: var(--surface);
	box-shadow: var(--shadow-soft);
	color: var(--text-dim);
	font-size: 12.5px;
	font-weight: 600;
	letter-spacing: 0.1px;
	white-space: nowrap;
}

.pill .dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}

.pill-idle {
	color: var(--text-faint);
}

.pill-busy {
	color: var(--warn);
	border-color: color-mix(in srgb, var(--warn) 34%, var(--line));
}

.pill-busy .dot {
	animation: pulse 1.3s ease-in-out infinite;
}

.pill-ok {
	color: var(--accent-strong);
	border-color: var(--accent-edge);
	background: linear-gradient(var(--accent-tint), var(--accent-tint)), var(--surface);
}

.pill-bad {
	color: var(--danger);
	border-color: var(--danger-edge);
	background: linear-gradient(var(--danger-tint), var(--danger-tint)), var(--surface);
}

@keyframes pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.25; }
}

/* =============================================================== cards */

.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow);
	padding: 20px;
}

.card-connect {
	padding: 18px;
}

/* =============================================================== tabs */

.tabs {
	position: relative;
	display: flex;
	gap: 4px;
	padding: 4px;
	margin-bottom: 20px;
	background: var(--surface-2);
	border: 1px solid var(--line-soft);
	border-radius: var(--r-md);
	isolation: isolate;
}

.tab-thumb {
	position: absolute;
	z-index: -1;
	top: 4px;
	bottom: 4px;
	left: 4px;
	width: calc(50% - 6px);
	border-radius: var(--r-sm);
	background: var(--surface);
	border: 1px solid var(--line);
	box-shadow: var(--shadow-soft);
	transition: transform 0.22s cubic-bezier(0.4, 0.1, 0.2, 1);
}

.tabs:has(.tab:last-of-type.is-active) .tab-thumb {
	transform: translateX(calc(100% + 4px));
}

.tab {
	flex: 1;
	padding: 9px 12px;
	border: 0;
	border-radius: var(--r-sm);
	background: transparent;
	color: var(--text-dim);
	font: inherit;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	transition: color 0.18s;
}

.tab:hover {
	color: var(--text);
}

.tab.is-active {
	color: var(--text);
}

.panel {
	display: none;
}

.panel.is-active {
	display: block;
}

/* =============================================================== steps */

.steps {
	counter-reset: step;
	list-style: none;
	margin: 0 0 20px;
	padding: 0;
	display: grid;
	gap: 9px;
	color: var(--text-dim);
	font-size: 13.5px;
}

/* The marker is absolutely positioned rather than a grid/flex child —
   inline children like <b> must keep flowing with the surrounding text. */
.steps li {
	counter-increment: step;
	position: relative;
	padding-left: 32px;
	min-height: 21px;
}

.steps li::before {
	content: counter(step);
	position: absolute;
	left: 0;
	top: 0;
	width: 21px;
	height: 21px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--accent-tint);
	border: 1px solid var(--accent-edge);
	color: var(--accent-strong);
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}

.steps b {
	color: var(--text);
	font-weight: 600;
}

/* =============================================================== qr */

.qr-stage {
	display: grid;
	place-items: center;
	padding: 6px 0 22px;
}

.qr-box {
	position: relative;
	width: 262px;
	height: 262px;
	display: grid;
	place-items: center;
	padding: 12px;
	border-radius: var(--r-md);
	background: #fff;
	box-shadow: 0 14px 34px -16px rgba(0, 0, 0, 0.55);
}

.qr-box img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	image-rendering: pixelated;
}

/* four bracket corners floating just outside the white plate */
.qr-corners {
	position: absolute;
	inset: -11px;
	pointer-events: none;
}

.qr-corners i {
	position: absolute;
	width: 20px;
	height: 20px;
	border: 2px solid var(--accent);
	opacity: 0.75;
}

.qr-corners i:nth-child(1) {
	top: 0;
	left: 0;
	border-width: 2px 0 0 2px;
	border-radius: 7px 0 0 0;
}

.qr-corners i:nth-child(2) {
	top: 0;
	right: 0;
	border-width: 2px 2px 0 0;
	border-radius: 0 7px 0 0;
}

.qr-corners i:nth-child(3) {
	bottom: 0;
	right: 0;
	border-width: 0 2px 2px 0;
	border-radius: 0 0 7px 0;
}

.qr-corners i:nth-child(4) {
	bottom: 0;
	left: 0;
	border-width: 0 0 2px 2px;
	border-radius: 0 0 0 7px;
}

.qr-placeholder {
	text-align: center;
	color: #7a8b98;
	padding: 16px;
}

.qr-glyph {
	width: 46px;
	height: 46px;
	opacity: 0.4;
}

.qr-placeholder p {
	margin: 12px 0 0;
	font-size: 13px;
	line-height: 1.45;
}

.qr-placeholder b {
	color: #40525f;
	font-weight: 600;
}

.qr-overlay {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	align-content: center;
	gap: 12px;
	border-radius: var(--r-md);
	background: rgba(255, 255, 255, 0.94);
	color: #5d7080;
	font-size: 13px;
	text-align: center;
	padding: 18px;
}

.qr-overlay p {
	margin: 0;
}

.spinner {
	width: 26px;
	height: 26px;
	border: 2.5px solid rgba(0, 168, 132, 0.22);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.75s linear infinite;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

/* =============================================================== fields */

.field {
	display: block;
	margin-bottom: 18px;
}

.field-label {
	display: block;
	margin-bottom: 7px;
	font-size: 12.5px;
	font-weight: 620;
	letter-spacing: 0.1px;
}

.input-row {
	display: flex;
	align-items: center;
	background: var(--surface-2);
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

.input-row:focus-within {
	background: var(--surface);
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-tint);
}

.input-prefix {
	padding: 0 3px 0 14px;
	color: var(--text-faint);
	font-size: 15px;
}

.input-row input {
	flex: 1;
	min-width: 0;
	padding: 12px 14px 12px 2px;
	border: 0;
	background: transparent;
	color: var(--text);
	font: inherit;
	font-size: 15px;
	letter-spacing: 0.5px;
	outline: none;
}

.input-row input::placeholder {
	color: var(--text-faint);
	letter-spacing: 0.4px;
}

.field-hint {
	display: block;
	margin-top: 7px;
	color: var(--text-faint);
	font-size: 12px;
}

/* =============================================================== pairing */

.pairing-result {
	text-align: center;
	padding: 20px 18px;
	margin-bottom: 18px;
	border-radius: var(--r-md);
	background: linear-gradient(var(--accent-tint), var(--accent-tint)), var(--surface-2);
	border: 1px solid var(--accent-edge);
}

.pairing-label {
	margin: 0 0 12px;
	color: var(--text-dim);
	font-size: 12.5px;
}

.pairing-code {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	color: var(--accent-strong);
	font-family: var(--mono);
	font-size: clamp(28px, 7vw, 38px);
	font-weight: 700;
	letter-spacing: 6px;
	line-height: 1.1;
	cursor: pointer;
	transition: opacity 0.15s;
}

.pairing-code:hover {
	opacity: 0.78;
}

.pairing-note {
	margin: 12px 0 0;
	color: var(--text-faint);
	font-size: 12px;
}

/* =============================================================== buttons */

.btn {
	padding: 12px 18px;
	border: 1px solid transparent;
	border-radius: var(--r-md);
	font: inherit;
	font-size: 14.5px;
	font-weight: 640;
	letter-spacing: 0.1px;
	cursor: pointer;
	transition: background 0.16s, border-color 0.16s, color 0.16s, opacity 0.16s, transform 0.1s;
}

.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.btn:not(:disabled):active {
	transform: translateY(1px);
}

.btn-block {
	display: block;
	width: 100%;
}

.btn-primary {
	background: var(--accent);
	color: var(--accent-ink);
	box-shadow: 0 10px 24px -12px rgba(0, 168, 132, 0.9);
}

.btn-primary:not(:disabled):hover {
	background: var(--accent-strong);
}

.btn-ghost {
	background: var(--surface-2);
	border-color: var(--line);
	color: var(--text);
}

.btn-ghost:not(:disabled):hover {
	background: var(--surface-3);
}

.btn-danger {
	background: transparent;
	border-color: var(--danger-edge);
	color: var(--danger);
}

.btn-danger:not(:disabled):hover {
	background: var(--danger-tint);
	border-color: var(--danger);
}

/* =============================================================== connected */

.connected-head {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-bottom: 20px;
}

.success-mark {
	flex: none;
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	color: var(--accent-ink);
	background: var(--accent);
	box-shadow: 0 10px 24px -10px rgba(0, 168, 132, 0.8);
}

.success-mark svg {
	width: 21px;
	height: 21px;
}

.card-connected h2 {
	margin: 0;
	font-size: 18px;
	font-weight: 640;
	letter-spacing: -0.2px;
}

.connected-sub {
	margin: 3px 0 0;
	color: var(--text-dim);
	font-size: 13px;
}

/* the one detail this page shows: which number the bot is running on */
.number-plate {
	display: grid;
	gap: 5px;
	margin-bottom: 18px;
	padding: 15px 17px;
	border-radius: var(--r-md);
	background: linear-gradient(var(--accent-tint), var(--accent-tint)), var(--surface-2);
	border: 1px solid var(--accent-edge);
	text-align: center;
}

.number-label {
	color: var(--text-dim);
	font-size: 11.5px;
	font-weight: 650;
	text-transform: uppercase;
	letter-spacing: 0.9px;
}

.number-value {
	color: var(--accent-strong);
	font-family: var(--mono);
	font-size: clamp(22px, 6vw, 28px);
	font-weight: 700;
	letter-spacing: 1.2px;
	line-height: 1.2;
	overflow-wrap: anywhere;
}

.btn-sm {
	padding: 9px 16px;
	font-size: 13px;
}

.link-btn {
	padding: 0;
	border: 0;
	background: none;
	color: var(--text-faint);
	font: inherit;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: color 0.15s;
}

.link-btn:hover {
	color: var(--accent-strong);
}

.meta-note {
	margin: 12px 0 0;
	color: var(--text-faint);
	font-size: 12px;
	line-height: 1.5;
}

.inline-code {
	padding: 1px 5px;
	border-radius: var(--r-sm);
	background: var(--surface-2);
	border: 1px solid var(--line);
	color: var(--text-dim);
	font-family: var(--mono);
	font-size: 11.5px;
	white-space: nowrap;
}

/* =============================================================== misc */

.error {
	display: flex;
	margin: 16px 0 0;
	padding: 11px 13px;
	border-radius: var(--r-md);
	background: var(--danger-tint);
	border: 1px solid var(--danger-edge);
	color: var(--danger);
	font-size: 13px;
}

/* toast — app.js rewrites className to `toast toast-<tone>`, so everything
   visual has to live on those two classes. */
.toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	z-index: 50;
	transform: translateX(-50%);
	max-width: calc(100% - 32px);
	padding: 12px 20px;
	border-radius: 999px;
	background: var(--surface);
	border: 1px solid var(--line);
	box-shadow: 0 20px 44px -16px rgba(0, 0, 0, 0.65);
	font-size: 13.5px;
	font-weight: 560;
	text-align: center;
	animation: rise 0.22s ease-out;
}

.toast-ok {
	color: var(--accent-strong);
	border-color: var(--accent-edge);
	background: linear-gradient(var(--accent-tint), var(--accent-tint)), var(--surface);
}

.toast-bad {
	color: var(--danger);
	border-color: var(--danger-edge);
	background: linear-gradient(var(--danger-tint), var(--danger-tint)), var(--surface);
}

@keyframes rise {
	from { opacity: 0; transform: translate(-50%, 12px); }
	to { opacity: 1; transform: translate(-50%, 0); }
}

/* =============================================================== narrow */

@media (max-width: 560px) {
	.page {
		width: min(460px, 100% - 28px);
		padding: 26px 0 40px;
	}

	.topbar {
		padding-bottom: 18px;
		margin-bottom: 18px;
	}

	.qr-box {
		width: min(262px, 78vw);
		height: min(262px, 78vw);
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	.spinner {
		animation: spin 0.75s linear infinite !important;
	}
}

/* ======================================================= bot sidebar */

.sidebar {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow);
	position: sticky;
	top: 24px;
}

@media (max-width: 860px) {
	.sidebar {
		position: static;
	}
}

.sidebar-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.sidebar-head h2 {
	margin: 0;
	font-size: 11.5px;
	font-weight: 650;
	text-transform: uppercase;
	letter-spacing: 0.9px;
	color: var(--text-dim);
}

.counter {
	font-family: var(--mono);
	font-size: 11.5px;
	color: var(--text-faint);
}

.bot-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.bot-item.is-active .bot-button {
	background: var(--accent-tint);
	border-color: var(--accent-edge);
}

.bot-button {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 11px;
	border: 1px solid transparent;
	border-radius: var(--r-sm);
	background: transparent;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}

.bot-button:hover {
	background: var(--surface-2);
}

/* The list dot is a status light in its own right, so it carries an explicit
   colour rather than inheriting the pill rule's currentColor. */
.bot-button .dot {
	flex: none;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--text-faint);
}

.dot-ok {
	background: var(--accent-strong);
	box-shadow: 0 0 0 3px var(--accent-tint);
}

.dot-bad {
	background: var(--danger);
}

.dot-busy {
	background: var(--warn);
	animation: pulse 1.3s ease-in-out infinite;
}

.dot-idle {
	background: var(--text-faint);
}

.bot-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
	line-height: 1.3;
}

.bot-text strong {
	font-size: 13.5px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bot-sub {
	font-size: 11.5px;
	color: var(--text-faint);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bot-empty {
	padding: 10px 11px;
	color: var(--text-faint);
	font-size: 13px;
}

.add-form {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding-top: 12px;
	border-top: 1px solid var(--line-soft);
}

.add-form .field input {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--line);
	border-radius: var(--r-sm);
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
	font-size: 13.5px;
}

.add-form .field input:focus {
	outline: none;
	border-color: var(--accent-edge);
	background: var(--surface);
}

/* ========================================================= main head */

.main-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}

.main-head h2 {
	margin: 0;
	font-size: 19px;
	font-weight: 640;
	letter-spacing: -0.3px;
}

.main-sub {
	margin: 3px 0 0;
	color: var(--text-dim);
	font-size: 12.5px;
}

.main-head .tabs {
	margin-bottom: 0;
	min-width: 240px;
}

.tabs-inner {
	margin-bottom: 20px;
}

.view {
	display: none;
	flex-direction: column;
	gap: 20px;
}

.view.is-active {
	display: flex;
}

/* ============================================================ stats */

.stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: 1px;
	margin: 18px 0;
	padding: 1px;
	background: var(--line-soft);
	border: 1px solid var(--line-soft);
	border-radius: var(--r-md);
	overflow: hidden;
}

.stat-grid dt {
	grid-row: 1;
	padding: 10px 12px 0;
	background: var(--surface-2);
	color: var(--text-faint);
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.6px;
}

.stat-grid dd {
	grid-row: 2;
	margin: 0;
	padding: 0 12px 10px;
	background: var(--surface-2);
	font-family: var(--mono);
	font-size: 17px;
	font-weight: 600;
}

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

.row-actions-end {
	justify-content: flex-end;
}

/* ========================================================= settings */

.settings-toolbar {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.search-box {
	flex: 1;
	min-width: 180px;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 12px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-md);
}

.search-box:focus-within {
	border-color: var(--accent-edge);
}

.search-box svg {
	width: 15px;
	height: 15px;
	flex: none;
	color: var(--text-faint);
}

.search-box input {
	flex: 1;
	min-width: 0;
	padding: 10px 0;
	border: 0;
	background: transparent;
	color: var(--text);
	font: inherit;
	font-size: 13.5px;
}

.search-box input:focus {
	outline: none;
}

.check-inline {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	color: var(--text-dim);
	font-size: 13px;
	cursor: pointer;
	white-space: nowrap;
}

.check-inline input {
	accent-color: var(--accent);
	width: 15px;
	height: 15px;
}

.settings-groups {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.settings-group {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow-soft);
	overflow: hidden;
}

.settings-group > summary {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 18px;
	cursor: pointer;
	font-weight: 600;
	font-size: 14px;
	list-style: none;
	user-select: none;
}

.settings-group > summary::-webkit-details-marker {
	display: none;
}

.settings-group > summary::after {
	content: "\203A";
	margin-left: auto;
	color: var(--text-faint);
	font-size: 18px;
	transition: transform 0.18s;
}

.settings-group[open] > summary::after {
	transform: rotate(90deg);
}

.settings-group > summary:hover {
	background: var(--surface-2);
}

.group-icon {
	font-size: 15px;
}

.group-title {
	flex: none;
}

.group-badge {
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--accent-tint);
	border: 1px solid var(--accent-edge);
	color: var(--accent-strong);
	font-size: 11px;
	font-weight: 600;
}

.group-help {
	margin: 0;
	padding: 0 18px 14px;
	color: var(--text-dim);
	font-size: 12.5px;
}

.group-body {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 1px;
	background: var(--line-soft);
	border-top: 1px solid var(--line-soft);
}

.setting {
	display: flex;
	flex-direction: column;
	gap: 7px;
	padding: 14px 18px;
	background: var(--surface);
}

/* A value changed from its default earns a quiet marker; an unsaved edit earns
   a loud one, because that is what the save bar is talking about. */
.setting.is-custom {
	box-shadow: inset 3px 0 0 var(--accent-edge);
}

.setting.is-dirty {
	box-shadow: inset 3px 0 0 var(--warn);
	background: color-mix(in srgb, var(--warn) 5%, var(--surface));
}

.setting-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
}

.setting-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--text);
}

.setting-help {
	margin: 0;
	color: var(--text-faint);
	font-size: 11.5px;
	line-height: 1.45;
}

.setting-placeholders {
	font-family: var(--mono);
	font-size: 10.5px;
}

.control {
	width: 100%;
	padding: 8px 11px;
	border: 1px solid var(--line);
	border-radius: var(--r-sm);
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
	font-size: 13px;
}

.control:focus {
	outline: none;
	border-color: var(--accent-edge);
	background: var(--surface);
}

.control-area {
	font-family: var(--mono);
	font-size: 12px;
	line-height: 1.5;
	resize: vertical;
	min-height: 78px;
}

select.control {
	cursor: pointer;
}

/* ------------------------------------------------------------ switch */

.switch {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	user-select: none;
	align-self: flex-start;
}

.switch input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.switch-track {
	position: relative;
	width: 40px;
	height: 22px;
	flex: none;
	border-radius: 999px;
	background: var(--surface-3);
	border: 1px solid var(--line);
	transition: background 0.18s, border-color 0.18s;
}

.switch-track::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--text-faint);
	transition: transform 0.18s, background 0.18s;
}

.switch input:checked + .switch-track {
	background: var(--accent-tint);
	border-color: var(--accent-edge);
}

.switch input:checked + .switch-track::after {
	transform: translateX(18px);
	background: var(--accent-strong);
}

.switch input:focus-visible + .switch-track {
	outline: 2px solid var(--accent-strong);
	outline-offset: 2px;
}

.switch-text {
	font-size: 12.5px;
	color: var(--text-dim);
}

.settings-foot {
	margin-top: 4px;
}

/* ========================================================== save bar */

.save-bar {
	position: fixed;
	left: 50%;
	bottom: 22px;
	transform: translateX(-50%);
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 10px 12px 10px 20px;
	background: var(--surface);
	border: 1px solid var(--accent-edge);
	border-radius: 999px;
	box-shadow: var(--shadow);
	font-size: 13px;
	font-weight: 600;
	animation: rise 0.2s ease-out;
}

@keyframes rise {
	from {
		opacity: 0;
		transform: translate(-50%, 10px);
	}
	to {
		opacity: 1;
		transform: translate(-50%, 0);
	}
}

/* ========================================================= sign-in gate */

.login-gate {
	min-height: 100vh;
	display: grid;
	place-items: center;
	padding: 24px;
}

.login-card {
	width: min(380px, 100%);
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 32px 28px;
	text-align: left;
}

.login-mark {
	width: 46px;
	height: 46px;
	margin-bottom: 4px;
}

.login-mark svg {
	width: 25px;
	height: 25px;
}

.login-card h1 {
	margin: 0;
	font-size: 21px;
	font-weight: 640;
	letter-spacing: -0.35px;
}

.login-sub {
	margin: -8px 0 6px;
	color: var(--text-dim);
	font-size: 13.5px;
}

.login-card .field input,
.account-form .field input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: var(--r-sm);
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
	font-size: 14px;
}

.login-card .field input:focus,
.account-form .field input:focus {
	outline: none;
	border-color: var(--accent-edge);
	background: var(--surface);
}

.login-card .btn {
	margin-top: 4px;
}

/* ============================================================= account */

.topbar-right {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

#accountBtn {
	max-width: 220px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.account-card {
	margin-bottom: 4px;
	animation: rise-in 0.18s ease-out;
}

@keyframes rise-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.account-card .section-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 16px;
}

.account-card .section-head h3 {
	margin: 0;
	color: var(--text-dim);
	font-size: 11.5px;
	font-weight: 650;
	text-transform: uppercase;
	letter-spacing: 0.9px;
}

.account-form {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 14px;
	align-items: start;
}

.account-form .error,
.account-form .row-actions {
	grid-column: 1 / -1;
}

/* ---------------------------------------------------- locked settings */

/* Fixed in templates.js. Marked in a way that reads as "not yours to change
   here" rather than as an error, since nothing is wrong with it. */
.setting.is-locked {
	box-shadow: inset 3px 0 0 var(--line);
	background: var(--surface-2);
}

.lock-badge {
	flex: none;
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--surface-3);
	border: 1px solid var(--line);
	color: var(--text-faint);
	font-size: 10.5px;
	font-weight: 600;
	white-space: nowrap;
}

.control-locked {
	color: var(--text-dim);
	background: var(--surface-3);
	cursor: default;
	resize: none;
}

.control-locked:focus {
	border-color: var(--line);
	background: var(--surface-3);
}
