:root {
	color-scheme: light dark;
	--bg: #f4f5f7;
	--surface: #ffffff;
	--surface-2: #e9ecf0;
	--text: #14171c;
	--muted: #5d6673;
	--border: #dde1e6;
	--accent: #2f6fed;
	--accent-text: #ffffff;
	--mine: #2f6fed;
	--mine-text: #ffffff;
	--ok: #1f9d55;
	--warn: #d68a00;
	--bad: #d64545;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f1217;
		--surface: #181c23;
		--surface-2: #252a34;
		--text: #e8ebf0;
		--muted: #98a2b3;
		--border: #2b313c;
		--accent: #5b8cff;
		--accent-text: #0b1020;
		--mine: #3563d6;
		--mine-text: #ffffff;
		--ok: #3ecf7a;
		--warn: #f0b429;
		--bad: #ff6b6b;
	}
}

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

[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	height: 100%;
}

body {
	background: var(--bg);
	color: var(--text);
	font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-tap-highlight-color: transparent;
}

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

h1 {
	margin: 0;
	font-size: 1.25rem;
}

.hint {
	margin: 0;
	color: var(--muted);
	font-size: 0.9rem;
}

/* --- layout --- */

/* Flex, not grid: hidden bars (banner, notice, tabs) must not shift main into an auto-sized row. */
.app {
	height: 100vh;
	height: 100dvh;
	display: flex;
	flex-direction: column;
}

.app > :not(main) {
	flex: none;
}

main {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.view {
	flex: 1;
	min-height: 0;
}

h2 {
	margin: 0;
	font-size: 1rem;
}

.topbar {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: calc(0.4rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.4rem max(1rem, env(safe-area-inset-left));
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.brand {
	font-weight: 700;
}

.status {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 0.45rem;
	color: var(--muted);
	font-size: 0.875rem;
	white-space: nowrap;
}

#status-text {
	overflow: hidden;
	text-overflow: ellipsis;
}

.dot {
	flex: none;
	width: 0.6rem;
	height: 0.6rem;
	border-radius: 50%;
	background: var(--muted);
}

.status[data-state="starting"] .dot,
.status[data-state="connecting"] .dot,
.status[data-state="reconnecting"] .dot,
.status[data-state="pending"] .dot {
	background: var(--warn);
	animation: pulse 1.2s ease-in-out infinite;
}

.status[data-state="waiting"] .dot {
	background: var(--warn);
}

.status[data-state="connected"] .dot {
	background: var(--ok);
}

.status[data-state="connected"] #status-text {
	color: var(--text);
}

.status[data-state="failed"] .dot {
	background: var(--bad);
}

.rtt,
.route {
	flex: none;
	padding: 0.05rem 0.45rem;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--text);
	font-size: 0.75rem;
	font-variant-numeric: tabular-nums;
}

.route[data-relayed="true"] {
	background: color-mix(in srgb, var(--accent) 20%, var(--surface-2));
}

/* On the narrowest phones the device name matters more. */
@media (max-width: 22rem) {
	.route {
		display: none;
	}
}

.banner {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem max(1rem, env(safe-area-inset-left));
	background: color-mix(in srgb, var(--warn) 16%, var(--surface));
	border-bottom: 1px solid var(--border);
	font-size: 0.875rem;
}

.banner[data-kind="bad"] {
	background: color-mix(in srgb, var(--bad) 16%, var(--surface));
}

.banner[data-kind="info"] {
	background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.banner span {
	flex: 1;
}

.notice {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.35rem max(0.5rem, env(safe-area-inset-right)) 0.35rem max(1rem, env(safe-area-inset-left));
	background: color-mix(in srgb, var(--accent) 12%, var(--surface));
	border-bottom: 1px solid var(--border);
	font-size: 0.875rem;
}

.notice span {
	flex: 1;
	min-width: 0;
	overflow-wrap: anywhere;
}

.topbar .icon-btn {
	width: 40px;
	height: 40px;
	margin-right: -0.5rem;
}

.topbar .icon-btn[aria-pressed="true"] {
	color: var(--accent);
}

/* --- controls --- */

.btn {
	min-height: 44px;
	padding: 0 1rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
}

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

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

.btn.small {
	min-height: 36px;
	padding: 0 0.7rem;
	font-size: 0.875rem;
}

.topbar .btn.small {
	flex: none;
	margin-right: -0.5rem;
}

.icon-btn {
	flex: none;
	width: 44px;
	height: 44px;
	display: inline-grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--muted);
	cursor: pointer;
}

.icon-btn.primary {
	background: var(--accent);
	color: var(--accent-text);
}

.icon-btn.small {
	width: 32px;
	height: 32px;
}

.btn:disabled,
.icon-btn:disabled {
	opacity: 0.45;
	cursor: default;
}

.icon {
	display: inline-block;
	width: 1.25rem;
	height: 1.25rem;
	flex: none;
}

.icon svg {
	display: block;
	width: 100%;
	height: 100%;
}

.icon-btn.small .icon,
.btn.small .icon {
	width: 1rem;
	height: 1rem;
}

.actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
}

.actions.start {
	justify-content: flex-start;
}

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

.actions .push {
	margin-right: auto;
}

