/* 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"],
input[type="number"],
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%;
}

/* a password with the show/hide button inside its right end (crate::ui::PasswordInput) */
.password-input {
	position: relative;
	display: block;
}

.password-input input {
	width: 100%;
	padding-right: 2.6rem;
}

.password-input .password-toggle {
	position: absolute;
	top: 50%;
	right: 0.3rem;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 0.3rem;
	background: transparent;
	border: none;
	box-shadow: none;
	color: var(--muted);
	cursor: pointer;
}

.password-input .password-toggle:hover {
	color: var(--text);
}

.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-logo {
	display: block;
	width: min(16rem, 100%);
	height: auto;
	margin: 0 auto 1.5rem;
}

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

.login-card .field > span {
	text-align: center;
}

/* ---- 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%;
	}
}

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

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

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

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

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

/* phones: every entry becomes a small card (when, source, 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.what,
	.activity td.detail {
		grid-column: 1 / -1;
	}

	.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;
	}
}

/* ---- virtual desktop (crate::desktop): icons, windows, taskbar */

body:has(.desktop) {
	overflow: hidden;
}

/* the taskbar has the version and the theme switch */
body:has(.desktop) .corner {
	display: none;
}

/* the theme's own desktop background (crate::background: "Theme") */
body {
	--desktop-default-bg:
		radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%),
		radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--success) 16%, transparent), transparent 50%),
		var(--bg);
}

.desktop {
	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	/* --desktop-bg: the user's background (inline style from crate::background) */
	background: var(--desktop-bg, var(--desktop-default-bg));
	touch-action: none;
}

.desktop.dragging,
.desktop.dragging * {
	user-select: none;
	-webkit-user-select: none;
}

.desktop-area {
	position: relative;
	flex: 1;
	overflow: hidden;
}

/* the icons sit on a grid of 96 x 104 px cells (desktop.rs: CELL_W, CELL_H, GRID_PAD) */
/* the empty desktop under the icons and windows (its right click opens the desktop menu) */
.desktop-wallpaper {
	position: absolute;
	inset: 0;
}

.desktop-icons {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.desktop-icons > * {
	pointer-events: auto;
}

.icon-target {
	position: absolute;
	width: 88px;
	height: 96px;
	border: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent);
	border-radius: var(--radius-sm);
	background: color-mix(in srgb, var(--accent) 10%, transparent);
	pointer-events: none;
}

.desktop-icon {
	position: absolute;
	width: 88px;
	touch-action: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 0.25rem;
	min-height: 0;
	padding: 0.5rem 0.25rem;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	color: var(--text);
	box-shadow: none;
}

