@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;1,300;1,400&display=swap");

:root,
html[data-theme="dark"] {
	--accent: #7c5cff;
	--accent-hover: #9179ff;
	--bg: #0d0d12;
	--panel: #17171f;
	--border: rgba(255, 255, 255, 0.12);
	--text: #f2f2f5;
	--text-dim: #9a9aa5;
	--banner-h: 0px;
	--sidebar-w: 64px;
}

body.sidebar-expanded {
	--sidebar-w: 200px;
}

body.mobile-ui {
	--sidebar-w: 0px;
}

body.has-broadcast {
	--banner-h: 36px;
}

html[data-theme="midnight"] {
	--accent: #4f8cff;
	--accent-hover: #6fa2ff;
	--bg: #05070f;
	--panel: #0d1120;
	--border: rgba(120, 150, 255, 0.15);
	--text: #eef1ff;
	--text-dim: #8891b0;
}

html[data-theme="sunset"] {
	--accent: #ff7a45;
	--accent-hover: #ff9466;
	--bg: #1a0f0d;
	--panel: #251512;
	--border: rgba(255, 150, 100, 0.15);
	--text: #fff1e8;
	--text-dim: #c99b8a;
}

html[data-theme="light"] {
	--accent: #6a4cff;
	--accent-hover: #7e63ff;
	--bg: #f4f4f8;
	--panel: #ffffff;
	--border: rgba(0, 0, 0, 0.12);
	--text: #1a1a1f;
	--text-dim: #6b6b75;
}

* {
	box-sizing: border-box;
}

body {
	font-family: "Roboto", Arial, Helvetica, sans-serif;
	margin: 0;
	background: var(--bg);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	position: relative;
	padding-left: var(--sidebar-w);
	box-sizing: border-box;
	transition: padding-left 0.15s ease;
}

body.mobile-ui {
	padding-left: 0;
}

#app-sidebar {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: var(--sidebar-w);
	background: var(--panel);
	border-right: 1px solid var(--border);
	z-index: 60;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: width 0.15s ease;
}

#sidebar-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 14px 14px;
	font-weight: 700;
	color: var(--text);
	white-space: nowrap;
	border-bottom: 1px solid var(--border);
	min-height: 20px;
}

#sidebar-header .sidebar-logo-text {
	background: linear-gradient(90deg, var(--accent), #ff5cf1);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	font-size: 15px;
	opacity: 0;
	transition: opacity 0.1s ease;
}

body.sidebar-expanded #sidebar-header .sidebar-logo-text {
	opacity: 1;
}

#sidebar-nav {
	flex: 1;
	overflow-y: auto;
	padding: 8px 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.sidebar-item {
	display: flex;
	align-items: center;
	gap: 12px;
	background: none;
	border: none;
	color: var(--text-dim);
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	padding: 10px 20px;
	cursor: pointer;
	white-space: nowrap;
	position: relative;
	text-align: left;
}

.sidebar-item .badge-dot {
	position: static;
	width: 6px;
	height: 6px;
	flex-shrink: 0;
}

.sidebar-item svg {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
}

.sidebar-item span {
	opacity: 0;
	transition: opacity 0.1s ease;
}

body.sidebar-expanded .sidebar-item span {
	opacity: 1;
}

.sidebar-item:hover {
	color: var(--text);
	background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.sidebar-item.active {
	color: var(--accent);
	background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.sidebar-item.active::before {
	content: "";
	position: absolute;
	left: 0;
	top: 6px;
	bottom: 6px;
	width: 3px;
	background: var(--accent);
	border-radius: 0 3px 3px 0;
}

#sidebar-footer {
	border-top: 1px solid var(--border);
	padding: 6px 0;
}

body::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background:
		radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
		radial-gradient(circle at 85% 75%, color-mix(in srgb, #ff5cf1 10%, transparent), transparent 55%);
}

html[data-bg-style="solid"] body::before {
	background: none;
}

html[data-bg-style="grid"] body::before {
	background:
		linear-gradient(color-mix(in srgb, var(--text) 6%, transparent) 1px, transparent 1px) 0 0 / 42px 42px,
		linear-gradient(90deg, color-mix(in srgb, var(--text) 6%, transparent) 1px, transparent 1px) 0 0 / 42px 42px,
		radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
	mask-image: radial-gradient(circle at 50% 25%, #000 0%, transparent 75%);
	-webkit-mask-image: radial-gradient(circle at 50% 25%, #000 0%, transparent 75%);
}

html[data-bg-style="dots"] body::before {
	background:
		radial-gradient(color-mix(in srgb, var(--text) 14%, transparent) 1.5px, transparent 1.5px) 0 0 / 26px 26px,
		radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
	mask-image: radial-gradient(circle at 50% 25%, #000 0%, transparent 75%);
	-webkit-mask-image: radial-gradient(circle at 50% 25%, #000 0%, transparent 75%);
}

html[data-bg-style="aurora"] body::before {
	background:
		radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%),
		radial-gradient(circle at 80% 30%, color-mix(in srgb, #ff5cf1 16%, transparent), transparent 55%),
		radial-gradient(circle at 50% 80%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 55%);
	background-size: 200% 200%;
	animation: aurora-drift 18s ease-in-out infinite;
}

@keyframes aurora-drift {
	0% {
		background-position: 0% 0%, 100% 0%, 50% 100%;
	}
	50% {
		background-position: 20% 30%, 70% 40%, 40% 70%;
	}
	100% {
		background-position: 0% 0%, 100% 0%, 50% 100%;
	}
}

html[data-bg-style="noise"] body::before {
	background: radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
}

html[data-bg-style^="particles"] body {
	background: #000;
}

/* The starfield is a dark-theme look; on the light theme keep the light
   background (the dots are drawn dark to match -- see drawBgParticles). */
html[data-theme="light"][data-bg-style^="particles"] body {
	background: var(--bg);
}

/* Soft glow behind the centered home content, like a spotlight. */
html[data-bg-style^="particles"] body::before {
	background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%);
}

#bg-particles-canvas {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: -1;
	pointer-events: none;
	display: none;
}

html[data-bg-style^="particles"] #bg-particles-canvas {
	display: block;
}

html[data-bg-style="image"] body::before {
	background-image: var(--bg-image-url);
	background-size: 100% 100%;
	background-position: center;
	background-repeat: no-repeat;
}

html[data-bg-style="noise"] body::after {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
	background-size: 180px 180px;
	mix-blend-mode: overlay;
	opacity: 0.18;
}

body.has-tabs {
	padding-top: calc(44px + var(--banner-h));
}

.hidden {
	display: none !important;
}

.flex-center {
	display: flex;
	justify-content: center;
	align-items: center;
}

.header-center {
	flex-direction: column;
	margin-top: 14vh;
}

.header-center h1 {
	color: var(--text);
	font-weight: 500;
	letter-spacing: 1px;
	font-size: 3rem;
	margin-bottom: 6px;
	background: linear-gradient(90deg, var(--accent), #ff5cf1);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.header-center .tagline {
	color: var(--text-dim);
	font-size: 14px;
	letter-spacing: 0.5px;
	margin: 0 0 8px;
}

.left-margin {
	margin: 0px 16px;
}

/* --- tab strip: hidden until the first tab exists --- */
#tabstrip {
	position: fixed;
	top: var(--banner-h);
	left: var(--sidebar-w);
	width: calc(100% - var(--sidebar-w));
	height: 44px;
	display: none;
	align-items: center;
	gap: 6px;
	padding: 0 10px;
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	z-index: 30;
}

body.has-tabs #tabstrip {
	display: flex;
}

#tabs-list {
	display: flex;
	align-items: center;
	gap: 4px;
	overflow-x: auto;
	max-width: 60vw;
}

.tab {
	display: flex;
	align-items: center;
	gap: 6px;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text-dim);
	border-radius: 8px;
	padding: 6px 8px 6px 12px;
	font-size: 13px;
	cursor: pointer;
	max-width: 160px;
	white-space: nowrap;
}

.tab.active {
	color: var(--text);
	border-color: var(--accent);
	background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}

.tab.incognito {
	background: #1a1a24;
	border-style: dashed;
}

.tab.incognito .tab-title::before {
	content: "🕶 ";
}

.tab-favicon {
	width: 14px;
	height: 14px;
	border-radius: 3px;
	flex-shrink: 0;
}

.tab-title {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 110px;
}

.tab-close {
	background: none;
	border: none;
	color: inherit;
	cursor: pointer;
	font-size: 14px;
	line-height: 1;
	padding: 2px;
	border-radius: 4px;
}

.tab-close:hover {
	background: var(--border);
}

.tab.dragging {
	opacity: 0.5;
}

.tab.drag-over {
	border-color: var(--accent);
	box-shadow: inset 2px 0 0 var(--accent);
}

.strip-btn {
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text-dim);
	width: 30px;
	height: 30px;
	border-radius: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	flex-shrink: 0;
}

