:root {
	--bg: #f7f5f1;
	--surface: #ffffff;
	--surface-2: #fbfaf7;
	--ink: #1f2d3d;
	--muted: #5d6875;
	--faint: #8a929b;
	--line: #e3ded5;
	--line-strong: #d3ccc0;
	--accent: #c2551f;
	--accent-ink: #ffffff;
	--accent-soft: #fbeee6;
	--danger: #b42318;
	--ok: #2f7d4f;
	--shadow: 0 1px 2px rgba(31, 45, 61, .06), 0 4px 16px rgba(31, 45, 61, .05);
	--radius: 12px;

	--c-slate: #64748b; --c-slate-bg: #eef1f4;
	--c-blue: #2563eb; --c-blue-bg: #e8efff;
	--c-teal: #0f8a83; --c-teal-bg: #e2f5f3;
	--c-green: #2f7d4f; --c-green-bg: #e5f3ea;
	--c-amber: #a86a00; --c-amber-bg: #fdf1d8;
	--c-orange: #c2551f; --c-orange-bg: #fbeee6;
	--c-rose: #c0335a; --c-rose-bg: #fce8ee;
	--c-violet: #6d4ed8; --c-violet-bg: #efeafd;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #12181f;
		--surface: #1a222c;
		--surface-2: #161d26;
		--ink: #ece8e1;
		--muted: #a7afb8;
		--faint: #7d8893;
		--line: #2b3541;
		--line-strong: #3a4654;
		--accent: #ee8a55;
		--accent-ink: #1a1007;
		--accent-soft: #3a2519;
		--danger: #f07167;
		--ok: #6cc690;
		--shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);

		--c-slate: #a3b0c0; --c-slate-bg: #26303b;
		--c-blue: #8bb0ff; --c-blue-bg: #1d2b48;
		--c-teal: #5fd0c7; --c-teal-bg: #15333a;
		--c-green: #79d39c; --c-green-bg: #1a3428;
		--c-amber: #f2c060; --c-amber-bg: #3a2e12;
		--c-orange: #ee8a55; --c-orange-bg: #3a2519;
		--c-rose: #f48aa8; --c-rose-bg: #3d1e2a;
		--c-violet: #b3a1ff; --c-violet-bg: #2a2445;
	}
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 15px/1.5 "Public Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.hidden { display: none !important; }

/* ---------- controls */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
	padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 14px;
	cursor: pointer; text-decoration: none; white-space: nowrap;
	transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; padding: 10px 14px; }

.input, .select, .textarea {
	width: 100%; background: var(--surface); border: 1px solid var(--line-strong);
	border-radius: 9px; padding: 9px 12px; outline: none;
	transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
	border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; cursor: pointer;
	background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
	background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.select.sm { width: auto; padding: 4px 28px 4px 10px; font-size: 13px; border-radius: 7px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.hint { font-size: 13px; color: var(--faint); }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

/* ---------- boot / auth */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin: 14px 0 4px; }
.auth-card p.lead { color: var(--muted); margin: 0 0 20px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 7px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.sent { text-align: center; padding: 8px 0; }
.sent .big { font-size: 34px; }

.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand img { width: 28px; height: 28px; display: block; }
.brand small { font-weight: 500; color: var(--faint); font-size: 13px; }

/* ---------- shell */
.topbar {
	position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
	backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.search { flex: 1; max-width: 420px; margin-left: auto; position: relative; }
.search .input { padding-left: 34px; background: var(--surface); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.menu { position: relative; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-btn { border: 0; background: transparent; padding: 2px; border-radius: 50%; cursor: pointer; display: flex; }
.avatar-btn:focus-visible { outline: 2px solid var(--accent); }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.dropdown .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.dropdown .who b { display: block; color: var(--ink); font-size: 14px; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; text-decoration: none; color: var(--ink); font-size: 14px; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }

.layout { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; }
.side { position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 90px); overflow: auto; }
.side h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 18px 10px 6px; }
.side h4:first-child { margin-top: 0; }
.nav-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 10px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--ink); font-size: 14px; text-align: left; text-decoration: none; }
.nav-item:hover { background: var(--surface); }
.nav-item.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-item.alert { color: var(--accent); font-weight: 600; }
.nav-item.alert .count { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 7px; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--c-slate); }

/* ---------- quick add */
.quick { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; margin-bottom: 18px; transition: border-color .12s, box-shadow .12s; }
.quick:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow); }
.quick-row { display: flex; align-items: center; gap: 8px; }
.quick-row .plus { width: 34px; height: 34px; display: grid; place-items: center; color: var(--accent); flex: none; }
.quick input.title { flex: 1; border: 0; outline: none; background: transparent; padding: 9px 0; font-size: 16px; min-width: 0; }
.quick textarea { width: 100%; border: 0; outline: none; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; min-height: 90px; resize: vertical; margin-top: 4px; }
.quick-tools { display: flex; align-items: center; gap: 8px; padding: 6px 4px 2px 42px; flex-wrap: wrap; }
.quick-tools .hint { margin-left: auto; }

