/*
 * Sammen — one stylesheet, no framework.
 * Understated, warm and precise: typography, spacing and quiet contrast do the work.
 */

:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --surface-2: #f0ede7;
  --surface-hover: #faf8f5;
  --border: #e4dfd6;
  --border-strong: #d3ccc0;
  --text: #1e1c19;
  --text-2: #57524a;
  --text-3: #857e73;
  --accent: #2c6a55;
  --accent-hover: #245847;
  --accent-text: #ffffff;
  --accent-soft: #e4efe9;
  --accent-softer: #f1f7f3;
  --danger: #a63d2a;
  --danger-soft: #f8e9e5;
  --focus: #3b82c4;
  --shadow: 0 1px 2px rgb(30 28 25 / 0.04), 0 1px 1px rgb(30 28 25 / 0.03);
  --shadow-raised: 0 8px 24px rgb(30 28 25 / 0.12), 0 2px 6px rgb(30 28 25 / 0.06);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
  --radius-small: 8px;
  --topbar-height: 56px;
  --reading: 42rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #1f1d1a;
    --surface-2: #2a2723;
    --surface-hover: #24221f;
    --border: #34302b;
    --border-strong: #46413a;
    --text: #ece8e1;
    --text-2: #b9b2a6;
    --text-3: #8d867b;
    --accent: #6cbc9c;
    --accent-hover: #82cbad;
    --accent-text: #0f1f19;
    --accent-soft: #1f3a30;
    --accent-softer: #1b2b25;
    --danger: #e58873;
    --danger-soft: #3a221c;
    --focus: #7fb6e8;
    --shadow: none;
    --shadow-raised: 0 8px 24px rgb(0 0 0 / 0.5);
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-height) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.012em; }
h1 { font-size: 1.625rem; }
h2 { font-size: 1.125rem; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img { max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
strong { font-weight: 620; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: 12px; top: 8px;
  transform: translateY(-200%);
  z-index: 100;
  padding: 8px 14px;
  background: var(--surface);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow-raised);
}
.skip-link:focus { transform: none; }

.muted { color: var(--text-3); }
.fine-print { color: var(--text-3); font-size: 0.8125rem; margin-top: 16px; }
.fine-print a { color: inherit; text-decoration: underline; }

.icon { flex: none; display: inline-block; vertical-align: middle; }

/* ---------- Buttons & forms ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.button:hover { background: var(--accent-hover); text-decoration: none; }
.button:active { transform: scale(0.98); }
.button:disabled { opacity: 0.55; cursor: default; transform: none; }
.button-small { min-height: 34px; padding: 6px 13px; font-size: 0.875rem; }
.button-block { width: 100%; }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.button-secondary:hover { background: var(--surface-2); }
.button-quiet { background: transparent; color: var(--text-2); }
.button-quiet:hover { background: var(--surface-2); }
.button-danger { background: var(--danger); color: #fff; }
.button-danger:hover { background: var(--danger); filter: brightness(0.92); }

.text-button {
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 2px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
}
.text-button:hover { color: var(--text); text-decoration: none; }
.text-button-danger:hover { color: var(--danger); }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  color: var(--text-3);
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }

.inline-form { display: inline; }
.stack { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; }
.field label, .field legend, .label { font-size: 0.875rem; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 0.8125rem; color: var(--text-3); }

input[type=text], input[type=email], input[type=search], input:not([type]), textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 44px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }

.code-input {
  font-family: var(--font-mono);
  font-size: 1.5rem !important;
  letter-spacing: 0.3em;
  text-align: center;
}

.choice-group { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.choice-group legend { margin-bottom: 6px; padding: 0; }
.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  cursor: pointer;
  background: var(--surface);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-softer); }
.choice input { margin-top: 4px; accent-color: var(--accent); }
.choice-text { display: grid; gap: 2px; }
.choice-title { font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.choice-description { font-size: 0.875rem; color: var(--text-2); }
.checkbox { display: inline-flex; gap: 6px; align-items: center; font-size: 0.875rem; color: var(--text-2); margin-top: 8px; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-errors {
  padding: 12px 14px;
  border-radius: var(--radius-small);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9375rem;
}

/* ---------- Top bar & navigation ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}
.brand {
  font-weight: 700;
  font-size: 1.1875rem;
  letter-spacing: -0.025em;
  color: var(--text);
}
.brand::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 6px 0 0 -1px color-mix(in srgb, var(--accent) 45%, transparent);
  vertical-align: 2px;
}
.brand:hover { text-decoration: none; }

.topbar-search {
  position: relative;
  flex: 0 1 380px;
  margin-left: auto;
  color: var(--text-3);
}
.topbar-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); }
.topbar-search input {
  padding: 7px 12px 7px 36px;
  border-radius: 999px;
  background: var(--surface-2);
  border-color: transparent;
  font-size: 0.9375rem;
}
.topbar-search input:focus { background: var(--surface); }

.topnav { display: flex; align-items: center; gap: 4px; }
.topnav .nav-link .nav-label { display: none; }
.nav-text-link { color: var(--text-2); font-weight: 550; padding: 6px 10px; }
.nav-profile { display: inline-flex; padding: 2px; border-radius: 999px; margin-left: 4px; }
.nav-search-mobile { display: none !important; }
body:not(.is-signed-in) .topbar-search { display: none; }
body:not(.is-signed-in) .topnav { margin-left: auto; }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-small);
  color: var(--text-2);
  font-weight: 550;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { color: var(--text); background: var(--surface-2); }
.nav-link .badge {
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.topnav .nav-link .badge { position: absolute; top: 2px; right: 0; }
.sidebar .nav-link .badge { margin-left: auto; }

/* ---------- Layout shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 96px;
}
.is-signed-in .shell { grid-template-columns: 232px minmax(0, 1fr); }
.is-signed-in .shell.has-aside { grid-template-columns: 232px minmax(0, 1fr) 280px; }
.shell.has-aside { grid-template-columns: minmax(0, 1fr) 280px; }
body:not(.is-signed-in) .main { max-width: var(--reading); margin: 0 auto; width: 100%; }
body:not(.is-signed-in) .shell.has-aside .main { max-width: none; }

.main { min-width: 0; outline: none; }
.is-signed-in .main { max-width: 46rem; }

.sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--topbar-height) - 48px);
  overflow-y: auto;
  display: grid;
  gap: 24px;
}
.sidebar-section { display: grid; gap: 2px; }
.sidebar-heading {
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  padding: 0 10px 6px;
}
.sidebar-empty { padding: 0 10px; color: var(--text-3); font-size: 0.875rem; }
.sidebar-groups { display: grid; gap: 1px; }
.sidebar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-small);
  color: var(--text-2);
  font-size: 0.9375rem;
}
.sidebar-group:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.sidebar-group.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.sidebar-group.has-unread { color: var(--text); font-weight: 600; }
.sidebar-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-actions { display: grid; gap: 1px; margin-top: 8px; }
.sidebar-action {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-small);
  color: var(--text-3);
  font-size: 0.875rem;
  font-weight: 550;
}
.sidebar-action:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}
.count-large { font-size: 0.8125rem; padding: 3px 10px; }

.aside {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  align-self: start;
  display: grid;
  gap: 16px;
}
.aside-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
}
.aside-title { font-size: 0.9375rem; }
.aside-subtitle { font-size: 0.8125rem; color: var(--text-3); font-weight: 600; }
.aside-description { font-size: 0.9375rem; color: var(--text-2); display: grid; gap: 8px; }
.facts { display: grid; gap: 10px; font-size: 0.875rem; color: var(--text-2); }
.facts li { display: flex; gap: 10px; align-items: flex-start; }
.facts .icon { margin-top: 2px; color: var(--text-3); }
.people-compact { display: grid; gap: 6px; font-size: 0.875rem; }
.people-compact li { display: flex; gap: 8px; align-items: center; }
.aside-actions { gap: 0; padding: 6px; }
.aside-link {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-small);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
}
.aside-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.aside-link-quiet { color: var(--text-3); font-size: 0.875rem; }
.aside-actions form { display: block; }

.tabbar { display: none; }

/* ---------- Page structure ---------- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 20px;
}
.page-subtitle { width: 100%; color: var(--text-3); margin-top: -6px; font-size: 0.9375rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.header-count { color: var(--text-3); font-weight: 500; }

.breadcrumb { margin-bottom: 14px; font-size: 0.9375rem; }
.breadcrumb a { display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); font-weight: 550; }
.breadcrumb a:hover { color: var(--text); }

.section { margin-top: 28px; }
.section-title {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 10px;
}

.flash {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-small);
  font-size: 0.9375rem;
  transition: opacity 300ms ease;
}
.flash-notice { background: var(--accent-soft); color: var(--text); }
.flash-alert { background: var(--danger-soft); color: var(--danger); }
.flash.is-leaving { opacity: 0; }

.empty-state {
  padding: 40px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-2);
  display: grid;
  gap: 12px;
  justify-items: center;
}
.empty-state p { max-width: 32rem; }
.empty-state h1, .empty-state h2 { color: var(--text); }
.empty-state-compact { padding: 28px 20px; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.9375rem;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}
.pill-new { background: var(--accent); color: var(--accent-text); margin-left: auto; align-self: flex-start; }

.dot { width: 9px; height: 9px; border-radius: 999px; background: var(--accent); flex: none; }

/* ---------- Avatars ---------- */

.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  object-fit: cover;
  background: var(--surface-2);
}
.avatar-initials {
  --avatar-hue: 40;
  background: hsl(var(--avatar-hue) 32% 86%);
  color: hsl(var(--avatar-hue) 35% 28%);
  font-weight: 650;
  letter-spacing: 0.01em;
  user-select: none;
}
@media (prefers-color-scheme: dark) {
  .avatar-initials { background: hsl(var(--avatar-hue) 18% 28%); color: hsl(var(--avatar-hue) 30% 82%); }
}
.avatar-tone-0 { --avatar-hue: 18; }
.avatar-tone-1 { --avatar-hue: 35; }
.avatar-tone-2 { --avatar-hue: 95; }
.avatar-tone-3 { --avatar-hue: 150; }
.avatar-tone-4 { --avatar-hue: 190; }
.avatar-tone-5 { --avatar-hue: 215; }
.avatar-tone-6 { --avatar-hue: 260; }
.avatar-tone-7 { --avatar-hue: 330; }
.avatar-24 { width: 24px; height: 24px; font-size: 0.625rem; }
.avatar-28 { width: 28px; height: 28px; font-size: 0.6875rem; }
.avatar-32 { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-36 { width: 36px; height: 36px; font-size: 0.8125rem; }
.avatar-40 { width: 40px; height: 40px; font-size: 0.875rem; }
.avatar-44 { width: 44px; height: 44px; font-size: 0.9375rem; }
.avatar-64 { width: 64px; height: 64px; font-size: 1.25rem; }

/* ---------- Groups ---------- */

.group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.group-header h1 { font-size: 1.75rem; }
.group-header-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 6px;
  color: var(--text-3);
  font-size: 0.875rem;
}
.group-header-actions { display: flex; gap: 8px; flex: none; }
.group-description-mobile { display: none; color: var(--text-2); margin-bottom: 16px; }

