/* Letops theme. Colours are CSS variables: light by default, dark under
   [data-theme="dark"] on <html> (set by ui::THEME_SCRIPT and the switch in the corner). */

:root {
	--bg: #f5f6fb;
	--surface: #ffffff;
	--surface-2: #f0f2f8;
	--text: #1d2130;
	--muted: #6b7185;
	--border: #e1e4ee;
	--accent: #5b5bd6;
	--accent-hover: #4a4ac4;
	--accent-text: #ffffff;
	--accent-soft: #ecebfd;
	--accent-soft-text: #3e3ea8;
	--highlight: #fff7e0;
	--highlight-border: #e9c46a;
	--danger: #c93b4a;
	--danger-soft: #fdecee;
	--success: #2f8a5b;
	--shadow: 0 1px 2px rgba(20, 24, 40, 0.06), 0 4px 16px rgba(20, 24, 40, 0.06);
	--shadow-lg: 0 12px 40px rgba(20, 24, 40, 0.22);
	--radius: 12px;
	--radius-sm: 8px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
	color-scheme: light;
}

[data-theme="dark"] {
	--bg: #12141c;
	--surface: #1b1e29;
	--surface-2: #232736;
	--text: #e6e8f0;
	--muted: #9aa0b4;
	--border: #2e3344;
	--accent: #8b8bf5;
	--accent-hover: #a2a2ff;
	--accent-text: #12141c;
	--accent-soft: #2a2b4d;
	--accent-soft-text: #c9c9ff;
	--highlight: #2f2a1a;
	--highlight-border: #8a7330;
	--danger: #f07884;
	--danger-soft: #3a2026;
	--success: #6fcf97;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
	--shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
	color-scheme: dark;
}

/* ---- base */

*,
*::before,
*::after {
	box-sizing: border-box;
}

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

body {
	margin: 0;
	font-family: var(--font);
	font-size: 16px;
	line-height: 1.5;
	background: var(--bg);
	color: var(--text);
	transition: background 0.2s, color 0.2s;
}

main {
	max-width: 72rem;
	margin: 0 auto;
	padding: 1.5rem 1.25rem 5rem;
}

h1 {
	font-size: 1.9rem;
	line-height: 1.2;
	margin: 0.5rem 0 0.5rem;
	letter-spacing: -0.02em;
}

h2 {
	font-size: 1.3rem;
	margin: 2rem 0 0.75rem;
	letter-spacing: -0.01em;
}

h3 {
	font-size: 1.1rem;
	margin: 0 0 0.5rem;
}

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

code,
pre {
	font-family: var(--mono);
	font-size: 0.88em;
}

code {
	padding: 0.1em 0.35em;
	background: var(--surface-2);
	border-radius: 5px;
}

.lead {
	color: var(--muted);
	margin-top: 0;
	font-size: 1.05rem;
}

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

.error {
	color: var(--danger);
	white-space: pre-wrap;
	font-family: inherit;
}

.error:empty,
.notice:empty {
	display: none;
}

.notice {
	padding: 0.6rem 1rem;
	background: var(--accent-soft);
	color: var(--accent-soft-text);
	border-radius: var(--radius-sm);
}

.empty {
	padding: 2rem;
	text-align: center;
	color: var(--muted);
	background: var(--surface);
	border: 1px dashed var(--border);
	border-radius: var(--radius);
}

.nowrap {
	white-space: nowrap;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 1.25rem 1.5rem;
}

.toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
}

.page-head,
.section-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem 1rem;
}

.section-head h2 {
	margin-bottom: 0.75rem;
}

.eyebrow {
	margin: 0;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--accent);
}

/* ---- buttons and inputs */

button,
.file-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	min-height: 2.4rem;
	padding: 0.45rem 1rem;
	font: inherit;
	font-size: 0.95rem;
	font-weight: 500;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}

button:hover:not(:disabled),
.file-button:hover {
	border-color: var(--accent);
	color: var(--accent);
}

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

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

button:disabled {
	opacity: 0.5;
	cursor: default;
}

button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-text);
}

button.primary:hover:not(:disabled) {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
	color: var(--accent-text);
}

