body:after {
	background-image: url('/noise.png');
	content: ' ';
	position: fixed;
	left: 0;
	bottom: 0;
	right: 0;
	top: 0;
	z-index: 99;
	pointer-events: none;
	opacity: 0.9; /* Reduzindo a opacidade do noise para o glow aparecer melhor */
	/* camada própria na GPU: sem isso a textura (tela inteira, por cima de tudo) era
	   recomposta a cada quadro da rolagem e travava o scroll rápido */
	transform: translateZ(0);
	will-change: transform;
}
:root {
	box-sizing: border-box;
	--safe-bottom: env(safe-area-inset-bottom, 0px);
	/* altura única da linha do composer: +, campo de texto, gravador, descartar e enviar/mic */
	--composer-h: 42px;

	--background: oklch(1 0 0);
	--foreground: oklch(0.145 0 0);
	--card: oklch(1 0 0);
	--card-foreground: oklch(0.145 0 0);
	--popover: oklch(1 0 0);
	--popover-foreground: oklch(0.145 0 0);
	--primary: var(--brand-light);
	--primary-foreground: var(--brand-fg);
	--secondary: oklch(0.967 0.001 286.375);
	--secondary-foreground: oklch(0.21 0.006 285.885);
	--muted-bg: oklch(0.97 0 0);
	--muted-foreground: oklch(0.556 0 0);
	--accent-bg: oklch(0.97 0 0);
	--accent-foreground: oklch(0.205 0 0);
	--destructive: oklch(0.577 0.245 27.325);
	--border-color: oklch(0.922 0 0);
	--input: oklch(0.922 0 0);
	--ring: oklch(0.708 0 0);
	--chart-1: oklch(0.809 0.105 251.813);
	--chart-2: var(--brand-2);
	--chart-3: var(--brand-3);
	--chart-4: oklch(0.488 0.243 264.376);
	--chart-5: oklch(0.424 0.199 265.638);
	--radius: 0.625rem;

	--bg: var(--background);
	--surface: var(--card);
	--surface-2: var(--secondary);
	--text: var(--foreground);
	--muted: var(--muted-foreground);
	--border: var(--border-color);
	--accent: var(--primary);
	--accent-2: var(--chart-3);
	--bubble-me: var(--primary);
	--bubble-me-text: var(--primary-foreground);
	--bubble-other: var(--card);
	--bubble-other-text: var(--card-foreground);
	--danger: var(--destructive);
	--shadow: 0 6px 20px rgba(36, 31, 24, 0.08);

	--chat-bg: oklch(0.955 0.008 var(--brand-h));
	--chat-doodle: oklch(0.45 0.06 var(--brand-h) / 0.09);

	/* cor principal (data-accent no <html>); sem escolha fica o azul. Cada cor
	   define o próprio primary claro/escuro porque o mesmo L/C não serve para
	   todo matiz; --brand-h só tinge o fundo do chat, que tem pouca saturação */
	--brand-h: 264;
	--brand-light: oklch(0.488 0.243 264.376);
	--brand-dark: oklch(0.424 0.199 265.638);
	--brand-fg: oklch(0.97 0.014 254.604);
	--brand-2: oklch(0.623 0.214 259.815);
	--brand-3: oklch(0.546 0.245 262.881);
	--audio-icon: oklch(0.63 0.17 150);
	--game-icon: oklch(0.65 0.17 45);
}
:root[data-accent='violet'] {
	--brand-h: 293;
	--brand-light: oklch(0.541 0.281 293.009);
	--brand-dark: oklch(0.491 0.27 292.581);
	--brand-fg: oklch(0.969 0.016 293.756);
	--brand-2: oklch(0.606 0.25 292.717);
	--brand-3: oklch(0.541 0.281 293.009);
}
:root[data-accent='green'] {
	--brand-h: 152;
	--brand-light: oklch(0.527 0.154 150.069);
	--brand-dark: oklch(0.448 0.119 151.328);
	--brand-fg: oklch(0.982 0.018 155.826);
	--brand-2: oklch(0.627 0.194 149.214);
	--brand-3: oklch(0.627 0.194 149.214);
	/* o microfone de áudio novo já é verde: aqui vira azul para não sumir no tema */
	--audio-icon: oklch(0.623 0.214 259.815);
}
:root[data-accent='pink'] {
	--brand-h: 0;
	/* rosa escurecido: no tom 500 o branco da bolha e a onda do áudio ficavam sem contraste */
	--brand-light: oklch(0.52 0.22 2);
	--brand-dark: oklch(0.459 0.187 3.815);
	--brand-fg: oklch(0.971 0.014 343.198);
	--brand-2: oklch(0.656 0.241 354.308);
	--brand-3: oklch(0.592 0.249 0.584);
}
:root[data-accent='orange'] {
	--brand-h: 40;
	--brand-light: oklch(0.553 0.195 38.402);
	--brand-dark: oklch(0.47 0.157 37.304);
	--brand-fg: oklch(0.98 0.016 73.684);
	--brand-2: oklch(0.705 0.213 47.604);
	--brand-3: oklch(0.646 0.222 41.116);
}
:root[data-accent='bordeaux'] {
	--brand-h: 18;
	--brand-light: oklch(0.44 0.15 18);
	--brand-dark: oklch(0.4 0.13 18);
	--brand-fg: oklch(0.97 0.015 18);
	--brand-2: oklch(0.57 0.17 18);
	--brand-3: oklch(0.52 0.17 18);
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) {
		--background: oklch(0.12 0 0);
		--foreground: oklch(0.985 0 0);
		--card: oklch(0.175 0 0);
		--card-foreground: oklch(0.985 0 0);
		--popover: oklch(0.175 0 0);
		--popover-foreground: oklch(0.985 0 0);
		--primary: var(--brand-dark);
		--secondary: oklch(0.24 0.006 286.033);
		--secondary-foreground: oklch(0.985 0 0);
		--muted-bg: oklch(0.235 0 0);
		--muted-foreground: oklch(0.708 0 0);
		--accent-bg: oklch(0.235 0 0);
		--accent-foreground: oklch(0.985 0 0);
		--destructive: oklch(0.704 0.191 22.216);
		--border-color: oklch(1 0 0 / 10%);
		--input: oklch(1 0 0 / 15%);
		--ring: oklch(0.556 0 0);

		--shadow: 0 6px 24px rgba(0, 0, 0, 0.4);

		--chat-bg: oklch(0.14 0.006 var(--brand-h));
		--chat-doodle: oklch(1 0 0 / 0.05);
	}
}
:root[data-theme='dark'],
:root[data-theme='amoled'] {
	--background: oklch(0.12 0 0);
	--foreground: oklch(0.985 0 0);
	--card: oklch(0.175 0 0);
	--card-foreground: oklch(0.985 0 0);
	--popover: oklch(0.175 0 0);
	--popover-foreground: oklch(0.985 0 0);
	--primary: var(--brand-dark);
	--secondary: oklch(0.24 0.006 286.033);
	--secondary-foreground: oklch(0.985 0 0);
	--muted-bg: oklch(0.235 0 0);
	--muted-foreground: oklch(0.708 0 0);
	--accent-bg: oklch(0.235 0 0);
	--accent-foreground: oklch(0.985 0 0);
	--destructive: oklch(0.704 0.191 22.216);
	--border-color: oklch(1 0 0 / 10%);
	--input: oklch(1 0 0 / 15%);
	--ring: oklch(0.556 0 0);

	--shadow: 0 6px 24px rgba(0, 0, 0, 0.4);

	--chat-bg: oklch(0.14 0.006 var(--brand-h));
	--chat-doodle: oklch(1 0 0 / 0.05);
}
/* AMOLED: o escuro acima com fundo preto puro (pixel apagado na tela OLED).
   Balões, menus e campos ficam um pouco acima do preto para não sumirem */