.strip-btn:hover {
	color: var(--text);
	border-color: var(--accent);
}

.badge-dot {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #ff6b6b;
	border: 1px solid var(--panel);
}

/* --- settings dropdown --- */
/* Translucent so changing the background style is visible live while you're
   still on this page; body.panel-open hides the home content behind it. */
#settings-panel {
	background: color-mix(in srgb, var(--bg) 78%, transparent);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	border: none;
	box-shadow: none;
	overflow-y: auto;
	padding: 0;
}

body.panel-open:not(.browsing) #home-title,
body.panel-open:not(.browsing) #topbar,
body.panel-open:not(.browsing) #frequent-sites {
	visibility: hidden;
}

#settings-header {
	text-align: center;
	padding: 32px 20px 8px;
}

#settings-header h2 {
	margin: 0;
	font-size: 32px;
	font-weight: 700;
	color: var(--text);
	letter-spacing: -0.5px;
}

#settings-header p {
	margin: 6px 0 0;
	color: var(--text-dim);
	font-size: 13px;
}

#settings-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 14px;
	padding: 20px;
	max-width: 1100px;
	margin: 0 auto;
	width: 100%;
	box-sizing: border-box;
}

.settings-card {
	background: color-mix(in srgb, var(--panel) 85%, transparent);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.settings-card:hover {
	border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.settings-card-icon {
	width: 34px;
	height: 34px;
	border-radius: 9px;
	background: color-mix(in srgb, var(--accent) 16%, transparent);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 17px;
	margin-bottom: 2px;
}

.settings-card h3 {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	color: var(--text);
}

.settings-card > p {
	margin: 0 0 4px;
	font-size: 12px;
	line-height: 1.45;
	color: var(--text-dim);
}

.settings-card-sublabel {
	font-size: 11px;
	font-weight: 600;
	color: var(--text-dim);
	text-transform: uppercase;
	letter-spacing: 0.4px;
	margin-top: 2px;
}

.settings-card-note {
	font-size: 11px;
	color: var(--text-dim);
	margin: 2px 0 0;
	min-height: 14px;
}

.settings-card select,
.settings-card input[type="text"],
.settings-card input[type="file"],
.settings-card button {
	background: var(--bg);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 8px 10px;
	font-family: inherit;
	font-size: 13px;
	width: 100%;
	box-sizing: border-box;
}

.settings-card button {
	cursor: pointer;
	font-weight: 500;
}

.settings-card button:hover {
	border-color: var(--accent);
	color: var(--text);
}

.settings-card input[type="color"] {
	width: 100%;
	height: 36px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: none;
	cursor: pointer;
	padding: 2px;
	box-sizing: border-box;
}

.settings-toggle {
	position: relative;
	display: inline-block;
	width: 46px;
	height: 26px;
	flex-shrink: 0;
}

.settings-toggle input {
	opacity: 0;
	width: 0;
	height: 0;
	position: absolute;
}

.settings-toggle-slider {
	position: absolute;
	inset: 0;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 26px;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.settings-toggle-slider::before {
	content: "";
	position: absolute;
	width: 18px;
	height: 18px;
	left: 3px;
	top: 3px;
	background: var(--text-dim);
	border-radius: 50%;
	transition: transform 0.15s ease, background 0.15s ease;
}

.settings-toggle input:checked + .settings-toggle-slider {
	background: color-mix(in srgb, var(--accent) 30%, transparent);
	border-color: var(--accent);
}

.settings-toggle input:checked + .settings-toggle-slider::before {
	transform: translateX(20px);
	background: var(--accent);
}

#settings-reset {
	display: block;
	width: calc(100% - 40px);
	max-width: 1060px;
	margin: 0 auto 28px;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text-dim);
	border-radius: 8px;
	padding: 10px 0;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
}

#settings-reset:hover {
	color: var(--text);
	border-color: var(--accent);
}

/* --- topbar: centered on home, slim strip once browsing --- */
#topbar {
	gap: 10px;
	margin-top: 24px;
	transition: all 0.15s ease;
}

body.browsing #home-title {
	display: none;
}

body.browsing #topbar {
	position: fixed;
	top: calc(44px + var(--banner-h));
	left: var(--sidebar-w);
	width: calc(100% - var(--sidebar-w));
	margin-top: 0;
	padding: 10px 14px;
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	z-index: 20;
}

.tab-frame {
	border: none;
	position: fixed;
	top: 0;
	left: var(--sidebar-w);
	width: calc(100vw - var(--sidebar-w));
	height: 100vh;
	background-color: #fff;
	display: none;
}