button.danger {
	background: var(--danger);
	border-color: var(--danger);
	color: #fff;
}

button.danger:hover:not(:disabled) {
	filter: brightness(1.08);
	color: #fff;
	border-color: var(--danger);
}

button.ghost {
	background: transparent;
	border-color: transparent;
}

button.ghost.danger {
	color: var(--danger);
}

button.ghost.danger:hover:not(:disabled) {
	background: var(--danger-soft);
	border-color: transparent;
	color: var(--danger);
	filter: none;
}

button.wide {
	width: 100%;
}

/* a button that looks like a link */
button.link {
	min-height: 0;
	padding: 0;
	border: none;
	background: none;
	color: var(--accent);
	font-weight: 400;
	text-decoration: underline;
	text-underline-offset: 2px;
}

button.link.danger {
	color: var(--danger);
}

.file-button input {
	display: none;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
textarea {
	font: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 0.5rem 0.75rem;
	min-height: 2.4rem;
	transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
	outline: none;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	margin-bottom: 1rem;
	font-size: 0.9rem;
	color: var(--muted);
}

.field input {
	width: 100%;
}

.form-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0.75rem 0;
}

.form-row input {
	flex: 1 1 14rem;
}

/* ---- top menu */

.topnav {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 1.5rem;
	padding: 0.6rem 1.25rem;
	background: color-mix(in srgb, var(--surface) 85%, transparent);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
}

