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

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

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;
	background: linear-gradient(90deg, var(--accent), #ff5cf1);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

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

/* --- tab strip: hidden until the first tab exists --- */
#tabstrip {
	position: fixed;
	top: var(--banner-h);
	left: 0;
	width: 100%;
	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-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);
}

#settings-btn {
	position: fixed;
	top: calc(7px + var(--banner-h));
	right: 10px;
	z-index: 35;
}

#messages-btn {
	position: fixed;
	top: calc(7px + var(--banner-h));
	right: 82px;
	z-index: 35;
}

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

#feedback-btn {
	position: fixed;
	top: calc(7px + var(--banner-h));
	right: 118px;
	z-index: 35;
}

#admin-btn {
	position: fixed;
	top: calc(7px + var(--banner-h));
	right: 154px;
	z-index: 35;
}

/* --- settings dropdown --- */
#settings-panel {
	position: fixed;
	top: calc(50px + var(--banner-h));
	right: 10px;
	width: 230px;
	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);
}

.settings-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 12px;
	gap: 10px;
}

.settings-row label {
	color: var(--text-dim);
	font-size: 13px;
}

.settings-row select {
	background: var(--bg);
	color: var(--text);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 4px 8px;
	font-family: inherit;
}

.settings-row input[type="color"] {
	width: 36px;
	height: 26px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: none;
	cursor: pointer;
	padding: 0;
}

#settings-reset {
	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;
}

#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: 0;
	width: 100%;
	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: 0;
	width: 100vw;
	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;
}

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

#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-btn {
	position: fixed;
	top: calc(7px + var(--banner-h));
	right: 46px;
	z-index: 35;
}

#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: 12px;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
	padding: 2px;
	border-radius: 4px;
}

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

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

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

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

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

.message-thread-name {
	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: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--accent);
	margin-right: 6px;
}

#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-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-delete-thread {
	background: none;
	border: none;
	color: var(--text-dim);
	cursor: pointer;
	font-size: 14px;
	opacity: 0;
	transition: opacity 0.1s ease;
}

#messages-conversation-header:hover #messages-delete-thread {
	opacity: 0.7;
}

#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-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: 300px;
	max-height: 70vh;
	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);
	text-align: left;
}

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

#admin-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-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 0;
	border-bottom: 1px solid var(--border);
	font-size: 13px;
}

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

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

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

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

/* --- 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 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: 300px;
	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);
}

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