body.browsing .tab-frame.active {
	display: block;
	top: calc(98px + var(--banner-h));
	height: calc(100vh - 98px - var(--banner-h));
}

#uv-error {
	color: #ff6b6b !important;
	white-space: pre-wrap;
	text-align: center;
}

#uv-error-code {
	font-size: 12px;
	color: var(--text-dim);
	font-family: "Courier New", Courier, monospace;
}

#uv-form {
	gap: 10px;
	flex: 1;
	max-width: 640px;
}

#frequent-sites {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 10px;
	margin: 22px auto 0;
	max-width: 640px;
	padding: 0 16px;
}

body.browsing #frequent-sites {
	display: none;
}

.frequent-site {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--panel);
	border: 1px solid var(--border);
	color: var(--text-dim);
	font-size: 13px;
	padding: 7px 14px 7px 10px;
	border-radius: 50px;
	cursor: pointer;
	max-width: 160px;
}

.frequent-site:hover {
	border-color: var(--accent);
	color: var(--text);
}

.frequent-site-favicon {
	width: 14px;
	height: 14px;
	border-radius: 3px;
	flex-shrink: 0;
}

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

.frequent-site-dismiss {
	flex-shrink: 0;
	color: var(--text-dim);
	opacity: 0;
	font-size: 14px;
	line-height: 1;
	padding: 2px;
	border-radius: 4px;
	transition: opacity 0.1s ease;
}

.frequent-site:hover .frequent-site-dismiss {
	opacity: 0.6;
}

.frequent-site-dismiss:hover {
	opacity: 1 !important;
	color: #ff6b6b;
}

.nav-btn {
	background: var(--panel);
	border: 1px solid var(--border);
	color: var(--text);
	width: 38px;
	height: 38px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.nav-btn:hover {
	background: color-mix(in srgb, var(--accent) 15%, var(--panel));
	border-color: var(--accent);
}

#uv-search-engine {
	background: var(--panel);
	font-family: inherit;
	font-size: 14px;
	height: 46px;
	padding: 0 14px;
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 50px;
	outline: none;
	cursor: pointer;
}

#uv-search-engine:focus {
	border-color: var(--accent);
}

#uv-address {
	background: var(--panel);
	font-family: inherit;
	font-size: 15px;
	padding: 0px 18px;
	height: 46px;
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 50px;
	outline: none;
	flex: 1;
	min-width: 0;
}

#uv-address:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

#uv-go {
	height: 46px;
	padding: 0 22px;
	border-radius: 50px;
	border: none;
	background: var(--accent);
	color: #fff;
	cursor: pointer;
	font-family: inherit;
	font-size: 15px;
	font-weight: 500;
}

#uv-go:hover {
	background: var(--accent-hover);
}

/* --- loading spinner --- */
#uv-spinner {
	width: 20px;
	height: 20px;
	border: 3px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
	flex-shrink: 0;
}

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

/* --- account button + panel --- */
#account-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 46px;
	width: 220px;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	text-align: center;
}

#account-username {
	color: var(--text);
	font-size: 14px;
	font-weight: 500;
	margin: 0 0 12px 0;
	word-break: break-word;
}

#password-form {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 8px;
}

#password-form input {
	padding: 8px 10px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
	font-family: inherit;
	font-size: 13px;
}

#password-submit {
	padding: 8px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
}

#password-submit:hover {
	border-color: var(--accent);
	color: var(--accent-hover);
}

#password-message {
	font-size: 12px;
	min-height: 14px;
	margin: 0 0 10px 0;
}

#password-message.error {
	color: #ff6b6b;
}

#password-message.success {
	color: #4ade80;
}

#account-logout {
	width: 100%;
	padding: 8px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
	cursor: pointer;
	font-family: inherit;
	font-size: 14px;
}

#account-logout:hover {
	border-color: var(--accent);
	color: var(--accent-hover);
}

/* --- messages panel --- */
#messages-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 82px;
	width: 280px;
	height: 360px;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

#messages-threads {
	display: flex;
	flex-direction: column;
	height: 100%;
}

#messages-thread-list {
	flex: 1;
	overflow-y: auto;
	padding: 8px;
}

.messages-empty {
	color: var(--text-dim);
	font-size: 13px;
	text-align: center;
	margin-top: 20px;
}

.message-thread {
	position: relative;
	display: flex;
	flex-direction: column;
	padding: 8px 46px 8px 10px;
	border-radius: 8px;
	cursor: pointer;
	margin-bottom: 4px;
}

.message-thread:hover {
	background: var(--bg);
}

.message-thread.pinned {
	background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}

.message-thread-pin,
.message-thread-delete {
	position: absolute;
	top: 8px;
	background: none;
	border: none;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.35;
	padding: 3px;
	border-radius: 4px;
}

.message-thread-pin {
	right: 28px;
}

.message-thread-delete {
	right: 6px;
	color: #e05555;
}

.message-thread:hover .message-thread-pin,
.message-thread:hover .message-thread-delete {
	opacity: 0.85;
}

.message-thread-pin.pinned {
	opacity: 1;
}

.message-thread-pin:hover,
.message-thread-delete:hover {
	opacity: 1 !important;
	background: var(--border);
}

.presence-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--text-dim);
	opacity: 0.35;
	flex-shrink: 0;
}

.presence-dot.online {
	background: #3ecf6e;
	opacity: 1;
}

.message-thread-name {
	display: flex;
	align-items: center;
	gap: 6px;
	color: var(--text);
	font-size: 13px;
	font-weight: 500;
}

.message-thread-preview {
	color: var(--text-dim);
	font-size: 12px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.message-thread.unread .message-thread-name {
	font-weight: 700;
	color: var(--text);
}

.message-thread.unread .message-thread-name::before {
	content: "";
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #ff6b6b;
	margin-right: 6px;
	flex-shrink: 0;
}

#messages-new-section {
	padding: 8px;
	border-top: 1px solid var(--border);
}

#messages-new-section label {
	display: block;
	color: var(--text-dim);
	font-size: 11px;
	margin-bottom: 4px;
}

#messages-new-picker {
	width: 100%;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 13px;
}

#messages-new-group-btn {
	width: 100%;
	margin-top: 6px;
	background: none;
	border: 1px solid var(--border);
	color: var(--text-dim);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 12px;
	cursor: pointer;
}

#messages-new-group-btn:hover {
	color: var(--text);
	border-color: var(--accent);
}

#messages-new-group-form {
	padding: 8px;
	border-top: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	gap: 6px;
}

#messages-new-group-name {
	width: 100%;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 13px;
}

#messages-new-group-members {
	width: 100%;
	max-height: 160px;
	overflow-y: auto;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 2px;
}

.group-member-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 7px 8px;
	border-radius: 4px;
	font-size: 13px;
	color: var(--text);
	cursor: pointer;
}