/* ---------- list */
.list-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 2px 10px; flex-wrap: wrap; }
.list-head h2 { font-size: 20px; }
.list-head .sub { color: var(--faint); font-size: 14px; }
.list-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ideas { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.idea-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; align-items: start; }
.idea-row:first-child { border-top: 0; }
.idea-row:hover { background: var(--surface-2); }
.idea-row .unread { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 8px; }
.idea-row .t { font-weight: 600; font-size: 15.5px; }
.idea-row.is-unread .t { font-weight: 700; }
.idea-row .ex { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--faint); margin-top: 6px; }
.stats { display: flex; gap: 12px; font-size: 13px; color: var(--faint); align-items: center; padding-top: 3px; }
.stats span { display: inline-flex; align-items: center; gap: 4px; }
.stats .mine { color: var(--accent); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--c-slate-bg); color: var(--c-slate); white-space: nowrap; }
.status { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.status.s-new { color: var(--c-blue); border-color: color-mix(in srgb, var(--c-blue) 35%, transparent); }
.status.s-discussing { color: var(--c-amber); border-color: color-mix(in srgb, var(--c-amber) 40%, transparent); }
.status.s-roadmap { color: var(--c-violet); border-color: color-mix(in srgb, var(--c-violet) 40%, transparent); }
.status.s-planned { color: var(--c-teal); border-color: color-mix(in srgb, var(--c-teal) 40%, transparent); }
.status.s-built { color: var(--c-green); border-color: color-mix(in srgb, var(--c-green) 40%, transparent); }
.status.s-parked { color: var(--faint); }
.status.s-pending { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- detail */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.back:hover { color: var(--ink); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.card + .card { margin-top: 16px; }
.detail h1 { font-size: 24px; letter-spacing: -.01em; }
.detail .meta { margin-top: 10px; font-size: 13.5px; }
.detail .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail .actions .right { margin-left: auto; display: flex; gap: 8px; }
.react { display: inline-flex; align-items: center; gap: 6px; }
.react.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.status-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.status-pick button { cursor: pointer; background: transparent; }
.status-pick button.on { background: var(--accent-soft); }

.md { margin-top: 16px; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre { margin: 0 0 12px; }
.md h1, .md h2, .md h3 { font-size: 16px; margin: 18px 0 8px; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 3px 0; }
.md code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.md pre { background: var(--surface-2); border: 1px solid var(--line); padding: 12px; border-radius: 8px; overflow: auto; }
.md pre code { background: none; border: 0; padding: 0; }
.md blockquote { border-left: 3px solid var(--line-strong); padding-left: 12px; color: var(--muted); }
.md.empty-body { color: var(--faint); font-style: italic; }

.thread h3 { font-size: 15px; margin-bottom: 4px; }
.comment { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.comment:first-of-type { border-top: 0; }
.comment .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 14px; }
.comment .head b { font-weight: 700; }
.comment .head .when { color: var(--faint); font-size: 13px; }
.comment .head .tools { margin-left: auto; display: flex; gap: 2px; }
.comment .md { margin-top: 4px; }
.event { display: flex; align-items: center; gap: 8px; padding: 10px 0 10px 42px; font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--line); }
.composer { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.composer .row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }

/* ---------- admin pages */
.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 22px; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.grid-form { display: grid; grid-template-columns: 1fr 1.3fr auto auto; gap: 8px; align-items: center; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td { padding: 12px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:first-child td { border-top: 0; }
.table .who { display: flex; align-items: center; gap: 10px; }
.table .who small { display: block; color: var(--faint); }
.table .acts { text-align: right; white-space: nowrap; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--accent); }
.cat-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.cat-row:first-child { border-top: 0; }
.cat-row .input { flex: 1; }
.swatches { display: flex; gap: 4px; }
.swatches button { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatches button.on { border-color: var(--ink); }
.pending-card .from { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.pending-card .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.invite-result { margin-top: 12px; padding: 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.invite-result code { word-break: break-all; font-size: 12px; }
.radio { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; margin-bottom: 8px; }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio input { margin-top: 4px; accent-color: var(--accent); }
.radio b { display: block; font-size: 14.5px; }
.radio span { font-size: 13.5px; color: var(--muted); }
.section-title { font-size: 15px; margin: 0 0 12px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast a { color: inherit; font-weight: 700; }

/* ---------- small screens */
@media (max-width: 820px) {
	.layout { grid-template-columns: 1fr; gap: 14px; padding-top: 14px; }
	.side { position: static; max-height: none; overflow: visible; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
	.side::-webkit-scrollbar { display: none; }
	.side h4, .side .side-extra { display: none; }
	.nav-item { width: auto; white-space: nowrap; flex: none; border: 1px solid var(--line); background: var(--surface); padding: 5px 11px; }
	.nav-item .count { margin-left: 4px; }
	.brand small { display: none; }
	.search { max-width: none; }
	.card { padding: 18px 16px; }
	.grid-form { grid-template-columns: 1fr; }
	.quick-tools { padding-left: 4px; }
	.quick-tools .hint { display: none; }
	.idea-row { grid-template-columns: 10px minmax(0, 1fr); }
	.idea-row .stats { grid-column: 2; padding-top: 0; }
	.table .hide-sm { display: none; }
}
