/* Hey Y'all Watch This: one dark theme, no build step. */

:root {
	color-scheme: dark;
	--bg: #0e1014;
	--surface: #161920;
	--raised: #1e222b;
	--hover: #272c37;
	--border: #2b303c;
	--text: #e9ebf0;
	--muted: #99a2b3;
	--accent: #ffb020;
	--accent-strong: #ffc247;
	--accent-ink: #1c1400;
	--on: #3ddc84;
	--danger: #ff6b6b;
	--danger-bg: #3a1c20;
	--relay: #c62828;
	--radius: 10px;
	--gap: 8px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
	height: 100%;
	margin: 0;
}

body {
	background: var(--bg);
	color: var(--text);
	font: 15px/1.45 var(--font);
	-webkit-font-smoothing: antialiased;
	overflow: hidden;
}

h1, h2, p { margin: 0; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
	width: 18px;
	height: 18px;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.icon.big { width: 56px; height: 56px; stroke-width: 1.2; }
.spacer { flex: 1; }

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* Buttons and fields */

.button, .tool, .chip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--raised);
	color: var(--text);
	font: inherit;
	font-weight: 550;
	padding: 9px 14px;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color .12s, border-color .12s, color .12s;
}
.button:hover, .tool:hover, .chip:hover { background: var(--hover); }
.button:disabled, .tool:disabled { opacity: .45; cursor: default; }
.button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-ink);
}
.button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button.quiet:hover { background: var(--raised); color: var(--text); }
.button.danger { background: var(--danger-bg); border-color: #5a2a30; color: #ffb4b4; }
.button.danger:hover { background: #4a2228; }
.button.danger-quiet { background: transparent; border-color: transparent; color: var(--danger); }
.button.danger-quiet:hover { background: var(--danger-bg); }
.link {
	background: none;
	border: 0;
	padding: 0;
	color: var(--accent);
	font: inherit;
	cursor: pointer;
	text-decoration: underline;
}

.field { display: grid; gap: 6px; }
.field-label { color: var(--muted); font-size: 13px; font-weight: 550; }
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; min-width: 0; }
input[type="text"], select {
	width: 100%;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--text);
	font: inherit;
	padding: 10px 12px;
}
input::placeholder { color: #5f6878; }
input[type="text"]:focus, select:focus {
	outline: none;
	border-color: var(--accent);
}
/* A room password is drawn as dots without being type="password": a browser offers to save
   what is typed into one of those, and there is a new password for every room. */
.secret { -webkit-text-security: disc; }
.secret::placeholder { -webkit-text-security: none; }
.error { color: var(--danger); font-size: 14px; }
.notice {
	margin-bottom: 18px;
	padding: 10px 12px;
	border: 1px solid #5c4a1d;
	border-radius: var(--radius);
	background: #2a2210;
	color: #ffd88a;
	font-size: 14px;
}

/* Lobby */

.lobby {
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
	padding: 24px;
	overflow: auto;
	background: radial-gradient(900px 500px at 50% -10%, #23201a 0%, transparent 70%), var(--bg);
}
.card {
	width: min(440px, 100%);
	padding: 32px;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: var(--surface);
	box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.brand {
	font-size: 34px;
	line-height: 1.1;
	font-weight: 800;
	letter-spacing: -.02em;
}
.brand-small {
	display: block;
	color: var(--accent);
	font-size: .5em;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	margin-bottom: 4px;
}
.tagline { color: var(--muted); margin: 10px 0 24px; }
.lobby-form { display: grid; gap: 16px; }
.invited {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px;
	padding: 12px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--raised);
}
.invited code { color: var(--accent); font-size: 18px; font-weight: 700; letter-spacing: .08em; }
.invited .link { margin-left: auto; font-size: 13px; color: var(--muted); }
.actions { display: grid; gap: 10px; margin-top: 4px; }
.actions .button { padding: 12px 14px; }
.or { color: var(--muted); font-size: 13px; text-align: center; }
.fine { color: #6c7586; font-size: 13px; text-align: center; max-width: 440px; }

/* Room */

.room {
	height: 100%;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
}
.topbar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 14px;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
	min-width: 0;
}
.brand-bar { font-size: 16px; letter-spacing: -.01em; white-space: nowrap; }
.room-id {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-left: 12px;
	padding-left: 22px;
	border-left: 1px solid var(--border);
	min-width: 0;
}
.room-id-label { color: var(--muted); font-size: 13px; }
.room-code {
	margin: 0 6px;
	color: var(--accent);
	font-size: 17px;
	font-weight: 700;
	letter-spacing: .1em;
	user-select: all;
}
.topbar .button { padding: 7px 10px; font-size: 14px; }
.button.locked { color: var(--on); }
.pill {
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
}
.pill.warn { background: #3a2e10; color: #ffd88a; }

.body { display: flex; min-height: 0; }
.stage {
	position: relative;
	flex: 1;
	min-width: 0;
	padding: var(--gap);
}
.grid {
	width: 100%;
	height: 100%;
	display: flex;
	flex-wrap: wrap;
	align-content: center;
	justify-content: center;
	gap: var(--gap);
	overflow: hidden;
}

.tile {
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
}
.tile-frame {
	position: relative;
	overflow: hidden;
	border-radius: var(--radius);
	background: #05060a;
	box-shadow: 0 0 0 1px var(--border);
}
.tile canvas, .tile video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}
.tile:fullscreen { background: #000; }
.tile:fullscreen .tile-frame {
	width: 100% !important;
	height: 100% !important;
	border-radius: 0;
	box-shadow: none;
}
.tile-wait {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--text);
	font-size: 14px;
	text-shadow: 0 1px 6px #000;
	pointer-events: none;
}
.tile-bar {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 22px 8px 8px;
	background: linear-gradient(transparent, rgba(0, 0, 0, .78));
	opacity: 0;
	transition: opacity .15s;
}
.tile-frame:hover .tile-bar, .tile-frame:focus-within .tile-bar { opacity: 1; }
@media (hover: none) { .tile-bar { opacity: 1; } }
.tile-name {
	position: absolute;
	left: 8px;
	top: 8px;
	max-width: calc(100% - 16px);
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 3px 9px;
	border-radius: 999px;
	background: rgba(0, 0, 0, .62);
	font-size: 13px;
	font-weight: 600;
	pointer-events: none;
}
.tile-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-badge { color: var(--muted); font-weight: 500; }

/* A stream that reaches this person through the server's relay: one red badge, because
   direct is better. Its note says what that means (ui/relay.js). */
.relay-badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	flex: none;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--relay);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 1.45;
	white-space: nowrap;
	cursor: help;
	user-select: none;
}
.relay-badge .icon { width: 14px; height: 14px; stroke-width: 2; }
.tile-relay { position: absolute; right: 8px; top: 8px; }
.tile-frame.relayed .tile-name { max-width: calc(100% - 124px); }