.group-list { display: grid; gap: 8px; }
.group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow);
}
.group-row:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-hover); }
.group-row-main { display: grid; gap: 3px; min-width: 0; }
.group-row-name { font-weight: 600; font-size: 1.0625rem; }
.group-row.has-unread .group-row-name { font-weight: 700; }
.group-row-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; color: var(--text-3); font-size: 0.8125rem; }

.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.group-tile {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow);
}
.group-tile:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-hover); }
.group-tile-name { font-weight: 650; }
.group-tile-description { color: var(--text-2); font-size: 0.875rem; }
.group-tile-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; color: var(--text-3); font-size: 0.8125rem; margin-top: 2px; }

.inline-search { display: flex; gap: 8px; margin-bottom: 20px; }
.inline-search input { border-radius: 999px; padding-left: 16px; }

.danger-zone {
  margin-top: 40px;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border));
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  justify-items: start;
}
.danger-zone h2 { font-size: 1rem; }
.danger-zone p { color: var(--text-2); font-size: 0.9375rem; }

/* ---------- Composer ---------- */

.composer {
  margin-bottom: 20px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.composer:focus-within { border-color: var(--border-strong); box-shadow: var(--shadow-raised); }
.composer textarea {
  border: 0;
  padding: 6px 6px;
  min-height: 48px;
  resize: none;
  font-size: 1.0625rem;
  background: transparent;
}
.composer textarea:focus { box-shadow: none; }
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.composer .composer-footer { padding-top: 10px; border-top: 1px solid var(--border); }
.composer-hint { color: var(--text-3); font-size: 0.8125rem; }
.composer-group select { width: auto; max-width: 16rem; padding: 6px 30px 6px 10px; font-size: 0.875rem; border-radius: 999px; background-color: var(--surface-2); border-color: transparent; }

/* ---------- Posts ---------- */

.post-list { display: grid; gap: 12px; }
.post-list > turbo-frame { display: grid; gap: 12px; }

.post-card, .post-full {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 12px;
  box-shadow: var(--shadow);
}
.post-card.is-unread { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.post-card.is-unread::before {
  content: "";
  position: absolute;
  left: -1px; top: 16px; bottom: 16px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.post-full { padding: 20px 22px; }

.post-meta { display: flex; align-items: center; gap: 10px; }
.post-meta-text { display: grid; min-width: 0; line-height: 1.3; }
.post-author { font-weight: 620; }
.post-context { color: var(--text-3); font-size: 0.8125rem; }
.post-context a { color: inherit; }
.post-group { font-weight: 600; color: var(--text-2) !important; }

.post-body {
  margin-top: 10px;
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  display: grid;
  gap: 0.7em;
}
.post-body-full { font-size: 1.0625rem; margin-top: 14px; }
.post-body a, .reply-body a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }
.read-more { font-weight: 600; text-decoration: none !important; }

.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}
.post-replies-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -6px -8px;
  padding: 6px 8px;
  border-radius: var(--radius-small);
  color: var(--text-2);
  font-weight: 600;
}
.post-replies-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.new-replies { color: var(--accent); font-weight: 700; }
.new-replies::before { content: "·"; margin-right: 6px; color: var(--text-3); font-weight: 400; }
.post-last-activity { color: var(--text-3); font-size: 0.8125rem; }