:root[data-theme='amoled'] {
	--background: oklch(0 0 0);
	--card: oklch(0.14 0 0);
	--popover: oklch(0.14 0 0);
	--secondary: oklch(0.2 0.006 286.033);
	--muted-bg: oklch(0.2 0 0);
	--accent-bg: oklch(0.2 0 0);
	--border-color: oklch(1 0 0 / 12%);

	--shadow: 0 6px 24px rgba(0, 0, 0, 0.8);

	--chat-bg: oklch(0 0 0);
	/* mesma cor do escuro, mais opaca: sobre o preto puro os 5% quase somem */
	--chat-doodle: oklch(1 0 0 / 0.1);
}
/* o grão do fundo acenderia os pixels pretos */
:root[data-theme='amoled'] body:after {
	display: none;
}

html {
	height: 100dvh;
	overflow: hidden;
}
* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}
body {
	margin: 0;
	height: 100dvh;
	background: var(--bg);
	color: var(--text);
	font-family:
		'Inter',
		-apple-system,
		BlinkMacSystemFont,
		'Segoe UI',
		sans-serif;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
h1,
h2,
h3 {
	font-family: 'Space Grotesk', 'Inter', sans-serif;
}
#app {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.screen {
	display: flex;
	flex-direction: column;
	height: 100%;
}
.landing {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 20px;
	overflow-y: auto;
	background: var(--chat-bg);
}
.card {
	position: relative;
	width: 100%;
	max-width: 380px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 20px;
	padding: 28px 24px;
	box-shadow: var(--shadow);
}

.field {
	margin-bottom: 14px;
}
.field label {
	display: block;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--muted);
	margin-bottom: 6px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}
input[type='text'],
input[type='password'] {
	width: 100%;
	padding: 12px 14px;
	border-radius: 12px;
	border: 1.5px solid var(--border);
	background: var(--surface-2);
	color: var(--text);
	font-size: 15px;
	font-family: inherit;
	outline: none;
	transition: border-color 0.15s ease;
}
input:focus {
	border-color: var(--accent);
}