.group-member-row:hover {
	background: var(--bg-hover, rgba(255, 255, 255, 0.05));
}

.group-member-row input[type="checkbox"] {
	width: 17px;
	height: 17px;
	flex-shrink: 0;
	cursor: pointer;
}

.group-member-row span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#messages-new-group-hint {
	margin: 0;
	font-size: 11px;
	color: var(--text-dim);
}

#messages-new-group-actions {
	display: flex;
	justify-content: flex-end;
	gap: 6px;
}

#messages-new-group-actions button {
	font-size: 12px;
	padding: 5px 10px;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: none;
	color: var(--text-dim);
	cursor: pointer;
}

#messages-new-group-actions button[type="submit"] {
	background: var(--accent);
	color: var(--accent-contrast, #fff);
	border-color: var(--accent);
}

#messages-new-group-actions button[type="submit"]:disabled {
	background: none;
	color: var(--text-dim);
	border-color: var(--border);
	cursor: not-allowed;
	opacity: 0.6;
}

.message-thread-group-icon {
	font-size: 11px;
}

#messages-new-group-error {
	color: #ff6b6b;
	font-size: 12px;
	margin: 0;
}

#messages-conversation {
	display: flex;
	flex-direction: column;
	height: 100%;
}

#messages-conversation-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px;
	border-bottom: 1px solid var(--border);
}

#messages-back {
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	font-size: 16px;
}

#messages-conversation-with {
	color: var(--text);
	font-size: 13px;
	font-weight: 500;
	flex: 1;
}

#messages-conversation-members {
	color: var(--text-dim);
	font-size: 11px;
}

.message-sender {
	color: var(--text-dim);
	font-size: 11px;
	margin: 0 0 2px 2px;
}

#messages-delete-thread,
#messages-rename-group {
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	font-size: 16px;
	opacity: 0.55;
	transition: opacity 0.1s ease;
}

#messages-conversation-header:hover #messages-delete-thread,
#messages-conversation-header:hover #messages-rename-group {
	opacity: 0.85;
}

#messages-rename-group:hover {
	opacity: 1 !important;
}

#messages-delete-thread:hover {
	opacity: 1 !important;
	color: #ff6b6b;
}

#messages-list {
	flex: 1;
	overflow-y: auto;
	padding: 10px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.message-item {
	display: flex;
	flex-direction: column;
	align-self: flex-start;
	max-width: 80%;
	gap: 2px;
}

.message-item.mine {
	align-self: flex-end;
}

.message-bubble {
	padding: 6px 10px;
	border-radius: 12px;
	background: var(--bg);
	color: var(--text);
	font-size: 13px;
	word-break: break-word;
	white-space: pre-wrap;
}

.message-bubble.mine {
	background: var(--accent);
	color: #fff;
}

.message-footer {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 2px;
}

.message-item.mine .message-footer {
	justify-content: flex-end;
}

.message-bubble-time {
	font-size: 10px;
	color: var(--text-dim);
	opacity: 0.7;
}

.message-bubble-actions {
	display: flex;
	gap: 8px;
	opacity: 0;
	transition: opacity 0.1s ease;
}

.message-item:hover .message-bubble-actions {
	opacity: 1;
}

.message-action {
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	font-size: 11px;
	line-height: 1;
	padding: 0;
	text-decoration: underline;
}

.message-image {
	max-width: 220px;
	max-height: 220px;
	border-radius: 10px;
	cursor: pointer;
	object-fit: cover;
	display: block;
}

.message-bubble a {
	color: inherit;
	text-decoration: underline;
}

#messages-image-btn {
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	font-size: 16px;
	padding: 4px 6px;
}

#messages-image-btn:hover {
	color: var(--text);
}

#messages-manage-members {
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	font-size: 14px;
	padding: 2px 4px;
}

#messages-manage-members:hover {
	color: var(--text);
}

#messages-voice-btn {
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	font-size: 16px;
	padding: 4px 6px;
}

#messages-voice-btn:hover {
	color: var(--text);
}

#messages-voice-btn.recording {
	color: #ff6b6b;
	animation: voice-pulse 1s ease-in-out infinite;
}

@keyframes voice-pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.4;
	}
}

.message-voice {
	max-width: 220px;
	height: 32px;
	margin-top: 4px;
}

#group-members-panel {
	padding: 8px 10px;
	border-bottom: 1px solid var(--border);
	background: var(--bg);
}

#group-members-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-bottom: 6px;
}

.group-member-row-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 12px;
	color: var(--text);
	gap: 8px;
}

.group-member-row-item button {
	background: none;
	border: 1px solid var(--border);
	color: var(--text-dim);
	border-radius: 4px;
	padding: 2px 6px;
	font-size: 10px;
	cursor: pointer;
	flex-shrink: 0;
}

.group-member-row-item button:hover {
	color: var(--text);
	border-color: var(--accent);
}

#group-members-close {
	background: none;
	border: 1px solid var(--border);
	color: var(--text-dim);
	border-radius: 6px;
	padding: 3px 8px;
	font-size: 11px;
	cursor: pointer;
}

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

#messages-compose {
	display: flex;
	gap: 6px;
	padding: 8px;
	border-top: 1px solid var(--border);
}

#messages-compose-text {
	flex: 1;
	min-width: 0;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 13px;
}

#messages-compose button {
	background: var(--accent);
	border: none;
	color: #fff;
	border-radius: 6px;
	padding: 6px 10px;
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
}

/* --- admin panel (own top-strip button, separate from account) --- */
#admin-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 154px;
	width: min(640px, 92vw);
	max-height: 76vh;
	overflow-y: auto;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 0;
	z-index: 40;
	box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
	text-align: left;
}

#admin-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 16px 18px 14px;
	background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), transparent 65%);
	border-bottom: 1px solid var(--border);
	color: var(--text);
	font-weight: 700;
	font-size: 15px;
}

#admin-header svg {
	color: var(--accent);
	flex-shrink: 0;
}

#admin-tabs {
	display: flex;
	gap: 2px;
	padding: 8px 10px 0;
	overflow-x: auto;
	border-bottom: 1px solid var(--border);
}

.admin-tab {
	background: none;
	border: none;
	color: var(--text-dim);
	font-family: inherit;
	font-size: 12.5px;
	font-weight: 600;
	padding: 9px 13px;
	cursor: pointer;
	white-space: nowrap;
	border-radius: 8px 8px 0 0;
	position: relative;
	transition: color 0.15s ease, background 0.15s ease;
}