.pagination { display: flex; justify-content: center; padding: 8px 0; }
.pagination-end { text-align: center; color: var(--text-3); font-size: 0.875rem; padding: 8px 0; }

/* ---------- Menus ---------- */

.menu { position: relative; margin-left: auto; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-items {
  position: absolute;
  right: 0; top: calc(100% + 4px);
  z-index: 30;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-raised);
  display: grid;
}
.menu-items form { display: block; }
.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item-danger { color: var(--danger); }

/* ---------- Replies ---------- */

.replies { margin-top: 28px; }
.replies-title { font-size: 1rem; margin-bottom: 12px; color: var(--text-2); }

.thread {
  display: grid;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: clip;
}
.reply {
  position: relative;
  padding: 14px 18px 8px;
  border-top: 1px solid var(--border);
}
.reply:first-child { border-top: 0; }
.reply.depth-1, .reply.depth-2 { border-top-color: transparent; padding-top: 6px; }
.reply.depth-1 { padding-left: 56px; }
.reply.depth-2 { padding-left: 94px; }
.reply.depth-1::before, .reply.depth-2::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}
.reply.depth-1::before { left: 31px; }
.reply.depth-2::before { left: 69px; }
.reply.is-new { background: var(--accent-softer); }
.reply.is-new .reply-author::after {
  content: "Ny";
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.625rem;
  font-weight: 700;
  vertical-align: 2px;
}
.new-marker {
  display: block;
  margin: -6px 0 8px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  scroll-margin-top: calc(var(--topbar-height) + 40px);
}
.reply-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.875rem; }
.reply-author { font-weight: 620; }
.reply-to { display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); font-size: 0.8125rem; }
.reply-time { color: var(--text-3); font-size: 0.8125rem; }
.reply-time a { color: inherit; }
.reply-body {
  margin: 4px 0 0 36px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  display: grid;
  gap: 0.6em;
}
.reply-actions { margin-left: 34px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.reply-deleted { color: var(--text-3); font-style: italic; font-size: 0.875rem; padding-bottom: 6px; }
.inline-reply { flex-basis: 100%; margin: 4px 0 8px; }
.inline-reply textarea { min-height: 64px; }
.inline-reply .composer-footer { justify-content: flex-end; }

.reply-composer {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.reply-composer-main { flex: 1; min-width: 0; }
.reply-composer textarea { min-height: 64px; }

/* ---------- People, notifications ---------- */

.people-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.person { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.person:first-child { border-top: 0; }
.person-text { display: grid; min-width: 0; flex: 1; line-height: 1.35; }
.person-name { font-weight: 600; }
.person-meta { color: var(--text-3); font-size: 0.8125rem; }
.person-actions { display: flex; gap: 6px; }
.person .menu { margin-left: 0; }

.notification-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: clip;
}
.notification-list li + li { border-top: 1px solid var(--border); }
.notification { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; color: var(--text); }
.notification:hover { background: var(--surface-hover); text-decoration: none; }
.notification.is-unread { background: var(--accent-softer); }
.notification-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.notification-message { font-weight: 550; }
.notification.is-unread .notification-message { font-weight: 650; }
.notification-excerpt { color: var(--text-2); font-size: 0.9375rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notification-meta { color: var(--text-3); font-size: 0.8125rem; }
.notification .dot { margin-top: 8px; }

/* ---------- Invitations, profile ---------- */

.invite-card { display: grid; gap: 14px; justify-items: start; }
.copy-field { display: flex; gap: 8px; width: 100%; }
.copy-field input { font-family: var(--font-mono); font-size: 0.875rem; background: var(--surface-2); }

.invite-landing {
  max-width: 34rem;
  margin: 24px auto 0;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
}
.invite-kicker { display: inline-flex; gap: 8px; align-items: center; color: var(--text-2); font-size: 0.9375rem; }
.invite-landing h1 { font-size: 2rem; }
.invite-description { color: var(--text-2); display: grid; gap: 8px; margin-top: 4px; }
.invite-actions { margin-top: 16px; display: grid; gap: 8px; justify-items: center; }

.profile-card { display: flex; align-items: center; gap: 16px; }
.profile-text { display: grid; flex: 1; min-width: 0; }
.profile-name { font-size: 1.25rem; font-weight: 650; }
.avatar-field { display: flex; gap: 16px; align-items: center; }

/* ---------- Landing & prose ---------- */

.hero { padding: 40px 0 32px; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.75rem); letter-spacing: -0.03em; max-width: 18ch; }
.hero-lead { margin-top: 16px; font-size: 1.1875rem; color: var(--text-2); max-width: 36rem; line-height: 1.55; }
.hero-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; padding: 24px 0; border-top: 1px solid var(--border); }
.feature h2 { font-size: 1rem; margin-bottom: 6px; }
.feature p { color: var(--text-2); font-size: 0.9375rem; }

.prose { max-width: var(--reading); display: grid; gap: 14px; line-height: 1.65; }
.prose h2 { margin-top: 12px; }
.prose ul { list-style: disc; padding-left: 1.25em; display: grid; gap: 6px; }

/* ---------- Minimal layout (sign in) ---------- */

.minimal-main {
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 24px;
  padding: 32px 16px;
}
.brand-large { font-size: 1.5rem; }
.minimal-card {
  width: 100%;
  max-width: 26rem;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.minimal-title { font-size: 1.375rem; }
.minimal-lead { margin: 8px 0 20px; color: var(--text-2); }
.minimal-footer { font-size: 0.8125rem; color: var(--text-3); }
.minimal-footer a { color: inherit; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .is-signed-in .shell.has-aside { grid-template-columns: 220px minmax(0, 1fr); }
  .shell.has-aside { grid-template-columns: minmax(0, 1fr); }
  .aside { display: none; }
  .group-description-mobile { display: grid; gap: 8px; }
}

@media (max-width: 760px) {
  :root { --topbar-height: 52px; }
  .topbar-inner { padding: 0 16px; gap: 8px; }
  .topbar-search { display: none; }
  .is-signed-in .topnav { margin-left: auto; }
  .is-signed-in .nav-search-mobile { display: flex !important; }
  .is-signed-in .topnav .nav-link[href="/notifications"] { display: none; }

  .shell, .is-signed-in .shell, .is-signed-in .shell.has-aside, .shell.has-aside {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 12px calc(88px + env(safe-area-inset-bottom));
    gap: 0;
  }
  .sidebar { display: none; }
  h1 { font-size: 1.4375rem; }
  .group-header h1 { font-size: 1.5rem; }

  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--border);
  }
  .tabbar .nav-link {
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: none;
  }
  .tabbar .nav-link.is-active { color: var(--accent); }
  .tabbar .nav-link .badge { position: absolute; top: 2px; left: calc(50% + 6px); }

  .post-card, .post-full { padding: 14px 14px 10px; border-radius: 10px; }
  .reply { padding: 12px 14px 6px; }
  .reply.depth-1 { padding-left: 34px; }
  .reply.depth-2 { padding-left: 54px; }
  .reply.depth-1::before { left: 20px; }
  .reply.depth-2::before { left: 40px; }
  .reply-body { margin-left: 0; }
  .reply-actions { margin-left: -2px; }
  .composer-hint { display: none; }
  .group-header { flex-direction: column; gap: 12px; }
  .person-actions { flex-direction: column; }
  .invite-landing { padding: 24px 18px; margin-top: 8px; }
  .notice-bar { flex-direction: column; align-items: stretch; text-align: center; }
  .copy-field { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* Grid children default to min-content width; let long group names truncate instead. */
.sidebar, .sidebar-section, .sidebar-groups { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 760px) {
  .reply-composer .composer-footer { justify-content: flex-end; }
}