.btn {
	width: 100%;
	padding: 13px 16px;
	border-radius: 12px;
	border: none;
	font-size: 15px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition:
		transform 0.08s ease,
		opacity 0.15s ease;
}
.btn:active {
	transform: scale(0.98);
}
.btn-primary {
	background: var(--accent);
	color: var(--primary-foreground);
}
.btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.error-box {
	background: rgba(179, 64, 47, 0.1);
	border: 1px solid var(--danger);
	color: var(--danger);
	padding: 10px 12px;
	border-radius: 10px;
	font-size: 13px;
	margin-bottom: 14px;
}
.pw-wrap {
	position: relative;
}
.pw-wrap input {
	padding-right: 44px;
}
.pw-eye {
	position: absolute;
	right: 4px;
	top: 50%;
	transform: translateY(-50%);
	width: 34px;
	height: 34px;
	border: none;
	background: transparent;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: var(--muted);
	padding: 0;
}
.pw-eye:active {
	background: var(--surface-2);
}

.chat-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
	position: relative;
}
.chat-header .room-info {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 8px;
}
.chat-header .room-name {
	font-weight: 700;
	font-size: 15.5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-family: 'Space Grotesk', monospace;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}
.status-pill {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 11.5px;
	color: var(--muted);
	background: var(--surface-2);
	border-radius: 999px;
	padding: 4px 10px;
	flex-shrink: 0;
	user-select: none;
}
.status-pill.hidden {
	display: none;
}
.online-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--accent-2);
	display: inline-block;
	flex-shrink: 0;
}
.status-pill:not(.offline) .online-dot {
	animation: pulse 1.6s ease-in-out infinite;
}
/* sem conexão: o ponto fica âmbar na hora; o texto só vira "Reconectando" depois de
   uns segundos (presence.js). Mesmo tamanho sempre. O toque tenta reconectar na hora */
.status-pill.offline {
	cursor: pointer;
}
.status-pill.offline .online-dot {
	background: oklch(0.75 0.15 70);
}
.status-pill .online-dot {
	transition: background-color 0.3s ease;
}
@keyframes pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.35;
	}
}
.icon-btn {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 10px;
	width: 38px;
	height: 38px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: var(--text);
	flex-shrink: 0;
	padding: 0;
}
.icon-btn:active {
	transform: scale(0.94);
}

