:root {
	--font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
	
	/* Colors - Modern, Neutral, Clean */
	--primary: #0f172a; /* Slate 900 */
	--primary-hover: #1e293b;
	--accent: #2563eb; /* Blue 600 */
	--accent-light: #eff6ff;
	--bg-body: #f8fafc; /* Slate 50 */
	--bg-card: #ffffff;
	--text-main: #334155; /* Slate 700 */
	--text-muted: #64748b; /* Slate 500 */
	--border: #e2e8f0; /* Slate 200 */
	
	/* Chat bubbles */
	--bubble-self: #2563eb;
	--text-self: #ffffff;
	--bubble-peer: #f1f5f9; /* Slate 100 */
	--text-peer: #1e293b;

	--radius-sm: 6px;
	--radius-md: 12px;
	--radius-lg: 20px;
	
	--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
	--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: var(--font-sans);
	background: var(--bg-body);
	color: var(--text-main);
	height: 100vh;
	height: 100dvh; /* Mobile adaptive */
	overflow: hidden;
	-webkit-font-smoothing: antialiased;
}

.app-layout {
	display: flex;
	flex-direction: column;
	height: 100%;
	max-width: 1200px;
	margin: 0 auto;
	background: var(--bg-card);
	box-shadow: 0 0 0 1px var(--border);
}

@media (min-width: 1201px) {
	.app-layout {
		border-left: 1px solid var(--border);
		border-right: 1px solid var(--border);
	}
}

/* Navbar */
.navbar {
	background: var(--bg-card);
	border-bottom: 1px solid var(--border);
	padding: 0.75rem 1rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 60px;
	flex-shrink: 0;
}

.nav-brand {
	font-weight: 600;
	font-size: 1.1rem;
	color: var(--primary);
	display: flex;
	align-items: center;
	gap: 0.25rem;
}
.logo-text { color: var(--primary); }
.logo-domain { 
	opacity: 0.5; 
	font-weight: 400; 
	font-size: 0.9em;
}

.nav-actions { display: flex; align-items: center; }
.nav-icons { display: flex; gap: 0.25rem; }

.icon-btn {
	background: transparent;
	border: 1px solid transparent;
	cursor: pointer;
	font-size: 1.1rem;
	padding: 0.4rem;
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s;
}
.icon-btn:hover { 
	background: var(--bg-body); 
	color: var(--text-main); 
}

/* Status/Join Bar (Former Hero Banner) */
.hero-banner {
	background: var(--bg-card);
	border-bottom: 1px solid var(--border);
	padding: 0.75rem 1rem;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;  /* Adaptive layout */
	gap: 0.75rem;
	flex-shrink: 0;
}

.banner-title { 
	display: none; /* Hide the big title for cleaner UI, or make it subtle */
}

.join-row { 
	display: flex; 
	gap: 0.5rem; 
	flex: 1;
	max-width: 400px;
}

.room-input {
	flex: 1;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	font-family: inherit;
	background: var(--bg-body);
	color: var(--text-main);
	transition: border-color 0.2s;
}
.room-input:focus { 
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 2px var(--accent-light);
}

.btn-primary {
	background: var(--primary);
	color: white;
	border: none;
	padding: 0.5rem 1rem;
	border-radius: var(--radius-sm);
	font-weight: 500;
	cursor: pointer;
	font-size: 0.9rem;
	transition: background 0.2s;
	white-space: nowrap;
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:hover { background: var(--primary-hover); }

.banner-status { 
	font-size: 0.85rem; 
	color: var(--text-muted); 
	display: flex;
	align-items: center;
	gap: 0.5rem;
	white-space: nowrap;
}

.status-pill {
	display: none;
	align-items: center;
	gap: 0.35rem;
	padding: 0.15rem 0.5rem;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	background: #e2e8f0;
	color: #475569;
}

.status-pill.is-visible {
	display: inline-flex;
}

.status-pill.is-connecting {
	background: #e0f2fe;
	color: #0369a1;
}

.status-pill::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	box-shadow: 0 0 0 0 currentColor;
}

.status-pill.is-connecting::before {
	animation: pulse 1.2s ease-out infinite;
}

@keyframes pulse {
	0% { box-shadow: 0 0 0 0 currentColor; opacity: 0.8; }
	70% { box-shadow: 0 0 0 6px transparent; opacity: 0.25; }
	100% { box-shadow: 0 0 0 0 transparent; opacity: 0.8; }
}

#roomStatus {
	font-weight: 500;
	color: var(--text-main);
}

/* Main Chat Area */
.chat-container {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	background: var(--bg-body);
	scroll-behavior: smooth;
}

.chat-log {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	width: 100%;
	max-width: 900px;
	margin: 0 auto;
}

/* Chat Entries */
.chat-entry {
	max-width: 85%;
	padding: 0.6rem 0.9rem;
	border-radius: var(--radius-md);
	position: relative;
	word-break: break-word;
	line-height: 1.5;
	font-size: 0.95rem;
	animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
	from { opacity: 0; transform: translateY(5px); }
	to { opacity: 1; transform: translateY(0); }
}