/* The note a badge opens (ui/tip.js): a floating panel, placed by the script. */
.tip {
	position: fixed;
	z-index: 20;
	width: max-content;
	max-width: min(360px, calc(100vw - 16px));
	padding: 12px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--raised);
	box-shadow: 0 10px 34px rgba(0, 0, 0, .55);
	color: var(--text);
	font-size: 13px;
	font-weight: 400;
	line-height: 1.45;
	text-align: left;
	white-space: normal;
	pointer-events: none;
}
.tip strong { display: block; margin-bottom: 4px; font-size: 14px; }
.tip p { margin: 0 0 8px; color: #c9cedb; }
.tip .tip-lead { margin-bottom: 2px; color: var(--text); font-weight: 600; }
.tip ul { margin: 0 0 8px; padding-left: 18px; color: #c9cedb; }
.tip li { margin: 2px 0; }
.tip > :last-child { margin-bottom: 0; }
.tile.mine .tile-frame { box-shadow: 0 0 0 1px #6b5520; }

.icon-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	flex: none;
	border: 0;
	border-radius: 8px;
	background: rgba(255, 255, 255, .1);
	color: var(--text);
	cursor: pointer;
}
.icon-button:hover { background: rgba(255, 255, 255, .2); }
.icon-button.off { color: var(--danger); }
.people .icon-button { background: transparent; color: var(--muted); }
.people .icon-button:hover { background: var(--hover); color: var(--text); }
.people .icon-button.off { color: var(--danger); }

.volume {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
	flex: 1;
}
.volume input[type="range"] { flex: 1; width: 40px; min-width: 40px; max-width: 220px; }
.volume-value {
	width: 44px;
	flex: none;
	color: var(--muted);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	text-align: right;
}
.tile .volume-value { color: var(--text); }
input[type="range"] {
	appearance: none;
	height: 4px;
	border-radius: 2px;
	background: #3a4150;
	accent-color: var(--accent);
	cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
	appearance: none;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--accent);
	border: 0;
}
input[type="range"]::-moz-range-thumb {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--accent);
	border: 0;
}
input[type="range"]:disabled { opacity: .4; cursor: default; }