.options-wrap {
	position: relative;
	flex-shrink: 0;
}
.options-menu {
	display: none;
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 20;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 12px 14px;
	box-shadow: var(--shadow);
	min-width: 160px;
	text-align: left;
}
.options-menu.show {
	display: block;
}
.options-menu .menu-section-label {
	font-size: 10.5px;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin-bottom: 8px;
}
.options-menu .menu-section {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid var(--border);
}
.options-menu .accent-picker {
	display: flex;
	gap: 8px;
	padding: 2px;
}
.options-menu .accent-swatch {
	width: 22px;
	height: 22px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	flex-shrink: 0;
	background: var(--swatch);
	transition: box-shadow 0.15s;
}
/* anel de seleção: uma folga da cor do menu e o anel na cor do texto */
.options-menu .accent-swatch[aria-checked='true'] {
	box-shadow:
		0 0 0 2px var(--surface),
		0 0 0 4px var(--text);
}
.options-menu .you-row {
	display: flex;
	align-items: center;
	gap: 8px;
}
.options-menu .you-name {
	font-weight: 600;
	font-size: 14px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.options-menu .you-tag {
	margin-left: auto;
	font-size: 11.5px;
	color: var(--muted);
}
.options-menu .online-list:empty {
	display: none;
}
.options-menu .online-list {
	margin-top: 8px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 180px;
	overflow-y: auto;
}
.options-menu .online-row {
	display: flex;
	align-items: center;
	gap: 8px;
}
.options-menu .online-row .msg-avatar {
	position: relative;
}
.options-menu .online-name {
	font-size: 13.5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.options-menu .online-dot-small {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #3ecf6c;
	flex-shrink: 0;
}
.options-menu .theme-picker {
	display: flex;
	padding: 2px;
	border-radius: 9px;
	background: var(--surface-2);
	border: 1px solid var(--border);
}
.options-menu .theme-option {
	flex: 1;
	padding: 5px 8px;
	border: 0;
	border-radius: 7px;
	background: none;
	color: var(--muted);
	font: inherit;
	font-size: 12.5px;
	white-space: nowrap;
	cursor: pointer;
	transition:
		background 0.15s,
		color 0.15s;
}
.options-menu .theme-option[aria-checked='true'] {
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.messages-wrap {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	background: var(--chat-bg);
}
/* Padrao de doodles estilo WhatsApp: fica parado enquanto as mensagens rolam.
   A tela de entrada usa o mesmo fundo, com o cartão por cima */
.messages-wrap::before,
.landing::before {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: var(--chat-doodle);
	-webkit-mask: url('/chat-pattern.svg') 0 0 / 260px 260px repeat;
	mask: url('/chat-pattern.svg') 0 0 / 260px 260px repeat;
	/* fica parado: pinta uma vez numa camada própria, em vez de reaplicar a máscara a
	   cada quadro enquanto as mensagens rolam por cima */
	transform: translateZ(0);
	will-change: transform;
}
.messages {
	position: relative;
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.scroll-bottom-btn {
	position: absolute;
	right: 16px;
	bottom: 16px;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: none;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: var(--shadow);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	transition: opacity 0.15s ease, transform 0.15s ease;
}
.scroll-bottom-btn:active {
	transform: scale(0.92);
}
.scroll-bottom-btn.hidden {
	opacity: 0;
	pointer-events: none;
	transform: scale(0.85);
}
.msg-row {
	display: flex;
	margin-bottom: 10px;
	max-width: 100%;
	gap: 7px;
	align-items: flex-end;
}
.msg-row.grouped {
	margin-bottom: 2px;
}
/* separador de dias: vai dentro da primeira linha do dia, ocupando a largura toda
   (o wrap joga o avatar e o balão para baixo dele) */
.msg-row:has(> .day-sep) {
	flex-wrap: wrap;
}
.day-sep {
	flex: 0 0 100%;
	display: flex;
	justify-content: center;
	margin: 8px 0 6px;
	pointer-events: none;
}
.day-sep span {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--muted);
	background: var(--bubble-other);
	border: 1px solid var(--border);
	padding: 4px 11px;
	border-radius: 8px;
	box-shadow: 0 1px 1px rgb(0 0 0 / 0.06);
}
.msg-row.me {
	justify-content: flex-end;
}
.msg-avatar-slot {
	width: 26px;
	flex-shrink: 0;
}
.msg-avatar {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	flex-shrink: 0;
	object-fit: cover;
	background: var(--secondary);
}
.msg-group {
	max-width: 74%;
	display: flex;
	flex-direction: column;
	position: relative;
}
.msg-author {
	font-size: 11.5px;
	color: var(--muted);
	margin: 0 2px 3px;
	font-weight: 600;
}
.bubble-wrap {
	position: relative;
}
.bubble {
	padding: 9px 13px;
	border-radius: 16px;
	font-size: 14.5px;
	line-height: 1.4;
	word-wrap: break-word;
	white-space: pre-wrap;
	cursor: pointer;
}
.msg-row:not(.me) .bubble {
	background: var(--bubble-other);
	color: var(--bubble-other-text);
	border: 1px solid var(--border);
	border-top-left-radius: 5px;
}
.msg-row.me .bubble {
	background: var(--bubble-me);
	color: var(--bubble-me-text);
	border-top-right-radius: 5px;
}
.msg-time {
	font-size: 10.5px;
	color: var(--muted);
	margin-top: 2px;
	padding: 0 3px;
	display: flex;
	align-items: center;
	gap: 3px;
}
.msg-row.me .msg-time {
	justify-content: flex-end;
}
.msg-group.has-reactions .msg-time {
	margin-top: 10px;
}
.msg-row.grouped .msg-time {
	display: none;
}
.msg-row.grouped.show-time .msg-time {
	display: flex;
	margin-top: 2px;
}
.ticks {
	display: inline-flex;
	color: var(--muted);
}
.ticks.seen {
	color: var(--accent);
}
.msg-row.sending .bubble,
.msg-row.queued .bubble {
	opacity: 0.6;
}
.queued-icon {
	display: inline-flex;
	color: var(--muted);
}
/* contorno por dentro (box-shadow), não borda: o balão não cresce quando o envio falha */
.msg-row.send-failed .bubble {
	box-shadow: inset 0 0 0 1px var(--danger);
	cursor: pointer;
}
.send-failed-label {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	color: var(--danger);
	cursor: pointer;
}

.typing-indicator {
	position: absolute;
	left: 0;
	right: 0;
	bottom: calc(100% + 6px);
	font-size: 12px;
	color: var(--muted);
	padding: 0 16px;
	font-style: italic;
	pointer-events: none;
	text-shadow:
		0 1px 2px var(--chat-bg),
		0 -1px 2px var(--chat-bg);
}
.typing-indicator.hidden {
	display: none;
}
.msg-group.has-reactions .bubble-wrap {
	margin-bottom: 14px;
}

.reactions-bar {
	position: absolute;
	bottom: -8px;
	display: flex;
	gap: 2px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 2px 5px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
	z-index: 2;
}
.msg-row.me .reactions-bar {
	right: 6px;
}
.msg-row:not(.me) .reactions-bar {
	left: 6px;
}
.reaction-chip {
	display: flex;
	align-items: center;
	gap: 2px;
	font-size: 12px;
	cursor: pointer;
	user-select: none;
	line-height: 1;
}
.reaction-chip .count {
	font-size: 10.5px;
	font-weight: 700;
	color: var(--muted);
}
.reaction-chip.mine .count {
	color: var(--accent);
}

.reaction-picker {
	display: none;
	gap: 2px;
	padding: 6px 7px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	box-shadow: var(--shadow);
	position: absolute;
	z-index: 5;
	bottom: calc(100% + 10px);
	transform-origin: bottom center;
}
.msg-row.me .reaction-picker {
	right: 0;
}
.msg-row:not(.me) .reaction-picker {
	left: 0;
}
.reaction-picker.show {
	display: flex;
	animation: popIn 0.12s ease-out;
}
@keyframes popIn {
	from {
		transform: scale(0.85);
		opacity: 0;
	}
	to {
		transform: scale(1);
		opacity: 1;
	}
}
.reaction-picker button {
	background: none;
	border: none;
	font-size: 20px;
	cursor: pointer;
	padding: 4px;
	line-height: 1;
	border-radius: 50%;
	transition:
		transform 0.1s ease,
		background 0.1s ease;
}
.reaction-picker button:active {
	transform: scale(1.25);
	background: var(--surface-2);
}
.reaction-picker .picker-sep {
	width: 1px;
	align-self: stretch;
	margin: 2px 1px;
	background: var(--border);
}
.reaction-picker button.picker-action {
	font-size: 15px;
	border-radius: 999px;
	padding: 4px 9px;
	display: inline-flex;
	align-items: center;
	color: var(--muted);
}
.reaction-picker button.picker-action:active {
	color: var(--accent-foreground);
}
.reaction-picker button.picker-action svg {
	display: block;
}

.reply-quote {
	display: flex;
	flex-direction: column;
	gap: 1px;
	padding: 5px 9px;
	margin-bottom: 4px;
	border-left: 3px solid var(--accent);
	border-radius: 6px;
	background: color-mix(in oklch, var(--accent) 10%, transparent);
	cursor: pointer;
	max-width: 100%;
}
.reply-quote .reply-author {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--accent);
}
.reply-quote .reply-text {
	font-size: 12.5px;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.msg-row.highlight .bubble {
	animation: highlightFlash 1.2s ease-out;
}
@keyframes highlightFlash {
	0% {
		box-shadow: 0 0 0 3px var(--accent);
	}
	100% {
		box-shadow: 0 0 0 0 transparent;
	}
}
.edited-label {
	font-style: italic;
}

.composer-context {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 100%;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	background: var(--surface);
	border-top: 1px solid var(--border);
	border-left: 3px solid var(--accent);
}
.composer-context.hidden {
	display: none;
}
.composer-context .ctx-body {
	flex: 1;
	min-width: 0;
}
.composer-context .ctx-title {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--accent);
}
.composer-context .ctx-text {
	font-size: 12.5px;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.composer-context .ctx-close {
	background: none;
	border: none;
	color: var(--muted);
	cursor: pointer;
	padding: 4px;
	line-height: 1;
}

.empty-state {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	color: var(--muted);
	padding: 30px;
	gap: 6px;
}
.empty-state .big {
	font-size: 34px;
}

.composer {
	position: relative;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px calc(10px + var(--safe-bottom));
	background: var(--surface);
	border-top: 1px solid var(--border);
	flex-shrink: 0;
}
.composer textarea {
	flex: 1;
	resize: none;
	min-height: var(--composer-h);
	max-height: 100px;
	/* line-height 1.4 * 14.5px ≈ 20px de texto: o padding completa os 42px com a borda */
	padding: 9.5px 14px;
	border-radius: 16px;
	border: 1.5px solid var(--border);
	background: var(--surface-2);
	color: var(--text);
	font-family: inherit;
	font-size: 14.5px;
	outline: none;
	line-height: 1.4;
	overflow-y: hidden;
}
.composer textarea:focus {
	border-color: var(--accent);
}
.send-btn {
	width: var(--composer-h);
	height: var(--composer-h);
	border-radius: 50%;
	background: var(--accent);
	color: var(--primary-foreground);
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	cursor: pointer;
	padding: 0;
}
.send-btn:active {
	transform: scale(0.92);
}
.send-btn:disabled {
	opacity: 0.4;
}
/* campo vazio: o botão vira o microfone (estilo WhatsApp) */
.send-btn .icon-mic,
.send-btn.mic-mode .icon-send {
	display: none;
}
.send-btn.mic-mode .icon-mic {
	display: block;
}
/* mesmo tamanho de ícone em todos os botões redondos do composer */
.composer .send-btn svg,
.composer .icon-btn svg {
	width: 20px;
	height: 20px;
}
.icon-btn {
	width: var(--composer-h);
	height: var(--composer-h);
	border-radius: 50%;
	background: transparent;
	color: var(--muted);
	border: 1.5px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	cursor: pointer;
	padding: 0;
}
.icon-btn:active {
	transform: scale(0.92);
}
.icon-btn:hover {
	color: var(--accent);
	border-color: var(--accent);
}

/* ---- botão "+" do composer: menu com foto e jogos ---- */
.attach-wrap {
	position: relative;
	flex-shrink: 0;
}
.attach-btn svg {
	transition: transform 0.15s ease;
}
.attach-wrap:has(.attach-menu.show) .attach-btn {
	color: var(--accent);
	border-color: var(--accent);
}
.attach-wrap:has(.attach-menu.show) .attach-btn svg {
	transform: rotate(45deg);
}
.attach-menu {
	display: none;
	position: absolute;
	left: 0;
	bottom: calc(100% + 10px);
	z-index: 20;
	flex-direction: column;
	gap: 2px;
	min-width: 220px;
	padding: 6px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	box-shadow: var(--shadow);
	transform-origin: bottom left;
}
.attach-menu.show {
	display: flex;
	animation: popIn 0.12s ease-out;
}
.attach-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px 10px;
	border: none;
	border-radius: 10px;
	background: none;
	color: var(--text);
	font-family: inherit;
	text-align: left;
	cursor: pointer;
}
.attach-item:hover,
.attach-item:active {
	background: var(--surface-2);
}
.attach-icon {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: #fff;
}
.attach-icon.photo {
	background: var(--chart-2);
}
/* no desktop "capture" é ignorado e viraria um segundo seletor de arquivos */
@media (hover: hover) and (pointer: fine) {
	.attach-camera {
		display: none;
	}
}
.attach-icon.game {
	background: var(--game-icon);
}
.attach-icon.sticker {
	background: var(--accent);
	color: var(--primary-foreground);
}
.attach-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}
.attach-chevron {
	flex-shrink: 0;
	color: var(--muted);
}
/* submenu de jogos: substitui o menu do "+" no mesmo lugar */
.attach-back {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 6px 8px 8px;
	margin-bottom: 2px;
	border: none;
	border-bottom: 1px solid var(--border);
	border-radius: 0;
	background: none;
	color: var(--muted);
	font-family: inherit;
	font-size: 12.5px;
	font-weight: 600;
	text-align: left;
	cursor: pointer;
}
.attach-back:hover {
	color: var(--text);
}
.attach-title {
	font-size: 14px;
	font-weight: 600;
}
.attach-sub {
	font-size: 11.5px;
	color: var(--muted);
}

/* ---- gravação de áudio: substitui o campo de texto enquanto grava ---- */
.recorder {
	display: none;
	flex: 1;
	min-width: 0;
	align-items: center;
	gap: 8px;
}
.composer.recording .recorder {
	display: flex;
}
.composer.recording textarea,
.composer.recording .attach-wrap {
	display: none;
}
.rec-cancel:hover {
	color: var(--danger);
	border-color: var(--danger);
}
.rec-status {
	flex: 1;
	min-width: 0;
	height: var(--composer-h);
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 14px;
	border-radius: 16px;
	border: 1.5px solid var(--border);
	background: var(--surface-2);
}
.rec-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--danger);
	flex-shrink: 0;
	animation: recBlink 1s ease-in-out infinite;
}
@keyframes recBlink {
	50% {
		opacity: 0.25;
	}
}
.rec-time {
	font-size: 13.5px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	min-width: 34px;
}
.rec-bars {
	flex: 1;
	min-width: 0;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 2px;
	overflow: hidden;
}
.rec-bars span {
	width: 3px;
	height: 100%;
	flex-shrink: 0;
	border-radius: 2px;
	background: var(--accent);
	/* scaleY em vez de height: só compõe, não recalcula o layout 10x por segundo */
	transform: scaleY(0.1);
	transition: transform 0.1s linear;
}

