* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family:
		-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif;
	background: linear-gradient(180deg, #fbfbfe, #f6f4f9);
	padding: 1rem;
	color: #1a1625;
	height: 100dvh;
}

.chat-app {
	max-width: 800px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	height: 98dvh;
}

.header {
	text-align: center;
	margin-bottom: 1.5rem;
}

.header h1 {
	font-size: 2rem;
	font-weight: bold;
	background: linear-gradient(135deg, #8b5cf6, #a855f7);
	background-clip: text;
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	margin-bottom: 0.5rem;
}

.header p {
	color: #64748b;
	font-size: 0.9rem;
}

.chat-container {
	flex: 1;
	background: white;
	border-radius: 0.75rem;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 1px solid #e2e8f0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.chat-header {
	background: white;
	border-bottom: 1px solid #e2e8f0;
	padding: 1rem;
	display: flex;
	justify-content: space-between;
}

.chat-header h2 {
	font-size: 1.125rem;
	font-weight: 600;
	color: #1a1625;
	margin-bottom: 0.25rem;
}

.chat-header p {
	font-size: 0.875rem;
	color: #64748b;
}

.user-count {
	height: max-content;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	background: #f0fdf4;
	color: #166534;
	padding: 0.25rem 0.5rem;
	border-radius: 0.375rem;
	font-size: 0.75rem;
	font-weight: 500;
	border: 1px solid #bbf7d0;
}

.user-count::before {
	content: "●";
	color: #22c55e;
}

/* Message Animation */
@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.messages-container {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	background: #faf9fc;
}

.message {
	display: flex;
	gap: 0.75rem;
	padding: 1rem;
	border-radius: 0.5rem;
	margin-bottom: 0.5rem;
	transition: background-color 0.2s;
	animation: fadeIn 0.3s ease-out;
}

.message:hover {
	background: #f1f0f4;
}

.message.own {
	background: #f3f1ff;
}

.message.own:hover {
	background: #ede9fe;
}

.avatar {
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.75rem;
	font-weight: 600;
	flex-shrink: 0;
	margin-top: 0.125rem;
}

.avatar.other {
	background: #f1f5f9;
	color: #64748b;
}

.avatar.own {
	background: #8b5cf6;
	color: white;
}

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

.message-header {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	margin-bottom: 0.25rem;
}

.username {
	font-weight: 600;
	font-size: 0.875rem;
}

.username.own {
	color: #8b5cf6;
}

.timestamp {
	font-size: 0.75rem;
	color: #64748b;
}

.message-text {
	font-size: 0.875rem;
	color: #1a1625;
	word-wrap: break-word;
	line-height: 1.4;
}

.input-container {
	background: white;
	border-top: 1px solid #e2e8f0;
	padding: 1rem;
}

.input-form {
	display: flex;
	gap: 0.75rem;
}

/* start new / bye member: */

.system-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.8125rem;
	margin: 0.5rem 0 0.25rem 3rem; /* indent under avatars */
	color: #94a3b8; /* default (join) text color */
}

.system-row .dot {
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
}

.system-row .time {
	margin-left: 0.4rem;
	color: #64748b;
}