/* Received (Peer) */
.chat-entry.peer {
	align-self: flex-start;
	background: var(--bubble-peer);
	color: var(--text-peer);
	border-bottom-left-radius: 2px;
}

/* Sent (Self) */
.chat-entry.self {
	align-self: flex-end;
	background: var(--bubble-self);
	color: var(--text-self);
	border-bottom-right-radius: 2px;
}

.chat-entry strong { 
	font-weight: 600; 
	display: block; 
	font-size: 0.75rem; 
	margin-bottom: 0.2rem;
	opacity: 0.7;
}

.chat-entry.self strong { display: none; } 

/* System Messages */
.chat-entry.system {
	align-self: center;
	background: transparent;
	font-size: 0.8rem;
	color: var(--text-muted);
	padding: 0.25rem 0.5rem;
	text-align: center;
	border-radius: 0;
	box-shadow: none;
	max-width: 100%;
}

/* Transfer Cards */
.transfer.chat-entry {
	padding: 0;
	min-width: 280px;
	max-width: 100%;
	width: 320px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	border: 1px solid var(--border);
	box-shadow: var(--shadow-sm);
	background: var(--bg-card) !important; /* Force card bg */
	color: var(--text-main) !important;
	border-radius: var(--radius-md);
}

.transfer .meta { padding: 1rem; }
.transfer .label { 
	font-weight: 600; 
	font-size: 0.95rem; 
	display: block; 
	margin-bottom: 0.25rem; 
	color: var(--text-main);
}
.transfer .detail { 
	font-size: 0.8rem; 
	color: var(--text-muted); 
}

.transfer .progress {
	height: 4px;
	background: var(--bg-body);
	width: 100%;
	margin-top: auto;
}
.transfer .progress span { 
	display: block;
	height: 100%;
	background: var(--accent); 
	transition: width 0.2s;
}

.transfer-actions {
	padding: 0.5rem;
	border-top: 1px solid var(--border);
	display: flex;
	gap: 0.5rem;
}
.transfer-actions button {
	flex: 1;
	padding: 0.5rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: white;
	cursor: pointer;
	font-size: 0.85rem;
	color: var(--text-main);
}
.transfer-actions button:hover { background: var(--bg-body); }
.transfer-actions button.danger { color: #ef4444; border-color: #fecaca; }
.transfer-actions button.danger:hover { background: #fef2f2; }

/* Footer Input */
.input-bar {
	background: var(--bg-card);
	padding: 0.75rem 1rem;
	border-top: 1px solid var(--border);
	flex-shrink: 0;
}

.input-wrapper {
	max-width: 900px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	background: var(--bg-body);
	border-radius: 24px; /* Pill shape */
	padding: 0.25rem 0.5rem;
	border: 1px solid var(--border);
	transition: border-color 0.2s, background 0.2s;
}

.input-wrapper:focus-within {
	border-color: var(--accent);
	background: white;
	box-shadow: 0 0 0 2px var(--accent-light);
}

.chat-input {
	flex: 1;
	border: none;
	background: transparent;
	padding: 0.6rem 0.5rem;
	outline: none;
	font-size: 0.95rem;
	min-height: 44px; /* Touch friendly */
}

.btn-send {
	background: var(--primary);
	color: white;
	border: none;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	font-size: 0.8rem;
	font-weight: 600;
	padding: 0;
	flex-shrink: 0;
	transition: background 0.2s;
}
.btn-send:hover { background: var(--primary-hover); }

/* SVG Icon replacement for text if wanted, but text is fine */

.attachment-btn {
	color: var(--text-muted);
	padding: 0.5rem;
	border-radius: 50%;
}
.attachment-btn:hover { 
	color: var(--text-main); 
	background: rgba(0,0,0,0.05); 
}
.ghost-btn {
	background: transparent;
	border: none;
	color: var(--text-muted);
}
.ghost-btn:hover {
	color: var(--text-main);
}

/* Mobile Adaptive */
@media (max-width: 600px) {
	.app-layout { box-shadow: none; border: none; }
	.nav-brand { font-size: 1rem; }
	
	.hero-banner { 
		flex-direction: column; 
		align-items: stretch; 
		gap: 0.75rem;
		padding: 0.5rem 1rem 0.75rem 1rem;
	}
	
	.join-row { width: 100%; max-width: none; }
	
	.banner-status { 
		justify-content: center; 
		font-size: 0.8rem;
		background: var(--bg-body);
		padding: 0.25rem;
		border-radius: var(--radius-sm);
	}

	.chat-container { padding: 0.75rem; }
	
	.chat-entry { max-width: 88%; }
	
	.input-bar { padding: 0.5rem; }
}

/* Transfer Card Alignment based on ID prefix (legacy app.js logic) */
.transfer.chat-entry[id^="send-"] {
	align-self: flex-end;
	border-color: var(--accent);
	background: var(--accent-light) !important;
}
.transfer.chat-entry[id^="recv-"] {
	align-self: flex-start;
}