.admin-tab:hover {
	color: var(--text);
	background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.admin-tab.active {
	color: var(--accent);
	background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.admin-tab.active::after {
	content: "";
	position: absolute;
	left: 10px;
	right: 10px;
	bottom: -1px;
	height: 2px;
	background: var(--accent);
	border-radius: 2px;
}

.admin-tab-panel {
	padding: 16px 18px 18px;
	animation: admin-tab-fade 0.15s ease;
}

@keyframes admin-tab-fade {
	from {
		opacity: 0;
		transform: translateY(2px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.admin-tab-panel > div {
	margin-bottom: 16px;
}

.admin-tab-panel > div:last-child {
	margin-bottom: 0;
}

#admin-panel label {
	display: block;
	color: var(--text-dim);
	font-size: 12px;
	margin-bottom: 6px;
	font-weight: 500;
}

.admin-empty {
	color: var(--text-dim);
	font-size: 12px;
	margin: 0;
}

.admin-feedback-item {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 8px;
	margin-bottom: 6px;
}

.admin-feedback-item.resolved {
	opacity: 0.5;
}

.admin-feedback-meta {
	color: var(--text-dim);
	font-size: 11px;
	margin-bottom: 4px;
}

.admin-feedback-text {
	color: var(--text);
	font-size: 13px;
	margin-bottom: 6px;
	word-break: break-word;
}

.admin-feedback-actions {
	display: flex;
	gap: 6px;
}

.admin-feedback-actions button {
	background: none;
	border: 1px solid var(--border);
	color: var(--text-dim);
	border-radius: 6px;
	padding: 3px 8px;
	cursor: pointer;
	font-family: inherit;
	font-size: 11px;
}

.admin-feedback-actions button:hover {
	border-color: var(--accent);
	color: var(--accent-hover);
}

.admin-account-card {
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 10px 12px;
	margin-bottom: 8px;
	background: rgba(255, 255, 255, 0.02);
}

.admin-account-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 13px;
	gap: 8px;
}

.admin-account-name {
	color: var(--text);
	font-weight: 600;
	word-break: break-word;
}

.admin-account-online {
	color: var(--text-dim);
	font-size: 12px;
	margin-right: auto;
	margin-left: 8px;
}

.admin-account-activity {
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid var(--border);
}

.admin-account-current {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	margin-bottom: 6px;
}

.admin-account-live-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #3ddc84;
	box-shadow: 0 0 6px rgba(61, 220, 132, 0.8);
	flex-shrink: 0;
}

.admin-account-current-label {
	color: var(--text-dim);
}

.admin-account-current-site {
	color: var(--accent-hover, var(--accent));
	font-weight: 600;
	max-width: 260px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.admin-account-recent-label {
	color: var(--text-dim);
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin-bottom: 4px;
}

.admin-account-recent-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.admin-account-recent-list li {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	font-size: 12px;
	color: var(--text);
}

.admin-account-recent-site {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.admin-account-recent-when {
	color: var(--text-dim);
	flex-shrink: 0;
	font-size: 11px;
}

.admin-account-row button {
	background: none;
	border: 1px solid var(--border);
	color: #ff6b6b;
	border-radius: 6px;
	padding: 3px 8px;
	cursor: pointer;
	font-family: inherit;
	font-size: 11px;
	flex-shrink: 0;
}

.admin-account-row button:hover {
	border-color: #ff6b6b;
	background: rgba(255, 107, 107, 0.1);
}

.admin-stat-row {
	display: flex;
	justify-content: space-between;
	padding: 4px 0;
	font-size: 12px;
	color: var(--text);
	border-bottom: 1px solid var(--border);
}

.admin-stat-row:last-child {
	border-bottom: none;
}

.admin-activity-row {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 6px 0;
	border-bottom: 1px solid var(--border);
	font-size: 11px;
	color: var(--text-dim);
}

.admin-activity-row:last-child {
	border-bottom: none;
}

.admin-activity-action {
	color: var(--accent);
	font-weight: 600;
	text-transform: uppercase;
	font-size: 10px;
}

.admin-activity-time {
	opacity: 0.7;
}

#admin-claude-chat-hint {
	color: var(--text-dim);
	font-size: 11px;
	margin: -2px 0 8px;
}

#admin-claude-chat-list {
	max-height: 260px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 8px;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	margin-bottom: 8px;
}

.admin-claude-chat-row {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	max-width: 85%;
}

.admin-claude-chat-row.mine {
	align-items: flex-end;
	align-self: flex-end;
}

.admin-claude-chat-bubble {
	background: var(--panel-bg, var(--bg));
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 6px 10px;
	font-size: 13px;
	color: var(--text);
	word-break: break-word;
	white-space: pre-wrap;
}

.admin-claude-chat-row.mine .admin-claude-chat-bubble {
	background: var(--accent);
	color: var(--accent-contrast, #fff);
	border-color: var(--accent);
}

.admin-claude-chat-time {
	font-size: 10px;
	color: var(--text-dim);
	margin-top: 2px;
}

#admin-claude-chat-form {
	display: flex;
	gap: 6px;
}

#admin-claude-chat-input {
	flex: 1;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 13px;
}

#admin-claude-chat-form button {
	background: var(--accent);
	color: var(--accent-contrast, #fff);
	border: 1px solid var(--accent);
	border-radius: 6px;
	padding: 6px 12px;
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
}

/* --- feedback panel (any signed-in user) --- */
#feedback-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 118px;
	width: 260px;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#feedback-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

#feedback-type {
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 13px;
}

#feedback-text {
	resize: vertical;
	min-height: 60px;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 13px;
}

#feedback-submit {
	background: var(--accent);
	border: none;
	color: #fff;
	border-radius: 6px;
	padding: 8px 0;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
}

#feedback-submit:hover {
	background: var(--accent-hover);
}

#feedback-message {
	font-size: 12px;
	margin: 8px 0 0 0;
}

#feedback-message.error {
	color: #ff6b6b;
}

#feedback-message.success {
	color: #4ade80;
}

/* --- apps panel --- */
#changelog-btn.has-unseen {
	animation: changelog-bounce 1.4s ease infinite;
}

@keyframes changelog-bounce {
	0%,
	60%,
	100% {
		transform: translateY(0);
	}
	20% {
		transform: translateY(-5px);
	}
	40% {
		transform: translateY(-2px);
	}
}

#changelog-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 262px;
	width: 300px;
	max-height: 60vh;
	overflow-y: auto;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#world-chat-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 298px;
	width: 300px;
	height: 380px;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	padding: 10px;
	gap: 8px;
}

#leaderboard-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	width: 280px;
	max-height: 60vh;
	overflow-y: auto;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	right: 334px;
}

#leaderboard-hint {
	margin: 0 0 8px;
	color: var(--text-dim);
	font-size: 11px;
}

.leaderboard-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 0;
	border-bottom: 1px solid var(--border);
	font-size: 13px;
}

.leaderboard-row:last-child {
	border-bottom: none;
}

.leaderboard-rank {
	color: var(--text-dim);
	width: 26px;
	flex-shrink: 0;
}

