/* ============ Design tokens ============ */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9ecf1;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ink: #ffffff;
  --up: #f2542d;
  --down: #5b7cfa;
  --ai: #b45309;
  --ai-soft: #fff8eb;
  --ai-border: #fcd9a1;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --danger: #d92d20;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar: 56px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #191d26;
  --surface-3: #222734;
  --border: #252b38;
  --border-strong: #333a4b;
  --text: #f2f4f7;
  --text-2: #d0d5dd;
  --muted: #98a2b3;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, .14);
  --primary-ink: #0b0d12;
  --up: #ff7a52;
  --down: #8ea2ff;
  --ai: #fbbf24;
  --ai-soft: rgba(251, 191, 36, .09);
  --ai-border: rgba(251, 191, 36, .28);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, .12);
  --danger: #f97066;
  --shadow-sm: none;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.015em; color: var(--text); }
p { margin: 0 0 .75em; }
img { max-width: 100%; }
[hidden] { display: none !important; }
svg.ic { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
::selection { background: var(--primary-soft); }

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gap-8 { gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ Buttons & inputs ============ */
.btn { font: inherit; font-weight: 600; font-size: 14px; border: 1px solid transparent; border-radius: 999px; padding: 8px 16px; cursor: pointer; background: var(--surface-2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; line-height: 1.2; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.outline { background: transparent; border-color: var(--border-strong); }
.btn.outline:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.ai { background: var(--ai-soft); color: var(--ai); border-color: var(--ai-border); }
.btn.ai:hover { filter: brightness(.98); }
.btn.danger { color: var(--danger); }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.google { width: 100%; background: var(--surface); color: var(--text); border-color: var(--border-strong); padding: 11px 16px; margin: 12px 0 4px; }
.btn.google:hover { background: var(--surface-2); }
.icon-btn { font: inherit; background: none; border: 0; cursor: pointer; color: var(--text-2); width: 36px; height: 36px; border-radius: 999px; display: inline-grid; place-items: center; position: relative; flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn .ic { width: 20px; height: 20px; }

input, textarea, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 44px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); }
label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; color: var(--text-2); }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 8px 0 0; }

.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; color: var(--text); letter-spacing: -.03em; }
.brand:hover { text-decoration: none; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); display: inline-block; position: relative; flex-shrink: 0; }
.logo::after { content: ""; position: absolute; inset: 7px; background:
  linear-gradient(var(--primary-ink), var(--primary-ink)) 0 0 / 6px 6px no-repeat,
  linear-gradient(var(--primary-ink), var(--primary-ink)) 100% 0 / 6px 6px no-repeat,
  linear-gradient(var(--primary-ink), var(--primary-ink)) 0 100% / 6px 6px no-repeat,
  linear-gradient(var(--primary-ink), var(--primary-ink)) 100% 100% / 6px 6px no-repeat; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 12px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.tag.sample { background: var(--ai-soft); color: var(--ai); border-color: var(--ai-border); }
.tag.verified { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.owner { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; font-family: inherit; }
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.skill { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; font-size: 13px; flex-shrink: 0; letter-spacing: 0; }
.avatar.xs { width: 22px; height: 22px; font-size: 10px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }
.c-av { width: 32px; height: 32px; border-radius: 10px; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.c-av.xs { width: 20px; height: 20px; border-radius: 6px; font-size: 10px; }
.c-av.sm { width: 24px; height: 24px; border-radius: 7px; font-size: 11px; }
.c-av.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 26px; border: 4px solid var(--surface); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 16px; }
.card h3 { font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty .ic { width: 28px; height: 28px; margin: 0 auto 8px; }
.loading { color: var(--muted); padding: 32px; text-align: center; }
.skeleton { height: 120px; border-radius: var(--radius); margin-bottom: 12px; background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: sh 1.2s infinite; border: 1px solid var(--border); }
@keyframes sh { to { background-position: -200% 0; } }

/* ============ Landing ============ */
.lp-wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.lp-nav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.lp-nav .lp-wrap { height: 64px; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; padding-top: 64px; padding-bottom: 32px; }
.hero h1 { font-size: clamp(34px, 5vw, 56px); letter-spacing: -.035em; line-height: 1.05; margin: 16px 0; font-weight: 800; }
.lead { font-size: 17px; color: var(--muted); line-height: 1.65; margin-bottom: 24px; }
.lead strong { color: var(--text); }
.fine { color: var(--muted); font-size: 12.5px; margin-top: 16px; max-width: 560px; }
.hero-art { display: flex; flex-direction: column; gap: 14px; }
.mock-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow-lg); display: flex; gap: 12px; flex-direction: column; }
.mock-card:first-child { flex-direction: row; }
.mock-card:nth-child(2) { margin-left: 32px; }
.mock-card:nth-child(3) { margin-right: 32px; }
.mock-vote { display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: 12px; }
.mock-vote b { color: var(--up); font-size: 14px; }
.mock-meta { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.mock-av { width: 18px; height: 18px; border-radius: 5px; color: #fff; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; }
.mock-title { font-weight: 700; font-size: 15px; margin: 6px 0; }
.mock-file { font-size: 12.5px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; background: var(--surface-2); display: inline-block; }
.mock-card.ai { background: var(--ai-soft); border-color: var(--ai-border); }
.mock-ai-head { font-weight: 700; color: var(--ai); font-size: 13px; }
.mock-ai-tldr { font-size: 13.5px; font-weight: 500; }
.mock-card.mock-chat { gap: 8px; }
.mock-bubble { background: var(--surface-2); border-radius: 14px 14px 14px 4px; padding: 7px 12px; font-size: 13px; align-self: flex-start; }
.mock-bubble.mine { background: var(--primary); color: var(--primary-ink); border-radius: 14px 14px 4px 14px; align-self: flex-end; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 40px; padding: 0; }
.stats div { background: var(--surface); padding: 18px 12px; text-align: center; }
.stats b { display: block; font-size: 26px; letter-spacing: -.03em; font-weight: 800; }
.stats span { color: var(--muted); font-size: 12px; }
.lp-block { margin-top: 72px; }
.lp-block h2 { font-size: 28px; letter-spacing: -.03em; font-weight: 800; margin-bottom: 20px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { padding: 20px; }
.feature h3 { font-size: 16px; margin-top: 12px; }
.feature p { color: var(--muted); margin: 0; line-height: 1.6; }
.feature-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.feature.ai { background: var(--ai-soft); border-color: var(--ai-border); }
.feature.ai .feature-ic { background: var(--ai-border); color: var(--ai); }
.aws { padding: 8px 24px; }
.aws ul { padding-left: 18px; color: var(--muted); line-height: 1.7; }
.aws b { color: var(--text); }
.lp-foot { border-top: 1px solid var(--border); padding-top: 24px; padding-bottom: 48px; margin-top: 72px; color: var(--muted); font-size: 13px; }
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 32px; gap: 32px; }
  .grid3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .mock-card:nth-child(2), .mock-card:nth-child(3) { margin: 0; }
}

/* ============ App shell ============ */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.topbar .brand { min-width: 200px; }
.search { flex: 1; max-width: 560px; margin: 0 auto; position: relative; display: flex; align-items: center; }
.search > span { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { border-radius: 999px; background: var(--surface-2); border-color: transparent; padding: 8px 14px 8px 38px; }
.search input:focus { background: var(--surface); }
.top-actions { display: flex; align-items: center; gap: 4px; }
.top-actions .btn { margin-right: 6px; }
.badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; font-style: normal; font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center; line-height: 1; border: 2px solid var(--surface); box-sizing: content-box; }
.avatar-btn { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; margin-left: 4px; }
.dropdown { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; z-index: 40; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-panel { width: 360px; max-height: 70vh; overflow-y: auto; padding: 0; }
.notif-head { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; }
.notif { display: flex; gap: 10px; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--border); }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { background: var(--primary-soft); }
.demo-banner { background: var(--ai-soft); color: var(--text); padding: 8px 16px; font-size: 13px; text-align: center; border-bottom: 1px solid var(--ai-border); }

.shell { display: flex; max-width: 1440px; margin: 0 auto; }
#sidebar { width: 248px; flex-shrink: 0; padding: 16px 12px; position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow-y: auto; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.side-nav a, .side-comms a, .side-link { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; background: none; border: 0; font: inherit; font-weight: 500; cursor: pointer; width: 100%; text-align: left; }
.side-nav a:hover, .side-comms a:hover, .side-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.side-nav a.active, .side-comms a.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.side-section { padding-top: 12px; }
.side-label { margin: 4px 12px 6px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.side-comms { display: flex; flex-direction: column; gap: 1px; }
.side-comms a { padding: 6px 12px; gap: 10px; }
.side-comms a span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link { color: var(--muted); }
.side-foot { margin-top: auto; padding: 16px 12px 0; color: var(--muted); font-size: 11px; }
#view { flex: 1; min-width: 0; padding: 20px 24px 48px; }
#scrim { display: none; }
.fab { display: none; }
.only-mobile { display: none !important; }

.page { display: flex; gap: 24px; align-items: flex-start; max-width: 1104px; margin: 0 auto; }
.page-main { flex: 1; min-width: 0; max-width: 760px; }
.page-main.wide { max-width: none; }
.rail { width: 316px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--topbar) + 20px); }
.rail .card { padding: 16px; }
.rail h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

@media (max-width: 1200px) { .rail { display: none; } }
@media (max-width: 860px) {
  .only-mobile { display: inline-grid !important; }
  .hide-mobile { display: none !important; }
  .topbar { padding: 0 8px; gap: 6px; }
  .topbar .brand { min-width: 0; }
  .brand-text { display: none; }
  #sidebar { position: fixed; left: 0; top: 0; z-index: 50; height: 100vh; background: var(--surface); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.menu-open #sidebar { transform: none; }
  body.menu-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 45; }
  #view { padding: 12px 12px 88px; }
  .fab { display: grid !important; position: fixed; right: 16px; bottom: 20px; width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); border: 0; box-shadow: var(--shadow-lg); z-index: 20; place-items: center; cursor: pointer; }
  .fab .ic { width: 24px; height: 24px; }
  .notif-panel { position: fixed; left: 8px; right: 8px; top: calc(var(--topbar) + 4px); width: auto; }
}