.empty {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 24px;
	color: var(--muted);
	text-align: center;
	pointer-events: none;
}
.empty h2 { color: var(--text); font-size: 20px; margin-top: 8px; }
.chip {
	position: absolute;
	padding: 6px 12px;
	border-radius: 999px;
	font-size: 13px;
	background: rgba(22, 25, 32, .92);
}
#stage-hidden { right: 16px; top: 16px; }
#stage-sound { left: 50%; top: 16px; transform: translateX(-50%); }
.chip.attention { border-color: var(--accent); color: var(--accent); }

/* People */

.people {
	width: 300px;
	flex: none;
	display: flex;
	flex-direction: column;
	min-height: 0;
	border-left: 1px solid var(--border);
	background: var(--surface);
}
.people-title {
	padding: 14px 16px 8px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
}
.people-list {
	list-style: none;
	margin: 0;
	padding: 0 8px 12px;
	overflow-y: auto;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	align-content: start;
	gap: 4px;
}
.person { padding: 8px; border-radius: var(--radius); }
.person:hover { background: var(--raised); }
.person-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
	width: 30px;
	height: 30px;
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--hover);
	color: var(--text);
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
}
.person.away .avatar { opacity: .45; }
.person-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.person-tags { display: flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); font-size: 12px; }
.person-tags .icon { width: 15px; height: 15px; }
.person-tags .owner { color: var(--accent); }
.person-tags .live { color: var(--on); }
.person-note { margin: 2px 0 0 40px; color: var(--muted); font-size: 12px; }
.person-row {
	display: flex;
	align-items: center;
	gap: 4px;
	margin: 4px 0 0 34px;
}
.person-row-label { width: 46px; flex: none; color: var(--muted); font-size: 12px; }
.person-relay { padding: 1px 8px; font-size: 11px; }

/* Toolbar */

.toolbar {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 10px 14px;
	border-top: 1px solid var(--border);
	background: var(--surface);
}
/* What belongs to one thing sits together: the screen share with its sound, its preview and
   its quality. */