.link-btn {
	padding: 0.4rem 0.2rem;
	border: 0;
	background: none;
	color: var(--accent);
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.spinner {
	width: 2.5rem;
	height: 2.5rem;
	border: 3px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.9s linear infinite;
}

/* --- start & message views --- */

.start-view,
.message {
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
	padding: 1.5rem max(1rem, env(safe-area-inset-left)) calc(1.5rem + env(safe-area-inset-bottom));
	text-align: center;
}

.message {
	justify-content: center;
}

.start-view > *,
.message > * {
	width: 100%;
	max-width: 26rem;
}

.message > .spinner {
	width: 2.5rem;
}

.start-inner {
	display: flex;
	flex-direction: column;
	gap: 1.75rem;
	text-align: left;
}

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

.start-section h1 {
	margin: 0;
}

.start-notice {
	margin: 0;
	padding: 0.6rem 0.8rem;
	border-radius: 10px;
	background: color-mix(in srgb, var(--warn) 15%, var(--surface));
	font-size: 0.875rem;
}

.btn.large {
	min-height: 52px;
	font-size: 1.05rem;
}

.segmented {
	display: flex;
	padding: 3px;
	border-radius: 12px;
	background: var(--surface-2);
}

.segment {
	flex: 1;
	min-height: 40px;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.segment[aria-selected="true"],
.segment[aria-pressed="true"] {
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 1px 3px rgb(0 0 0 / 0.15);
}

.room-code {
	margin: 0;
	font: 700 clamp(1.25rem, 6.5vw, 1.75rem) / 1.25 ui-monospace, SFMono-Regular, Menlo, monospace;
	text-align: center;
	letter-spacing: 0.02em;
	overflow-wrap: anywhere;
}

.join-form {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.join-row {
	display: flex;
	gap: 0.5rem;
}

.input.room-input {
	flex: 1;
	min-width: 0;
	font: 600 1.25rem ui-monospace, SFMono-Regular, Menlo, monospace;
}

.recent {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-top: 0.5rem;
}

.recent-list {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.recent-item {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	padding-right: 0.4rem;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
}

.recent-main {
	flex: 1;
	min-width: 0;
	min-height: 56px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: center;
	gap: 0.1rem;
	padding: 0.5rem 0.75rem;
	border: 0;
	border-radius: 12px;
	background: none;
	color: var(--text);
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.recent-name {
	font-weight: 600;
	overflow-wrap: anywhere;
}

.recent-meta {
	color: var(--muted);
	font-size: 0.8rem;
	overflow-wrap: anywhere;
}

.invite .qr {
	align-self: center;
	width: min(72vw, 18rem);
	aspect-ratio: 1;
	padding: 12px;
	border-radius: 14px;
	background: #ffffff;
	box-shadow: 0 1px 4px rgb(0 0 0 / 0.15);
}

.qr img,
.qr canvas {
	width: 100%;
	height: auto;
}

.link {
	padding: 0.6rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--text);
	font: 0.8rem ui-monospace, SFMono-Regular, Menlo, monospace;
	text-overflow: ellipsis;
}

.server-line {
	margin: 0;
	color: var(--muted);
	font-size: 0.85rem;
	overflow-wrap: anywhere;
}

.server-line strong {
	color: var(--text);
	font-weight: 600;
}

.legacy {
	color: var(--muted);
	font-size: 0.85rem;
}

.legacy summary {
	cursor: pointer;
}

/* --- room bar --- */

.room-bar {
	flex: none;
	display: flex;
	flex-wrap: wrap; /* the voice row goes under the members */
	align-items: center;
	gap: 0.5rem;
	min-height: 48px;
	padding: 0.35rem max(1rem, env(safe-area-inset-right)) 0.35rem max(1rem, env(safe-area-inset-left));
	border-bottom: 1px solid var(--border);
	background: var(--surface);
}

.members {
	min-width: 0;
	display: flex;
	gap: 0.3rem;
	overflow-x: auto;
	scrollbar-width: none;
}

.member-chip {
	flex: none;
	padding: 0.2rem 0.6rem;
	font-size: 0.8rem;
}

.members-note {
	min-width: 0;
	color: var(--muted);
	font-size: 0.8rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.room-bar .push {
	margin-left: auto;
}

/* Voice: the row under the members, reachable from every tool. */
.voice-bar {
	flex-basis: 100%;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 36px;
}

.voice-note {
	min-width: 0;
	color: var(--muted);
	font-size: 0.8rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.voice-bar[data-mine="speaking"] .voice-note {
	color: var(--ok);
}

/* The others play here. It sits outside the tool panels, so switching tabs never stops the sound. */
.voice-audio {
	display: none;
}

.voice-list {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.voice-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.voice-name {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: color-mix(in srgb, var(--who, var(--accent)) 75%, var(--text));
	font-weight: 500;
}

.voice-percent {
	flex: none;
	min-width: 3ch;
	color: var(--muted);
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.voice-percent.boosted {
	color: var(--accent);
	font-weight: 600;
}

.voice-row input[type="range"] {
	flex: none;
	width: 40%;
	accent-color: var(--accent);
}

.member-pick {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.member-pick-item {
	width: 100%;
	min-height: 48px;
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0 0.9rem;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-weight: 500;
	text-align: left;
	cursor: pointer;
}

.member-pick-item::before {
	content: "";
	flex: none;
	width: 0.7rem;
	height: 0.7rem;
	border-radius: 50%;
	background: var(--who, var(--accent));
}

/* --- session & tools --- */

.session,
.tool-host,
.tool {
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.tool-host,
.tool {
	flex: 1;
}

.tabs {
	display: flex;
	padding-bottom: env(safe-area-inset-bottom);
	background: var(--surface);
	border-top: 1px solid var(--border);
}

.tabs button {
	flex: 1;
	min-height: 48px;
	border: 0;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: 0.875rem;
}

.tabs button[aria-current="true"] {
	color: var(--accent);
	font-weight: 600;
}

.tabs button.notify::after {
	content: "";
	display: inline-block;
	width: 0.5rem;
	height: 0.5rem;
	margin-left: 0.35rem;
	border-radius: 50%;
	background: var(--accent);
	vertical-align: middle;
}

/* Who is looking at a tool (app/presence.js): a stripe in their colours along the tab's edge next to the content. */
.tabs button,
.dock-tab {
	position: relative;
}

.tab-here {
	position: absolute;
	left: 18%;
	right: 18%;
	top: 0;
	height: 3px;
	display: flex;
	gap: 2px;
	pointer-events: none;
}

.tab-here[hidden] {
	display: none;
}

.tab-here i {
	flex: 1;
	border-radius: 0 0 2px 2px;
	background: var(--who);
}

.dock-tab .tab-here {
	top: auto;
	bottom: 0;
	left: 6px;
	right: 6px;
}

.dock-tab .tab-here i {
	border-radius: 2px 2px 0 0;
}

/* The tab bar already pads for the home indicator. */
.app:has(.tabs:not([hidden])) .composer {
	padding-bottom: 0.5rem;
}

/* --- desktop layout: dockview panels on a wide window with a mouse (app/ui/layout.js) --- */

.tool-host.docked {
	position: relative;
}

.dock {
	position: absolute;
	inset: 0;
}

.dock-panel {
	height: 100%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.dock-tab.notify .dv-default-tab-content::after {
	content: "";
	display: inline-block;
	width: 0.45rem;
	height: 0.45rem;
	margin-left: 0.35rem;
	border-radius: 50%;
	background: var(--accent);
	vertical-align: middle;
}

/* A tool's own panel (a stream) can be closed from its tab. */
.icon-btn.dock-tab-close {
	width: 22px;
	height: 22px;
	min-height: 0;
	margin-left: 0.25rem;
	padding: 0;
}


.dock-actions {
	height: 100%;
	display: flex;
	align-items: center;
	padding: 0 0.25rem;
}

.dock-actions .icon-btn {
	width: 28px;
	height: 28px;
	border-radius: 6px;
}

.dock-actions .icon-btn:hover {
	background: var(--surface-2);
	color: var(--text);
}

.dock-actions .icon {
	width: 16px;
	height: 16px;
}

/* dockview's variables, from the app's colours, so light and dark follow the system like the rest. */
.dockview-theme-peerkit {
	--dv-paneview-active-outline-color: var(--accent);
	--dv-tabs-and-actions-container-font-size: 0.875rem;
	--dv-tabs-and-actions-container-height: 36px;
	--dv-drag-over-background-color: color-mix(in srgb, var(--accent) 22%, transparent);
	--dv-drag-over-border-color: var(--accent);
	--dv-edge-dock-indicator-color: var(--accent);
	--dv-tabs-container-scrollbar-color: var(--muted);
	--dv-icon-hover-background-color: var(--surface-2);
	--dv-floating-box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
	--dv-floating-border: 1px solid var(--border);
	--dv-overlay-z-index: 999;
	--dv-tab-font-size: inherit;
	--dv-border-radius: 0px;
	--dv-tab-margin: 0;
	--dv-sash-color: transparent;
	--dv-active-sash-color: var(--accent);
	--dv-active-sash-transition-duration: 0.1s;
	--dv-active-sash-transition-delay: 0.3s;
	--dv-spacing-padding: 0px;
	--dv-tab-border-radius: 0px;
	--dv-sash-border-radius: 0px;
	--dv-dropdown-border-radius: 8px;
	--dv-tab-close-icon-size: inherit;
	--dv-floating-group-border: 1px solid var(--border);
	--dv-drag-over-border: none;
	--dv-floating-group-dragging-opacity: 0.6;
	--dv-floating-titlebar-height: 22px;
	--dv-floating-titlebar-background-color: var(--surface);
	--dv-floating-titlebar-border-bottom: 1px solid var(--border);
	--dv-group-view-background-color: var(--bg);
	--dv-tabs-and-actions-container-background-color: var(--surface);
	--dv-activegroup-visiblepanel-tab-background-color: var(--bg);
	--dv-activegroup-hiddenpanel-tab-background-color: var(--surface);
	--dv-inactivegroup-visiblepanel-tab-background-color: var(--bg);
	--dv-inactivegroup-hiddenpanel-tab-background-color: var(--surface);
	--dv-tab-divider-color: var(--border);
	--dv-activegroup-visiblepanel-tab-color: var(--text);
	--dv-activegroup-hiddenpanel-tab-color: var(--muted);
	--dv-inactivegroup-visiblepanel-tab-color: var(--muted);
	--dv-inactivegroup-hiddenpanel-tab-color: var(--muted);
	--dv-separator-border: var(--border);
	--dv-paneview-header-border-color: var(--border);
	--dv-scrollbar-background-color: color-mix(in srgb, var(--muted) 45%, transparent);
}

/* The tool in front in the focused group is marked like the bottom tabs mark theirs. */
.dockview-theme-peerkit .dv-groupview.dv-active-group .dv-tab.dv-active-tab {
	box-shadow: inset 0 -2px 0 var(--accent);
}

.dockview-theme-peerkit .dv-tabs-and-actions-container {
	border-bottom: 1px solid var(--border);
}

.btn.danger {
	color: var(--bad);
}

/* --- stream tool --- */

.stream {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.stage {
	position: relative;
	flex: 1;
	min-height: 0;
	display: grid;
	grid-template: minmax(0, 1fr) / minmax(0, 1fr);
	place-items: center;
	overflow: hidden;
}

.stream.has-remote .stage,
.stream.has-preview .stage {
	background: #000000;
	color: #ffffff;
}

/* [hidden] loses to the display of the grids otherwise. */
.stream-grid[hidden],
.previews[hidden] {
	display: none;
}

/* Out of the layout: a video's natural size would otherwise grow the stage under the bars. */
.stream-grid {
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
	grid-auto-rows: minmax(0, 1fr);
	gap: 2px;
}

/* One stream tapped: it takes the stage, the others make a strip under it. */
.stream-grid.focused {
	grid-template-columns: repeat(var(--others), minmax(0, 1fr));
	grid-template-rows: minmax(0, 1fr) minmax(0, 22%);
}

.stream-grid.focused .tile.focus {
	grid-column: 1 / -1;
	grid-row: 1;
}

.stream-grid.focused .tile:not(.focus) {
	grid-row: 2;
}

.tile {
	position: relative;
	min-width: 0;
	min-height: 0;
	display: grid;
	grid-template: minmax(0, 1fr) / minmax(0, 1fr);
	place-items: center;
	overflow: hidden;
	background: #000000;
	color: #ffffff;
}

/* A stream in a panel of its own (desktop). */
.tile.in-panel {
	flex: 1;
}

.tile > video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.tile-label {
	position: absolute;
	left: 0.5rem;
	bottom: 0.5rem;
	z-index: 1;
	max-width: calc(100% - 1rem);
	overflow: hidden;
	padding: 0.15rem 0.5rem;
	border-radius: 6px;
	background: rgb(0 0 0 / 0.5);
	font-size: 0.8125rem;
	white-space: nowrap;
	text-overflow: ellipsis;
	pointer-events: none;
}

.previews {
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
	grid-auto-rows: minmax(0, 1fr);
	gap: 2px;
}

.preview-box {
	position: relative;
	min-width: 0;
	min-height: 0;
}

.preview-box > video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* With streams from the others in the grid, your own previews go small into a corner. */
.stream.has-remote .previews {
	inset: auto 0.75rem 0.75rem auto;
	z-index: 1;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	width: min(30%, 11rem);
	pointer-events: none;
}

.stream.has-remote .preview-box {
	overflow: hidden;
	border-radius: 10px;
	box-shadow: 0 2px 10px rgb(0 0 0 / 0.5);
}

.stream.has-remote .preview-box > video {
	position: static;
	display: block;
	height: auto;
	max-height: 8rem;
	object-fit: cover;
}

/* Pointers and strokes over a stream, in the picture's own coordinates (stream-marks.js). */
.marks {
	position: absolute;
	inset: 0;
	z-index: 1;
	overflow: hidden;
	pointer-events: none;
}

.marks.marking {
	pointer-events: auto;
	touch-action: none;
	cursor: crosshair;
}

.marks[data-mode="point"] {
	cursor: default;
}

.marks-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.mark-pointer {
	position: absolute;
	display: flex;
	align-items: center;
	gap: 0.3rem;
	pointer-events: none;
	transition: left 60ms linear, top 60ms linear;
}

.mark-dot {
	width: 14px;
	height: 14px;
	margin: -7px 0 0 -7px;
	border: 2px solid #ffffff;
	border-radius: 50%;
	background: var(--mark, #868e96);
	box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4), 0 0 10px var(--mark, #868e96);
}

.mark-name {
	margin-top: -7px;
	padding: 0.05rem 0.4rem;
	border-radius: 6px;
	background: var(--mark, #868e96);
	color: #ffffff;
	font-size: 0.75rem;
	white-space: nowrap;
}

/* While a stream is pointed at or drawn on, its label steps aside. */
.tile.marking .tile-label {
	opacity: 0.4;
}

.preview.mirror {
	transform: scaleX(-1);
}

.stage-message {
	grid-area: 1 / 1;
	z-index: 1;
	max-width: 22rem;
	max-height: 100%;
	overflow: auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.6rem;
	padding: 1rem;
	text-align: center;
}

.stage-message p {
	margin: 0;
}

.stage-message > .icon {
	width: 2.5rem;
	height: 2.5rem;
	color: var(--muted);
}

.sound-btn {
	grid-area: 1 / 1;
	z-index: 2;
	box-shadow: 0 2px 12px rgb(0 0 0 / 0.4);
}

.stage-actions {
	position: absolute;
	top: max(0.5rem, env(safe-area-inset-top));
	right: max(0.5rem, env(safe-area-inset-right));
	z-index: 2;
	display: flex;
	gap: 0.25rem;
}

.stage-actions .icon-btn {
	background: rgb(0 0 0 / 0.45);
	color: #ffffff;
}

.stream-closed {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 0.5rem;
	padding: 0.3rem max(0.75rem, env(safe-area-inset-right)) 0.3rem max(0.75rem, env(safe-area-inset-left));
	border-bottom: 1px solid var(--border);
	font-size: 0.875rem;
}

.stream-resume {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.4rem max(0.5rem, env(safe-area-inset-right)) 0.4rem max(1rem, env(safe-area-inset-left));
	background: color-mix(in srgb, var(--accent) 12%, var(--surface));
	border-top: 1px solid var(--border);
	font-size: 0.875rem;
}

.stream-resume span {
	flex: 1;
	min-width: 0;
}

.stream-bar {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) 0.5rem max(0.75rem, env(safe-area-inset-left));
	background: var(--surface);
	border-top: 1px solid var(--border);
}

.stream-out,
.stream-start {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 0.5rem;
}

.stream-start {
	justify-content: center;
}

.stream-bar .icon-btn[aria-pressed="true"] {
	color: var(--bad);
}

.stream-warn {
	flex-basis: 100%;
	order: 1;
	color: var(--warn);
	font-size: 0.8125rem;
}

.live {
	flex: 1;
	min-width: 8rem;
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	font-size: 0.875rem;
	font-weight: 600;
}

.live::before {
	content: "";
	flex: none;
	width: 0.6rem;
	height: 0.6rem;
	border-radius: 50%;
	background: var(--bad);
	animation: pulse 1.6s ease-in-out infinite;
}

.live[data-paused]::before {
	background: var(--warn);
}

/* Capturing with nobody in the room yet: not live, just ready. */
.live[data-waiting]::before {
	background: var(--muted);
	animation: none;
}

.input.select {
	width: auto;
	min-height: 36px;
	padding: 0 0.5rem;
	font-size: 0.875rem;
}

@media (pointer: coarse) {
	.input.select {
		font-size: 16px;
	}
}

/* --- chat --- */

.chat {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 48rem;
	margin: 0 auto;
}

.feed {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	padding: 1rem max(0.75rem, env(safe-area-inset-left));
}

.chat.dragging .feed {
	outline: 2px dashed var(--accent);
	outline-offset: -8px;
}

.feed-empty {
	margin: auto;
	max-width: 20rem;
	text-align: center;
}

.feed-empty p {
	margin: 0.25rem 0;
}

.feed-empty .spinner {
	margin: 0 auto 0.5rem;
}

.feed-earlier {
	align-self: center;
}

.sys {
	align-self: center;
	padding: 0.2rem 0.75rem;
	color: var(--muted);
	font-size: 0.75rem;
}

.msg {
	display: flex;
}

.msg.mine {
	justify-content: flex-end;
}

.bubble {
	max-width: min(85%, 32rem);
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: var(--surface);
	overflow-wrap: anywhere;
}

.msg.mine .bubble {
	border-color: transparent;
	background: var(--mine);
	color: var(--mine-text);
}

.msg.mine .bubble a {
	color: inherit;
}

.msg .icon-btn {
	color: inherit;
}

.text {
	white-space: pre-wrap;
}

.sender {
	margin-bottom: 0.1rem;
	color: color-mix(in srgb, var(--who, var(--accent)) 75%, var(--text));
	font-size: 0.75rem;
	font-weight: 600;
}

/* The files about to be sent, listed in the send sheet. */
.share-list {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	max-height: 40vh;
	overflow: auto;
	margin: 0;
	padding: 0;
	list-style: none;
}

.share-list li {
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	min-width: 0;
}

.share-list .file-name {
	min-width: 0;
}

.share-list .file-size {
	flex: none;
}

.file-recipients {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.8rem;
}

.file-recipients li {
	display: flex;
	justify-content: space-between;
	gap: 0.5rem;
}

.file-recipient-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.file-recipient-status {
	flex: none;
	font-variant-numeric: tabular-nums;
	opacity: 0.85;
}

.meta {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.15rem;
	margin: 0.1rem -0.45rem -0.35rem 0;
	font-size: 0.7rem;
	opacity: 0.75;
}

.meta .read {
	margin-right: 0.4rem;
	font-weight: 600;
}

.meta .read:empty {
	display: none;
}

.bubble.file {
	width: min(85%, 22rem);
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.file-head {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

.file-head .icon {
	width: 2rem;
	height: 2rem;
	opacity: 0.8;
}

.file-title {
	min-width: 0;
}

.file-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
}

.file-size {
	font-size: 0.8rem;
	opacity: 0.75;
}

.file-preview img {
	display: block;
	width: 100%;
	max-height: 16rem;
	object-fit: contain;
	border-radius: 10px;
	background: var(--surface-2);
	cursor: zoom-in;
}

/* Removed from the room: the entry stays, the file is gone everywhere. */
.msg[data-state="removed"] .file-head {
	opacity: 0.55;
}

.msg[data-state="removed"] .file-name {
	text-decoration: line-through;
}

.file-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
}

.file-status {
	font-size: 0.8rem;
	font-variant-numeric: tabular-nums;
	opacity: 0.85;
}

.file-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-left: auto;
}

.msg.mine .file-actions .btn {
	border-color: rgb(255 255 255 / 0.35);
	background: rgb(255 255 255 / 0.15);
	color: inherit;
}

progress {
	width: 100%;
	height: 6px;
	border: 0;
	border-radius: 3px;
	overflow: hidden;
	appearance: none;
	background: var(--surface-2);
}

progress::-webkit-progress-bar {
	background: var(--surface-2);
}

progress::-webkit-progress-value {
	background: var(--accent);
}

progress::-moz-progress-bar {
	background: var(--accent);
}

.msg.mine progress,
.msg.mine progress::-webkit-progress-bar {
	background: rgb(255 255 255 / 0.25);
}

.msg.mine progress::-webkit-progress-value {
	background: #ffffff;
}

.msg.mine progress::-moz-progress-bar {
	background: #ffffff;
}

.composer {
	display: flex;
	align-items: flex-end;
	gap: 0.25rem;
	padding: 0.5rem max(0.5rem, env(safe-area-inset-right)) calc(0.5rem + env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
	background: var(--surface);
	border-top: 1px solid var(--border);
}

.composer textarea {
	flex: 1;
	min-width: 0;
	min-height: 44px;
	max-height: 160px;
	padding: 0.6rem 0.9rem;
	border: 1px solid var(--border);
	border-radius: 22px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
	font-size: 16px; /* below 16px mobile browsers zoom on focus */
	line-height: 1.4;
	resize: none;
}

/* --- file viewer: a received file full screen, opened from the chat --- */

.sheet.viewer-sheet {
	width: 100%;
	max-width: 100%;
	height: 100%;
	max-height: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
}

.viewer {
	height: 100%;
	display: flex;
	flex-direction: column;
}

.viewer-head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: calc(0.5rem + env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) 0.5rem max(0.75rem, env(safe-area-inset-left));
	border-bottom: 1px solid var(--border);
}

.viewer-title {
	flex: 1;
	min-width: 0;
}

.viewer-tools {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 0.4rem;
}

.viewer-body {
	--editor-font-size: 14px;
	flex: 1;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: auto;
	background: var(--bg);
}

.viewer-body > img,
.viewer-body > video {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.viewer-body > audio {
	width: min(100% - 2rem, 32rem);
}

.viewer-body > iframe {
	width: 100%;
	height: 100%;
	border: 0;
	background: #ffffff;
}

.viewer-body[data-kind="text"],
.viewer-body[data-kind="pdf"] {
	align-items: stretch;
	justify-content: flex-start;
}

.viewer-code {
	flex: 1;
	min-width: 0;
}

.viewer-note {
	margin: auto;
	max-width: 22rem;
	padding: 1rem;
	text-align: center;
}

.viewer-note > .icon {
	width: 2.5rem;
	height: 2.5rem;
	opacity: 0.6;
}

.viewer-note > .spinner {
	margin: 0 auto 0.5rem;
}

/* pdf.js pages, where the browser has no PDF viewer of its own (Android). */
.pdf-pages {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	padding: 0.75rem;
}

.pdf-page {
	width: min(100%, 60rem);
	background: #ffffff;
	box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
}

.pdf-page canvas {
	display: block;
	width: 100%;
	height: auto;
}

.pdf-count {
	position: sticky;
	bottom: 0.5rem;
	align-self: center;
	padding: 0.15rem 0.6rem;
	border-radius: 999px;
	background: var(--surface);
}

/* --- editor tool --- */

.editor {
	--editor-font-size: 15px;
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.editor-bar {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0.2rem max(0.25rem, env(safe-area-inset-right)) 0.2rem max(0.25rem, env(safe-area-inset-left));
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.editor-bar .push {
	margin-left: auto;
}

.doc-switch {
	flex: 0 1 auto;
	min-width: 0;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0 0.6rem;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: var(--text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.doc-switch:disabled {
	opacity: 0.45;
	cursor: default;
}

.doc-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.doc-switch .icon:last-child {
	width: 1rem;
	height: 1rem;
	color: var(--muted);
}

.presence {
	min-width: 0;
	display: flex;
	gap: 0.25rem;
	overflow: hidden;
}

.presence-chip,
.member-chip {
	min-width: 0;
	max-width: 10rem;
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.05rem 0.5rem;
	border-radius: 999px;
	background: color-mix(in srgb, var(--who, var(--accent)) 18%, var(--surface));
	color: var(--text);
	font-size: 0.75rem;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Voice marks: a ring while that member speaks, a crossed-out mic when muted. */
.member-chip[data-voice] .icon {
	width: 0.85rem;
	height: 0.85rem;
	opacity: 0.7;
}

.voice-name small {
	display: block;
	color: var(--muted);
	font-size: 0.75rem;
}

/* In voice, but nothing is coming through yet. */
.member-chip[data-voice="waiting"] .icon {
	opacity: 0.35;
}

.member-chip[data-voice="speaking"] {
	background: color-mix(in srgb, var(--who, var(--accent)) 34%, var(--surface));
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--who, var(--accent)) 55%, transparent);
}

.member-chip[data-voice="speaking"] .icon {
	opacity: 1;
}

.presence-chip::before,
.member-chip::before {
	content: "";
	flex: none;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--who, var(--accent));
}

.editor-body {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.editor-stage {
	flex: 1;
	min-height: 0;
	display: flex;
	position: relative;
}

.editor-stage[hidden] {
	display: none;
}

.editor-host {
	flex: 1;
	min-width: 0;
	min-height: 0;
	overflow: hidden; /* Monaco sizes itself to it */
	position: relative;
	z-index: 0; /* the editor's own layers stay under the stripes */
}

/* The others' lines in view: a stripe in their colour at the left edge, a short one at the top or bottom when they are elsewhere. */
.editor-sight {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 16px;
	z-index: 1;
	overflow: hidden;
	pointer-events: none;
}

.editor-sight[hidden],
.editor-rail[hidden] {
	display: none;
}

.editor-sight i {
	position: absolute;
	width: 3px;
	border-radius: 2px;
	background: var(--who);
	opacity: 0.85;
	transition: top 0.12s ease-out, height 0.12s ease-out;
}

.editor-sight i[data-side="above"],
.editor-sight i[data-side="below"] {
	width: 8px;
	opacity: 1;
}

/* The whole document, top to bottom: this device's view as an outline, the others' as marks to click. */
.editor-rail {
	flex: none;
	width: 10px;
	position: relative;
	background: var(--bg);
	border-left: 1px solid var(--border);
}

.editor-rail-mine {
	position: absolute;
	left: 0;
	right: 0;
	border: 1px solid var(--muted);
	border-radius: 2px;
	opacity: 0.6;
	pointer-events: none;
}

.editor-rail-mark {
	position: absolute;
	left: 2px;
	right: 2px;
	min-height: 4px;
	padding: 0;
	border: 0;
	border-radius: 2px;
	background: var(--who);
	opacity: 0.7;
	cursor: pointer;
}

.editor-rail-mark:hover,
.editor-rail-mark:focus-visible {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.editor-sight i {
		transition: none;
	}
}

/* Monaco: another member's cursor and name (monaco-binding.js writes each member's colour as a rule of its own). */
.editor-host .peerkit-yhead {
	margin-left: -1px;
	border-left: 2px solid;
}

.editor-host .peerkit-yname {
	padding: 0 0.3em;
	border-radius: 4px 4px 4px 0;
	color: #fff;
	font: 0.7rem/1.5 system-ui, sans-serif;
	white-space: nowrap;
	transition: opacity 0.2s ease-in-out;
}

/* Another member's name can cover a word. Pointing at it fades it out: transparent, it still has the pointer, so it
   doesn't come back under it. A tap on a name hides them all for a moment (.names-peek, editor.js). */
.editor-host .peerkit-yname:hover,
.editor-host.names-peek .peerkit-yname,
.editor-host.names-peek .cm-ySelectionInfo {
	opacity: 0 !important;
}

.editor-message {
	margin: auto;
	max-width: 22rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.6rem;
	padding: 1.5rem 1rem;
	text-align: center;
}

.editor-message p {
	margin: 0;
}

.editor-message > .icon {
	width: 2.5rem;
	height: 2.5rem;
	color: var(--muted);
}

/* Phones only, while typing: it sits right above the on-screen keyboard. */
.editor-keys {
	display: none;
	align-items: center;
	justify-content: space-around;
	gap: 0.25rem;
	padding: 0.1rem max(0.5rem, env(safe-area-inset-right)) 0.1rem max(0.5rem, env(safe-area-inset-left));
	background: var(--surface);
	border-top: 1px solid var(--border);
}

@media (pointer: coarse) {
	.editor[data-focused] .editor-keys {
		display: flex;
	}

	/* The keyboard needs the room more than the tab bar does. */
	.app:has(.editor[data-focused]) .tabs {
		display: none;
	}
}

.doc-list {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	max-height: 55vh;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	list-style: none;
}

.doc-item {
	width: 100%;
	min-height: 52px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.15rem;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.doc-item[aria-current="true"] {
	border-color: var(--accent);
	box-shadow: inset 0 0 0 1px var(--accent);
}

.doc-item-name {
	font-weight: 600;
	overflow-wrap: anywhere;
}

.doc-item-meta {
	max-width: 100%;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem;
	color: var(--muted);
	font-size: 0.8rem;
}

/* --- whiteboard tool --- */

.whiteboard {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

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

/* The minimap (minimap.js): the drawing as a sketch, this device's view and the others' in their colours. */
.wb-map {
	position: absolute;
	right: 0.75rem;
	bottom: 0.75rem;
	width: 160px;
	height: 110px;
	z-index: 2;
	border: 1px solid #ced4da;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.92); /* paper, like the board, in both colour schemes */
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
	overflow: hidden;
}

.wb-map[hidden] {
	display: none;
}

.wb-map.empty {
	visibility: hidden;
}

.wb-map canvas {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
	cursor: pointer;
}

@media (pointer: coarse) {
	.wb-map {
		width: 120px;
		height: 84px;
		right: 0.5rem;
		bottom: 0.5rem;
	}
}

/* Paper in both colour schemes: images and ink look the same on every device. */
.wb-stage {
	position: relative;
	flex: 1;
	min-height: 0;
	overflow: hidden;
	background: #ffffff;
	cursor: crosshair;
	/* Every touch is the board's: drawing, panning and pinching, never scrolling or zooming the page. */
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
	outline: none;
}

.wb-stage:focus-visible {
	box-shadow: inset 0 0 0 2px var(--accent);
}

.wb-stage[data-tool="select"] {
	cursor: default;
}

.wb-stage[data-tool="eraser"] {
	cursor: none;
}

.wb-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.wb-tools {
	display: flex;
	align-items: center;
	gap: 0.1rem;
	padding: 0.2rem max(0.25rem, env(safe-area-inset-right)) 0.2rem max(0.25rem, env(safe-area-inset-left));
	background: var(--surface);
	border-top: 1px solid var(--border);
	overflow-x: auto;
	scrollbar-width: none;
}

.wb-tools .icon-btn {
	width: 40px;
	height: 40px;
}

.wb-tools .icon-btn[aria-pressed="true"] {
	background: color-mix(in srgb, var(--accent) 16%, transparent);
	color: var(--accent);
}

.wb-tools .push {
	margin-left: auto;
}

.wb-sep {
	flex: none;
	width: 1px;
	height: 24px;
	margin: 0 0.25rem;
	background: var(--border);
}

/* The colour and size of the pen (a round dot) or the highlighter (a square one). */
.wb-swatch {
	width: 26px;
	height: 26px;
	display: grid;
	place-items: center;
	border: 2px solid var(--border);
	border-radius: 50%;
	background: #ffffff;
}

.wb-swatch::after {
	content: "";
	width: var(--dot, 8px);
	height: var(--dot, 8px);
	border-radius: 50%;
	background: var(--ink, #1e1e1e);
	box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15);
}

.wb-swatch[data-kind="highlighter"]::after {
	border-radius: 2px;
	opacity: 0.7;
}

.wb-popover {
	position: absolute;
	bottom: 0.5rem;
	left: 0.5rem;
	z-index: 2;
	width: max-content;
	max-width: calc(100% - 1rem);
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	padding: 0.75rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}

.wb-popover[data-menu="image"] {
	left: auto;
	right: 0.5rem;
}

.wb-popover .hint {
	max-width: 16rem;
	margin: 0;
}

.wb-swatches {
	display: grid;
	grid-template-columns: repeat(4, 36px);
	gap: 0.5rem;
}

.wb-color {
	width: 36px;
	height: 36px;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 50%;
	background: var(--ink);
	cursor: pointer;
}

.wb-color[aria-pressed="true"] {
	box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.wb-sizes {
	display: flex;
	gap: 0.5rem;
}

.wb-size {
	width: 48px;
	height: 36px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	cursor: pointer;
}

.wb-size span {
	width: var(--dot);
	height: var(--dot);
	border-radius: 50%;
	background: var(--text);
}

.wb-size[aria-pressed="true"] {
	border-color: var(--accent);
	box-shadow: inset 0 0 0 1px var(--accent);
}

/* --- settings --- */

.settings {
	overflow-y: auto;
	padding: 0 max(1rem, env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.settings-inner {
	max-width: 40rem;
	margin: 0 auto;
}

.settings-head {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin: 0.5rem 0 0 -0.6rem;
}

.settings-section {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1rem 0;
	border-bottom: 1px solid var(--border);
}

.version {
	margin: 0;
	color: var(--muted);
	font-size: 0.9rem;
	font-variant-numeric: tabular-nums;
}

.settings-section:last-child {
	border-bottom: 0;
}

.settings-section > .btn {
	align-self: flex-start;
}

.profiles {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.profile {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	padding: 0.75rem;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
}

.profile[data-active] {
	border-color: var(--accent);
	box-shadow: inset 0 0 0 1px var(--accent);
}

.profile-main {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	cursor: pointer;
}

.profile-main input {
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0.1rem 0 0;
	accent-color: var(--accent);
}

.profile-text {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
}

.profile-name {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem;
	font-weight: 600;
	overflow-wrap: anywhere;
}

.profile-addr {
	color: var(--muted);
	font: 0.8rem ui-monospace, SFMono-Regular, Menlo, monospace;
	overflow-wrap: anywhere;
}

.badge {
	padding: 0 0.45rem;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--muted);
	font-size: 0.7rem;
	font-weight: 500;
}

.profile-actions,
.profile .test-result {
	padding-left: 2rem;
}

/* The TURN card has no radio button to line up with. */
.profile.turn .profile-actions,
.profile.turn .test-result {
	padding-left: 0;
}

.profile-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.test-result {
	margin: 0;
	font-size: 0.85rem;
}

.test-result[data-kind="busy"] {
	color: var(--muted);
}

.test-result[data-kind="ok"] {
	color: var(--ok);
}

.test-result[data-kind="bad"] {
	color: var(--bad);
}

/* --- dialogs & forms --- */

.sheet {
	width: min(calc(100% - 2rem), 28rem);
	max-height: calc(100% - 2rem);
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 10px 40px rgb(0 0 0 / 0.3);
}

.sheet::backdrop {
	background: rgb(0 0 0 / 0.45);
}

.sheet-body {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1.25rem;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
	color: var(--muted);
	font-size: 0.85rem;
}

.field > span {
	font-weight: 500;
}

.field-row {
	display: grid;
	grid-template-columns: 7rem minmax(0, 1fr);
	gap: 0.75rem;
}

.input {
	width: 100%;
	min-height: 44px;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
	font-size: 16px; /* below 16px mobile browsers zoom on focus */
}

.input:focus {
	outline: 2px solid var(--accent);
	outline-offset: -1px;
}

textarea.input {
	resize: vertical;
}

.input.code {
	font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (pointer: coarse) {
	.input.code {
		font-size: 16px;
	}
}

.check {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	min-height: 44px;
	cursor: pointer;
}

.check input {
	width: 1.2rem;
	height: 1.2rem;
	margin: 0;
	accent-color: var(--accent);
}

.form-error,
.warn-text {
	margin: 0;
	font-size: 0.85rem;
}

.form-error {
	color: var(--bad);
}

.warn-text {
	color: var(--warn);
}

/* --- toasts --- */

.toasts {
	position: fixed;
	left: 50%;
	bottom: calc(5rem + env(safe-area-inset-bottom));
	z-index: 2000; /* above the floating panels of the desktop layout (about 1000) */
	width: max-content;
	max-width: calc(100vw - 2rem);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
	transform: translateX(-50%);
	pointer-events: none;
}

.toast {
	padding: 0.5rem 1rem;
	border-radius: 18px;
	background: var(--text);
	color: var(--bg);
	font-size: 0.875rem;
	text-align: center;
	animation: fade-in 0.15s ease-out;
}

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

@keyframes pulse {
	50% {
		opacity: 0.35;
	}
}

@keyframes fade-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
}

/* --- Controller (app/tools/controller/) --- */

.tool.controller {
	overflow-y: auto;
}

.controller-body {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	max-width: 56rem;
	margin: 0 auto;
	padding: 1rem;
}

.controller-setup {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.controller-setup h3 {
	margin: 0.5rem 0 0;
	color: var(--muted);
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.controller-hosts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.controller-hosts:empty {
	display: none;
}

.host-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 40px;
	padding: 0 0.9rem;
	border: 2px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	cursor: pointer;
}

.host-chip[aria-pressed="true"] {
	border-color: var(--accent);
	font-weight: 600;
}

.host-chip .dot,
.mon-card header .dot {
	width: 0.65rem;
	height: 0.65rem;
	border-radius: 50%;
	background: var(--member, var(--muted));
	flex: none;
}

.controller-setup > .btn.primary {
	margin-top: 0.5rem;
}

/* The pad while playing: full screen, dark, every touch its own. */
.pad-play {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: flex;
	flex-direction: column;
	background: #101318;
	color: #e8ebf0;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}

.pad-top {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: calc(0.5rem + env(safe-area-inset-top)) calc(0.75rem + env(safe-area-inset-right)) 0.5rem calc(0.75rem + env(safe-area-inset-left));
	font-size: 0.875rem;
}

.pad-host::before {
	content: "";
	display: inline-block;
	width: 0.6rem;
	height: 0.6rem;
	margin-right: 0.4rem;
	border-radius: 50%;
	background: var(--member);
}

.pad-latency {
	flex: 1;
	color: #98a2b3;
}

.pad-top-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	min-width: 40px;
	min-height: 40px;
	padding: 0 0.6rem;
	border: 1px solid #2b313c;
	border-radius: 10px;
	background: #181c23;
	color: inherit;
	font: inherit;
}

.pad-surface {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem calc(1.5rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1.5rem + env(safe-area-inset-left));
}

.pad-left,
.pad-right,
.pad-middle {
	display: flex;
	align-items: center;
	justify-content: center;
}

.pad-middle {
	gap: 1rem;
	align-self: flex-end;
	margin-bottom: 8vmin;
}

.pad-right {
	gap: 5vmin;
	transform: rotate(-20deg);
}

.pad-dpad {
	position: relative;
	width: min(52vmin, 16rem);
	aspect-ratio: 1;
	border-radius: 50%;
	background: #181c23;
}

.pad-arrow {
	position: absolute;
	width: 33%;
	height: 33%;
	border-radius: 8px;
	background: #2b313c;
}

.pad-arrow.up { left: 33.5%; top: 4%; }
.pad-arrow.down { left: 33.5%; bottom: 4%; }
.pad-arrow.left { top: 33.5%; left: 4%; }
.pad-arrow.right { top: 33.5%; right: 4%; }

.pad-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #2b313c;
	font-weight: 700;
}

.pad-btn.round {
	width: min(24vmin, 7.5rem);
	aspect-ratio: 1;
	border-radius: 50%;
	background: #b02a37;
	font-size: 1.4rem;
}

.pad-btn.small {
	min-width: 5rem;
	min-height: 2.25rem;
	padding: 0 0.75rem;
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 600;
}

.pad-arrow.on,
.pad-btn.on {
	background: #5b8cff;
}

.pad-btn.round.on {
	background: #ff6b6b;
	transform: scale(0.94);
}

.pad-motion {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
}

.pad-btn.trigger {
	width: min(100%, 36rem);
	height: min(55vh, 20rem);
	border-radius: 28px;
	font-size: 1.5rem;
}

.pad-motion-status {
	margin: 0;
	color: #98a2b3;
	font-size: 0.875rem;
	text-align: center;
}

/* The Monitor */

.monitor-empty {
	text-align: center;
}

.monitor-pads {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
	gap: 1rem;
}

.mon-card {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 0.9rem;
	border: 1px solid var(--border);
	border-top: 4px solid var(--member, var(--border));
	border-radius: 12px;
	background: var(--surface);
}

.mon-card.quiet {
	opacity: 0.6;
}

.mon-card header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.mon-kind,
.mon-stats {
	color: var(--muted);
	font-size: 0.8rem;
}

.mon-stats {
	margin-left: auto;
	font-variant-numeric: tabular-nums;
}

.mon-buttons {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 0.35rem;
}

.mon-btn {
	padding: 0.3rem 0;
	border-radius: 6px;
	background: var(--surface-2);
	color: var(--muted);
	font-size: 0.7rem;
	text-align: center;
}

.mon-btn.on {
	background: var(--accent);
	color: var(--accent-text);
	font-weight: 600;
}

.mon-axes {
	display: flex;
	gap: 1rem;
}

.mon-stick {
	position: relative;
	width: 4rem;
	aspect-ratio: 1;
	border-radius: 50%;
	background: var(--surface-2);
}

.mon-dot {
	position: absolute;
	left: 37.5%;
	top: 37.5%;
	width: 25%;
	height: 25%;
	border-radius: 50%;
	background: var(--accent);
}

.mon-motion {
	display: flex;
	justify-content: center;
	padding: 0.5rem 0;
}

.mon-cube-stage {
	width: 8rem;
	height: 8rem;
	display: flex;
	align-items: center;
	justify-content: center;
	perspective: 500px;
}

/* A phone held flat: 3 × 6 rem, 0.6 rem thick, the screen towards the viewer. */
.mon-cube {
	position: relative;
	width: 3rem;
	height: 6rem;
	transform-style: preserve-3d;
}

.mon-cube .face {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--border);
	background: color-mix(in srgb, var(--member, var(--accent)) 35%, var(--surface));
	font-size: 0.6rem;
	color: var(--text);
	backface-visibility: hidden;
}

.mon-cube .front,
.mon-cube .back { inset: 0; }
.mon-cube .front { transform: translateZ(0.3rem); background: color-mix(in srgb, var(--member, var(--accent)) 70%, var(--surface)); }
.mon-cube .back { transform: rotateY(180deg) translateZ(0.3rem); }
.mon-cube .right,
.mon-cube .left { top: 0; left: 1.2rem; width: 0.6rem; height: 6rem; }
.mon-cube .right { transform: rotateY(90deg) translateZ(1.5rem); }
.mon-cube .left { transform: rotateY(-90deg) translateZ(1.5rem); }
.mon-cube .top,
.mon-cube .bottom { left: 0; top: 2.7rem; width: 3rem; height: 0.6rem; }
.mon-cube .top { transform: rotateX(90deg) translateZ(3rem); }
.mon-cube .bottom { transform: rotateX(-90deg) translateZ(3rem); }

/* Remote play (a game's guests in the Games tool): the game's picture fills the pad, the buttons float over it. */
.pad-play.over-picture {
	background: #000;
}

.pad-picture {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.pad-picture video {
	width: 100%;
	height: 100%;
	object-fit: contain;
	image-rendering: pixelated;
}

.pad-play.over-picture .pad-top,
.pad-play.over-picture .pad-surface {
	position: relative;
}

.pad-play.over-picture .pad-top {
	background: linear-gradient(rgb(0 0 0 / 0.6), transparent);
}

.pad-play.over-picture .pad-surface {
	align-items: flex-end;
}

.pad-play.over-picture .pad-dpad,
.pad-play.over-picture .pad-btn {
	opacity: 0.55;
}

.pad-play.over-picture .pad-arrow.on,
.pad-play.over-picture .pad-btn.on {
	opacity: 0.9;
}

/* --- Games (app/tools/games/), and the NES and Swing test in it (app/games/) --- */

.tool.games {
	overflow-y: auto;
}

.games-body {
	width: 100%;
	max-width: 64rem;
	margin: 0 auto;
	padding: 1rem;
}

.games-lobby,
.games-stage,
.games-section {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.games-lobby {
	gap: 1.5rem;
}

.games-lobby[hidden],
.games-stage[hidden],
.games-section[hidden] {
	display: none;
}

.games-section h3 {
	margin: 0;
	color: var(--muted);
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.games-section .hint,
.games-game .hint,
.nes-rom .hint {
	margin: 0;
}

.games-section > .btn {
	align-self: flex-start;
}

.games-list,
.nes-recent,
.nes-saves {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.games-game,
.nes-rom,
.nes-save {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5rem 0.75rem;
	padding: 0.6rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
}

.games-game {
	border-left: 4px solid var(--member, var(--border));
}

.games-game > .dot {
	display: none;
}

.games-players {
	flex-basis: 100%;
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
}

.games-player {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	max-width: 100%;
	padding: 0.15rem 0.55rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	overflow-wrap: anywhere;
}

.games-player .dot {
	background: var(--member, transparent);
	box-shadow: inset 0 0 0 1px var(--muted);
}

.games-player.free {
	color: var(--muted);
	border-style: dashed;
}

.games-player.away {
	border-color: var(--warn);
}

.games-player.mine {
	font-weight: 600;
	border-color: var(--member);
}

.games-text {
	flex: 1;
	min-width: 10rem;
	display: flex;
	flex-direction: column;
	overflow-wrap: anywhere;
}

.nes-save > span:first-child {
	font-weight: 600;
}

.nes-save > .hint {
	flex: 1;
}

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

.games-title {
	flex: 1 1 100%;
	overflow-wrap: anywhere;
}

@media (min-width: 640px) {
	.games-title {
		flex: 1;
	}
}

/* The game's picture (or board): as large as fits. */
.games-screen-wrap {
	position: relative;
	width: 100%;
	margin: 0 auto;
	border-radius: 8px;
	overflow: hidden;
}

/* The NES: 256 × 224, square pixels. */
.nes-screen-wrap {
	max-height: 75vh;
	aspect-ratio: 256 / 224;
	background: #000;
}

.games-screen-wrap:fullscreen {
	max-height: none;
	overflow: auto;
	border-radius: 0;
}

.nes-screen,
.nes-frame {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

.nes-frame {
	pointer-events: none; /* keys stay with this page, never the emulator's */
}

.games-notice {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	border: 0;
	background: rgb(0 0 0 / 0.55);
	color: #fff;
	font: inherit;
	font-weight: 600;
	text-align: center;
	cursor: pointer;
}

.games-notice[hidden] {
	display: none;
}

.games-panels {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
	gap: 1.5rem;
}

.games-seat {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.games-seat > span:not(.dot) {
	min-width: 5rem;
	font-weight: 600;
}

.games-seat > .dot {
	background: var(--member);
}

.games-seat.empty > .dot {
	box-shadow: inset 0 0 0 1px var(--muted);
}

.games-seat select {
	flex: 1;
	min-width: 0;
	min-height: 40px;
	font-size: 16px;
}

.games-seat.away select {
	border-color: var(--warn);
}

.nes-keys {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin: 0.75rem 0;
}

.nes-keys .btn {
	min-width: 8rem;
}

/* The NES host's own touch pad: in its picture, which fills the screen while the pad is on. */
.pad-play.inline {
	position: absolute;
	inset: 0;
	z-index: 2;
	background: transparent;
}

.games-screen-wrap.pad-on {
	position: fixed;
	inset: 0;
	z-index: 60;
	width: auto;
	max-height: none;
	aspect-ratio: auto;
	border-radius: 0;
}

.games-tools {
	display: contents;
}

.games-heading {
	margin: 0;
	font-size: 1.1rem;
}

.games-sub {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.5rem;
}

.games-sub[hidden] {
	display: none;
}

.games-sub h4 {
	margin: 0.5rem 0 0;
	color: var(--muted);
	font-size: 0.8rem;
	font-weight: 600;
}

.games-sub > .nes-recent {
	align-self: stretch;
}

.games-module > .btn {
	align-self: flex-start;
}

.games-seats {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.games-toolbar .btn[hidden] {
	display: none;
}

/* A guest's choice of player, over its pad */
.pad-seats {
	position: absolute;
	top: calc(3.5rem + env(safe-area-inset-top));
	right: calc(0.75rem + env(safe-area-inset-right));
	z-index: 2;
	display: grid;
	grid-template-columns: repeat(2, minmax(8rem, 12rem));
	gap: 0.5rem;
	padding: 0.5rem;
	border: 1px solid #2b313c;
	border-radius: 12px;
	background: #181c23;
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
}

.pad-seats .games-player {
	min-height: 44px;
	justify-content: flex-start;
	border-radius: 10px;
	border-color: #2b313c;
	background: #101318;
	color: inherit;
	font: inherit;
	font-size: 0.875rem;
}

.pad-seats .games-player .hint {
	margin-left: auto;
	color: #98a2b3;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pad-seats .games-player.free {
	border-color: #98a2b3;
}

.pad-seats .games-player:disabled {
	opacity: 0.75;
}

.pad-seats .games-player.mine {
	border-color: var(--member);
	opacity: 1;
}

/* Swing test: a card per player with the speed meter */
.swing-board {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	gap: 0.75rem;
	padding: 0.25rem 0;
}

.games-screen-wrap.swing-wrap:fullscreen {
	padding: 1rem;
	background: var(--bg);
}

.swing-card {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	padding: 0.75rem 0.9rem;
	border: 1px solid var(--border);
	border-left: 4px solid var(--member, var(--border));
	border-radius: 12px;
	background: var(--surface);
}

.swing-card.empty {
	border-style: dashed;
	border-left-width: 1px;
	color: var(--muted);
}

.swing-card.away {
	border-color: var(--warn);
}

.swing-head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-width: 0;
}

.swing-head .dot {
	background: var(--member, transparent);
	box-shadow: inset 0 0 0 1px var(--muted);
}

.swing-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.swing-meter {
	position: relative;
	height: 14px;
	border-radius: 7px;
	background: var(--border);
	overflow: hidden;
}

.swing-fill {
	height: 100%;
	width: 0;
	background: var(--member, var(--accent));
	transition: width 80ms linear;
}

.swing-peak {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 3px;
	margin-left: -1px;
	background: var(--text);
}

.swing-peak[hidden] {
	display: none;
}

.swing-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem;
}

.swing-last {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 600;
}

.swing-speed {
	color: var(--muted);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.swing-best {
	margin: 0;
}

.swing-card.hit {
	animation: swing-hit 600ms ease-out;
}

@keyframes swing-hit {
	from {
		box-shadow: 0 0 0 4px var(--member, var(--accent));
	}

	to {
		box-shadow: 0 0 0 0 transparent;
	}
}

@media (prefers-reduced-motion: reduce) {
	.swing-card.hit {
		animation: none;
	}

	.swing-fill {
		transition: none;
	}
}