/* ---- balão de áudio ---- */
.bubble.audio-bubble {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 200px;
	padding: 7px 12px 7px 7px;
	white-space: normal;
}
.audio-btn {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: none;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	cursor: pointer;
	background: var(--accent);
	color: var(--primary-foreground);
}
.msg-row.me .audio-btn {
	background: color-mix(in oklch, var(--bubble-me-text) 22%, transparent);
	color: var(--bubble-me-text);
}
.audio-btn:disabled {
	cursor: default;
}
.audio-btn:not(:disabled):active {
	transform: scale(0.92);
}
.audio-btn .spin svg {
	display: block;
	animation: photoSpin 1.1s linear infinite;
}
.audio-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
}
.audio-wave {
	position: relative;
	height: 24px;
}
.audio-wave svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: visible;
}
.audio-wave path {
	fill: none;
	stroke: currentColor;
	stroke-width: 1.3;
	stroke-linecap: round;
	vector-effect: non-scaling-stroke;
}
.audio-wave .wave-base path {
	stroke-width: 2.6px;
	opacity: 0.35;
}
/* na bolha colorida o branco translúcido some nas cores mais claras (rosa, laranja) */
.msg-row.me .audio-wave .wave-base path {
	opacity: 0.6;
}
.audio-wave .wave-played path {
	stroke-width: 2.6px;
}
.msg-row:not(.me) .audio-wave .wave-played path {
	stroke: var(--accent);
}
/* altura fixa: o botão de velocidade aparece ao dar play e não pode empurrar o balão */
.audio-time {
	display: flex;
	align-items: center;
	gap: 6px;
	height: 16px;
	font-size: 11px;
	line-height: 16px;
	font-variant-numeric: tabular-nums;
}
.audio-time > span:first-child {
	flex: 1;
	opacity: 0.75;
}
/* velocidade 1x / 1,5x / 2x */
.audio-speed {
	border: none;
	height: 16px;
	padding: 0 6px;
	border-radius: 999px;
	font: inherit;
	font-size: 10.5px;
	font-weight: 700;
	line-height: 16px;
	color: inherit;
	background: color-mix(in oklch, currentColor 16%, transparent);
	cursor: pointer;
}
/* microfone no canto: verde = ainda não ouvi (dos outros); azul = ouvido (meu) */
.heard-mark {
	display: inline-flex;
	pointer-events: none;
}
.heard-mark svg {
	display: block;
}
.msg-row:not(.me) .heard-mark.new {
	color: var(--audio-icon);
	opacity: 1;
}
.msg-row.me .heard-mark.heard {
	color: oklch(0.8 0.13 230);
	opacity: 1;
}
.msg-row.me .heard-mark.new {
	opacity: 0.6;
}
/* tocar na onda pula para aquele ponto (sem bloquear a rolagem da conversa) */
.audio-wave[data-seek-audio] {
	cursor: pointer;
}
.bubble.audio-consumed .audio-wave {
	opacity: 0.5;
}

