/* Web chat: the app's public room in the browser, on top of styles.css. */

.chat-page {
	height: 100vh;
	height: 100dvh;
	min-height: 0;
	overflow: hidden;
}

.screen[hidden] {
	display: none !important;
}

.screen-center {
	display: grid;
	place-items: center;
	align-content: center;
	gap: 18px;
	height: 100%;
	padding: 24px;
	overflow-y: auto;
}

/* ---------- Loading ---------- */

.loading-logo {
	width: 120px;
	animation: float 4s ease-in-out infinite;
}

.loading-text {
	margin: 0;
	color: var(--text-muted);
	font: 600 15px/1 var(--font-display);
}

@keyframes float {
	50% {
		transform: translateY(-8px);
	}
}

/* ---------- Sign in ---------- */

.auth-card {
	width: min(100%, 420px);
	padding: 34px 30px 26px;
	border-radius: var(--radius-xl);
	text-align: center;
}

.auth-logo {
	display: block;
	width: 124px;
	margin: 0 auto 18px;
	filter: drop-shadow(0 18px 28px rgba(22, 66, 140, 0.32));
}

.auth-step {
	display: grid;
	gap: 12px;
}

.auth-step[hidden] {
	display: none;
}

.auth-step h1 {
	margin: 0;
	font-size: 30px;
}

.auth-lead {
	margin: 0 0 8px;
	color: var(--text-muted);
	font-size: 16px;
	line-height: 1.5;
}

.auth-button {
	width: 100%;
	border-radius: 999px;
}

.auth-button[disabled] {
	opacity: 0.6;
	cursor: progress;
	transform: none;
}

.auth-divider {
	display: flex;
	align-items: center;
	gap: 12px;
	color: var(--text-muted);
	font-size: 14px;
}

.auth-divider::before,
.auth-divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--rim);
}

.auth-fine {
	margin: 6px 0 0;
	color: var(--text-muted);
	font-size: 13px;
	line-height: 1.5;
}

.auth-back,
.link-button {
	justify-self: start;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 6px 4px 0;
	border: 0;
	background: none;
	color: var(--accent);
	font: 600 14px/1 var(--font-body);
	cursor: pointer;
}

.link-button {
	justify-self: center;
	padding: 6px;
}

.link-button[disabled] {
	color: var(--text-muted);
	cursor: default;
}

.auth-back .icon {
	width: 18px;
	height: 18px;
}

.field-label {
	justify-self: start;
	color: var(--text);
	font-weight: 600;
	font-size: 14px;
}

.field-input {
	width: 100%;
	min-height: 52px;
	padding: 12px 18px;
	border: 1px solid var(--rim);
	border-radius: 16px;
	background: var(--field);
	color: var(--text);
	font: 500 17px/1.2 var(--font-body);
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus {
	border-color: var(--blue-light);
	box-shadow: 0 0 0 4px rgba(96, 137, 205, 0.2);
}

.code-input {
	text-align: center;
	letter-spacing: 0.5em;
	font: 700 24px/1 var(--font-display);
}

.auth-error {
	margin: 12px 0 0;
	color: #c62828;
	font-size: 14px;
	font-weight: 500;
}

.auth-error:empty {
	display: none;
}

/* ---------- Room layout ---------- */

.chat-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 300px;
	grid-template-rows: auto minmax(0, 1fr);
	gap: 14px;
	width: min(100%, 1180px);
	height: 100%;
	margin-inline: auto;
	padding: 14px 16px 0;
}

.chat-header {
	grid-column: 1 / -1;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 10px 8px 12px;
	border-radius: 999px;
}

.chat-brand img {
	width: 38px;
	height: auto;
	filter: drop-shadow(0 4px 8px rgba(22, 66, 140, 0.3));
}

.chat-title {
	display: grid;
	flex: 1;
	min-width: 0;
	line-height: 1.2;
}

.chat-title strong {
	font: 800 19px/1.2 var(--font-display);
	color: var(--text);
}

.chat-title strong span {
	color: var(--text-muted);
	font-weight: 600;
}