.tool-group {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	min-width: 0;
}
.tool { padding: 10px 16px; }
.tool[aria-pressed="true"] { border-color: #2f6b48; background: #16301f; color: #a5f0c5; }
.tool[aria-pressed="true"]:hover { background: #1b3b27; }
.tool.sharing { border-color: #5a2a30; background: var(--danger-bg); color: #ffb4b4; }
.tool.sharing:hover { background: #4a2228; }
.tool.select { cursor: default; padding: 4px 6px 4px 14px; color: var(--muted); font-weight: 500; }
.tool.select:hover { background: var(--raised); }
.tool.select select { width: auto; border: 0; background: transparent; padding: 6px 4px; font-weight: 550; cursor: pointer; }
.tool.select option { background: var(--raised); color: var(--text); }
.divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

/* A sharing control this browser cannot use: it looks switched off, but can still be pointed
   at and focused so its note (ui/tip.js) can say why. */
.tool.unavailable, .tool.unavailable[aria-pressed="true"] {
	border-color: var(--border);
	background: var(--raised);
	color: var(--text);
	opacity: .45;
	cursor: not-allowed;
}
.tool.unavailable select { pointer-events: none; opacity: 1; }
.park {
	position: fixed;
	left: 0;
	bottom: 0;
	width: 2px;
	height: 2px;
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
}
.park video { width: 2px; height: 2px; }

/* Full screen (ui/immersive.js): only the pictures, edge to edge on black, so one shared
   screen looks like the monitor it came from. The toolbar and the people panel float, out of
   sight until the pointer nears the bottom or the right edge. */

.room.immersive {
	position: relative;
	grid-template-rows: minmax(0, 1fr);
	background: #000;
}
.room.immersive .topbar { display: none; }
.room.immersive .body { position: relative; }
.room.immersive .stage { padding: 0; }
.room.immersive .grid { gap: 4px; }
.room.immersive .tile-frame, .room.immersive .tile.mine .tile-frame {
	border-radius: 0;
	box-shadow: none;
	background: #000;
}
/* The people panel has each screen's controls, so the pictures carry none of their own. */
.room.immersive .tile-bar { display: none; }
.room.immersive .tile-frame > :not(canvas, video), .room.immersive #stage-hidden {
	transition: opacity .25s;
}
.room.immersive.idle { cursor: none; }
.room.immersive.idle .tile-frame > :not(canvas, video, .tile-wait),
.room.immersive.idle #stage-hidden {
	opacity: 0;
}
.room.immersive .toolbar, .room.immersive .people {
	position: absolute;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: rgba(22, 25, 32, .88);
	backdrop-filter: blur(14px);
	box-shadow: 0 16px 48px rgba(0, 0, 0, .6);
	opacity: 0;
	pointer-events: none;
	transition: opacity .16s, transform .16s;
}
.room.immersive .toolbar {
	left: 50%;
	bottom: 16px;
	z-index: 6;
	width: max-content;
	max-width: calc(100% - 32px);
	transform: translate(-50%, 12px);
}
.room.immersive .people {
	right: 16px;
	top: 16px;
	bottom: auto;
	z-index: 5;
	width: min(320px, calc(100% - 32px));
	max-height: calc(100% - 32px);
	transform: translateX(12px);
}
.room.immersive.show-tools .toolbar { transform: translate(-50%, 0); }
.room.immersive.show-tools .people { max-height: calc(100% - 48px - var(--tools-height, 72px)); }
.room.immersive.show-people .people { transform: none; }
.room.immersive.show-tools .toolbar, .room.immersive.show-people .people {
	opacity: 1;
	pointer-events: auto;
}

/* Dialog and toasts */

.dialog {
	width: min(420px, calc(100% - 32px));
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog form { display: grid; gap: 14px; }
.dialog h2 { font-size: 20px; }
.dialog-text { color: var(--muted); font-size: 14px; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

.toasts {
	position: fixed;
	left: 50%;
	bottom: 84px;
	transform: translateX(-50%);
	display: grid;
	gap: 8px;
	justify-items: center;
	width: min(520px, calc(100% - 32px));
	pointer-events: none;
	z-index: 10;
}
.toast {
	padding: 10px 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--raised);
	box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
	font-size: 14px;
	animation: toast-in .18s ease-out;
}
.toast.bad { border-color: #5a2a30; color: #ffb4b4; }
.toast.leaving { opacity: 0; transition: opacity .3s; }
@keyframes toast-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}
.noscript { padding: 24px; text-align: center; }

/* Narrow screens: the people panel covers the stage instead of squeezing it. */

@media (max-width: 860px) {
	.brand-bar, .room-id-label, .topbar .button span, .divider { display: none; }
	.room-id { margin-left: 0; padding-left: 0; border-left: 0; }
	.people {
		position: absolute;
		right: 0;
		top: 0;
		bottom: 0;
		z-index: 5;
		width: min(320px, 88vw);
		box-shadow: -12px 0 40px rgba(0, 0, 0, .5);
	}
	.body { position: relative; }
	.tool { padding: 10px 12px; }
	.tool.select span { display: none; }
}
@media (max-width: 520px) {
	.card { padding: 22px; }
	.tool span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; animation: none !important; }
}