/* ============ Feed & posts ============ */
.feed-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button .ic { width: 15px; height: 15px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.compose-prompt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px; }
.compose-prompt input { background: var(--surface-2); border-color: transparent; cursor: pointer; border-radius: 999px; }

.post-card { display: flex; gap: 0; margin-bottom: 10px; overflow: hidden; transition: border-color .15s; }
.post-card.clickable:hover { border-color: var(--border-strong); cursor: pointer; }
.vote { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; width: 48px; flex-shrink: 0; background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.vote button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 30px; height: 28px; border-radius: 6px; display: grid; place-items: center; }
.vote button:hover { background: var(--surface-3); }
.vote button .ic { width: 18px; height: 18px; }
.vote b { font-size: 13px; font-weight: 700; color: var(--text-2); }
.vote.up b, .vote.up .v-up { color: var(--up); }
.vote.up .v-up .ic { fill: var(--up); }
.vote.down b, .vote.down .v-down { color: var(--down); }
.vote.down .v-down .ic { fill: var(--down); }
.post-body { flex: 1; min-width: 0; padding: 10px 16px 6px 12px; }
.post-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.post-meta a { color: var(--text-2); font-weight: 600; }
.post-meta .dot::before { content: "·"; }
.post-title { display: block; font-size: 17px; font-weight: 600; color: var(--text); margin: 4px 0 4px; letter-spacing: -.01em; line-height: 1.35; word-wrap: break-word; }
.post-title:hover { text-decoration: none; }
.post-text { color: var(--text-2); white-space: pre-wrap; word-wrap: break-word; line-height: 1.6; }
.post-text.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.post-actions { display: flex; gap: 2px; margin: 6px 0 0 -8px; }
.post-actions .btn { background: transparent; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 6px 10px; }
.post-actions .btn:hover { background: var(--surface-2); color: var(--text); }
.new-posts { position: sticky; top: calc(var(--topbar) + 8px); z-index: 5; display: flex; justify-content: center; margin-bottom: 8px; }

.atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.att-img { max-width: 100%; max-height: 360px; border-radius: 10px; border: 1px solid var(--border); display: block; object-fit: cover; }
.att-file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 13px; max-width: 100%; }
.att-file:hover { text-decoration: none; border-color: var(--primary); }
.att-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* comments */
.comment-box { padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.comment-form textarea { min-height: 80px; }
.comment-form .row { justify-content: flex-end; margin-top: 8px; }
.thread { padding: 4px 16px 16px; }
.cmt { display: flex; gap: 10px; margin-top: 14px; }
.cmt-body { flex: 1; min-width: 0; }
.cmt-head { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cmt-head b { color: var(--text); font-weight: 600; }
.cmt-text { white-space: pre-wrap; word-wrap: break-word; margin: 2px 0 2px; color: var(--text-2); line-height: 1.55; }
.cmt-text.deleted { color: var(--muted); font-style: italic; }
.cmt-actions { display: flex; gap: 2px; margin-left: -8px; }
.cmt-actions button { font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 4px 8px; border-radius: 6px; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.cmt-actions button:hover { background: var(--surface-2); color: var(--text); }
.cmt-actions .ic { width: 14px; height: 14px; }
.replies { border-left: 2px solid var(--border); padding-left: 14px; margin-left: 4px; }
.reply-form { margin-top: 8px; }
.reply-form textarea { min-height: 60px; }

/* ============ Community ============ */
.c-banner { height: 88px; border-radius: var(--radius) var(--radius) 0 0; }
.c-head { padding: 0 20px 16px; margin-bottom: 16px; border-radius: 0 0 var(--radius) var(--radius); border-top: 0; }
.c-head-row { display: flex; align-items: flex-end; gap: 14px; margin-top: -28px; flex-wrap: wrap; }
.c-head h1 { font-size: 24px; margin: 0; font-weight: 800; }
.c-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 2px; }
.c-desc { color: var(--muted); margin: 12px 0 0; white-space: pre-wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--text); border-color: var(--primary); }
.tabs .ic { width: 16px; height: 16px; }
.about-stats { display: flex; gap: 24px; margin: 12px 0; }
.about-stats b { display: block; font-size: 18px; }
.about-stats span { color: var(--muted); font-size: 12px; }
.ai-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.comm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.comm-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.comm-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.comm-card h3 { font-size: 15px; margin: 0; }
.comm-card p { color: var(--muted); font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.mini-list { display: flex; flex-direction: column; gap: 10px; }
.mini-item { display: flex; align-items: center; gap: 10px; color: var(--text); }
.mini-item:hover { text-decoration: none; }

/* ============ Chat ============ */
.chat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; height: calc(100vh - var(--topbar) - 240px); min-height: 420px; }
.rail.fill { height: calc(100vh - var(--topbar) - 80px); min-height: 560px; }
.rail.fill #rail-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.rail.fill .chat { flex: 1; height: auto; min-height: 0; }
.rail .about-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dm-pane .chat { height: calc(100vh - var(--topbar) - 60px); }
.chat.full { height: calc(100vh - var(--topbar) - 60px); }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.chat-head .live { width: 8px; height: 8px; border-radius: 50%; background: #12b76a; box-shadow: 0 0 0 3px rgba(18, 183, 106, .2); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; }
.msg { display: flex; gap: 8px; max-width: 86%; margin-top: 10px; position: relative; }
.msg.cont { margin-top: 2px; }
.msg.cont .msg-av { visibility: hidden; height: 0; }
.msg-av { width: 28px; flex-shrink: 0; }
.msg .bubble { background: var(--surface-2); border-radius: 16px 16px 16px 4px; padding: 7px 12px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; }
.msg .meta { font-size: 11.5px; color: var(--muted); margin: 0 0 3px 2px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .bubble { background: var(--primary); color: var(--primary-ink); border-radius: 16px 16px 4px 16px; }
.msg.mine .bubble a { color: inherit; text-decoration: underline; }
.msg.mine .meta { text-align: right; }
.msg .del { position: absolute; top: 50%; transform: translateY(-50%); left: -30px; opacity: 0; width: 26px; height: 26px; }
.msg:hover .del { opacity: 1; }
.msg .del .ic { width: 14px; height: 14px; }
.day-sep { text-align: center; font-size: 11px; color: var(--muted); margin: 16px 0 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.chat-form { border-top: 1px solid var(--border); padding: 10px; }
.chat-form .row { gap: 6px; align-items: flex-end; }
.chat-form textarea { min-height: 40px; max-height: 140px; border-radius: 20px; padding: 9px 14px; resize: none; }
.chat-form .send { width: 40px; height: 40px; border-radius: 50%; padding: 0; }
.pending { display: flex; flex-wrap: wrap; gap: 6px; }
.pending:not(:empty) { margin-top: 8px; }

/* messages page */
.dm-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; max-width: 1104px; margin: 0 auto; }
.dm-list { overflow: hidden; height: calc(100vh - var(--topbar) - 60px); display: flex; flex-direction: column; }
.dm-list-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.dm-list-items { overflow-y: auto; flex: 1; }
.dm-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); border-bottom: 1px solid var(--border); position: relative; }
.dm-item:hover { background: var(--surface-2); text-decoration: none; }
.dm-item.active { background: var(--primary-soft); }
.dm-item .title { font-weight: 600; }
.dm-item .sub { color: var(--muted); font-size: 13px; }
.dm-item .badge { position: static; border: 0; }
.dm-empty { display: grid; place-items: center; height: calc(100vh - var(--topbar) - 60px); color: var(--muted); text-align: center; }
@media (max-width: 860px) {
  .dm-layout { grid-template-columns: 1fr; }
  .dm-layout.has-conv .dm-list, .dm-layout:not(.has-conv) .dm-pane { display: none; }
  .chat, .chat.full, .dm-pane .chat { height: calc(100dvh - var(--topbar) - 40px); }
  .c-banner { height: 48px; }
  .c-head-row { margin-top: -20px; }
  .c-head .c-av.lg { width: 48px; height: 48px; font-size: 20px; border-radius: 14px; }
  .c-head h1 { font-size: 20px; }
  .compact-head .c-desc { display: none; }
  body.no-fab .fab { display: none !important; }
}

/* lists */
.list { overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .title { font-weight: 600; }
.list-item .sub { color: var(--muted); font-size: 13px; }

/* profile */
.profile-banner { height: 96px; border-radius: var(--radius) var(--radius) 0 0; }
.profile-card { padding: 0 20px 20px; border-radius: 0 0 var(--radius) var(--radius); border-top: 0; }
.profile-top { display: flex; align-items: flex-end; gap: 16px; margin-top: -32px; flex-wrap: wrap; }
.profile-top .avatar.lg { border: 4px solid var(--surface); }
.profile-top h1 { margin: 0; font-size: 22px; }
.facts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 12px; }
.facts span { display: inline-flex; align-items: center; gap: 6px; }
.facts .ic { width: 15px; height: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* ============ Modal ============ */
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10, 12, 18, .55); backdrop-filter: blur(2px); }
#modal-body { padding: 22px 24px 24px; max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 19px; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.switch { text-align: center; margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.dropzone { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

/* AI panels */
.ai-head { display: flex; align-items: center; gap: 8px; color: var(--ai); font-weight: 700; }
.ai-head .ic { width: 18px; height: 18px; }
.cmu-windows { margin: 12px 0 16px; }
.cmu-counts { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.cmu-tldr { background: var(--ai-soft); border: 1px solid var(--ai-border); border-radius: 12px; padding: 12px 14px; font-weight: 500; line-height: 1.55; margin-bottom: 8px; }
.cmu h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.cmu ul { margin: 0; padding-left: 18px; }
.cmu li { margin: 6px 0; line-height: 1.5; }
.cmu .mood { color: var(--muted); font-style: italic; margin-top: 14px; }
.ai-note { color: var(--muted); font-size: 11.5px; margin-top: 16px; }
.match { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.match:last-child { border-bottom: 0; }
.shimmer { height: 12px; border-radius: 6px; margin: 10px 0; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sh 1.2s infinite; }

/* toasts */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow-lg); max-width: min(420px, calc(100vw - 32px)); cursor: pointer; font-weight: 500; animation: pop .2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.noscript { text-align: center; padding: 16px; }