/* join variant (green) */
.system-row.join .dot {
	background: #22c55e;
	box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

/* leave variant (red, dimmer text) */
.system-row.leave {
	color: #a1a1aa; /* zinc-400 */
}
.system-row.leave .time {
	color: #71717a; /* zinc-500 */
}
.system-row.leave .dot {
	background: #ef4444;
	box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

/* end new / bye member: */

.message-input {
	flex: 1;
	padding: 0.75rem 1rem;
	border: 1px solid #e2e8f0;
	border-radius: 0.5rem;
	font-size: 0.875rem;
	background: white;
	outline: none;
	transition: border-color 0.2s;
}

.message-input:focus {
	border-color: #8b5cf6;
	box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.send-button {
	padding: 0.75rem;
	background: linear-gradient(135deg, #8b5cf6, #a855f7);
	color: white;
	border: none;
	border-radius: 0.5rem;
	cursor: pointer;
	transition: background 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 2.75rem;
}

.send-button:hover {
	background: linear-gradient(135deg, #7c3aed, #9333ea);
}

.send-button:active {
	transform: translateY(1px);
}

/* Scrollbar styling */
.messages-container::-webkit-scrollbar {
	width: 6px;
}

.messages-container::-webkit-scrollbar-track {
	background: #f1f5f9;
	border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
	background: #94a3b8;
}

/* Login Styles */
.login-container {
	flex: 1;
	background: white;
	border-radius: 0.75rem;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 1px solid #e2e8f0;
	display: flex;
	flex-direction: column;
	max-width: 400px;
	margin: 0 auto;
	padding: 2rem;
}

.login-header {
	text-align: center;
	margin-bottom: 2rem;
}

.login-header h2 {
	font-size: 1.5rem;
	font-weight: 600;
	color: #1a1625;
	margin-bottom: 0.5rem;
}

.login-header p {
	font-size: 0.875rem;
	color: #64748b;
}

.login-form {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.form-group {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.form-label {
	font-size: 0.875rem;
	font-weight: 600;
	color: #1a1625;
}

.form-input {
	padding: 0.75rem 1rem;
	border: 1px solid #e2e8f0;
	border-radius: 0.5rem;
	font-size: 0.875rem;
	background: white;
	outline: none;
	transition: border-color 0.2s;
}

.form-input:focus {
	border-color: #8b5cf6;
	box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.radio-group {
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
}

.radio-option {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	cursor: pointer;
	padding: 0.5rem;
	border-radius: 0.375rem;
	transition: background-color 0.2s;
}

.radio-option:hover {
	background: #f8fafc;
}

.radio-input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.radio-custom {
	width: 1rem;
	height: 1rem;
	border: 2px solid #e2e8f0;
	border-radius: 50%;
	position: relative;
	transition: border-color 0.2s;
}

.radio-input:checked + .radio-custom {
	border-color: #8b5cf6;
}

.radio-input:checked + .radio-custom::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 0.375rem;
	height: 0.375rem;
	background: #8b5cf6;
	border-radius: 50%;
}

.radio-label {
	font-size: 0.875rem;
	color: #1a1625;
	user-select: none;
}

/* Subtle focus ring just on the circle */
.radio-input:focus-visible + .radio-custom {
	box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); /* soft violet glow */
	border-color: #8b5cf6;
}

/* Optional: slight background for the whole option when focused */
.radio-option:has(.radio-input:focus-visible) {
	background: #f3f0ff; /* very light violet */
}

/* Selected option background */
.radio-option:has(.radio-input:checked) {
	background: #f9f6ff; /* lighter, almost white with violet hint */
}

/* Keep existing checked dot + border */
.radio-input:checked + .radio-custom {
	border-color: #8b5cf6;
}
.radio-input:checked + .radio-custom::after {
	background: #8b5cf6;
}

.join-button {
	padding: 0.75rem 1.5rem;
	background: linear-gradient(135deg, #8b5cf6, #a855f7);
	color: white;
	border: none;
	border-radius: 0.5rem;
	cursor: pointer;
	font-size: 0.875rem;
	font-weight: 600;
	transition: background 0.2s;
	margin-top: 0.5rem;
}

.join-button:hover {
	background: linear-gradient(135deg, #7c3aed, #9333ea);
}

.join-button:active {
	transform: translateY(1px);
}

/* Responsive design */
@media (max-width: 768px) {
	body {
		padding: 0.5rem;
	}

	.header h1 {
		font-size: 1.5rem;
	}

	.login-container {
		padding: 1.5rem;
	}

	.radio-group {
		flex-direction: column;
		gap: 0.5rem;
	}
}

/* iOS zoom prevention: any focused control must be >=16px */
.input-form,
.message-input,
.form-input,
.radio-label,
.send-button {
	font-size: 16px;
}