.brand {
	font-weight: 800;
	font-size: 1.15rem;
	letter-spacing: -0.02em;
	text-decoration: none;
	color: var(--text);
	background: linear-gradient(120deg, var(--accent), #c05bd6);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
}

.topnav nav {
	display: flex;
	gap: 0.25rem;
	flex: 1;
}

.topnav a {
	text-decoration: none;
	color: var(--muted);
	padding: 0.4rem 0.75rem;
	border-radius: var(--radius-sm);
	font-weight: 500;
	transition: background 0.15s, color 0.15s;
}

.topnav nav a:hover,
.topnav .userbox a:hover {
	color: var(--text);
	background: var(--surface-2);
}

.topnav a.active {
	color: var(--accent-soft-text);
	background: var(--accent-soft);
}

.topnav .userbox {
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

.topnav .user {
	color: var(--text);
	font-weight: 600;
}

.menu-toggle {
	display: none;
	flex-direction: column;
	gap: 4px;
	width: 2.6rem;
	padding: 0;
	margin-left: auto;
	background: transparent;
	border-color: transparent;
}

.menu-toggle span {
	display: block;
	width: 20px;
	height: 2px;
	border-radius: 2px;
	background: var(--text);
	transition: transform 0.2s, opacity 0.2s;
}

.topnav.open .menu-toggle span:nth-child(1) {
	transform: translateY(6px) rotate(45deg);
}

.topnav.open .menu-toggle span:nth-child(2) {
	opacity: 0;
}

.topnav.open .menu-toggle span:nth-child(3) {
	transform: translateY(-6px) rotate(-45deg);
}

/* ---- bottom right corner: version (logged-in users only) and the light/dark switch */

.corner {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 6;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.25rem;
	background: color-mix(in srgb, var(--surface) 90%, transparent);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	border: 1px solid var(--border);
	border-radius: 999px;
	box-shadow: var(--shadow);
}

.app-version {
	padding-left: 0.6rem;
	font-size: 0.72rem;
	color: var(--muted);
	pointer-events: none;
}

.theme-toggle {
	width: 2.4rem;
	height: 2.4rem;
	min-height: 0;
	padding: 0;
	border-radius: 50%;
	border-color: transparent;
	background: var(--accent-soft);
	color: var(--accent-soft-text);
}

/* ---- home */

.tiles {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	gap: 1rem;
	margin-top: 1.5rem;
}

.tile {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	padding: 1.25rem;
	text-decoration: none;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	transition: transform 0.15s, border-color 0.15s;
}

.tile:hover {
	transform: translateY(-2px);
	border-color: var(--accent);
}

.tile-title {
	font-weight: 700;
	font-size: 1.1rem;
}

.tile-text {
	color: var(--muted);
	font-size: 0.92rem;
}

/* ---- login */

main.login {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.login-card {
	width: 100%;
	max-width: 24rem;
	padding: 2rem;
}

/* honeypot field of the login form: off screen, still in the DOM for bots */
.login-card .hp {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.login-card .brand {
	font-size: 1.5rem;
}

.login-card h1 {
	font-size: 1.3rem;
	margin: 0.25rem 0 1.5rem;
	color: var(--muted);
	font-weight: 500;
}

/* ---- tables */

.table-wrap {
	overflow-x: auto;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.invoices {
	width: 100%;
	border-collapse: collapse;
	text-align: left;
	font-size: 0.93rem;
}

.invoices th,
.invoices td {
	padding: 0.6rem 0.85rem;
	border-bottom: 1px solid var(--border);
	vertical-align: top;
}

.invoices tbody tr:last-child td {
	border-bottom: none;
}

.invoices tbody tr:hover {
	background: var(--surface-2);
}

.invoices th {
	background: var(--surface-2);
	color: var(--muted);
	font-weight: 600;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	white-space: nowrap;
}

.invoices td:first-child {
	white-space: nowrap;
}

.invoices td.links a,
.invoices td.links button {
	display: block;
	margin-bottom: 0.2rem;
}

.invoices td.num {
	text-align: right;
}

.invoices ul.products {
	margin: 0;
	padding: 0;
	list-style: none;
}

.invoices ul.products li {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
}

.invoices ul.products li.total {
	border-top: 1px solid var(--border);
	font-weight: bold;
}

.invoices ul.products .num {
	white-space: nowrap;
}

.invoices .warning {
	color: var(--danger);
}

.invoices .warranty-yes {
	color: var(--success);
	font-weight: 600;
}

.method {
	display: inline-block;
	min-width: 3.6rem;
	padding: 0.05rem 0.4rem;
	font-size: 0.72rem;
	font-weight: 700;
	text-align: center;
	border-radius: 5px;
	background: var(--accent-soft);
	color: var(--accent-soft-text);
}

.method-delete {
	background: var(--danger-soft);
	color: var(--danger);
}

/* ---- API endpoints on /account/api: one card per endpoint */

.endpoint-filter {
	width: 100%;
	max-width: 24rem;
	margin-bottom: 0.75rem;
}

.endpoints {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.endpoint {
	padding: 0.75rem 1rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
}

.endpoint-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem 0.6rem;
}

/* long paths and tool names wrap anywhere instead of widening the page */
.endpoint-path,
.endpoint-tool code,
.endpoint-params code {
	overflow-wrap: anywhere;
}

.endpoint-path {
	font-weight: 600;
}

.endpoint-tool {
	margin-left: auto;
	color: var(--muted);
	font-size: 0.85rem;
}

.endpoint-desc {
	margin: 0.4rem 0 0;
}

.endpoint-params {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.3rem;
	margin-top: 0.45rem;
	font-size: 0.85rem;
}

.endpoint-params code.optional {
	opacity: 0.7;
}

/* phones: the MCP name goes under the path */
@media (max-width: 760px) {
	.endpoint-tool {
		margin-left: 0;
		flex-basis: 100%;
	}
}

/* ---- /email */

.mail-form {
	max-width: 40rem;
}

.mail-form .field input,
.mail-form .field textarea {
	width: 100%;
}

.mail-form textarea {
	resize: vertical;
}

p.ok {
	color: var(--success);
}

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

/* ---- /logs: the user's flow log */

.activity td {
	font-size: 0.9rem;
}

.activity-toolbar {
	margin-bottom: 0.75rem;
}

/* phones: every entry becomes a small card (when, source, flow, what, details) */
@media (max-width: 760px) {
	.activity thead {
		display: none;
	}

	.activity tr {
		display: grid;
		grid-template-columns: 1fr auto;
		gap: 0.15rem 0.5rem;
		padding: 0.6rem 0.85rem;
		border-bottom: 1px solid var(--border);
	}

	.activity tbody tr:last-child {
		border-bottom: none;
	}

	.activity td {
		display: block;
		padding: 0;
		border: none;
	}

	.activity td.when {
		color: var(--muted);
		font-size: 0.8rem;
	}

	/* the source next to the time */
	.activity td.src {
		grid-row: 1;
		grid-column: 2;
	}

	.activity td.who,
	.activity td.flow,
	.activity td.what,
	.activity td.detail {
		grid-column: 1 / -1;
	}

	/* "—" of entries without a flow says nothing on a card */
	.activity td.flow.empty {
		display: none;
	}

	.activity td.who {
		color: var(--muted);
		font-size: 0.85rem;
	}

	.activity td.what {
		font-weight: 600;
	}
}

.activity .badge.source-rest,
.activity .badge.source-mcp {
	color: var(--accent-soft-text);
	background: var(--accent-soft);
	border-color: transparent;
}

.toolbar select {
	font: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 0.45rem 0.6rem;
	min-height: 2.4rem;
	max-width: 100%;
}

/* ---- /logs for admins: operations or the service log; /admin */

.tabs {
	display: flex;
	gap: 0.25rem;
	margin-bottom: 0.9rem;
	border-bottom: 1px solid var(--border);
}

.tabs button,
.tabs a {
	font: inherit;
	text-decoration: none;
	font-weight: 500;
	color: var(--muted);
	background: none;
	border: none;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	padding: 0.5rem 0.8rem;
	margin-bottom: -1px;
	cursor: pointer;
}

.tabs button:hover,
.tabs a:hover {
	color: var(--text);
}

.tabs button.active,
.tabs a.active {
	color: var(--accent-soft-text);
	border-bottom-color: var(--accent);
}

/* the log viewer of admins (`logview.rs`): dense lines, filters in the column headers */
.logview {
	position: relative;
}

.lv-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.lv-search {
	flex: 1 1 22rem;
	min-width: 0;
	font-family: var(--mono);
}

.lv-live {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	white-space: nowrap;
	font-size: 0.9rem;
}

.lv-chips {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35rem;
	min-height: 1.6rem;
	margin-bottom: 0.25rem;
}

.lv-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	font-size: 0.8rem;
	padding: 0.1rem 0.2rem 0.1rem 0.5rem;
	border-radius: 999px;
	background: var(--accent-soft);
	color: var(--accent-soft-text);
	max-width: 100%;
}

.lv-chip-x {
	border: none;
	background: none;
	color: inherit;
	cursor: pointer;
	font-size: 1rem;
	line-height: 1;
	padding: 0 0.3rem;
}

.lv-status {
	font-size: 0.8rem;
	margin-bottom: 0.4rem;
}

.lv-scroll {
	overflow: auto;
	max-height: calc(100vh - 16rem);
	min-height: 12rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
}

.lv-grid {
	display: grid;
	min-width: 56rem;
	font-family: var(--mono);
	font-size: 0.78rem;
	line-height: 1.35;
}

/* rows and the header lay their cells straight on the grid */
.lv-head,
.lv-row {
	display: contents;
}

.lv-h {
	position: sticky;
	top: 0;
	z-index: 2;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	padding: 0.3rem 0.45rem;
	font-family: var(--font);
	font-weight: 600;
	font-size: 0.8rem;
	white-space: nowrap;
	display: flex;
	align-items: center;
}

.lv-hbtn {
	font: inherit;
	color: inherit;
	background: none;
	border: none;
	padding: 0;
	min-height: 0;
	height: auto;
	box-shadow: none;
	cursor: pointer;
}

.lv-hbtn:hover {
	background: none;
	color: var(--accent);
}

.lv-hbtn.on {
	color: var(--accent);
}

.lv-count {
	display: inline-block;
	margin-left: 0.3rem;
	padding: 0 0.35rem;
	border-radius: 999px;
	background: var(--accent);
	color: var(--accent-text);
	font-size: 0.7rem;
}

.lv-c {
	padding: 0.12rem 0.45rem;
	border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
	cursor: default;
}

.lv-row:hover .lv-c {
	background: var(--accent-soft);
}

.lv-row.open .lv-c {
	white-space: pre-wrap;
	word-break: break-word;
	background: var(--highlight);
}

.lv-time {
	color: var(--muted);
}

.lv-f {
	cursor: pointer;
}

.lv-f:hover {
	text-decoration: underline dotted;
}

.lv-f.chosen {
	color: var(--accent);
	font-weight: 600;
}

.lv-link {
	margin-left: 0.3rem;
	text-decoration: none;
}

.lv-level-error {
	color: var(--danger);
	font-weight: 600;
}

.lv-level-warn {
	color: #c27c0e;
}

.lv-f.chosen.lv-level-error {
	color: var(--danger);
}

.lv-c mark {
	background: var(--highlight-border);
	color: inherit;
	border-radius: 2px;
}

.lv-empty {
	padding: 1rem;
	color: var(--muted);
}

.lv-backdrop {
	position: fixed;
	inset: 0;
	z-index: 5;
}

.lv-menu {
	position: fixed;
	z-index: 6;
	width: 19rem;
	max-width: 80vw;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-lg);
	padding: 0.5rem;
	font-weight: normal;
	white-space: normal;
}

.lv-menu-find {
	width: 100%;
}

.lv-menu-actions {
	display: flex;
	justify-content: space-between;
	margin: 0.3rem 0;
	font-size: 0.8rem;
}

.lv-menu-list {
	max-height: 18rem;
	overflow: auto;
}

.lv-menu-item {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.15rem 0.2rem;
	border-radius: 4px;
	cursor: pointer;
}

.lv-menu-item:hover {
	background: var(--accent-soft);
}

.lv-menu-item.zero {
	color: var(--muted);
}

.lv-menu-label {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.lv-menu-count {
	font-family: var(--mono);
	font-size: 0.75rem;
	color: var(--muted);
}

/* /admin users */
.users td.actions .link {
	margin-right: 0.6rem;
}

.users .badge {
	margin-left: 0.4rem;
}

.inline-form {
	display: flex;
	gap: 0.3rem;
}

.inline-form input {
	min-width: 0;
	width: 11rem;
	padding-top: 0.25rem;
	padding-bottom: 0.25rem;
}

.inline-form button {
	padding-top: 0.25rem;
	padding-bottom: 0.25rem;
}

code.secret {
	font-size: 1.05rem;
	padding: 0.1rem 0.4rem;
	user-select: all;
}

.invoices th.center,
.invoices td.center {
	text-align: center;
}

.admin-grid input[type="checkbox"] {
	width: 1.1rem;
	height: 1.1rem;
	accent-color: var(--accent);
	cursor: pointer;
}

.admin-grid input[type="checkbox"]:disabled {
	cursor: not-allowed;
}

/* ---- logs */

.logs {
	margin: 0;
	padding: 1rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	white-space: pre-wrap;
	word-break: break-word;
	font-size: 0.82rem;
	max-height: 75vh;
	overflow: auto;
}

/* ---- popups */

.modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: rgba(10, 12, 20, 0.45);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	animation: fade-in 0.15s ease-out;
}

.modal {
	width: 100%;
	max-width: 28rem;
	max-height: calc(100vh - 2rem);
	overflow-y: auto;
	padding: 1.5rem;
	background: var(--surface);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: 16px;
	box-shadow: var(--shadow-lg);
	text-align: left;
	animation: pop-in 0.18s ease-out;
}

.modal.wide {
	max-width: 46rem;
}

.modal h2 {
	margin-top: 0;
}

.modal .buttons {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 1rem;
}

@keyframes fade-in {
	from {
		opacity: 0;
	}
}

@keyframes pop-in {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.97);
	}
}

/* ---- the /account pages: sidebar of sections + the chosen section */

.account-layout {
	display: grid;
	grid-template-columns: 14rem minmax(0, 1fr);
	gap: 2rem;
	align-items: start;
}

.account-nav {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	position: sticky;
	top: 1rem;
	padding: 0.5rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.account-nav a {
	text-decoration: none;
	color: var(--muted);
	padding: 0.55rem 0.8rem;
	border-radius: var(--radius-sm);
	font-weight: 500;
	transition: background 0.15s, color 0.15s;
}

.account-nav a:hover {
	color: var(--text);
	background: var(--surface-2);
}

.account-nav a.active {
	color: var(--accent-soft-text);
	background: var(--accent-soft);
}

.account {
	max-width: 60rem;
}

.account > h2:first-child {
	margin-top: 0;
}

/* phones: the sections become a scrollable row of tabs above the content */
@media (max-width: 760px) {
	.account-layout {
		grid-template-columns: minmax(0, 1fr);
		gap: 1rem;
	}

	.account-nav {
		position: static;
		flex-direction: row;
		overflow-x: auto;
		white-space: nowrap;
		box-shadow: none;
		/* swiped sideways; the cut-off last tab shows there is more */
		scrollbar-width: none;
	}

	.account-nav::-webkit-scrollbar {
		display: none;
	}

	.account-nav a {
		flex: none;
	}
}

.account .new-token {
	padding: 0.75rem 1rem;
	background: var(--highlight);
	border: 1px solid var(--highlight-border);
	border-radius: var(--radius-sm);
	margin-bottom: 1rem;
}

/* password, two-factor login and sessions on the account page */
.account .narrow-form {
	max-width: 24rem;
}

.account p.ok {
	color: var(--success);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.55rem;
	border-radius: 999px;
	font-size: 0.82rem;
	background: var(--surface-2);
	color: var(--muted);
	border: 1px solid var(--border);
}

.badge.ok {
	color: var(--success);
	border-color: var(--success);
}

.account .qr {
	width: 220px;
	margin: 0.5rem 0 1rem;
	border-radius: var(--radius-sm);
	overflow: hidden;
	line-height: 0;
}

.account .qr svg {
	width: 100%;
	height: auto;
}

.account .totp-code {
	max-width: 20rem;
}

.account .totp-steps {
	margin: 1rem 0 0.25rem;
	padding-left: 1.4rem;
}

.account details summary {
	cursor: pointer;
	color: var(--danger);
	margin: 0.5rem 0;
}

/* one click selects the whole token for copying */
.account code.token {
	display: block;
	user-select: all;
	word-break: break-all;
	font-size: 1rem;
	padding: 0.5rem;
	background: var(--surface);
}

.account pre.example {
	padding: 0.75rem 1rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	white-space: pre-wrap;
	word-break: break-all;
}


/* a link that looks like a button */
a.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.2rem;
	padding: 0.35rem 0.65rem;
	font-size: 0.88rem;
	font-weight: 500;
	color: var(--text);
	text-decoration: none;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	transition: border-color 0.15s, color 0.15s;
}

a.button:hover {
	border-color: var(--accent);
	color: var(--accent);
}

a.button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-text);
}

