* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	background: #0f1115;
	color: #e7e9ee;
	height: 100vh;
	overflow: hidden;
}

.hidden { display: none !important; }

.screen { height: 100vh; }

/* ---- Auth screen ---- */
#auth-screen {
	display: flex;
	align-items: center;
	justify-content: center;
}
.card {
	background: #171a21;
	border: 1px solid #262b36;
	border-radius: 12px;
	padding: 32px;
	width: 360px;
}
.card h1 { margin: 0 0 4px; font-size: 22px; }
.subtitle { color: #9aa3b2; font-size: 13px; margin: 0 0 20px; }

.tabs { display: flex; margin-bottom: 16px; border-bottom: 1px solid #262b36; }
.tab {
	flex: 1;
	background: none;
	border: none;
	color: #9aa3b2;
	padding: 10px;
	cursor: pointer;
	font-size: 14px;
	border-bottom: 2px solid transparent;
}
.tab.active { color: #e7e9ee; border-bottom-color: #4f8cff; }

form { display: flex; flex-direction: column; gap: 10px; }
input {
	background: #0f1115;
	border: 1px solid #2c313d;
	color: #e7e9ee;
	padding: 10px 12px;
	border-radius: 8px;
	font-size: 14px;
}
input:focus { outline: none; border-color: #4f8cff; }

button[type="submit"] {
	background: #4f8cff;
	border: none;
	color: white;
	padding: 10px;
	border-radius: 8px;
	font-size: 14px;
	cursor: pointer;
	margin-top: 4px;
}
button[type="submit"]:hover { background: #3d78e8; }

.error { color: #ff6b6b; font-size: 13px; min-height: 18px; margin-top: 12px; }

/* ---- Chat screen ---- */
#chat-screen { display: flex; }

.sidebar {
	width: 240px;
	background: #14161c;
	border-right: 1px solid #262b36;
	padding: 20px;
	display: flex;
	flex-direction: column;
}
.me { font-size: 13px; color: #9aa3b2; margin-bottom: 20px; }
.sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; margin: 0 0 10px; }

.sidebar-lists {
	flex: 1;
	overflow-y: auto;
	min-height: 60px;
	margin-bottom: 12px;
}
.peer-list { list-style: none; padding: 0; margin: 0 0 16px; }
.peer-list li {
	padding: 8px 10px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 14px;
	margin-bottom: 4px;
}
.peer-list li:hover { background: #1f232c; }
.peer-list li.active-peer { background: #23324f; }
.peer-list .empty { color: #6b7280; font-size: 13px; padding: 8px 10px; cursor: default; }

.start-chat-form {
	flex-direction: row;
	gap: 6px;
	margin-bottom: 16px;
}
.start-chat-form input {
	flex: 1;
	padding: 8px 10px;
	font-size: 13px;
}
.start-chat-form button {
	background: #2c313d;
	border: none;
	color: #e7e9ee;
	padding: 0 12px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 13px;
}
.start-chat-form button:hover { background: #38404f; }

#logout-btn {
	background: none;
	border: 1px solid #2c313d;
	color: #9aa3b2;
	padding: 8px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 13px;
}
#logout-btn:hover { color: #e7e9ee; border-color: #4f8cff; }

.chat-pane { flex: 1; display: flex; flex-direction: column; }

.placeholder {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	color: #6b7280;
	padding: 40px;
	font-size: 14px;
}

#chat-active { flex: 1; display: flex; flex-direction: column; }

.chat-header {
	padding: 16px 20px;
	border-bottom: 1px solid #262b36;
	font-size: 14px;
}
.key-status { float: right; font-size: 12px; color: #4ade80; }

.messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.msg {
	max-width: 60%;
	padding: 8px 12px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.4;
	word-wrap: break-word;
}
.msg.mine { align-self: flex-end; background: #4f8cff; color: white; }
.msg.theirs { align-self: flex-start; background: #21252f; }
.msg.system { align-self: center; color: #6b7280; font-size: 12px; background: none; }

.msg.raw-mode {
	font-family: "SF Mono", Consolas, Menlo, monospace;
	font-size: 11px;
	white-space: pre-wrap;
	word-break: break-all;
	max-width: 80%;
	color: #ffd88f;
	background: #14161c;
	border: 1px dashed #3a3f4c;
}

.msg.failed {
	background: #2a1f1f;
	border: 1px solid #5a3030;
	cursor: pointer;
	max-width: 75%;
	align-self: flex-start;
}
.msg.failed.mine-failed { align-self: flex-end; }
.msg.failed:hover { border-color: #ff6b6b; }
.failed-label { color: #ff9b9b; font-size: 13px; }
.failed-actions { display: flex; gap: 12px; margin-top: 6px; }
.link-btn {
	background: none;
	border: none;
	color: #8fb4ff;
	font-size: 12px;
	padding: 0;
	cursor: pointer;
	text-decoration: underline;
}
.link-btn:hover { color: #b7cfff; }
.raw-ciphertext {
	margin-top: 8px;
	padding: 8px;
	background: #14161c;
	border-radius: 6px;
	font-size: 11px;
	color: #9aa3b2;
	white-space: pre-wrap;
	word-break: break-all;
}
.failed-error { margin-top: 6px; font-size: 11px; color: #ff9b9b; }

#message-form {
	display: flex;
	gap: 10px;
	padding: 16px 20px;
	border-top: 1px solid #262b36;
}
#message-input {
	flex: 1;
}
#message-form button {
	background: #4f8cff;
	border: none;
	color: white;
	padding: 0 18px;
	border-radius: 8px;
	cursor: pointer;
	white-space: nowrap;
}
#toggle-raw-btn {
	background: none;
	border: 1px solid #2c313d;
	color: #9aa3b2;
	font-size: 12px;
	padding: 0 12px;
}
#toggle-raw-btn:hover { color: #e7e9ee; border-color: #4f8cff; }