.chat-title small {
	color: var(--text-muted);
	font-size: 13px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chat-title small.online::before {
	content: "";
	display: inline-block;
	width: 7px;
	height: 7px;
	margin-right: 6px;
	border-radius: 50%;
	background: var(--green);
	vertical-align: 1px;
}

.round-button {
	position: relative;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	color: var(--blue);
	cursor: pointer;
}

.round-button .icon {
	width: 21px;
	height: 21px;
}

.people-toggle {
	display: none;
}

.count-badge {
	position: absolute;
	top: -4px;
	right: -6px;
	min-width: 20px;
	padding: 2px 6px;
	border-radius: 999px;
	font: 700 11px/16px var(--font-body);
	text-align: center;
}

.me-menu {
	position: relative;
}

.me-button,
.me-avatar-large,
.cm-avatar,
.person-avatar {
	display: grid;
	place-items: center;
	flex: none;
	border-radius: 50%;
	color: #fff;
	background: var(--avatar, var(--blue-light));
	background-size: cover;
	background-position: center;
	font-weight: 600;
}

.me-button {
	width: 44px;
	height: 44px;
	border: 2px solid #fff;
	font-size: 18px;
	cursor: pointer;
	box-shadow: 0 6px 14px -6px rgba(22, 66, 140, 0.5);
}

.popover {
	position: absolute;
	z-index: 40;
	border-radius: 22px;
	padding: 8px;
	background: rgba(255, 255, 255, 0.92);
}

.popover[hidden] {
	display: none;
}

#me-popover {
	top: calc(100% + 10px);
	right: 0;
	width: 250px;
}

.me-card {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 8px 12px;
	border-bottom: 1px solid var(--rim);
	margin-bottom: 6px;
}

.me-card strong {
	display: block;
	color: var(--text);
	line-height: 1.2;
	word-break: break-word;
}

.me-card small {
	color: var(--text-muted);
	font-size: 13px;
}

.me-avatar-large {
	width: 46px;
	height: 46px;
	font-size: 19px;
}

.menu-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 11px 12px;
	border: 0;
	border-radius: 14px;
	background: none;
	color: var(--text);
	font: 600 15px/1 var(--font-body);
	cursor: pointer;
	text-align: left;
}

.menu-item:hover {
	background: var(--field);
}

.menu-item.danger {
	color: #c62828;
}

.menu-item .icon {
	width: 19px;
	height: 19px;
}

/* ---------- Messages ---------- */

.room {
	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.messages {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 8px 6px 18px;
	scrollbar-width: thin;
	scrollbar-color: rgba(96, 137, 205, 0.4) transparent;
	-webkit-mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 100%);
	mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 100%);
}

.messages-empty {
	display: grid;
	place-items: center;
	height: 100%;
	color: var(--text-muted);
	text-align: center;
	font-size: 15px;
}

.cm-day {
	display: block;
	width: fit-content;
	margin: 18px auto 10px;
	padding: 4px 14px;
	border-radius: 999px;
	color: var(--text-muted);
	font: 600 12px/1.4 var(--font-body);
}

.cm-event {
	margin: 8px auto;
	width: fit-content;
	max-width: 90%;
	color: var(--text-muted);
	font-size: 13px;
	text-align: center;
}

.cm-row {
	position: relative;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin-top: 10px;
	padding-right: 15%;
}

.cm-row.cm-continued {
	margin-top: 3px;
}

.cm-row.cm-mine {
	flex-direction: row-reverse;
	padding-right: 0;
	padding-left: 15%;
}

.cm-avatar {
	width: 34px;
	height: 34px;
	font-size: 14px;
	align-self: flex-start;
}

.cm-continued .cm-avatar {
	visibility: hidden;
	height: 0;
}

.cm-mine .cm-avatar {
	display: none;
}

.cm-avatar.shield {
	background: linear-gradient(180deg, #fff, var(--field));
	color: var(--blue);
	box-shadow: inset 0 0 0 1px var(--rim);
}

.cm-avatar.shield .icon {
	width: 18px;
	height: 18px;
}

.cm-body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	min-width: 0;
	max-width: 100%;
}