.leaderboard-name {
	flex: 1;
	color: var(--text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.leaderboard-count {
	font-weight: 600;
}

#friends-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 370px;
	width: 280px;
	max-height: 60vh;
	overflow-y: auto;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#friends-hint {
	margin: 0 0 8px;
	color: var(--text-dim);
	font-size: 11px;
}

.friend-row {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 6px 0;
	border-bottom: 1px solid var(--border);
	font-size: 13px;
	background: none;
	border-left: none;
	border-right: none;
	border-top: none;
	font-family: inherit;
	cursor: pointer;
	text-align: left;
}

.friend-row:last-child {
	border-bottom: none;
}

.friend-row .presence-dot {
	flex-shrink: 0;
}

.friend-name {
	flex: 1;
	color: var(--text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.friend-status {
	color: var(--text-dim);
	font-size: 11px;
	flex-shrink: 0;
}

#world-chat-hint {
	margin: 0;
	color: var(--text-dim);
	font-size: 11px;
}

#world-chat-list {
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 4px;
}

.world-chat-row {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	max-width: 85%;
}

.world-chat-row.mine {
	align-items: flex-end;
	align-self: flex-end;
}

.world-chat-row.mentioned .world-chat-bubble {
	background: color-mix(in srgb, var(--accent) 18%, var(--bg));
	border-color: var(--accent);
}

.world-chat-sender {
	font-size: 10px;
	color: var(--text-dim);
	margin-bottom: 2px;
}

.world-chat-bubble {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 6px 10px;
	font-size: 13px;
	color: var(--text);
	word-break: break-word;
	white-space: pre-wrap;
}

.world-chat-row.mine .world-chat-bubble {
	background: var(--accent);
	color: var(--accent-contrast, #fff);
	border-color: var(--accent);
}

.world-chat-time {
	font-size: 10px;
	color: var(--text-dim);
	margin-top: 2px;
}

#world-chat-online-count {
	color: var(--accent);
}

.world-chat-delete {
	background: none;
	border: none;
	color: var(--text-dim);
	opacity: 0.5;
	cursor: pointer;
	font-size: 11px;
	padding: 2px 0;
	align-self: flex-end;
}

.world-chat-delete:hover {
	opacity: 1;
	color: #ff6b6b;
}

#world-chat-form {
	display: flex;
	gap: 6px;
}

#world-chat-input {
	flex: 1;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 13px;
}

#world-chat-form button {
	background: var(--accent);
	color: var(--accent-contrast, #fff);
	border: 1px solid var(--accent);
	border-radius: 6px;
	padding: 6px 12px;
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
}

.changelog-item {
	padding: 10px 0;
	border-bottom: 1px solid var(--border);
}

.changelog-item:last-child {
	border-bottom: none;
}

.changelog-item-title {
	margin: 0;
	font-size: 13px;
	color: var(--text);
}

.changelog-item-time {
	font-size: 11px;
	color: var(--text-dim);
}

.changelog-item-text {
	margin: 4px 0 0;
	font-size: 12px;
	color: var(--text-dim);
	white-space: pre-wrap;
}

#apps-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 226px;
	width: 320px;
	max-height: 70vh;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

#apps-hint {
	font-size: 11px;
	color: var(--text-dim);
	padding: 10px 12px;
	margin: 0;
	border-bottom: 1px solid var(--border);
}

#apps-grid {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 10px;
	overflow-y: auto;
	flex: 1;
	min-height: 0;
}

.apps-group-heading {
	margin: 10px 0 2px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	color: var(--text-dim);
}

.apps-group-heading:first-child {
	margin-top: 0;
}

.apps-subgrid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}

.app-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 8px 4px;
}

.app-card-open {
	background: none;
	border: none;
	color: var(--text);
	cursor: pointer;
	font-family: inherit;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	width: 100%;
	padding: 4px 0;
}

.app-card-icon {
	width: 28px;
	height: 28px;
	border-radius: 8px;
	background: var(--accent);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 13px;
	font-weight: 700;
	overflow: hidden;
}

.app-card-logo {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.app-card-icon.light-icon-bg {
	background: #f2f2f5;
}

.app-card-icon.light-icon-bg .app-card-logo {
	object-fit: contain;
	padding: 4px;
	box-sizing: border-box;
}

.app-card-name {
	font-size: 11px;
	color: var(--text);
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.app-card-status {
	font-size: 9px;
	color: var(--text-dim);
	margin-top: 2px;
}

.app-card-status.saved {
	color: #4ade80;
}

.app-card-forget {
	position: absolute;
	top: 2px;
	right: 2px;
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	font-size: 10px;
	opacity: 0;
	padding: 2px;
	border-radius: 4px;
}

#games-panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

#games-hint {
	font-size: 12px;
	color: var(--text-dim);
	padding: 12px 20px 0;
	margin: 0;
}

#games-search {
	margin: 12px 20px;
	padding: 8px 12px;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	font-family: inherit;
	font-size: 13px;
}

#games-search:focus {
	outline: none;
	border-color: var(--accent);
}

#games-grid {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 0 20px 20px;
}

.games-empty {
	color: var(--text-dim);
	font-size: 13px;
	text-align: center;
	padding: 24px 0;
}

.games-group-heading {
	margin: 16px 0 8px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	color: var(--text-dim);
}

.games-group-heading:first-child {
	margin-top: 0;
}

.games-subgrid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 10px;
}

.game-card {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px 8px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	font-family: inherit;
	color: var(--text);
	transition: border-color 0.15s, transform 0.1s;
}

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

.game-card-icon {
	width: 40px;
	height: 40px;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.06);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	line-height: 1;
	overflow: hidden;
	flex-shrink: 0;
}

.game-card-logo {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 6px;
	box-sizing: border-box;
}

.game-card-name {
	font-weight: 600;
	font-size: 12px;
	text-align: center;
}

body.mobile-ui .games-subgrid {
	grid-template-columns: repeat(3, 1fr);
}

body.mobile-ui #games-grid {
	padding: 0 16px 16px;
}

.app-card:hover .app-card-forget {
	opacity: 0.7;
}

.app-card-forget:hover {
	opacity: 1 !important;
	background: var(--border);
}

/* --- history & bookmarks panel --- */
#history-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 190px;
	width: 300px;
	max-height: 70vh;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	z-index: 40;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.history-tabs {
	display: flex;
	gap: 4px;
	padding: 8px;
	border-bottom: 1px solid var(--border);
}

.history-tab {
	flex: 1;
	padding: 6px;
	border: none;
	border-radius: 6px;
	background: transparent;
	color: var(--text-dim);
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
}

.history-tab.active {
	background: var(--bg);
	color: var(--text);
}

#history-view,
#bookmarks-view {
	overflow-y: auto;
	max-height: 60vh;
	padding: 8px;
}