.desktop-icon:hover {
	background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.desktop-icon.selected {
	background: color-mix(in srgb, var(--accent) 22%, transparent);
	border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.desktop-icon.moving {
	z-index: 5;
	opacity: 0.85;
	transition: none;
}

/* the menu of an icon (right click) */
.desktop-menu {
	position: absolute;
	z-index: 100000;
	min-width: 11rem;
	display: flex;
	flex-direction: column;
	padding: 0.3rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-lg);
}

.desktop-menu button {
	justify-content: flex-start;
	text-align: left;
	background: transparent;
	border: none;
	box-shadow: none;
	padding: 0.45rem 0.7rem;
}

.desktop-menu button:hover:not(:disabled) {
	background: var(--accent-soft);
}

.desktop-menu button.danger-item {
	color: var(--danger);
}

.desktop-menu button:disabled {
	color: var(--muted);
}

.app-details h2 .icon {
	font-size: 1.6rem;
}

.app-details dl {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.35rem 1rem;
	margin: 0.75rem 0;
}

.app-details dt {
	color: var(--muted);
}

.app-details dd {
	margin: 0;
}

.app-details .endpoints {
	font-size: 0.85rem;
	padding-left: 1.2rem;
}

.desktop-icon .icon {
	font-size: 2rem;
	line-height: 1;
}

.desktop-icon .label {
	font-size: 0.8rem;
	text-align: center;
	text-shadow: 0 1px 2px var(--bg);
}

/* ---- windows */

.window {
	position: absolute;
	top: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
	/* the transform also makes the window the frame of its fixed modals */
	will-change: transform;
}

.window.active {
	box-shadow: var(--shadow-lg);
	border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.window.minimized {
	display: none;
}

.window.maximized {
	inset: 0;
	width: auto !important;
	height: auto !important;
	border-radius: 0;
	transform: translate(0, 0) !important;
}

/* tiled to a half of the desktop (crate::desktop::Snap) */
.window.snapped {
	top: 0;
	bottom: 0;
	width: 50% !important;
	height: auto !important;
	border-radius: 0;
	transform: none !important;
}

.window.snapped.left {
	left: 0;
}

.window.snapped.right {
	left: 50%;
}

.window.snapped .window-titlebar {
	border-radius: 0;
}

.snap-preview {
	position: absolute;
	top: 0.4rem;
	bottom: 0.4rem;
	z-index: 99999;
	width: calc(50% - 0.6rem);
	background: color-mix(in srgb, var(--accent) 16%, transparent);
	border: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
	border-radius: var(--radius-sm);
	pointer-events: none;
	animation: fade-in 0.12s ease-out;
}

.snap-preview.left {
	left: 0.4rem;
}

.snap-preview.right {
	right: 0.4rem;
}

.window-titlebar {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex: none;
	height: 2.2rem;
	padding: 0 0.35rem 0 0.75rem;
	background: var(--bg);
	border-bottom: 1px solid var(--border);
	border-radius: var(--radius-sm) var(--radius-sm) 0 0;
	cursor: default;
	touch-action: none;
}

.window.active .window-titlebar {
	background: var(--accent-soft);
	color: var(--accent-soft-text);
}

.window.maximized .window-titlebar {
	border-radius: 0;
}

.window-title {
	flex: 1;
	overflow: hidden;
	font-size: 0.88rem;
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.window-buttons {
	display: flex;
	gap: 0.2rem;
}

.window-button {
	width: 1.8rem;
	height: 1.6rem;
	min-height: 0;
	padding: 0;
	font-size: 0.85rem;
	line-height: 1;
	background: transparent;
	border-color: transparent;
	color: inherit;
	box-shadow: none;
}

.window-button:hover {
	background: color-mix(in srgb, var(--text) 10%, transparent);
}

.window-button.close:hover {
	background: var(--danger);
	color: #fff;
}

.window-body {
	position: relative;
	flex: 1;
	min-height: 0;
	overflow: auto;
}

main.in-window {
	max-width: none;
	margin: 0;
	padding: 1rem 1.25rem 2rem;
}

.window-resize {
	position: absolute;
	z-index: 1;
	touch-action: none;
}

.window-resize.n,
.window-resize.s {
	left: 8px;
	right: 8px;
	height: 6px;
	cursor: ns-resize;
}

.window-resize.e,
.window-resize.w {
	top: 8px;
	bottom: 8px;
	width: 6px;
	cursor: ew-resize;
}

.window-resize.n { top: -3px; }
.window-resize.s { bottom: -3px; }
.window-resize.e { right: -3px; }
.window-resize.w { left: -3px; }

.window-resize.ne,
.window-resize.nw,
.window-resize.se,
.window-resize.sw {
	width: 12px;
	height: 12px;
}

.window-resize.ne { top: -4px; right: -4px; cursor: nesw-resize; }
.window-resize.sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.window-resize.nw { top: -4px; left: -4px; cursor: nwse-resize; }
.window-resize.se { bottom: -4px; right: -4px; cursor: nwse-resize; }

/* ---- taskbar */

.taskbar {
	position: relative;
	z-index: 100000;
	display: flex;
	align-items: center;
	gap: 0.4rem;
	flex: none;
	padding: 0 0.4rem;
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border-top: 1px solid var(--border);
}

.start-button {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	height: 2.2rem;
	min-height: 0;
	padding: 0 0.8rem;
	font-weight: 700;
}

.start-button.open,
.start-button.open:hover:not(:disabled) {
	background: var(--accent-hover);
	color: var(--accent-text);
}

.start-logo {
	display: block;
	height: 1.5rem;
	width: auto;
}

.start-menu {
	position: absolute;
	bottom: calc(100% + 0.4rem);
	left: 0.4rem;
	display: flex;
	flex-direction: column;
	min-width: 14rem;
	padding: 0.4rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-lg);
}

/* the user's name: opens the account */
.start-user {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 0.6rem;
	min-height: 0;
	padding: 0.45rem 0.6rem 0.6rem;
	margin-bottom: 0.3rem;
	font-weight: 700;
	text-align: left;
	background: transparent;
	border: none;
	border-bottom: 1px solid var(--border);
	border-radius: var(--radius-sm) var(--radius-sm) 0 0;
	box-shadow: none;
	color: var(--text);
}

.start-user:hover {
	background: var(--accent-soft);
	color: var(--accent-soft-text);
}

/* a category with its submenu to the right */
.start-category {
	position: relative;
	display: flex;
	flex-direction: column;
}

.start-item.category .grow {
	flex: 1;
}

.start-item.category .arrow {
	color: var(--muted);
}

.start-category.open > .start-item.category {
	background: var(--accent-soft);
	color: var(--accent-soft-text);
}

.start-submenu {
	position: absolute;
	left: calc(100% + 0.4rem);
	bottom: -0.4rem;
	display: flex;
	flex-direction: column;
	min-width: 13rem;
	padding: 0.4rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-lg);
}

/* the gap between the menu and the submenu does not close it while the pointer crosses it */
.start-submenu::before {
	content: "";
	position: absolute;
	left: -0.6rem;
	top: 0;
	bottom: 0;
	width: 0.6rem;
}

.start-separator {
	height: 1px;
	margin: 0.3rem 0;
	background: var(--border);
}

.start-item.restart {
	color: var(--danger);
}

.system-info {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.35rem 1rem;
}

.system-info dt {
	color: var(--muted);
}

.system-info dd {
	margin: 0;
	overflow-wrap: anywhere;
}

.system-settings {
	max-width: 28rem;
}

.system-settings .check {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin-bottom: 1rem;
}

.start-item {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 0.6rem;
	min-height: 0;
	padding: 0.5rem 0.6rem;
	font-weight: 500;
	text-align: left;
	text-decoration: none;
	background: transparent;
	border-color: transparent;
	color: var(--text);
	box-shadow: none;
}

.start-item:hover {
	background: var(--accent-soft);
	color: var(--accent-soft-text);
}

.start-item.logout {
	margin-top: 0.3rem;
	border-top: 1px solid var(--border);
	border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.tasks {
	display: flex;
	flex: 1;
	gap: 0.3rem;
	min-width: 0;
	overflow-x: auto;
}

.task {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	flex: 0 1 11rem;
	min-width: 3rem;
	height: 2.2rem;
	min-height: 0;
	padding: 0 0.6rem;
	font-weight: 500;
	background: transparent;
	border-color: var(--border);
	color: var(--text);
	box-shadow: none;
}

.task .label {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.task.active {
	background: var(--accent-soft);
	border-color: var(--accent);
	color: var(--accent-soft-text);
}

.task.minimized {
	opacity: 0.6;
}

.tray {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding-left: 0.4rem;
}

.tray .theme-toggle {
	width: 2rem;
	height: 2rem;
}

.clock {
	min-width: 2.8rem;
	font-size: 0.85rem;
	font-variant-numeric: tabular-nums;
	text-align: right;
}

@media (max-width: 640px) {
	.tray .app-version,
	.task .label {
		display: none;
	}
}

/* installed apps (crate::apps): iframe windows, drop on the desktop, /admin/apps, /account/links */
.window-body.app-frame {
  padding: 0;
  overflow: hidden;
}
.window-body.app-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--bg, transparent);
}
/* the iframe would swallow the pointer while a window is moved or resized */
.desktop.dragging iframe {
  pointer-events: none;
}
.desktop-area.drop-target {
  outline: 3px dashed var(--accent, #4c8bf5);
  outline-offset: -8px;
}
/* notifications (crate::notify): top centre, a bar under each counting down */
.notifications {
	position: absolute;
	top: 12px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 100001;
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: min(420px, calc(100% - 24px));
	pointer-events: none;
}

.notification {
	pointer-events: auto;
	position: relative;
	overflow: hidden;
	background: var(--surface);
	border: 1px solid var(--border);
	border-left: 4px solid var(--accent);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-lg);
	animation: notification-in 0.2s ease-out;
}

.notification.success { border-left-color: var(--success); }
.notification.warning { border-left-color: #e0a100; }
.notification.error { border-left-color: var(--danger); }
.notification.clickable { cursor: pointer; }

.notification-body {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	padding: 10px 8px 10px 12px;
}

.notification-icon {
	font-size: 1.4rem;
	line-height: 1.2;
}

.notification-text {
	flex: 1;
	min-width: 0;
}

.notification-source {
	font-size: 0.75rem;
	color: var(--muted);
}

.notification-title {
	font-weight: 600;
	overflow-wrap: anywhere;
}

.notification-message {
	font-size: 0.88rem;
	color: var(--muted);
	overflow-wrap: anywhere;
	white-space: pre-line;
}

.notification-close {
	min-height: 0;
	padding: 0 6px;
	background: transparent;
	border: none;
	box-shadow: none;
	color: var(--muted);
	font-size: 1.1rem;
	line-height: 1.2;
}

/* the micro bar: shrinks from full to empty over the notification's time */
.notification-bar {
	height: 3px;
	background: var(--accent);
	transform-origin: left;
	animation-name: notification-countdown;
	animation-timing-function: linear;
	animation-fill-mode: forwards;
}

.notification.success .notification-bar { background: var(--success); }
.notification.warning .notification-bar { background: #e0a100; }
.notification.error .notification-bar { background: var(--danger); }

/* the pointer over a card pauses its countdown */
.notification:hover .notification-bar {
	animation-play-state: paused;
}

@keyframes notification-countdown {
	from { transform: scaleX(1); }
	to { transform: scaleX(0); }
}

@keyframes notification-in {
	from { opacity: 0; transform: translateY(-8px); }
	to { opacity: 1; transform: none; }
}

.app-upload {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}
.apps-table td, .links-table td, .links-table th {
  vertical-align: top;
}
.apps-table .app-icon {
  font-size: 1.6em;
}
.apps-table .actions {
  white-space: nowrap;
}
.links-table td:not(:first-child), .links-table th:not(:first-child) {
  text-align: center;
}
/* a phone: every app a card (icon on the left, the rest under its name); the exchange table
   scrolls sideways */
@media (max-width: 760px) {
  .apps-table, .apps-table tbody {
    display: block;
  }
  .apps-table thead {
    display: none;
  }
  .apps-table tr {
    display: grid;
    grid-template-columns: 2.4rem minmax(0, 1fr);
    column-gap: 0.6rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
  }
  .apps-table td {
    grid-column: 2;
    display: block;
    padding: 0.1rem 0;
    border: none;
    overflow-wrap: anywhere;
  }
  .apps-table td.app-icon {
    grid-column: 1;
    grid-row: 1 / span 6;
  }
  .apps-table td:empty {
    display: none;
  }
  .apps-table td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.35rem;
    white-space: normal;
  }
  .links-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
}
.my-apps details.endpoints summary {
  cursor: pointer;
  color: var(--muted, #888);
  font-size: .9em;
}

/* ---- desktop background (crate::background) */

/* the labels stay readable on any picture or colour */
.desktop.custom-background .desktop-icon .label {
	color: #fff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.6);
}

.background-dialog h2 {
	margin-top: 0;
}

.bg-choices {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
	gap: 0.6rem;
	margin: 0.75rem 0;
}

.bg-choice {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.3rem;
	padding: 0.35rem;
	min-height: 0;
	background: transparent;
	border: 2px solid transparent;
	border-radius: var(--radius-sm);
	box-shadow: none;
	color: var(--text);
	cursor: pointer;
	font: inherit;
}

.bg-choice:hover {
	background: var(--accent-soft);
}

.bg-choice.selected {
	border-color: var(--accent);
}

.bg-swatch {
	position: relative;
	display: block;
	height: 4rem;
	border-radius: calc(var(--radius-sm) - 2px);
	border: 1px solid var(--border);
	overflow: hidden;
}

.bg-swatch.bg-default {
	background: var(--desktop-default-bg);
}

/* the colour input covers its swatch: a click opens the browser's colour picker */
.bg-color {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
	border: none;
	padding: 0;
}

.bg-label {
	font-size: 0.85rem;
	text-align: center;
}

.bg-picture {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
}

.bg-fit select {
	margin-left: 0.25rem;
}

.background-dialog .small {
	font-size: 0.8rem;
}

/* the bell next to the clock (crate::notify::NotificationBell) and the history it opens */
.notification-bell {
	position: relative;
	width: 2rem;
	height: 2rem;
	min-height: 0;
	padding: 0;
	background: transparent;
	border: none;
	box-shadow: none;
	font-size: 1.05rem;
	line-height: 1;
	opacity: 0.75;
}

.notification-bell.unread {
	opacity: 1;
}

.notification-badge {
	position: absolute;
	top: -2px;
	right: -4px;
	min-width: 1.05rem;
	height: 1.05rem;
	padding: 0 3px;
	border-radius: 999px;
	background: var(--danger);
	color: #fff;
	font-size: 0.66rem;
	font-weight: 700;
	line-height: 1.05rem;
	text-align: center;
}

.notification-center-backdrop {
	position: fixed;
	inset: 0;
	z-index: 100002;
}

.notification-center {
	position: fixed;
	right: 8px;
	bottom: 52px;
	z-index: 100003;
	display: flex;
	flex-direction: column;
	width: min(400px, calc(100vw - 16px));
	max-height: min(70vh, 560px);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-lg);
	animation: notification-in 0.15s ease-out;
}

.notification-center-head {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 10px;
	border-bottom: 1px solid var(--border);
}

.notification-center-head .grow {
	flex: 1;
}

.notification-center-head button {
	min-height: 0;
	padding: 3px 8px;
	font-size: 0.8rem;
}

.notification-center-list {
	overflow-y: auto;
	padding: 4px 0;
}

.notification-center-list > p {
	margin: 12px;
}

.notification-entry {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	padding: 8px 12px 8px 9px;
	border-left: 3px solid transparent;
	cursor: pointer;
	opacity: 0.7;
}

.notification-entry:hover {
	background: var(--bg);
}

.notification-entry.unread {
	opacity: 1;
	border-left-color: var(--accent);
}

.notification-entry.unread.success { border-left-color: var(--success); }
.notification-entry.unread.warning { border-left-color: #e0a100; }
.notification-entry.unread.error { border-left-color: var(--danger); }

/* ---- phone view of the desktop (crate::desktop::Phone): no windows, one app on the whole screen */

/* until the browser takes over, the desktop rendered on the server is not shown on a phone
   (data-view from ui::VIEW_SCRIPT) */
html[data-view="mobile"] .desktop:not(.phone) {
	visibility: hidden;
}

.desktop.phone {
	touch-action: auto;
	height: 100dvh;
}

/* no backdrop-filter: it would make the bar the containing block of the fixed popups inside
   it (the notification history of the bell) and cut them off */
.phone-bar {
	position: relative;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 0.35rem;
	min-height: 3.25rem;
	padding: 0.35rem 0.5rem;
	padding-top: calc(0.35rem + env(safe-area-inset-top, 0px));
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.phone-bar .menu-toggle {
	display: flex;
	margin-left: 0;
}

.phone-bar .phone-home,
.phone-bar .phone-close {
	min-height: 2.6rem;
	width: 2.6rem;
	padding: 0;
	background: transparent;
	border-color: transparent;
	box-shadow: none;
	color: var(--text);
	font-size: 1.2rem;
}

.phone-bar .phone-home {
	font-size: 1.9rem;
	line-height: 1;
}

.phone-title,
.phone-brand {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 0.45rem;
	font-weight: 600;
}

.phone-brand {
	padding-left: 0.4rem;
}

.phone-logo {
	display: block;
	height: 1.9rem;
	width: auto;
}

.phone-title .label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.phone-menu-backdrop {
	position: fixed;
	inset: 0;
	z-index: 18;
	background: color-mix(in srgb, #000 30%, transparent);
}

.phone-menu {
	position: absolute;
	z-index: 19;
	top: calc(3.25rem + env(safe-area-inset-top, 0px));
	right: 0;
	left: 0;
	max-height: calc(100dvh - 3.25rem - env(safe-area-inset-top, 0px));
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	padding: 0.4rem 0.5rem 0.75rem;
	padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	box-shadow: var(--shadow-lg);
}

.phone-menu-head {
	padding: 0.7rem 0.75rem 0.25rem;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--muted);
}

.phone-item {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 0.7rem;
	min-height: 2.9rem;
	padding: 0.55rem 0.75rem;
	text-align: left;
	text-decoration: none;
	font-weight: 500;
	color: var(--text);
	background: transparent;
	border: none;
	border-radius: var(--radius-sm);
	box-shadow: none;
}

.phone-item:hover,
.phone-task.active .phone-item {
	color: var(--accent-soft-text);
	background: var(--accent-soft);
}

.phone-item .icon {
	width: 1.6rem;
	text-align: center;
	font-size: 1.25rem;
}

.phone-task {
	display: flex;
	align-items: center;
}

.phone-task .phone-item {
	flex: 1;
	min-width: 0;
}

.phone-task .label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.phone-task-close {
	min-height: 2.6rem;
	width: 2.6rem;
	padding: 0;
	background: transparent;
	border-color: transparent;
	box-shadow: none;
	color: var(--muted);
}

.phone-menu-foot {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.5rem;
	padding-top: 0.5rem;
	border-top: 1px solid var(--border);
}

.phone-menu-foot .logout {
	flex: 1;
}

.phone-menu .app-version {
	display: inline;
	padding: 0;
}

.phone-area {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.phone-home-screen {
	flex: 1;
	overflow-y: auto;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr));
	align-content: start;
	gap: 0.5rem;
	padding: 1rem 0.75rem;
	padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.phone-icon {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.35rem;
	min-height: 0;
	padding: 0.6rem 0.25rem;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	box-shadow: none;
	color: var(--text);
}

.phone-icon:active {
	background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.phone-icon .icon {
	display: grid;
	place-items: center;
	width: 3.4rem;
	height: 3.4rem;
	font-size: 2rem;
	line-height: 1;
	background: color-mix(in srgb, var(--surface) 70%, transparent);
	border: 1px solid var(--border);
	border-radius: 1rem;
	box-shadow: var(--shadow);
}

.phone-icon .label {
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 0.8rem;
	text-shadow: 0 1px 2px var(--bg);
}

.phone-app {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	background: var(--bg);
}

.phone-app.hidden {
	display: none;
}

.phone-app .window-body {
	-webkit-overflow-scrolling: touch;
}

.phone-app main.in-window {
	padding: 0.85rem 0.85rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
}

/* the bell's history: under the bar, not above the taskbar */
.desktop.phone .notification-center {
	top: calc(3.4rem + env(safe-area-inset-top, 0px));
	bottom: auto;
	right: 6px;
	max-height: calc(100dvh - 4.5rem - env(safe-area-inset-top, 0px));
}

.phone-bar .notification-bell {
	width: 2.6rem;
	height: 2.6rem;
	font-size: 1.25rem;
}

/* the notifications under the bar */
.desktop.phone .notifications {
	top: calc(3.6rem + env(safe-area-inset-top, 0px));
	max-width: calc(100vw - 1rem);
}