.cm-mine .cm-body {
	align-items: flex-end;
}

.cm-meta {
	display: flex;
	align-items: baseline;
	gap: 6px;
	margin: 0 0 3px 12px;
	font-size: 13px;
}

.cm-meta b {
	color: var(--text);
	font-weight: 700;
}

.cm-meta time {
	color: var(--text-muted);
	font-size: 12px;
}

.cm-role {
	padding: 0 6px;
	border-radius: 5px;
	background: rgba(242, 107, 29, 0.14);
	color: #b4480b;
	font: 700 10px/16px var(--font-body);
	letter-spacing: 0.04em;
}

.cm-bubble {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	max-width: 100%;
	padding: 9px 14px;
	border-radius: 20px;
	background: var(--surface);
	color: var(--text);
	font-size: 16px;
	line-height: 1.42;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	box-shadow: inset 0 0 0 1px rgba(96, 137, 205, 0.18), 0 3px 8px -4px rgba(22, 66, 140, 0.2);
}

/* My bubbles: the glossy logo blue, with a softer reflection than buttons. */
.cm-mine .cm-bubble {
	background: linear-gradient(180deg, #285cb0 0%, var(--blue) 55%, var(--blue-deep) 100%);
	color: #fff;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 6px 14px -8px rgba(6, 38, 92, 0.65);
}

.cm-mine .cm-bubble::before {
	content: "";
	position: absolute;
	inset: 1px;
	z-index: -1;
	border-radius: inherit;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 45%, transparent 55%);
	pointer-events: none;
}

.cm-bot .cm-bubble {
	background: linear-gradient(180deg, #fff, #f1f6ff);
	box-shadow: inset 0 0 0 1px rgba(96, 137, 205, 0.32), 0 3px 8px -4px rgba(22, 66, 140, 0.2);
}

.cm-sending .cm-bubble {
	opacity: 0.7;
}

.cm-blocked .cm-bubble {
	opacity: 0.55;
}

.cm-deleted .cm-bubble {
	background: transparent;
	color: var(--text-muted);
	font-style: italic;
	box-shadow: inset 0 0 0 1px var(--rim);
}

.cm-gift {
	display: block;
	font-size: 44px;
	line-height: 1.1;
	text-align: center;
}

.cm-mention {
	padding: 0 3px;
	border-radius: 6px;
	background: rgba(26, 76, 160, 0.1);
	color: var(--accent);
	font-weight: 600;
}

.cm-mention.me {
	background: rgba(242, 107, 29, 0.16);
	color: #b4480b;
}

.cm-mine .cm-mention {
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
}

.cm-quote {
	display: block;
	margin: 0 0 6px;
	padding: 4px 10px;
	border-left: 3px solid var(--blue-light);
	border-radius: 4px 10px 10px 4px;
	background: rgba(96, 137, 205, 0.1);
	font-size: 14px;
	line-height: 1.35;
	white-space: normal;
	cursor: pointer;
}

.cm-quote b {
	display: block;
	font-size: 13px;
	color: var(--accent);
}

.cm-quote span {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	color: var(--text-muted);
}

.cm-mine .cm-quote {
	border-left-color: rgba(255, 255, 255, 0.7);
	background: rgba(255, 255, 255, 0.14);
}

.cm-mine .cm-quote b,
.cm-mine .cm-quote span {
	color: rgba(255, 255, 255, 0.88);
}

.cm-media {
	display: grid;
	gap: 6px;
	margin-top: 4px;
}

.cm-media img {
	max-width: min(260px, 100%);
	max-height: 260px;
	border-radius: 16px;
	object-fit: cover;
}

.cm-status {
	display: flex;
	align-items: center;
	gap: 4px;
	margin: 3px 8px 0;
	color: var(--text-muted);
	font-size: 12px;
}

.cm-status .icon {
	width: 13px;
	height: 13px;
}

.cm-status.danger {
	color: #c62828;
	font-weight: 500;
}

.cm-private {
	margin: 3px 8px 0;
	color: var(--text-muted);
	font-size: 12px;
}

.cm-reactions {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 4px;
}

.cm-reaction {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 9px;
	border: 1px solid var(--rim);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.85);
	color: var(--text);
	font: 600 13px/20px var(--font-body);
	cursor: pointer;
}