#history-clear {
	width: 100%;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text-dim);
	border-radius: 6px;
	padding: 6px 0;
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
	margin-bottom: 8px;
}

#history-clear:hover {
	border-color: #ff6b6b;
	color: #ff6b6b;
}

.history-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 6px 8px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 12px;
	color: var(--text);
}

.history-row:hover {
	background: var(--bg);
}

.history-title {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1;
}

.history-time {
	color: var(--text-dim);
	font-size: 11px;
	flex-shrink: 0;
}

#btn-bookmark.active {
	color: #ffd43b;
	border-color: #ffd43b;
}

/* --- admin invite code (inside admin panel) --- */
#admin-invite {
	text-align: left;
}

#admin-invite label {
	display: block;
	color: var(--text-dim);
	font-size: 12px;
	margin-bottom: 4px;
}

.invite-row {
	display: flex;
	gap: 6px;
}

#invite-code-display {
	flex: 1;
	min-width: 0;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: "Courier New", Courier, monospace;
	font-size: 13px;
	letter-spacing: 1px;
}

#invite-regenerate {
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	width: 32px;
	cursor: pointer;
	font-size: 14px;
	flex-shrink: 0;
}

#invite-regenerate:hover {
	border-color: var(--accent);
	color: var(--accent-hover);
}

#invite-hint {
	color: var(--text-dim);
	font-size: 11px;
	margin: 4px 0 0 0;
}

/* --- admin broadcast composer (inside admin panel) --- */
#admin-broadcast {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

#broadcast-text {
	resize: vertical;
	min-height: 50px;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 12px;
}

#broadcast-send {
	background: var(--accent);
	border: none;
	color: #fff;
	border-radius: 6px;
	padding: 6px 0;
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
}

#broadcast-current {
	display: flex;
	flex-direction: column;
	gap: 6px;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 8px;
}

#broadcast-current-text {
	margin: 0;
	font-size: 12px;
	color: var(--text);
	white-space: pre-wrap;
}

#broadcast-clear {
	align-self: flex-start;
	background: none;
	border: 1px solid var(--border);
	color: #ff6b6b;
	border-radius: 6px;
	padding: 4px 10px;
	cursor: pointer;
	font-family: inherit;
	font-size: 11px;
}

#broadcast-clear:hover {
	border-color: #ff6b6b;
	background: color-mix(in srgb, #ff6b6b 10%, transparent);
}

#admin-changelog {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

#changelog-title-input {
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 12px;
}

#changelog-text-input {
	resize: vertical;
	min-height: 50px;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 6px;
	padding: 6px 8px;
	font-family: inherit;
	font-size: 12px;
}

#changelog-post {
	background: var(--accent);
	border: none;
	color: #fff;
	border-radius: 6px;
	padding: 6px 0;
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
}

#admin-changelog-list {
	max-height: 160px;
	overflow-y: auto;
}

.admin-changelog-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 0;
	border-bottom: 1px solid var(--border);
	font-size: 12px;
}

.admin-changelog-row:last-child {
	border-bottom: none;
}

.admin-changelog-row-title {
	color: var(--text);
	word-break: break-word;
}

.admin-changelog-row button {
	background: none;
	border: 1px solid var(--border);
	color: #ff6b6b;
	border-radius: 6px;
	padding: 3px 8px;
	cursor: pointer;
	font-family: inherit;
	font-size: 11px;
	flex-shrink: 0;
}

.admin-changelog-row button:hover {
	border-color: #ff6b6b;
	background: rgba(255, 107, 107, 0.1);
}

/* --- broadcast banner: reserves --banner-h at the very top; everything
   else (tabstrip, toolbar buttons, panels, topbar) is offset by that
   variable so the banner never overlaps them --- */
#broadcast-banner {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 36px;
	box-sizing: border-box;
	background: var(--accent);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 0 16px;
	font-size: 13px;
	z-index: 50;
}

#broadcast-banner-text {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: calc(100% - 40px);
}

#broadcast-banner-dismiss {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
}

/* --- auth overlay: blocks the app until logged in --- */
#auth-overlay {
	position: fixed;
	inset: 0;
	background: var(--bg);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
}

#auth-overlay.hidden {
	display: none !important;
}

#auth-card {
	width: min(300px, 90vw);
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 28px 24px;
	text-align: center;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

#auth-card h1 {
	margin: 0 0 18px 0;
	background: linear-gradient(90deg, var(--accent), #ff5cf1);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.auth-tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 16px;
	background: var(--bg);
	border-radius: 8px;
	padding: 4px;
}

.auth-tab {
	flex: 1;
	padding: 8px;
	border: none;
	border-radius: 6px;
	background: transparent;
	color: var(--text-dim);
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
}

.auth-tab.active {
	background: var(--panel);
	color: var(--text);
}

#auth-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

#auth-form input {
	padding: 10px 12px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
	font-family: inherit;
	font-size: 14px;
}

#auth-submit {
	padding: 10px;
	border-radius: 8px;
	border: none;
	background: var(--accent);
	color: #fff;
	cursor: pointer;
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	margin-top: 4px;
}

#auth-submit:hover {
	background: var(--accent-hover);
}

/* =========================================================
   Mobile view
   ========================================================= */

#mobile-ui-prompt {
	position: fixed;
	left: 12px;
	right: 12px;
	bottom: 12px;
	max-width: 420px;
	margin: 0 auto;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 14px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
	z-index: 200;
}

#mobile-ui-prompt p {
	margin: 0 0 10px 0;
	color: var(--text);
	font-size: 13px;
	line-height: 1.4;
}

#mobile-ui-prompt-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

#mobile-ui-prompt-actions button {
	font-family: inherit;
	font-size: 13px;
	padding: 8px 14px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text-dim);
	cursor: pointer;
}

#mobile-ui-prompt-yes {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}

#mobile-panel-close {
	display: none;
}

#mobile-panel-close-btn {
	width: 100%;
	text-align: left;
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	padding: 12px 14px;
	border: none;
	border-bottom: 1px solid var(--border);
	background: var(--panel);
	color: var(--text);
	cursor: pointer;
}

#mobile-panel-close:not(.hidden) {
	display: block;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 210;
}

body:not(.mobile-ui) #mobile-panel-close:not(.hidden) {
	left: var(--sidebar-w, 64px);
}

body.mobile-ui #auth-card {
	width: min(340px, 92vw);
	padding: 32px 22px;
}

body.mobile-ui #tabstrip {
	height: 50px;
}

body.mobile-ui.has-tabs {
	padding-top: calc(50px + var(--banner-h));
}

body.mobile-ui #tabs-list {
	max-width: 45vw;
}

body.mobile-ui .tab {
	max-width: 120px;
	padding: 8px 8px 8px 12px;
}

body.mobile-ui .tab-title {
	max-width: 70px;
}

