:root {
	--accent: #16a34a;
	--text: #111827;
	--muted: #6b7280;
	--line: #e5e7eb;
	--bg: #f9fafb;
	--danger: #dc2626;
	font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
	color: var(--text);
	background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: inherit; }
button {
	font: inherit;
	padding: 0.45rem 0.9rem;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: default; }
button.link { border: 0; background: none; color: var(--muted); padding: 0.25rem; }
button.danger { color: var(--danger); }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 0.9rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card {
	width: 100%;
	max-width: 360px;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 1.5rem;
	display: grid;
	gap: 0.9rem;
}
.card h1 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.card label { display: grid; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.card input {
	font: inherit;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--line);
	border-radius: 8px;
}
.card button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* App shell */
.topbar {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.75rem 1rem;
	background: #fff;
	border-bottom: 1px solid var(--line);
	position: sticky;
	top: 0;
}
.brand { font-weight: 600; text-decoration: none; }
.me { margin-left: auto; color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main#inbox, main#message { max-width: 860px; margin: 0 auto; padding: 1rem; }

/* Inbox list */
.list { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a {
	display: grid;
	grid-template-columns: 12px 1fr auto;
	column-gap: 0.6rem;
	padding: 0.75rem 1rem;
	text-decoration: none;
}
.list a:hover { background: var(--bg); }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 0.4rem; }
.unread .dot { background: var(--accent); }
.unread .from, .unread .subject { font-weight: 600; }
.from, .subject, .snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { color: var(--muted); font-size: 0.85rem; }
.subject, .snippet { grid-column: 2 / 4; }
.snippet { color: var(--muted); font-size: 0.9rem; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

/* Message view */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.back { text-decoration: none; color: var(--muted); }
#m-subject { font-size: 1.3rem; margin: 0 0 0.75rem; overflow-wrap: anywhere; }
.headers { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.75rem; margin: 0 0 1rem; font-size: 0.9rem; }
.headers dt { color: var(--muted); }
.headers dd { margin: 0; overflow-wrap: anywhere; }
.attachments { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.attachments a {
	display: inline-block;
	padding: 0.35rem 0.7rem;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #fff;
	font-size: 0.85rem;
	text-decoration: none;
}
#load-images { margin-bottom: 0.75rem; }
#m-html { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#m-text {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	font: inherit;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 1rem;
	margin: 0;
}

@media (max-width: 600px) {
	main#inbox, main#message { padding: 0.5rem; }
	.list { border-radius: 8px; }
}