/* ---- balão de jogo: tabuleiro jogável dentro da mensagem ---- */
/* cinza neutro para todos (inclusive no meu balão): o tabuleiro é o mesmo para
   quem joga e quem assiste, e as cores de X/O ficam legíveis em qualquer tema */
.msg-row .bubble.game-bubble {
	background: var(--surface-2);
	color: var(--text);
	border: 1px solid var(--border);
}
.bubble.game-bubble {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 220px;
	max-width: 100%;
	padding: 10px 12px 11px;
	white-space: normal;
}
.game-title {
	font-size: 13px;
	font-weight: 700;
}
.game-players {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
}
.game-player {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-width: 0;
	flex: 1;
}
.game-player:last-child {
	justify-content: flex-end;
}
.game-player-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	opacity: 0.85;
}
.game-player.you .game-player-name {
	font-weight: 700;
	opacity: 1;
}
.game-vs {
	font-size: 10.5px;
	opacity: 0.55;
	flex-shrink: 0;
}
.game-player .game-mark {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}
.game-mark {
	display: block;
}
.game-mark svg {
	display: block;
	width: 100%;
	height: 100%;
}
/* X na cor principal e O na cor do texto: seguem a cor escolhida e o claro/escuro */
.game-mark.x {
	color: var(--accent);
}
.game-mark.o {
	color: var(--text);
	opacity: 0.75;
}
/* linhas e colunas de tamanho fixo (minmax(0, 1fr)): o X/O que entra numa casa
   não pode mudar o tamanho de nenhuma delas */