/* Sidebar becomes an even, touch-sized bottom nav bar on mobile instead
   of a left rail. */
body.mobile-ui #app-sidebar {
	display: flex;
	position: fixed;
	bottom: 0;
	top: auto;
	left: 0;
	width: 100%;
	height: 58px;
	background: var(--panel);
	border-top: 1px solid var(--border);
	border-right: none;
	z-index: 50;
}

body.mobile-ui #sidebar-header,
body.mobile-ui #sidebar-footer {
	display: none;
}

body.mobile-ui #sidebar-nav {
	flex-direction: row;
	justify-content: space-around;
	align-items: center;
	padding: 0 4px;
	width: 100%;
	overflow-x: auto;
	overflow-y: hidden;
}

body.mobile-ui .sidebar-item {
	flex-direction: column;
	justify-content: center;
	gap: 2px;
	width: 44px;
	height: 50px;
	padding: 0;
	flex-shrink: 0;
}

body.mobile-ui .sidebar-item span {
	opacity: 1;
	font-size: 8px;
}

body.mobile-ui .sidebar-item svg {
	width: 20px;
	height: 20px;
}

body.mobile-ui .sidebar-item.active::before {
	display: none;
}

body.mobile-ui #home-title {
	margin-top: 8vh;
	padding: 0 16px;
}

/* Topbar: nav buttons wrap onto their own row above the full-width
   address bar, instead of everything crammed into one line. */
body.mobile-ui #topbar {
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 10px;
}

body.mobile-ui #uv-form {
	width: 100%;
	max-width: none;
	order: 2;
	flex: 1 1 100%;
}

body.mobile-ui #uv-search-engine {
	height: 42px;
	padding: 0 10px;
	font-size: 13px;
}

body.mobile-ui #uv-address {
	height: 42px;
	font-size: 14px;
}

body.mobile-ui #uv-go {
	height: 42px;
	padding: 0 16px;
}

body.mobile-ui .nav-btn {
	width: 42px;
	height: 42px;
}

body.mobile-ui.browsing #topbar {
	top: calc(50px + var(--banner-h));
	padding-bottom: 8px;
}

body.mobile-ui.browsing .tab-frame.active {
	top: calc(158px + var(--banner-h));
	height: calc(100vh - 158px - var(--banner-h) - 58px);
}

/* Sidebar categories act like real pages, not small floating boxes --
   applies on desktop too, not just mobile (mobile's own rule below wins
   there via higher specificity). */
#settings-panel,
#account-panel,
#messages-panel,
#feedback-panel,
#admin-panel,
#history-panel,
#apps-panel,
#games-panel,
#changelog-panel,
#world-chat-panel,
#leaderboard-panel,
#friends-panel {
	position: fixed;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: var(--sidebar-w, 64px);
	width: auto;
	height: 100%;
	max-height: 100%;
	border-radius: 0;
	border: none;
	z-index: 90;
	padding-top: 46px;
	box-sizing: border-box;
}

/* Panels become full-screen sheets instead of small floating boxes
   pinned at desktop-only pixel offsets. */
body.mobile-ui #settings-panel,
body.mobile-ui #account-panel,
body.mobile-ui #messages-panel,
body.mobile-ui #feedback-panel,
body.mobile-ui #admin-panel,
body.mobile-ui #history-panel,
body.mobile-ui #apps-panel,
body.mobile-ui #games-panel,
body.mobile-ui #changelog-panel,
body.mobile-ui #world-chat-panel {
	position: fixed;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-height: 100%;
	border-radius: 0;
	border: none;
	z-index: 90;
	padding-top: 46px;
	box-sizing: border-box;
}

body.mobile-ui #messages-conversation {
	padding-top: 0;
}

body.mobile-ui #apps-grid {
	padding: 16px;
}

body.mobile-ui .apps-subgrid {
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}

body.mobile-ui .app-card {
	padding: 14px 8px;
}

body.mobile-ui .app-card-icon {
	width: 40px;
	height: 40px;
	font-size: 17px;
}

body.mobile-ui .app-card-name {
	font-size: 13px;
}

body.mobile-ui #history-view,
body.mobile-ui #bookmarks-view,
body.mobile-ui #admin-panel,
body.mobile-ui #feedback-panel,
body.mobile-ui #account-panel {
	max-height: none;
}

body.mobile-ui #messages-thread-list,
body.mobile-ui #messages-list {
	max-height: none;
}

#auth-error {
	color: #ff6b6b;
	font-size: 13px;
	min-height: 16px;
	margin: 12px 0 0 0;
}

#request-access-link {
	background: none;
	border: none;
	color: var(--text-dim);
	font-size: 12px;
	cursor: pointer;
	margin-top: 14px;
	font-family: inherit;
	text-decoration: underline;
}

#request-access-link:hover {
	color: var(--text);
}

#request-access-overlay {
	position: fixed;
	inset: 0;
	background: var(--bg);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
}

#request-access-overlay.hidden {
	display: none !important;
}

#request-access-card {
	width: min(320px, 90vw);
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 28px 24px;
	text-align: center;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

#request-access-card h2 {
	margin: 0 0 16px 0;
	font-size: 18px;
	color: var(--text);
}

#request-access-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

#request-access-form input,
#request-access-form textarea {
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	border-radius: 8px;
	padding: 10px 12px;
	font-family: inherit;
	font-size: 14px;
	resize: vertical;
}

#request-access-message {
	font-size: 13px;
	min-height: 16px;
	margin: 12px 0 0 0;
}

#request-access-message.error {
	color: #ff6b6b;
}

#request-access-message.success {
	color: #3ecf6e;
}

#request-access-close {
	background: none;
	border: none;
	color: var(--text-dim);
	font-size: 12px;
	cursor: pointer;
	margin-top: 14px;
	font-family: inherit;
	text-decoration: underline;
}

#request-access-close:hover {
	color: var(--text);
}

.message-toasts {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 500;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: 320px;
}

.message-toast {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 12px 14px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
	cursor: pointer;
	animation: message-toast-in 0.2s ease-out;
}

.message-toast-out {
	animation: message-toast-out 0.2s ease-in forwards;
}

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

@keyframes message-toast-out {
	to {
		opacity: 0;
		transform: translateY(8px);
	}
}

.message-toast-icon {
	font-size: 18px;
	line-height: 1;
	margin-top: 1px;
}

.message-toast-body {
	flex: 1;
	min-width: 0;
}

.message-toast-title {
	font-weight: 600;
	font-size: 13px;
	color: var(--text);
}

.message-toast-preview {
	font-size: 12px;
	color: var(--text-dim);
	margin-top: 2px;
	overflow-wrap: break-word;
}

.message-toast-close {
	background: transparent;
	border: none;
	color: var(--text-dim);
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	padding: 0 2px;
}

.message-toast-close:hover {
	color: var(--text);
}