.cm-reaction.mine {
	border-color: var(--blue-light);
	background: rgba(196, 216, 251, 0.65);
	color: var(--blue-deep);
}

.cm-actions {
	position: absolute;
	top: -14px;
	right: 15%;
	z-index: 5;
	display: none;
	gap: 2px;
	padding: 3px;
	border-radius: 999px;
}

.cm-mine .cm-actions {
	right: auto;
	left: 15%;
}

.cm-row:hover .cm-actions,
.cm-row:focus-within .cm-actions,
.cm-row.show-actions .cm-actions {
	display: flex;
}

.icon-button {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--text-muted);
	cursor: pointer;
}

.icon-button:hover {
	background: var(--field);
	color: var(--blue);
}

.icon-button .icon {
	width: 18px;
	height: 18px;
}

.emoji-picker {
	display: flex;
	gap: 2px;
	padding: 5px;
	border-radius: 999px;
}

.emoji-picker button {
	width: 38px;
	height: 38px;
	border: 0;
	border-radius: 50%;
	background: none;
	font-size: 22px;
	cursor: pointer;
	transition: transform 0.12s;
}

.emoji-picker button:hover {
	background: var(--field);
	transform: scale(1.15);
}

.jump-button {
	position: absolute;
	right: 14px;
	bottom: 96px;
	z-index: 10;
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	color: var(--blue);
	cursor: pointer;
}

.jump-button[hidden] {
	display: none;
}

.jump-button .icon {
	width: 20px;
	height: 20px;
}

/* ---------- Composer ---------- */

.composer-area {
	position: relative;
	padding: 0 0 max(14px, env(safe-area-inset-bottom));
}

.typing {
	min-height: 20px;
	margin: 0 0 4px 16px;
	color: var(--text-muted);
	font-size: 13px;
	font-style: italic;
}

.reply-bar {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 8px;
	padding: 6px 6px 6px 14px;
	border-radius: 18px;
	color: var(--blue);
}

.reply-bar[hidden] {
	display: none;
}

.reply-bar div {
	display: grid;
	flex: 1;
	min-width: 0;
	font-size: 14px;
	line-height: 1.3;
}

.reply-bar b {
	color: var(--accent);
}

.reply-bar span {
	color: var(--text-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 6px 6px 6px 20px;
	border-radius: 28px;
}

.composer textarea {
	flex: 1;
	min-height: 40px;
	max-height: 160px;
	padding: 9px 0;
	border: 0;
	background: none;
	color: var(--text);
	font: 400 16px/1.4 var(--font-body);
	resize: none;
	outline: none;
}

.composer textarea::placeholder {
	color: var(--text-muted);
}

.composer textarea:disabled {
	cursor: not-allowed;
}

.send-button {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	flex: none;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: opacity 0.15s, transform 0.15s;
}

.send-button:not([disabled]):hover {
	transform: scale(1.05);
}

.send-button[disabled] {
	opacity: 0.4;
	cursor: default;
}

.send-button .icon {
	width: 21px;
	height: 21px;
	stroke-width: 2.5;
}

.composer-note {
	min-height: 0;
	margin: 6px 16px 0;
	color: #c62828;
	font-size: 13px;
	font-weight: 500;
}

.composer-note:empty {
	display: none;
}

.mention-popover {
	bottom: calc(100% - 20px);
	left: 12px;
	width: min(280px, calc(100% - 24px));
	max-height: 240px;
	overflow-y: auto;
}

.mention-option {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 7px 8px;
	border: 0;
	border-radius: 12px;
	background: none;
	color: var(--text);
	font: 600 15px/1.2 var(--font-body);
	text-align: left;
	cursor: pointer;
}

.mention-option[aria-selected="true"],
.mention-option:hover {
	background: var(--field);
}

/* ---------- People ---------- */

.people {
	display: flex;
	flex-direction: column;
	min-height: 0;
	margin-bottom: 14px;
	padding: 16px 12px 12px;
	border-radius: var(--radius-lg);
}

.people-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 6px 8px;
}