.ttt-board {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	grid-template-rows: repeat(3, minmax(0, 1fr));
	gap: 5px;
	aspect-ratio: 1;
}
.ttt-cell {
	position: relative;
	min-width: 0;
	min-height: 0;
	padding: 0;
	border: none;
	border-radius: 9px;
	background: color-mix(in oklch, currentColor 9%, transparent);
	color: inherit;
	font-family: inherit;
	cursor: default;
	transition: background 0.12s ease, transform 0.08s ease;
}
/* a marca fica por cima da casa (absoluta): não participa do tamanho */
.ttt-cell .game-mark {
	position: absolute;
	inset: 20%;
}
/* só a marca que acabou de entrar anima: a cada jogada o balão inteiro é redesenhado,
   e animar todas fazia o tabuleiro inteiro "pular" */
.ttt-cell .game-mark.fresh {
	animation: popIn 0.14s ease-out;
}
.ttt-cell[data-game-cell] {
	cursor: pointer;
	background: color-mix(in oklch, currentColor 14%, transparent);
}
.ttt-cell[data-game-cell]:hover {
	background: color-mix(in oklch, currentColor 22%, transparent);
}
.ttt-cell[data-game-cell]:active {
	transform: scale(0.93);
}
.ttt-cell.pending {
	animation: gamePending 0.9s ease-in-out infinite;
}
@keyframes gamePending {
	50% {
		background: color-mix(in oklch, currentColor 26%, transparent);
	}
}
.ttt-cell.win {
	background: color-mix(in oklch, var(--accent) 28%, transparent);
}
.ttt-board.ended .ttt-cell:not(.win) {
	opacity: 0.6;
}
/* uma linha só: um nome longo não empurra a altura do balão a cada jogada */
.game-status {
	font-size: 12px;
	text-align: center;
	opacity: 0.8;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.game-status.your-turn {
	font-weight: 700;
	opacity: 1;
}

.photo-bubble {
	display: flex;
	align-items: center;
	gap: 6px;
	font-weight: 500;
}
/* caixa fixa: cadeado, relógio e câmera trocam de lugar sem mexer no texto ao lado */
.photo-bubble .photo-icon {
	width: 16px;
	height: 16px;
	font-size: 15px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	opacity: 0.9;
}
.photo-bubble.photo-consumed {
	opacity: 0.6;
}
.photo-bubble .photo-icon.spin svg {
	animation: photoSpin 1.4s linear infinite;
}
@keyframes photoSpin {
	to {
		transform: rotate(360deg);
	}
}
.bubble.photo-clickable {
	cursor: pointer;
	transition: transform 0.1s ease, filter 0.1s ease;
}
.bubble.photo-clickable:active {
	transform: scale(0.98);
	filter: brightness(0.96);
}

/* ---- links e prévia de YouTube/Instagram ---- */
.msg-link {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	word-break: break-all;
}
.msg-row:not(.me) .msg-link {
	color: var(--accent);
}
.bubble.link-bubble {
	padding: 4px 4px 7px;
	width: 280px;
	max-width: 100%;
}
.link-bubble .link-text {
	padding: 6px 9px 0;
}
.link-card {
	display: flex;
	flex-direction: column;
	border-radius: 12px;
	overflow: hidden;
	background: rgba(128, 128, 128, 0.14);
	color: inherit;
	text-decoration: none;
	cursor: pointer;
	white-space: normal;
	transition: filter 0.1s ease;
}
.link-card:active {
	filter: brightness(0.94);
}
.link-thumb {
	position: relative;
	aspect-ratio: 16 / 9;
	background: #000;
}
.link-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.link-play {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 48px;
	height: 48px;
	margin: -24px 0 0 -24px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.62);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	padding-left: 3px;
}
.link-meta {
	display: flex;
	flex-direction: column;
	gap: 1px;
	padding: 7px 10px 8px;
	line-height: 1.3;
}
.link-site {
	font-size: 12px;
	font-weight: 600;
	opacity: 0.75;
}
.link-title {
	font-size: 13px;
}
.ig-card {
	flex-direction: row;
	align-items: center;
}
.ig-badge {
	flex: none;
	width: 52px;
	height: 52px;
	margin: 6px 0 6px 6px;
	border-radius: 10px;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(45deg, #f9b233, #e1306c 55%, #833ab4);
}
/* ---- figurinhas: sem balão, imagem grande com fundo transparente ---- */
.msg-row .bubble.sticker-bubble {
	background: none;
	border: none;
	box-shadow: none;
	padding: 0;
	line-height: 0;
}
.sticker-img {
	display: block;
	width: 150px;
	height: 150px;
	object-fit: contain;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}
/* figurinha do histórico enquanto a imagem não chega */
.sticker-placeholder {
	border-radius: 18px;
	background: var(--surface-2);
	opacity: 0.6;
}
.msg-row.send-failed .bubble.sticker-bubble {
	box-shadow: inset 0 0 0 1px var(--danger);
	border-radius: 16px;
}

/* bandeja "Minhas figurinhas": substitui o menu do "+", como a de jogos */
.attach-menu.attach-stickers {
	width: min(320px, calc(100vw - 32px));
}
.attach-back-row {
	display: flex;
	align-items: center;
	border-bottom: 1px solid var(--border);
	margin-bottom: 4px;
}
.attach-back-row .attach-back {
	flex: 1;
	border-bottom: none;
	margin-bottom: 0;
}
/* abas dos pacotes (Recentes + uma por subpasta de public/stickers) */
.sticker-tabs {
	display: flex;
	gap: 4px;
	overflow-x: auto;
	scrollbar-width: none;
	margin-bottom: 4px;
}
.sticker-tabs:empty {
	display: none;
}
.sticker-tab {
	flex-shrink: 0;
	padding: 5px 10px;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--muted);
	font: inherit;
	font-size: 12.5px;
	font-weight: 600;
	text-transform: capitalize;
	cursor: pointer;
}
.sticker-tab[aria-selected='true'] {
	background: var(--surface-2);
	color: var(--text);
}
.sticker-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 4px;
	max-height: min(300px, 45vh);
	overflow-y: auto;
	overscroll-behavior: contain;
}
.sticker-cell {
	position: relative;
	aspect-ratio: 1;
	padding: 4px;
	border: none;
	border-radius: 10px;
	background: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
.sticker-cell:hover,
.sticker-cell:active {
	background: var(--surface-2);
}
.sticker-cell img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	pointer-events: none;
}
.sticker-empty {
	grid-column: 1 / -1;
	text-align: center;
	align-self: center;
	font-size: 12px;
	color: var(--muted);
	padding: 4px;
}

