:root {
	color-scheme: light dark;
	--bg: #ffffff;
	--fg: #0b0d12;
	--muted: #5b6472;
	--accent: #2f6df6;
	--border: #e4e7ec;
	--danger: #b42318;
	--radius: 10px;
	--space: 1rem;
	--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0b0d12;
		--fg: #f4f6fa;
		--muted: #9aa4b2;
		--accent: #6f9bff;
		--border: #232833;
		--danger: #ff9a8f;
	}
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: calc(var(--space) * 3) var(--space);
}

h1 {
	margin: 0 0 0.5rem;
	font-size: clamp(1.6rem, 4vw, 2.25rem);
	letter-spacing: -0.02em;
}

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0.9rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.btn:hover {
	filter: brightness(1.05);
}

.btn-secondary {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
}

.card {
	padding: var(--space);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
}

.input,
.select,
.textarea {
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--fg);
	font: inherit;
}

.field {
	display: grid;
	gap: 0.35rem;
	margin-bottom: var(--space);
}

.field > label {
	font-size: 0.875rem;
	color: var(--muted);
}

.stack {
	display: grid;
	gap: var(--space);
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

/*
 * 390px-safe. An unclamped minmax track overflows a 390px viewport once the
 * shell padding is subtracted, and nothing in the pipeline ever looked at a
 * phone-width layout, so every generated app inherited the horizontal scroll.
 * min() clamps the track to the container instead.
 */
.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

.table th {
	font-size: 0.8125rem;
	color: var(--muted);
	font-weight: 600;
}

.empty {
	padding: calc(var(--space) * 2);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 600;
}

/* Loading. Every fetch has one; without a primitive each app invented its own. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Placeholder for content whose shape is known before its data arrives. */
.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Error strip: a failure the user can see and retry, never a silent no-op. */
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/*
 * The scaffold had exactly one @media rule (prefers-color-scheme) and no width
 * breakpoint at all, so the shell was a 42rem column at every size.
 * Mobile-first stays the default; these only widen it.
 */
@media (min-width: 48rem) {
	.shell {
		max-width: 52rem;
		padding: calc(var(--space) * 3) calc(var(--space) * 1.5);
	}
}

@media (min-width: 64rem) {
	.shell {
		max-width: 64rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton {
		animation: none;
	}
}

:root {
	color-scheme: light;
	--bg: #f2f4f8;
	--surface: #ffffff;
	--fg: #151a2d;
	--muted: #5a6180;
	--accent: #0f7b6c;
	--accent-soft: #e2f3f0;
	--heart: #d9365a;
	--border: #dfe3ec;
	--danger: #b42318;
	--radius: 14px;
	--font: "Figtree", ui-sans-serif, system-ui, sans-serif;
	--display: "Bricolage Grotesque", "Figtree", sans-serif;
}

body { background: var(--bg); font-size: 16px; }
h1, h2, .brand, .auth-title { font-family: var(--display); }
.card { background: var(--surface); box-shadow: 0 1px 2px rgb(21 26 45 / 0.05); }
.btn { min-height: 44px; border-radius: 10px; font-weight: 600; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-secondary { background: var(--surface); }
.btn-block { width: 100%; justify-content: center; }
.input, .textarea { background: var(--surface); min-height: 44px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.8125rem; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline-error { color: var(--danger); margin: 0.5rem 0 0; font-size: 0.875rem; }
.section-title { margin: 0.5rem 0 0; font-size: 1.25rem; }
.empty-card { padding: 0.5rem; }

.brand {
	display: inline-flex; align-items: center; gap: 0.5rem;
	border: 0; background: none; color: var(--fg); font-size: 1.35rem; font-weight: 800; cursor: pointer; padding: 0;
}
.brand-mark { width: 22px; height: 22px; border-radius: 50%; border: 5px solid var(--accent); box-shadow: 6px 0 0 -2px var(--heart); }
.brand-lg { font-size: 2rem; }

.app-header { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.app-header-inner { max-width: 44rem; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 1rem; }
.nav { display: flex; gap: 0.25rem; }
.nav-item {
	display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; padding: 0 0.75rem;
	border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.nav-item.is-active { color: var(--accent); background: var(--accent-soft); }
.page { max-width: 44rem; margin: 0 auto; padding: 1.25rem 1rem 6rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

@media (max-width: 640px) {
	.app-header-inner { justify-content: center; }
	.app-header .brand { display: none; }
	.app-header { position: fixed; top: auto; bottom: 0; left: 0; right: 0; border-top: 1px solid var(--border); border-bottom: 0; }
	.nav { width: 100%; justify-content: space-around; }
	.nav-item { flex-direction: column; gap: 0.1rem; font-size: 0.75rem; padding: 0.3rem 0.5rem; }
	.hide-sm { display: none; }
}

.auth-wrap { max-width: 28rem; margin: 0 auto; padding: 3rem 1rem; display: grid; gap: 1.5rem; }
.auth-title { font-size: clamp(1.9rem, 7vw, 2.6rem); line-height: 1.1; margin: 1rem 0 0.5rem; letter-spacing: -0.02em; }
.auth-card { padding: 1.25rem; }
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--border); gap: 2px; margin-bottom: 1rem; }
.segmented button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 0.45rem 0.9rem; border-radius: 9px; cursor: pointer; min-height: 38px; }
.segmented button.is-on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.page-head .segmented { margin: 0; }

.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-weight: 700; }
.avatar-sm { width: 36px; height: 36px; font-size: 0.8rem; }
.avatar-md { width: 42px; height: 42px; font-size: 0.9rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; font-family: var(--display); }

.composer { display: grid; gap: 0.75rem; }
.composer-top { display: flex; gap: 0.75rem; align-items: flex-start; }
.composer-input { flex: 1; min-width: 0; border: 0; resize: vertical; font: inherit; font-size: 1.05rem; background: none; color: var(--fg); padding: 0.5rem 0; }
.composer-input:focus { outline: none; }
.composer-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.composer-bar label.btn { cursor: pointer; }
.char-count { margin-left: auto; color: var(--muted); font-size: 0.8125rem; }
.pending-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 0.5rem; }
.pending { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--border); }
.pending img, .pending video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pending-remove {
	position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; display: grid; place-items: center;
	border: 0; border-radius: 50%; background: rgb(21 26 45 / 0.7); color: #fff; cursor: pointer;
}

.post-list { display: grid; gap: 0.75rem; }
.post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; scroll-margin-top: 5rem; }
.post-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.author { display: inline-flex; align-items: center; gap: 0.6rem; border: 0; background: none; padding: 0; font: inherit; color: var(--fg); cursor: pointer; min-width: 0; }
.author-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-time { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.post-body { margin: 0.75rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.02rem; }
.media-grid { display: grid; gap: 4px; margin-top: 0.75rem; border-radius: 12px; overflow: hidden; }
.media-count-2, .media-count-3, .media-count-4 { grid-template-columns: 1fr 1fr; }
.media-item { width: 100%; display: block; background: #0e1120; max-height: 520px; object-fit: cover; }
.media-count-2 .media-item, .media-count-3 .media-item, .media-count-4 .media-item { aspect-ratio: 1; height: 100%; }
video.media-item { object-fit: contain; }
.post-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.action {
	display: inline-flex; align-items: center; gap: 0.35rem; min-height: 40px; padding: 0 0.6rem;
	border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; cursor: pointer;
}
.action:hover { background: var(--bg); }
.action.is-liked { color: var(--heart); }
.action-quiet { margin-left: auto; }
.count { font-variant-numeric: tabular-nums; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.chip { min-height: 40px; padding: 0 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.is-on { background: var(--fg); color: var(--surface); border-color: var(--fg); }
.chip-note { color: var(--muted); font-size: 0.875rem; margin-left: auto; font-variant-numeric: tabular-nums; }

.person {
	display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left; padding: 0.6rem;
	border: 0; border-radius: 10px; background: none; font: inherit; color: var(--fg); cursor: pointer; min-height: 52px;
}
.person:hover, .person.is-on { background: var(--accent-soft); }
.person-text { display: grid; min-width: 0; flex: 1; }
.person-name { font-weight: 700; }
.person-bio { color: var(--muted); font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-meta { display: grid; justify-items: end; gap: 0.2rem; }
.unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 700; display: grid; place-items: center; }

.messages { display: grid; gap: 1rem; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.pane-head h1 { margin: 0; }
.messages.has-active .convo-pane { display: none; }
.messages:not(.has-active) .thread-pane { display: none; }
.thread-empty { display: grid; place-items: center; min-height: 300px; }
.thread { display: flex; flex-direction: column; height: calc(100vh - 10rem); min-height: 380px; padding: 0; overflow: hidden; }
.thread-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.thread-skel { width: 140px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--fg); cursor: pointer; }
.thread-body { flex: 1; overflow-y: auto; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; }
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble { margin: 0; max-width: 78%; padding: 0.55rem 0.85rem; border-radius: 16px 16px 16px 4px; background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; }
.mine .bubble { background: var(--accent); color: #fff; border-radius: 16px 16px 4px 16px; }
.thread-form { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--border); }
.thread > .alert { margin: 0 0.75rem; }

@media (min-width: 760px) {
	.page { max-width: 60rem; }
	.app-header-inner { max-width: 60rem; }
	.messages { grid-template-columns: 20rem 1fr; align-items: start; }
	.messages.has-active .convo-pane, .messages:not(.has-active) .thread-pane { display: block; }
	.thread-back { display: none; }
	.page > .stack { max-width: 40rem; margin: 0 auto; }
}

.profile { display: grid; gap: 1rem; padding: 1.25rem; }
.profile-top { display: flex; align-items: center; gap: 1rem; }
.profile-id { min-width: 0; }
.profile-name { margin: 0; font-size: clamp(1.6rem, 6vw, 2.2rem); overflow-wrap: anywhere; }
.profile-bio { margin: 0; white-space: pre-wrap; }
.stats { display: flex; gap: 1.5rem; margin: 0; flex-wrap: wrap; }
.stats dt { color: var(--muted); font-size: 0.8125rem; }
.stats dd { margin: 0; font-family: var(--display); font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.edit-form .field { margin-bottom: 0.75rem; }

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
