/* Frame: top bar, left sidebar, right rail, and the shared spacing scale. Loaded last. */
:root {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 40px; --sp-8: 48px;
  --sidebar: 272px;
}

/* ── Top bar ───────────────────────────────────────────────────────────── */
.top { background: rgba(255, 255, 255, .92); border-bottom-color: var(--line); }
.top.scrolled { background: rgba(255, 255, 255, .92); }
.top .brand { padding: 0 8px 0 4px; }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar { background: var(--card); border-right: 1px solid var(--line); padding: var(--sp-4) var(--sp-3) var(--sp-8); }
.sidebar ul, .sidebar .group-body { grid-template-columns: minmax(0, 1fr); }
.sidebar ul { gap: 2px; }
.sidebar li { min-width: 0; }
.sidebar .primary { margin: 0; }
.sidebar li a { gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: 10px; color: var(--ink); font-size: 15px; line-height: 1.4; }
.sidebar li a > span:last-child { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar li a:hover { background: var(--sunken); color: var(--deep); }
.sidebar li a:focus-visible { box-shadow: inset 0 0 0 2px var(--sky); border-radius: 10px; }
.sidebar li a.active { background: var(--blue); color: #fff; font-weight: 700; box-shadow: none; }
.sidebar li a.active::before { display: none; }
.sidebar li a.active:hover { background: #00477e; color: #fff; }
.sidebar li a.active:focus-visible { box-shadow: 0 0 0 3px rgba(80, 148, 176, .45); }
.sidebar .nav-icon { width: 24px; height: 24px; color: var(--ink-2); }
.sidebar .nav-icon svg { width: 20px; height: 20px; }
.sidebar li a.active .nav-icon { color: #fff; }
.sidebar li img, .sidebar li .dot { width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 0 0 1px rgba(9, 48, 77, .06); }
.sidebar li a.active img, .sidebar li a.active .dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); }
.sidebar li .dot { background: linear-gradient(135deg, var(--pale), #e7f1f8); }

/* Groups: a hairline, then a sentence-case heading that collapses the group. */
.sidebar .loose, .sidebar .group { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.sidebar .group > button { min-height: 36px; padding: 6px 12px; border-radius: 10px; font: 700 14px/1.4 Lato, sans-serif; letter-spacing: 0; text-transform: none; color: var(--deep); }
.sidebar .group > button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .group > button:hover { background: var(--sunken); }
.sidebar .group > button:focus-visible { box-shadow: inset 0 0 0 2px var(--sky); }
.sidebar .group > button .chev { width: 16px; height: 16px; color: var(--muted); opacity: 1; }
.sidebar .group-body > ul { padding-top: 2px; }

/* Create button for hosts and moderators. */
.side-create { position: relative; margin: 0 0 var(--sp-3); }
.side-create-btn { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); color: var(--deep); font: 700 15px/1.4 Lato, sans-serif; cursor: pointer; transition: background-color var(--dur-1), border-color var(--dur-1), box-shadow var(--dur-1); }
.side-create-btn:hover { background: var(--sunken); border-color: rgba(9, 48, 77, .24); }
.side-create-btn[aria-expanded="true"] { border-color: var(--sky); box-shadow: var(--focus); }
.side-create-btn svg { color: var(--blue); }
.side-create-pop { left: 0; right: 0; width: auto; max-height: min(70vh, 520px); overflow-y: auto; transform-origin: top center; }
.side-create-pop .sc-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.45; color: var(--muted); }
.side-create-pop .sc-head strong { color: var(--deep); font-size: 13px; }
.side-create-pop .sc-head > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-create-pop button.sc-back { width: 28px; height: 28px; padding: 0; justify-content: center; flex: none; border-radius: 8px; color: var(--ink-2); }
.side-create-pop .create-icon { width: 32px; height: 32px; border-radius: 8px; }
.side-create-pop .create-icon svg { width: 18px; height: 18px; }
.side-create-pop button.sc-other { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; padding: 10px; justify-content: center; color: var(--blue); font-weight: 700; font-size: 14px; }
.side-create-pop .sc-spaces { display: grid; gap: 2px; }
.side-create-pop .sc-spaces button { gap: 10px; padding: 6px 8px; min-height: 40px; font-size: 14.5px; }
.side-create-pop .sc-spaces button > span:last-child { display: block; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-create-pop .sc-spaces img, .side-create-pop .sc-spaces .dot { width: 24px; height: 24px; border-radius: 7px; object-fit: cover; flex: none; background: var(--pale); }
.side-create-pop .sc-empty { margin: 8px; }

/* ── Right rail ────────────────────────────────────────────────────────── */
.with-rail { gap: var(--sp-5); }
.with-rail > .rail { gap: var(--sp-4); top: calc(var(--top) + var(--sp-5)); }
.rail-card { padding: var(--sp-4); border-radius: var(--radius); }
.rail-card > h2, .rail-card > header h2 { font: 600 17px/1.35 'Playfair Display', Georgia, serif; margin: 0 0 var(--sp-2); }
.rail-card > header { align-items: center; margin: 0 0 var(--sp-2); }
.rail-card > header h2 { margin: 0; }
.rail-card > header a { font: 700 13px/1.4 Lato, sans-serif; color: var(--blue); flex: none; }
.rail-list { gap: 0; }
.rail-list a { gap: 12px; padding: 8px; margin: 0 -8px; }
.rail-list strong { font-size: 14px; line-height: 1.4; font-weight: 700; color: var(--deep); }
.rail-list .small { font-size: 12.5px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-list .ring-wrap > span { font-size: 9.5px; }
.rail-people .avatar { width: 36px; height: 36px; font-size: 13px; }

.rail-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.re-item { position: relative; }
.re-row { display: flex; align-items: center; gap: 12px; padding: 8px; margin: 0 -8px; border-radius: 10px; color: var(--ink); transition: background-color var(--dur-1); }
.re-row:hover { background: var(--sunken); text-decoration: none; }
.re-row:focus-visible { box-shadow: inset 0 0 0 2px var(--sky); }
.re-thumb { width: 48px; height: 48px; flex: none; border-radius: 10px; overflow: hidden; background: var(--sunken); }
.re-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.re-date { display: grid; place-content: center; text-align: center; background: var(--tint); box-shadow: inset 0 0 0 1px rgba(80, 148, 176, .2); }
.re-date span { font: 700 10px/1.3 Lato, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
.re-date strong { font: 700 18px/1.15 Lato, sans-serif; color: var(--deep); font-variant-numeric: tabular-nums lining-nums; }
.re-body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.re-title { font-size: 14px; line-height: 1.4; font-weight: 700; color: var(--deep); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.re-time { font-size: 12.5px; line-height: 1.4; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.re-live { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; color: #d93025; font-weight: 700; }
.re-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: re-pulse 1.6s ease-in-out infinite; }
@keyframes re-pulse { 50% { opacity: .35; } }
.re-item:has(.re-join) .re-row { padding-right: 64px; }
.re-join { position: absolute; right: 0; top: 50%; transform: translateY(-50%); padding: 4px 12px; border-radius: 99px; background: #d93025; color: #fff; font: 700 12.5px/1.4 Lato, sans-serif; }
.re-join:hover { background: #b9271d; text-decoration: none; }

.space-about .rich { font-size: 14px; line-height: 1.55; }
.space-facts { margin: var(--sp-3) 0 0; padding: var(--sp-3) 0 0; }
.space-facts strong { font-size: 18px; }

/* ── Phones and tablets ────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .with-rail > .rail { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (max-width: 800px) {
  .sidebar { background: var(--card); width: min(86vw, 304px); border-right: 0; padding: var(--sp-3) var(--sp-3) calc(96px + env(safe-area-inset-bottom)); }
  .sidebar li a { min-height: 44px; }
  .with-rail > .rail { grid-template-columns: minmax(0, 1fr); }
}

/* ── Spacing and overflow fixes ────────────────────────────────────────── */
.home-main { grid-template-columns: minmax(0, 1fr); }
.side-create-pop .create-list-desc, .side-create-pop [data-create] .muted.small { display: none; }
.side-create-pop [data-create] { min-height: 40px; padding: 4px 8px; }

/* Admin sidebar follows the member sidebar. */
.admin-side { background: var(--card); padding: var(--sp-4) var(--sp-3); }
.admin-side nav { gap: 2px; }
.admin-side .nav-group { font: 700 13px/1.45 Lato, sans-serif; letter-spacing: 0; text-transform: none; color: var(--deep); padding: var(--sp-4) 12px 6px; margin-top: var(--sp-2); border-top: 1px solid var(--line); }
.admin-side .nav-group:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.admin-side a { gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: 10px; color: var(--ink); font-size: 15px; }
.admin-side a svg { color: var(--ink-2); }
.admin-side a:hover { background: var(--sunken); }
.admin-side a.active { background: var(--blue); color: #fff; box-shadow: none; }
.admin-side a.active svg { color: #fff; }
.admin-side a.active::before { display: none; }
.admin-side a:focus-visible { box-shadow: inset 0 0 0 2px var(--sky); }
@media (max-width: 800px) {
  .admin-side { background: rgba(255, 255, 255, .94); padding: var(--sp-2); }
  .admin-side a { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 99px; }
}

/* Spacing scale: page titles, panels, section heads. */
.panel { padding: var(--sp-6); }
.page-title { margin: 0 0 var(--sp-5); line-height: 1.25; }
.home-main { gap: var(--sp-6); }
.feed-col { gap: var(--sp-4); }
.block-head { margin-bottom: var(--sp-3); }
.group-title { margin: var(--sp-5) 0 var(--sp-3); }
.account { gap: var(--sp-4); }
.account .panel { padding: var(--sp-5); }
.crumb { margin: 0 0 var(--sp-3); }
@media (max-width: 800px) {
  .panel { padding: var(--sp-5) var(--sp-4); }
  .account .panel { padding: var(--sp-5) var(--sp-4); }
  .page-title { font-size: 26px; margin-bottom: var(--sp-4); }
}