a.button.primary:hover {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
	color: var(--accent-text);
}

/* ---- narrow screens */

@media (max-width: 760px) {
	main {
		padding: 1rem 0.85rem 5rem;
	}

	h1 {
		font-size: 1.55rem;
	}

	.topnav {
		flex-wrap: wrap;
		gap: 0;
		padding: 0.5rem 0.85rem;
	}

	.menu-toggle {
		display: flex;
	}

	.topnav nav,
	.topnav .userbox {
		display: none;
		width: 100%;
	}

	.topnav.open nav,
	.topnav.open .userbox {
		display: flex;
		flex: 1 0 100%;
		flex-direction: column;
		align-items: stretch;
		padding-top: 0.5rem;
	}

	.topnav.open .userbox {
		border-top: 1px solid var(--border);
		margin-top: 0.5rem;
	}

	.topnav nav a,
	.topnav .userbox a {
		padding: 0.7rem 0.75rem;
	}

	.card {
		padding: 1rem;
	}

	input.search {
		width: 100%;
	}

	.section-head h2 {
		margin-bottom: 0;
	}

	.modal {
		padding: 1.15rem;
	}

	.modal .buttons button {
		flex: 1;
	}

	.app-version {
		display: none;
	}

	.corner {
		right: 0.75rem;
		bottom: 0.75rem;
		padding: 0.2rem;
	}
}