.people-head h2 {
	margin: 0;
	font-size: 18px;
}

.people-head h2 span {
	color: var(--text-muted);
	font-weight: 600;
}

.people-close {
	display: none;
}

.people-list {
	flex: 1;
	min-height: 0;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	list-style: none;
	scrollbar-width: thin;
}

.person {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 8px;
	border-radius: 14px;
	cursor: pointer;
}

.person:hover {
	background: rgba(196, 216, 251, 0.4);
}

.person-avatar {
	position: relative;
	width: 36px;
	height: 36px;
	font-size: 15px;
}

.person-avatar::after {
	content: "";
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 11px;
	height: 11px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--green);
}

.person.away .person-avatar::after {
	background: #f5a623;
}

.person-name {
	display: grid;
	flex: 1;
	min-width: 0;
	line-height: 1.25;
}

.person-name b {
	color: var(--text);
	font-weight: 600;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.person-name small {
	color: var(--text-muted);
	font-size: 12px;
}

.people-empty {
	padding: 20px 8px;
	color: var(--text-muted);
	font-size: 14px;
	text-align: center;
}

.app-promo {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 10px;
	padding: 14px;
	border-radius: 20px;
	color: #fff;
	text-decoration: none;
}

.app-promo:hover {
	color: #fff;
}

.app-promo strong {
	display: block;
	font: 800 15px/1.2 var(--font-display);
}

.app-promo small {
	display: block;
	margin-top: 2px;
	color: rgba(255, 255, 255, 0.82);
	font-size: 12.5px;
	line-height: 1.35;
}

.app-promo-icon {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex: none;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.16);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.app-promo-icon .icon {
	width: 20px;
	height: 20px;
}

.people-scrim {
	display: none;
}

/* ---------- Toast ---------- */

.toast {
	position: fixed;
	left: 50%;
	top: 86px;
	z-index: 90;
	max-width: min(92vw, 460px);
	padding: 12px 18px;
	border-radius: 18px;
	color: var(--text);
	font-size: 15px;
	font-weight: 500;
	text-align: center;
	transform: translateX(-50%);
	animation: toast-in 0.25s ease-out;
}

.toast[hidden] {
	display: none;
}

@keyframes toast-in {
	from {
		opacity: 0;
		transform: translate(-50%, -8px);
	}
}

/* ---------- Small screens: the people list slides in from the side ---------- */

@media (max-width: 900px) {
	.chat-layout {
		grid-template-columns: minmax(0, 1fr);
		gap: 10px;
		padding: max(10px, env(safe-area-inset-top)) 10px 0;
	}

	.people-toggle {
		display: grid;
	}

	.people {
		position: fixed;
		top: 10px;
		right: 10px;
		bottom: 10px;
		z-index: 60;
		width: min(320px, calc(100vw - 40px));
		margin: 0;
		background: rgba(255, 255, 255, 0.94);
		transform: translateX(calc(100% + 24px));
		transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
	}

	.people.open {
		transform: none;
	}

	.people-close {
		display: grid;
	}

	.people-scrim:not([hidden]) {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 55;
		background: rgba(6, 38, 92, 0.18);
	}

	.cm-row {
		padding-right: 8%;
	}

	.cm-row.cm-mine {
		padding-left: 8%;
	}

	.cm-actions {
		right: 8%;
	}

	.cm-mine .cm-actions {
		left: 8%;
	}
}

@media (max-width: 480px) {
	.chat-title strong {
		font-size: 17px;
	}

	.auth-card {
		padding: 28px 20px 22px;
	}
}

@media (hover: none) {
	.cm-row:hover .cm-actions {
		display: none;
	}

	.cm-row.show-actions .cm-actions {
		display: flex;
	}
}