.photo-viewer-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.92);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
	padding: 20px;
}
.photo-viewer-overlay img {
	max-width: 100%;
	max-height: 100%;
	border-radius: 8px;
	object-fit: contain;
}
.photo-viewer-close {
	position: absolute;
	top: calc(16px + env(safe-area-inset-top, 0px));
	right: 16px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.toast {
	position: fixed;
	bottom: calc(90px + var(--safe-bottom));
	left: 50%;
	transform: translateX(-50%);
	background: var(--text);
	color: var(--bg);
	padding: 9px 16px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	box-shadow: var(--shadow);
	opacity: 0;
	pointer-events: none;
	transition:
		opacity 0.25s ease,
		transform 0.25s ease;
	z-index: 50;
	white-space: nowrap;
	max-width: 90vw;
	text-overflow: ellipsis;
	overflow: hidden;
}
.toast.show {
	opacity: 1;
	transform: translateX(-50%) translateY(-4px);
}

.spinner {
	width: 20px;
	height: 20px;
	border: 2.5px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
	margin: 0 auto;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}
::-webkit-scrollbar {
	height: 4px;
	width: 4px;
}
::-webkit-scrollbar-track {
	background: var(--muted-bg);
}
::-webkit-scrollbar-thumb {
	background: color-mix(in oklch, var(--muted-foreground) 60%, transparent);
	border-radius: 3px;
}
