/*
 * Copyright (c) 2026 Uncook Inc. All rights reserved.
 *
 * This source code is provided for reference purposes only.
 * You may NOT copy, modify, distribute, or use this code — in whole
 * or in part — in any other project, product, or service without
 * prior written permission from Uncook Inc.
 *
 * Commercial use is strictly prohibited.
 *
 * See LICENSE for full terms.
 */

@import './reset.css';
@import './variables.css';

/* ─── Accessibility: Focus rings ───────────────────────────────────────── */
/* Visible focus ring for keyboard users; suppressed for mouse/touch */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* Skip-to-content link (visually hidden until focused) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--font-size-small);
  z-index: 10000;
  transition: top 0.15s ease;
  white-space: nowrap;
}
.skip-link:focus { top: var(--space-sm); }

/* Screen-reader-only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Base */
html {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  color: var(--text);
  background: var(--bg);
  scroll-behavior: smooth;
  overscroll-behavior-y: none;
}
body { min-height: 100vh; min-height: 100dvh; }
#app { overscroll-behavior-y: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--font-mono); font-size: var(--font-size-small); }
pre { background: var(--surface); padding: var(--space-md); border-radius: var(--radius); overflow-x: auto; }
code { background: var(--surface); padding: 2px 5px; border-radius: 3px; }
hr { border: none; border-top: 1px solid var(--border); }

/* Layout */
#header { position: sticky; top: 0; z-index: 200; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top, 0); }
#app { max-width: var(--content-max-width); margin: 0 auto; padding: var(--space-md); min-height: calc(100vh - 56px); min-height: calc(100dvh - 56px); padding-inline-start: max(var(--space-md), env(safe-area-inset-left, 0)); padding-inline-end: max(var(--space-md), env(safe-area-inset-right, 0)); }
#toast-container { position: fixed; bottom: max(80px, calc(80px + env(safe-area-inset-bottom, 0))); left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: var(--space-sm); align-items: center; pointer-events: none; }
#fab-container { position: fixed; bottom: max(24px, calc(24px + env(safe-area-inset-bottom, 0))); inset-inline-end: max(24px, calc(24px + env(safe-area-inset-right, 0))); z-index: 100; }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-md); height: 56px; }
.header__logo { font-weight: 700; font-size: 18px; color: var(--text); letter-spacing: -0.5px; }
.header__actions { display: flex; align-items: center; gap: var(--space-sm); }
.header__avatar { display: flex; align-items: center; gap: var(--space-xs); background: none; border: none; cursor: pointer; padding: 8px 10px; border-radius: var(--radius); min-height: 44px; }
.header__avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.header__hash { font-size: var(--font-size-small); color: var(--text-muted); font-family: var(--font-mono); }
.header__settings { font-size: 18px; padding: 10px 12px; border-radius: var(--radius); min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.header__settings:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.header__budget { display: flex; gap: var(--space-sm); align-items: center; font-size: var(--font-size-small); color: var(--text-muted); }
.budget-item--exhausted { color: var(--downvote); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border-radius: var(--radius); font-size: var(--font-size-small); font-weight: 600; cursor: pointer; border: none; transition: opacity .15s, transform .1s; line-height: 1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--secondary { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); }
.btn--danger { background: var(--downvote); color: #fff; }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: var(--font-size-small); padding: 10px 8px; min-height: 44px; display: inline-flex; align-items: center; }
.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* FAB */
.fab { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 24px; box-shadow: 0 4px 12px rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; transition: transform .15s; }
.fab:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Post card */
.post-card { display: flex; gap: var(--space-md); padding: var(--space-md) 0; border-bottom: 1px solid var(--border); }
.post-card:last-child { border-bottom: none; }
.post-card__votes { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 32px; }
.post-card__body { flex: 1; min-width: 0; }
.post-card__title { font-size: var(--font-size-title); font-weight: 600; margin-bottom: var(--space-xs); }
.post-card__title a { color: var(--text); }
.post-card__title a:hover { color: var(--accent); }
.post-card__domain { font-size: var(--font-size-small); color: var(--text-muted); margin-inline-start: var(--space-sm); }
.post-card__preview { font-size: var(--font-size-small); color: var(--text-muted); margin-bottom: var(--space-xs); }
/* OG link preview card */
.link-preview { display: flex; gap: var(--space-sm); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; margin-top: var(--space-sm); max-width: 100%; transition: border-color var(--transition-fast); }
.link-preview:hover { border-color: var(--accent); text-decoration: none; }
.link-preview--loading { opacity: 0.6; pointer-events: none; }
.link-preview--plain { background: var(--surface); padding: var(--space-sm); align-items: center; }
.link-preview__image { width: 120px; min-height: 80px; object-fit: cover; flex-shrink: 0; background: var(--surface-raised); }
.link-preview__text { padding: var(--space-sm); overflow: hidden; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.link-preview__site { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.link-preview__title { display: block; font-size: var(--font-size-small); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-preview__desc { font-size: 12px; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.link-preview__url { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-card__meta { display: flex; align-items: center; gap: var(--space-sm); font-size: var(--font-size-small); color: var(--text-muted); flex-wrap: wrap; }
.post-card__community { color: var(--accent); font-weight: 600; }
.post-card__comments { color: var(--text-muted); }

/* Vote buttons — touch targets + color-independent active state */
.vote-btn { background: none; border: none; cursor: pointer; color: var(--text-faint); font-size: 14px; padding: 10px 12px; border-radius: 3px; line-height: 1; transition: color .15s; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.vote-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
.vote-btn--up.vote-btn--active { color: var(--upvote); font-weight: 900; border-bottom: 2px solid var(--upvote); }
.vote-btn--down.vote-btn--active { color: var(--downvote); font-weight: 900; border-bottom: 2px solid var(--downvote); }
.vote-btn--sm { font-size: 11px; padding: 8px 10px; min-width: 44px; min-height: 44px; }

/* Post detail */
.post-detail { display: flex; gap: var(--space-md); padding-bottom: var(--space-lg); border-bottom: 1px solid var(--border); }
.post-detail__content { flex: 1; }
.post-detail__meta { display: flex; align-items: center; gap: var(--space-sm); font-size: var(--font-size-small); color: var(--text-muted); margin-bottom: var(--space-sm); flex-wrap: wrap; }
.post-detail__title { font-size: 22px; font-weight: 700; margin-bottom: var(--space-md); }
.post-detail__body { line-height: var(--line-height); }
.post-detail__body p { margin-bottom: var(--space-md); }
.post-detail__url { color: var(--accent); word-break: break-all; font-size: var(--font-size-small); margin-bottom: var(--space-md); display: block; }

/* Comments */
.comment-section { margin-top: var(--space-lg); }
.comment-count-divider { font-size: var(--font-size-small); color: var(--text-muted); padding: var(--space-sm) 0; border-bottom: 1px solid var(--border); margin-bottom: var(--space-md); }
.comment-compose { margin-bottom: var(--space-lg); }
.comment-textarea, .reply-textarea { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: var(--space-sm); resize: vertical; }
.comment-textarea:focus-visible, .reply-textarea:focus-visible { border-color: var(--accent); }
.comment { margin-bottom: var(--space-sm); }
.comment__header { display: flex; align-items: center; gap: var(--space-sm); font-size: var(--font-size-small); color: var(--text-muted); margin-bottom: 4px; }
.comment__body { font-size: var(--font-size-base); line-height: var(--line-height); margin-bottom: var(--space-xs); }
.comment__actions { display: flex; gap: var(--space-sm); font-size: var(--font-size-small); }
.comment__reply-form { margin-top: var(--space-sm); }
.comment__collapsed { color: var(--text-muted); font-style: italic; }

/* Feed */
.feed { margin-top: var(--space-md); }

/* Directory */
.directory-list { margin-top: var(--space-md); display: flex; flex-direction: column; gap: var(--space-sm); }
.collective-card { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.collective-card__link { display: flex; align-items: center; gap: var(--space-md); flex: 1; min-width: 0; color: var(--text); }
.collective-card__link:hover { text-decoration: none; }
.collective-card__name { font-weight: 600; }
.collective-card__desc { font-size: var(--font-size-small); color: var(--text-muted); }

/* Sort bar — tablist semantics, color-independent active state */
.sort-bar { display: flex; gap: var(--space-xs); margin-bottom: var(--space-md); }
.sort-btn { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: var(--font-size-small); font-weight: 600; padding: 10px 16px; border-radius: 20px; cursor: pointer; min-height: 44px; }
.sort-btn--active { background: var(--surface-raised); color: var(--text); border-bottom-color: var(--accent); font-weight: 700; }
.sort-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Toasts */
.toast { display: flex; align-items: flex-start; gap: var(--space-sm); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-sm) var(--space-md); max-width: 360px; pointer-events: auto; animation: toast-in .25s ease; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.toast--badge { border-color: var(--accent); }
.toast--unlock { border-color: #4aff9e; }
.toast__icon { font-size: 20px; flex-shrink: 0; }
.toast__title { font-weight: 600; font-size: var(--font-size-small); }
.toast__message { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toast--out { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* Forms */
.form-group { margin-bottom: var(--space-md); }
.form-group label { display: block; font-size: var(--font-size-small); font-weight: 600; color: var(--text-muted); margin-bottom: var(--space-xs); }
.form-group input[type=text], .form-group input[type=url], .form-group input[type=email], .form-group textarea, .form-group select { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 8px var(--space-sm); font-size: var(--font-size-base); }
.form-group input:focus-visible, .form-group textarea:focus-visible, .form-group select:focus-visible { border-color: var(--accent); }
.form-actions { display: flex; gap: var(--space-sm); margin-top: var(--space-lg); }
.required { color: var(--downvote); }
.field-error { font-size: 12px; color: var(--downvote); }
.char-count { font-size: 11px; color: var(--text-muted); }

/* Avatar */
.avatar { display: inline-block; border-radius: 20%; vertical-align: middle; flex-shrink: 0; }
.avatar-generated { line-height: 0; }
.avatar img { object-fit: cover; border-radius: 20%; }

/* Profile */
.profile-header { display: flex; align-items: flex-start; gap: var(--space-lg); margin-bottom: var(--space-xl); }
.profile-name { font-size: 22px; font-weight: 700; }
.profile-hash { font-family: var(--font-mono); font-size: var(--font-size-small); color: var(--text-muted); cursor: pointer; }
.profile-bio { color: var(--text-muted); margin-top: var(--space-xs); }
.badge-list { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.badge { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: var(--font-size-small); }

/* Mnemonic */
.mnemonic-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-sm); margin: var(--space-lg) 0; }
.mnemonic-word { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-xs) var(--space-sm); display: flex; gap: var(--space-xs); align-items: baseline; }
.mnemonic-num { font-size: 11px; color: var(--text-muted); min-width: 16px; }
.mnemonic-word__text { font-family: var(--font-mono); font-size: var(--font-size-small); font-weight: 600; }
.setup-warning { color: #f5a623; background: rgba(245,166,35,.1); border: 1px solid rgba(245,166,35,.3); border-radius: var(--radius); padding: var(--space-sm) var(--space-md); margin-bottom: var(--space-md); }
.setup-restore-hint { text-align: center; margin-top: var(--space-md); font-size: var(--font-size-small); color: var(--text-muted); }
.setup-restore-link { color: var(--accent); text-decoration: none; }
.setup-restore-link:hover { text-decoration: underline; }
/* Standalone recovery page */
.page--recover { display: flex; justify-content: center; align-items: flex-start; padding-top: var(--space-xl); }
.recover-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-xl); max-width: 480px; width: 100%; }
.recover-card__title { font-size: 24px; font-weight: 700; margin-bottom: var(--space-sm); }
.recover-card__desc { font-size: var(--font-size-small); color: var(--text-muted); margin-bottom: var(--space-lg); }
.recover-card__actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin-bottom: var(--space-md); }

/* Spinner */
.spinner { display: flex; align-items: center; gap: var(--space-sm); color: var(--text-muted); padding: var(--space-xl); justify-content: center; }
.spinner__ring { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Error / empty — icon prefix for color-independence */
.error { color: var(--downvote); font-size: var(--font-size-small); }
.success { color: #4aff9e; font-size: var(--font-size-small); }
.empty { color: var(--text-muted); text-align: center; padding: var(--space-xl) 0; }
.error-page { text-align: center; padding: var(--space-xl); }

/* Page headers */
.page__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); padding-bottom: var(--space-md); border-bottom: 1px solid var(--border); }
.page__header h1 { font-size: 20px; font-weight: 700; }

/* Collective header */
.collective-header { display: flex; align-items: flex-start; gap: var(--space-md); padding: var(--space-md) 0; border-bottom: 1px solid var(--border); margin-bottom: var(--space-md); flex-wrap: wrap; }
.collective-header__info { flex: 1; }
.collective-header__name { font-size: 22px; font-weight: 700; }
.collective-header__actions { display: flex; gap: var(--space-sm); align-items: center; margin-inline-start: auto; }
.collective-rules { margin-bottom: var(--space-md); font-size: var(--font-size-small); }
.collective-rules summary { cursor: pointer; color: var(--text-muted); }

/* Search */
.search-bar { margin-bottom: var(--space-md); }
.search-input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 8px 16px; color: var(--text); font-size: var(--font-size-base); }
.search-input:focus-visible { border-color: var(--accent); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: var(--space-md); }
.tab { background: none; border: none; color: var(--text-muted); font-size: var(--font-size-small); font-weight: 600; padding: 12px 16px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 44px; }
.tab--active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Sub chips */
.subscribed-list { display: flex; gap: var(--space-xs); flex-wrap: wrap; margin-bottom: var(--space-md); }
.sub-chip { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 20px; padding: 8px 14px; font-size: var(--font-size-small); color: var(--text-muted); min-height: 44px; display: inline-flex; align-items: center; }

/* Post type tabs — ARIA tablist, color-independent active state */
.type-tabs { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.type-tab { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-muted); font-size: var(--font-size-small); font-weight: 600; padding: 10px 16px; cursor: pointer; transition: all .15s; min-height: 44px; }
.type-tab--active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; box-shadow: inset 0 -2px 0 rgba(255,255,255,0.3); }
.type-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Post detail media */
.post-detail__media { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin: var(--space-md) 0; }
.post-detail__image { max-width: 100%; max-height: 600px; border-radius: var(--radius); object-fit: contain; }

/* Unsynced / pending-sync — color-independent structural indicator */
.post-card--unsynced {
  opacity: 1;
  border-inline-start: 3px solid var(--text-faint);
}
.post-card__unsynced-badge,
.comment__unsynced-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface-raised);
  border: 1px dashed var(--text-faint);
  border-radius: 10px;
  padding: 1px 7px;
  white-space: nowrap;
}
.comment--unsynced { opacity: 0.8; }

/* Settings */
.settings-section { margin-bottom: var(--space-xl); padding-bottom: var(--space-lg); border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: none; }
.settings-section h2 { font-size: 16px; font-weight: 700; margin-bottom: var(--space-md); }
.settings-hint { font-size: var(--font-size-small); color: var(--text-muted); margin-bottom: var(--space-md); }
.settings-row { display: flex; align-items: center; justify-content: space-between; }
.toggle { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 20px; padding: 10px 16px; cursor: pointer; font-size: var(--font-size-small); color: var(--text-muted); min-height: 44px; }
.toggle--on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Theme picker */
.theme-picker { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-sm); }
.theme-swatch { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px; border-radius: var(--radius); border: 2px solid var(--border); cursor: pointer; transition: all var(--transition-fast); background: var(--swatch-bg, var(--surface)); min-width: 90px; }
.theme-swatch--active { border-color: var(--swatch-accent, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--swatch-accent, var(--accent)) 30%, transparent); }
.theme-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-swatch__emoji { font-size: 22px; }
.theme-swatch__label { font-size: 11px; font-weight: 600; color: var(--swatch-accent, var(--accent)); white-space: nowrap; }
.theme-swatch__check { position: absolute; top: 4px; inset-inline-end: 4px; font-size: 12px; font-weight: 700; color: var(--swatch-accent, var(--accent)); }

/* Budget indicator in header */
.header__budget-btn { background: none; border: none; cursor: pointer; padding: 10px 12px; border-radius: var(--radius); display: flex; align-items: center; min-width: 44px; min-height: 44px; }
.header__budget-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.budget-indicator__ring { font-size: 18px; transition: all var(--transition-base); }
.budget-indicator__ring--full  { filter: drop-shadow(0 0 6px var(--accent)); }
.budget-indicator__ring--mid   { opacity: 0.9; }
.budget-indicator__ring--low   { opacity: 0.7; animation: pulse-low 2s ease infinite; }
.budget-indicator__ring--empty { opacity: 0.4; filter: grayscale(1); }
@keyframes pulse-low { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }

/* Budget drawer */
.budget-drawer { position: fixed; inset: 0; z-index: 500; animation: drawer-in .2s ease; }
.budget-drawer--out { animation: drawer-out .2s ease forwards; }
.budget-drawer__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.budget-drawer__panel { position: absolute; top: 56px; right: var(--space-md); width: 340px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-lg); box-shadow: var(--shadow-md); z-index: 1; }
.budget-drawer__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-sm); }
.budget-drawer__title { font-size: 16px; font-weight: 700; }
.budget-drawer__close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; padding: 12px; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.budget-drawer__close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.budget-drawer__mood { font-size: var(--font-size-small); color: var(--text-muted); margin-bottom: var(--space-md); }
.budget-drawer__rows { display: flex; flex-direction: column; gap: var(--space-sm); margin-bottom: var(--space-md); }
.budget-row { display: grid; grid-template-columns: 24px 90px 1fr auto; gap: var(--space-xs); align-items: center; font-size: var(--font-size-small); }
.budget-row__emoji { font-size: 14px; }
.budget-row__label { font-weight: 600; }
.budget-row__bar { font-family: var(--font-mono); font-size: 10px; color: var(--accent); letter-spacing: -1px; }
.budget-row__count { color: var(--text-muted); white-space: nowrap; }
.budget-row--exhausted .budget-row__bar { color: var(--text-faint); }
.budget-row--exhausted .budget-row__label { color: var(--text-muted); }
.budget-row--near .budget-row__bar { color: var(--accent-tertiary); }
.budget-row__done { color: var(--text-faint); font-style: italic; }
.budget-drawer__reset { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: var(--space-sm); }
.budget-drawer__upgrade { display: block; text-align: center; font-size: var(--font-size-small); color: var(--accent-secondary); font-weight: 600; }
.budget-drawer__upgrade:hover { opacity: .8; text-decoration: none; }
@keyframes drawer-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawer-out { to { opacity: 0; } }

/* Invite gate */
.invite-gate { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-xl) var(--space-md); text-align: center; gap: var(--space-md); min-height: 300px; }
.invite-gate__icon { font-size: 48px; }
.invite-gate__title { font-size: 22px; font-weight: 700; }
.invite-gate__desc { color: var(--text-muted); max-width: 400px; }
.invite-gate__hint { font-size: var(--font-size-small); color: var(--text-faint); }

/* Invite manager */
.invite-manager-wrapper { margin-top: var(--space-md); padding: var(--space-md); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); }
.invite-manager__title { font-size: 15px; font-weight: 700; margin-bottom: var(--space-xs); }
.invite-manager__desc { font-size: var(--font-size-small); color: var(--text-muted); margin-bottom: var(--space-md); }
.invite-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-small); margin-bottom: var(--space-md); }
.invite-table th { text-align: start; color: var(--text-muted); font-weight: 600; padding: var(--space-xs) var(--space-sm); border-bottom: 1px solid var(--border); }
.invite-row td { padding: var(--space-xs) var(--space-sm); border-bottom: 1px solid var(--border); vertical-align: middle; }
.invite-code { font-family: var(--font-mono); font-size: 11px; word-break: break-all; }
.invite-create { margin-top: var(--space-md); }
.invite-create summary { list-style: none; }
.invite-create summary::-webkit-details-marker { display: none; }
.invite-create__toggle { cursor: pointer; }
.invite-create__form { margin-top: var(--space-md); padding: var(--space-md); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.invite-created { margin-top: var(--space-sm); padding: var(--space-sm); background: color-mix(in srgb, var(--accent-secondary) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent-secondary) 30%, transparent); border-radius: var(--radius); }

/* Join page */
.join-page { display: flex; align-items: center; justify-content: center; min-height: 60vh; padding: var(--space-xl); }
.join-page__card { display: flex; flex-direction: column; align-items: center; gap: var(--space-md); text-align: center; max-width: 420px; padding: var(--space-xl); background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * 2); box-shadow: var(--shadow-md); }
.join-page__icon { font-size: 48px; }
.join-page__name { font-size: 24px; font-weight: 700; }
.join-page__desc { color: var(--text-muted); }
.join-page__invite-note { font-size: var(--font-size-small); color: var(--accent-secondary); font-weight: 600; }
.join-page__label { font-size: var(--font-size-small); color: var(--text-muted); }
.join-page__cta { min-width: 200px; font-size: 16px; padding: 12px 24px; }
.join-page__skip { margin-top: var(--space-xs); font-size: var(--font-size-small); }

/* Empty states */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-md); padding: var(--space-xl) var(--space-md); text-align: center; }
.empty-state__icon { font-size: 48px; }
.empty-state h2 { font-size: 20px; font-weight: 700; }
.empty-state p { color: var(--text-muted); max-width: 400px; }
.home-empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-md); padding: var(--space-xl) var(--space-md); text-align: center; }
.home-empty__icon { font-size: 48px; }
.home-empty h2 { font-size: 22px; font-weight: 700; }
.home-empty p { color: var(--text-muted); max-width: 440px; }
.home-empty__actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; justify-content: center; }

/* ─── Touch active states (mobile press feedback) ──────────────────────── */
.btn:active:not(:disabled) { transform: scale(0.97); opacity: 0.9; }
.btn--sm:active:not(:disabled) { transform: scale(0.95); }
.fab:active { transform: scale(0.92); }
.vote-btn--up:active { color: var(--upvote); }
.vote-btn--down:active { color: var(--downvote); }
.sort-btn:active { background: var(--surface-raised); }
.tab:active { background: var(--surface-raised); }
.type-tab:active { opacity: 0.8; }
.post-card__title a:active { color: var(--accent); }
.sub-chip:active { background: var(--surface); }
.collective-card:active { background: var(--surface-raised); }
.theme-swatch:active { border-color: var(--swatch-accent, var(--accent)); }
.header__avatar:active { background: var(--surface-raised); }
.header__settings:active { background: var(--surface-raised); }
.header__budget-btn:active { background: var(--surface-raised); }
.btn-link:active { opacity: 0.7; }
.budget-drawer__close:active { color: var(--text); }
.toggle:active { opacity: 0.8; }

/* ─── Hover-only effects (not on touch devices) ─────────────────────────── */
@media (hover: hover) and (pointer: fine) {
  .theme-swatch:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--swatch-accent, var(--accent)); }
  .fab:hover { transform: scale(1.05); }
  .header__avatar:hover { background: var(--surface-raised); }
  .header__settings:hover { background: var(--surface-raised); }
  .header__budget-btn:hover { background: var(--surface-raised); }
  .vote-btn--up:hover { color: var(--upvote); }
  .vote-btn--down:hover { color: var(--downvote); }
  .sort-btn:hover { background: var(--surface-raised); color: var(--text); }
  .post-card__title a:hover { color: var(--accent); }
  .btn--primary:hover:not(:disabled) { opacity: .85; }
  .btn--secondary:hover:not(:disabled) { background: var(--surface); }
  .collective-card__link:hover { text-decoration: none; }
  .sub-chip:hover { color: var(--accent); text-decoration: none; }
  .type-tab:hover { color: var(--text); border-color: var(--text-muted); }
  .btn-link:hover { text-decoration: underline; }
  .budget-drawer__close:hover { color: var(--text); }
  .legal-table tr:hover td { background: var(--surface-raised); }
  .app-footer a:hover { color: var(--text); }
  .setup__legal a:hover { color: var(--text); }
  .budget-drawer__upgrade:hover { opacity: .8; text-decoration: none; }
  .invite-button:hover { opacity: 0.85; text-decoration: none; color: var(--bg); }
}

/* ─── Pull-to-refresh indicator ─────────────────────────────────────────── */
.pull-refresh-indicator {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-small);
  color: var(--text-muted);
  background: var(--surface);
  overflow: hidden;
  z-index: 9999;
  transition: opacity 0.1s;
}

/* ─── Tier / pricing table ───────────────────────────────────────────────── */
.tier-table { display: flex; gap: var(--space-md); margin: var(--space-lg) 0; }
.tier-column { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-lg); display: flex; flex-direction: column; }
.tier-column h2 { font-size: 20px; font-weight: 700; margin-bottom: var(--space-xs); }
.tier-price { font-size: 28px; font-weight: 800; margin-bottom: var(--space-md); color: var(--accent); }

/* ─── Budget bar rows (upgrade page) ────────────────────────────────────── */
.budget-current { margin-top: var(--space-xl); }
.budget-current h3 { font-size: 15px; margin-bottom: var(--space-md); }
.budget-bar-row { display: grid; grid-template-columns: 100px 1fr 60px; gap: var(--space-sm); align-items: center; margin-bottom: var(--space-xs); font-size: var(--font-size-small); }
.budget-bar { height: 8px; background: var(--surface-raised); border-radius: 4px; overflow: hidden; }
.budget-bar__fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width var(--transition-base); }
.budget-cat { color: var(--text-muted); }
.budget-nums { color: var(--text-muted); text-align: end; }

/* ─── Invite table scroll wrapper ───────────────────────────────────────── */
.invite-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── Responsive: Mobile/Tablet ─────────────────────────────────────────── */
/* Small phones (≤480px) */
@media (max-width: 480px) {
  :root { --space-md: 12px; --space-lg: 16px; --space-xl: 24px; }
  #app { padding: var(--space-sm); }
  .mnemonic-grid { grid-template-columns: repeat(2, 1fr); }
  .header__hash { display: none; }
  .post-card { gap: var(--space-sm); }
  .post-card__title { font-size: 15px; }
  .budget-drawer__panel { inset-inline-start: var(--space-xs); inset-inline-end: var(--space-xs); width: auto; top: env(safe-area-inset-top, 0); }
  .theme-picker { justify-content: center; gap: var(--space-xs); }
  .theme-swatch { min-width: 75px; padding: 8px 10px; }
  .legal-table { display: block; overflow-x: auto; }
  .tier-table { flex-direction: column; }
  .tier-column { width: 100%; }
  .invite-table { display: block; overflow-x: auto; }
  .join-page { padding: var(--space-md); min-height: auto; }
  .join-page__card { padding: var(--space-md); }
  .budget-bar-row { grid-template-columns: 70px 1fr 50px; }
}

/* Medium phones (≤640px) */
@media (max-width: 640px) {
  .collective-header { flex-direction: column; }
  .collective-header__actions { margin-inline-start: 0; width: 100%; justify-content: flex-start; }
  .profile-header { flex-direction: column; }
  .mnemonic-grid { grid-template-columns: repeat(3, 1fr); }
  .post-detail { flex-direction: column; gap: var(--space-sm); }
  .post-detail__votes { flex-direction: row; gap: var(--space-sm); }
  .settings-row { flex-direction: column; align-items: flex-start; gap: var(--space-sm); }
  .region-selector { flex-direction: column; }
  .region-selector .btn { width: 100%; }
  .invite-manager-wrapper { padding: var(--space-sm); }
  .tier-table { flex-direction: column; }
}

/* Tablets (≤768px) */
@media (max-width: 768px) {
  .post-detail__title { font-size: 20px; }
  .legal-header h1 { font-size: 24px; }
  .collective-header__name { font-size: 20px; }
  .collectiv-banner { --collectiv-banner-height: 150px; }
}

/* iOS font-size fix: prevent zoom on input focus (needs ≥16px) */
@media screen and (max-width: 768px) {
  .form-group input[type=text],
  .form-group input[type=url],
  .form-group input[type=email],
  .form-group textarea,
  .form-group select,
  .comment-textarea,
  .reply-textarea,
  .search-input,
  .mnemonic-input,
  .confirm-input { font-size: 16px; }
}

/* ─── Legal pages (Privacy Policy, Terms of Service) ───────────────────── */
.page--legal { max-width: 760px; }
.legal-header { margin-bottom: var(--space-xl); padding-bottom: var(--space-md); border-bottom: 1px solid var(--border); }
.legal-header h1 { font-size: 28px; font-weight: 800; margin-bottom: var(--space-xs); }
.legal-meta { font-size: var(--font-size-small); color: var(--text-muted); }
.legal-content { display: flex; flex-direction: column; gap: var(--space-xl); }
.legal-section h2 { font-size: 18px; font-weight: 700; margin-bottom: var(--space-md); padding-bottom: var(--space-xs); border-bottom: 1px solid var(--border); }
.legal-section h3 { font-size: 15px; font-weight: 600; margin: var(--space-md) 0 var(--space-sm); }
.legal-section p { color: var(--text); line-height: 1.7; margin-bottom: var(--space-sm); }
.legal-section a { color: var(--accent); }
.legal-section a:hover { text-decoration: underline; }
.legal-list { list-style: disc; padding-inline-start: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-xs); }
.legal-list li { color: var(--text); line-height: 1.6; }
.legal-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-small); margin: var(--space-md) 0; }
.legal-table th { text-align: start; color: var(--text-muted); font-weight: 600; padding: var(--space-sm); border-bottom: 2px solid var(--border); background: var(--surface-raised); }
.legal-table td { padding: var(--space-sm); border-bottom: 1px solid var(--border); vertical-align: top; line-height: 1.5; }
.legal-table tr:hover td { background: var(--surface-raised); }
.legal-note { background: color-mix(in srgb, var(--accent) 8%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); border-radius: var(--radius); padding: var(--space-md); font-size: var(--font-size-small); }
.legal-footer { padding-top: var(--space-lg); border-top: 1px solid var(--border); text-align: center; color: var(--text-muted); font-size: var(--font-size-small); display: flex; flex-direction: column; gap: var(--space-xs); }

/* ─── App Footer ────────────────────────────────────────────────────────── */
.app-footer { text-align: center; padding: var(--space-md) 0 var(--space-xl); font-size: var(--font-size-small); color: var(--text-faint); border-top: 1px solid var(--border); margin-top: var(--space-xl); display: flex; align-items: center; justify-content: center; gap: var(--space-sm); }
.app-footer a { color: var(--text-muted); text-decoration: none; }
.app-footer a:hover { color: var(--text); }
.app-footer__sep { color: var(--text-faint); }

/* ─── Setup legal notice ─────────────────────────────────────────────────── */
.setup__legal { font-size: 12px; color: var(--text-faint); text-align: center; margin-top: var(--space-sm); }
.setup__legal a { color: var(--text-muted); text-decoration: underline; }
.setup__legal a:hover { color: var(--text); }

/* ─── Settings: Your Data section ───────────────────────────────────────── */
.data-summary { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-md); margin-bottom: var(--space-md); }
.data-summary h3 { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: var(--space-sm); }
.data-summary__list { list-style: none; display: flex; flex-direction: column; gap: var(--space-xs); font-size: var(--font-size-small); }
.data-summary__label { color: var(--text-muted); margin-inline-end: var(--space-sm); }
.data-action-group { padding: var(--space-md) 0; border-top: 1px solid var(--border); }
.data-action-group h3 { font-size: 15px; font-weight: 600; margin-bottom: var(--space-xs); }
.data-action-group--danger h3 { color: var(--downvote); }
.data-action-group .settings-hint { margin-bottom: var(--space-sm); }
.region-selector { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin-bottom: var(--space-sm); }

/* Danger button */
.btn--danger { background: var(--downvote); color: white; border-color: var(--downvote); }
.btn--danger:hover { background: color-mix(in srgb, var(--downvote) 80%, black); }

/* ─── Form helpers ───────────────────────────────────────────────────────── */
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 2px; display: block; }
.form-optional { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.page-hint { color: var(--text-muted); font-size: var(--font-size-small); margin-bottom: var(--space-lg); }

/* ─── Post edit ──────────────────────────────────────────────────────────── */
.post-meta__edited { font-size: var(--font-size-small); color: var(--text-faint); font-style: italic; margin-inline-start: var(--space-xs); }
#post-edit-form { margin-top: var(--space-md); padding: var(--space-md); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); }
.post-edit-actions { display: flex; gap: var(--space-sm); margin-top: var(--space-sm); }

/* ─── PWA Install Banner ─────────────────────────────────────────────────── */
.install-banner { position: fixed; bottom: var(--space-md); left: 50%; transform: translateX(-50%); z-index: 9990; background: var(--surface-raised); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.5); padding: var(--space-md); display: flex; align-items: center; gap: var(--space-md); box-shadow: var(--shadow-md); max-width: 420px; width: calc(100vw - var(--space-xl)); }
.install-banner__content { display: flex; align-items: center; gap: var(--space-sm); flex: 1; }
.install-banner__icon { width: 40px; height: 40px; border-radius: 8px; }
.install-banner__content > div { display: flex; flex-direction: column; }
.install-banner__content strong { font-size: var(--font-size-small); }
.install-banner__content span { font-size: 12px; color: var(--text-muted); }
.install-banner__actions { display: flex; gap: var(--space-xs); flex-shrink: 0; }

/* ─── Offline banner ─────────────────────────────────────────────────────── */
#offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 9998; background: var(--surface-raised); color: var(--text-muted); border-bottom: 1px solid var(--border); text-align: center; padding: 8px 16px; font-size: 13px; }

/* ─── Beta banner ─────────────────────────────────────────────────────────── */
.beta-banner { position: sticky; top: 0; z-index: 200; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); padding: 8px var(--space-md); display: flex; align-items: center; gap: var(--space-sm); font-size: 13px; }
.beta-banner__pill { background: var(--accent); color: white; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; flex-shrink: 0; }
.beta-banner__text { flex: 1; color: var(--text-muted); }
.beta-banner__dismiss { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 4px 8px; margin-left: auto; flex-shrink: 0; }
.beta-banner__dismiss:hover { color: var(--text); }

/* ─── Upgrade page enhancements ──────────────────────────────────────────── */
.upgrade-banner { padding: var(--space-md); border-radius: var(--radius); margin-bottom: var(--space-xl); text-align: center; font-weight: 600; }
.upgrade-banner--success { background: color-mix(in srgb, var(--accent-secondary) 15%, transparent); border: 1px solid color-mix(in srgb, var(--accent-secondary) 30%, transparent); color: var(--accent-secondary); }
.upgrade-banner--info { background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }
.tier-column--active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tier-features { list-style: none; display: flex; flex-direction: column; gap: 6px; padding: 0; }
.tier-features li { color: var(--text); font-size: var(--font-size-small); }
.tier-badge { display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent); margin-top: var(--space-md); }
.tier-badge--popular { background: var(--accent); color: white; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; display: inline-block; margin-bottom: var(--space-xs); }

/* ─── Upgrade beta / coming soon ─────────────────────────────────────────── */
.upgrade-beta-banner { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-radius: var(--radius); padding: var(--space-md) var(--space-lg); display: flex; align-items: flex-start; gap: var(--space-md); margin-bottom: var(--space-xl); }
.upgrade-beta-pill { background: var(--accent); color: white; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 99px; flex-shrink: 0; margin-top: 2px; }
.upgrade-coming-soon { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); margin: var(--space-xl) 0; }
.coming-soon-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-xl); text-align: center; }
.coming-soon-icon { font-size: 48px; margin-bottom: var(--space-md); }
.coming-soon-card h2 { font-size: 20px; font-weight: 700; margin-bottom: var(--space-sm); }
.coming-soon-features { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-xl); }
.coming-soon-features h3 { font-size: 16px; font-weight: 700; margin-bottom: var(--space-md); }
.coming-soon-features ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-sm); }
.coming-soon-features li { color: var(--text); font-size: var(--font-size-small); }
.coming-soon-price { margin-top: var(--space-lg); font-weight: 600; color: var(--accent); font-size: 18px; }
.budget-note { font-size: 12px; color: var(--text-muted); margin-bottom: var(--space-sm); font-style: italic; }
@media (max-width: 640px) { .upgrade-coming-soon { grid-template-columns: 1fr; } }
.upgrade-faq { margin-top: var(--space-xl); max-width: 600px; }
.upgrade-faq h2 { margin-bottom: var(--space-md); }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--space-sm); }
.faq-item summary { padding: var(--space-md); cursor: pointer; font-weight: 600; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item p { padding: 0 var(--space-md) var(--space-md); color: var(--text-muted); line-height: 1.6; }

/* ─── Collectiv theming cascade ──────────────────────────────────────────── */
/* Collectiv-scoped overrides via [data-collectiv-theme] attribute */
/* Only CSS custom properties are overridden — no layout or structural changes */

/* ─── Collectiv banner ───────────────────────────────────────────────────── */
.collectiv-banner { position: relative; overflow: hidden; height: var(--collectiv-banner-height, 200px); border-radius: var(--radius); margin-bottom: var(--space-lg); background: var(--surface-raised); }
.collectiv-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.collectiv-banner__overlay { position: absolute; inset: 0; }
.collectiv-banner__overlay--dark { background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.2) 60%, transparent 100%); }
.collectiv-banner__overlay--light { background: linear-gradient(to top, rgba(255,255,255,0.5) 0%, transparent 60%); }
.collectiv-banner__content { position: absolute; bottom: 0; left: 0; right: 0; padding: var(--space-md) var(--space-lg); }
.collectiv-banner__content h1 { font-size: 24px; font-weight: 800; color: white; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.collectiv-banner__content p { color: rgba(255,255,255,0.85); font-size: var(--font-size-small); text-shadow: 0 1px 3px rgba(0,0,0,0.5); }

/* ─── Custom emoji ───────────────────────────────────────────────────────── */
.custom-emoji { display: inline; vertical-align: middle; height: 1.5em; width: auto; max-width: 3em; margin: 0 0.1em; object-fit: contain; }
.emoji-only .custom-emoji { height: 2.5em; }

/* ─── Inbox / DM conversation ───────────────────────────────────────────── */
.conversation-item { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md); border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.conversation-item__info { flex: 1; min-width: 0; }
.conversation-item__name { font-weight: 600; display: block; }
.conversation-item__preview { font-size: var(--font-size-small); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.conversation-item__time { font-size: var(--font-size-small); color: var(--text-faint); white-space: nowrap; }
.conversation-header { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-md); padding-bottom: var(--space-md); border-bottom: 1px solid var(--border); }
.conversation-header h1 { font-size: 18px; font-weight: 700; margin: 0; }
.message-list { display: flex; flex-direction: column; gap: var(--space-sm); padding: var(--space-md) 0; min-height: 200px; overflow-y: auto; }
.message { max-width: 80%; padding: var(--space-sm) var(--space-md); border-radius: var(--radius); }
.message--sent { align-self: flex-end; background: var(--accent-dim); }
.message--received { align-self: flex-start; background: var(--surface-raised); }
.message__time { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.message-compose { display: flex; gap: var(--space-sm); padding: var(--space-md) 0; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--bg); }
.message-compose textarea { flex: 1; }

/* ─── Delegation / device management ────────────────────────────────────── */
.device-item { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) 0; border-bottom: 1px solid var(--border); font-size: var(--font-size-small); }
.device-item__id { font-family: var(--font-mono); flex: 1; }
.device-item__scope, .device-item__date { color: var(--text-muted); }

/* ─── RTL support: keep mono/code content LTR ───────────────────────────── */
code, pre, .header__hash, .invite-code, .hash-display, .mnemonic-word__text {
  direction: ltr;
  unicode-bidi: isolate;
}
.mnemonic-num { direction: ltr; unicode-bidi: isolate; }

/* RTL: flip directional icons */
[dir="rtl"] .post-card__continue a::after { transform: scaleX(-1); }

/* ─── Emoji management (collectiv settings) ─────────────────────────────── */
.emoji-list { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-md); }
.emoji-item { display: flex; align-items: center; gap: var(--space-sm); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-xs) var(--space-sm); }
.emoji-upload__form { margin-top: var(--space-md); padding: var(--space-md); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.theme-editor { display: flex; flex-direction: column; gap: var(--space-md); }

/* ─── Platform collectiv (uncollectiv) styling ───────────────────────────── */
.post-card__collectiv--platform { color: var(--accent); font-weight: 600; }
.post-card__collectiv--platform::before { content: '★ '; }
.collectiv-item--platform { border-inline-start: 2px solid var(--accent); }
.collectiv-item--platform .collectiv-item__badge { font-size: 10px; opacity: 0.6; }
.membership-item--platform .membership-item__note { font-size: var(--font-size-small); color: var(--text-faint); font-style: italic; }

/* ─── Welcome overlay (uncollectiv first visit) ──────────────────────────── */
.welcome-overlay { position: fixed; inset: 0; z-index: 9995; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: var(--space-md); }
.welcome-card { background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * 2); padding: var(--space-xl); max-width: 420px; width: 100%; box-shadow: var(--shadow-md); }
.welcome-card h2 { font-size: 22px; font-weight: 800; margin-bottom: var(--space-md); }
.welcome-card ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-xs); margin-bottom: var(--space-lg); }
.welcome-card ul li { color: var(--text-muted); }
.welcome-card__cta { width: 100%; }

/* ─── Invite button (Find a Collectiv space) ─────────────────────────────── */
.invite-button { display: inline-block; padding: var(--space-sm) var(--space-md); background: var(--accent); color: var(--bg); border-radius: var(--radius); font-weight: 600; text-decoration: none; margin: var(--space-sm) 0; transition: opacity var(--transition-fast); }
.invite-button:hover { opacity: 0.85; text-decoration: none; color: var(--bg); }

/* ─── Skeleton loading shimmer ──────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-raised) 25%, var(--border) 50%, var(--surface-raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius);
}
.skeleton--avatar { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
.skeleton--text { height: 14px; flex: 1; min-width: 60px; }

/* ─── Collectiv Rail (persistent desktop sidebar) ────────────────────────── */
.collectiv-rail {
  position: fixed;
  top: 0;
  left: 0;
  width: 56px;
  height: 100dvh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 150;
  overflow: hidden;
  flex-shrink: 0;
}
.collectiv-rail:not([hidden]) { display: block; }
.rail__nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm) 0;
  gap: 2px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.rail__nav::-webkit-scrollbar { display: none; }
.rail__list { display: contents; }
.rail__spacer { flex: 1; }
.rail__divider { width: 32px; height: 1px; background: var(--border); margin: var(--space-xs) 0; flex-shrink: 0; }
.rail__icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
  min-width: 40px;
  min-height: 40px;
}
.rail__icon-btn:hover { background: var(--surface-raised); text-decoration: none; }
.rail__icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rail__home { margin-bottom: 2px; }
.rail__add { font-size: 22px; font-weight: 300; }
.rail__item {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-radius var(--transition-fast), transform var(--transition-fast);
  text-decoration: none;
  flex-shrink: 0;
}
.rail__item:hover { border-radius: 8px; transform: scale(1.05); text-decoration: none; }
.rail__item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.rail__item--active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.rail__item--active { border-radius: 8px; }
.rail__avatar { display: flex; align-items: center; justify-content: center; border-radius: inherit; overflow: hidden; }
.rail__avatar svg, .rail__avatar img { border-radius: 8px; display: block; }
.rail__unread {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

/* Push content right when rail is visible */
body.has-rail #header,
body.has-rail #app {
  margin-left: 56px;
}

@media (max-width: 768px) {
  .collectiv-rail { display: none !important; }
  body.has-rail #header,
  body.has-rail #app { margin-left: 0; }
}

/* ─── Home page: 3-column hub layout ─────────────────────────────────────── */
.page--home {
  /* Full-width override — #app inline style removes max-width on this page */
  min-height: 100dvh;
}
.page--home-empty {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-md);
}
.home__layout {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  gap: 0;
  align-items: start;
  min-height: 100dvh;
}
@media (max-width: 1280px) {
  .home__layout { grid-template-columns: 220px 1fr; }
  .home__right-rail { display: none; }
}
@media (max-width: 768px) {
  .home__layout { grid-template-columns: 1fr; }
  .home__sidebar {
    position: static !important;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: var(--space-sm);
  }
  .home__sidebar-header, .home__sidebar-footer { display: none; }
  .home__collectiv-item {
    flex-direction: column;
    min-width: 64px;
    text-align: center;
    scroll-snap-align: start;
    border-left: none !important;
    padding: var(--space-sm);
  }
  .home__collectiv-name { font-size: 11px; }
}
/* Sidebar */
.home__sidebar {
  position: sticky;
  top: 56px;
  height: calc(100dvh - 56px);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
}
.home__sidebar-header { padding: var(--space-md) var(--space-md) var(--space-sm); }
.home__sidebar-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.home__collectiv-list { flex: 1; display: flex; flex-direction: column; padding: var(--space-xs) 0; }
.home__collectiv-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-md);
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 0;
  border-left: 3px solid transparent;
  transition: background var(--transition-fast), color var(--transition-fast);
  min-height: 44px;
  position: relative;
}
.home__collectiv-item--skeleton { pointer-events: none; }
.home__collectiv-item:hover { background: var(--surface-raised); color: var(--text); text-decoration: none; }
.home__collectiv-item--active { color: var(--text); background: var(--accent-dim); border-left-color: var(--accent); }
.home__collectiv-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.home__collectiv-avatar { flex-shrink: 0; border-radius: 8px; overflow: hidden; display: flex; }
.home__collectiv-avatar svg, .home__collectiv-avatar img { border-radius: 6px; display: block; }
.home__collectiv-name { flex: 1; font-size: var(--font-size-small); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home__collectiv-unread { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; flex-shrink: 0; }
.home__sidebar-footer { padding: var(--space-md); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--space-sm); }
.home__create-btn { width: 100%; text-align: center; }
.home__join-link { font-size: var(--font-size-small); color: var(--text-muted); text-align: center; }
/* Feed column */
.home__feed-col { min-width: 0; padding: var(--space-md); max-width: 760px; }
.home__feed-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); padding-bottom: var(--space-md); border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: var(--space-sm); }
.home__feed-title { font-size: 20px; font-weight: 700; }
/* Right rail */
.home__right-rail { padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-md); position: sticky; top: 56px; height: calc(100dvh - 56px); overflow-y: auto; }
.home__activity-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-md); }
.home__activity-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-sm); }
.home__activity-links { display: flex; flex-direction: column; gap: 2px; }
.home__activity-link { display: block; padding: 8px var(--space-sm); border-radius: 8px; font-size: var(--font-size-small); color: var(--text-muted); text-decoration: none; transition: background var(--transition-fast), color var(--transition-fast); }
.home__activity-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.home__active-list { display: flex; flex-direction: column; gap: 2px; }
.home__active-item { display: flex; align-items: center; gap: var(--space-sm); padding: 8px var(--space-xs); border-radius: 8px; text-decoration: none; color: var(--text-muted); font-size: var(--font-size-small); transition: background var(--transition-fast), color var(--transition-fast); min-height: 36px; }
.home__active-item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.home__active-item__avatar { flex-shrink: 0; display: flex; border-radius: 4px; overflow: hidden; }
.home__active-item__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home__active-item__count { background: var(--accent-dim); color: var(--accent); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 10px; flex-shrink: 0; }
/* Activity contribution grid (easter egg) */
.home__activity-card--grid { padding-bottom: var(--space-sm); }
.activity-grid { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.activity-grid__svg { overflow: visible; }
.activity-grid__summary { font-size: 11px; color: var(--text-faint); margin: var(--space-xs) 0 0; }
.activity-grid__empty { font-size: var(--font-size-small); color: var(--text-faint); }
/* Cell intensity levels — 0 = empty, 1–4 = ascending activity */
.activity-cell { fill: var(--surface-raised); transition: opacity 0.1s; }
.activity-cell:hover { opacity: 0.8; }
.activity-cell--0 { fill: var(--surface-raised); }
.activity-cell--1 { fill: color-mix(in srgb, var(--accent) 25%, var(--surface-raised)); }
.activity-cell--2 { fill: color-mix(in srgb, var(--accent) 50%, var(--surface-raised)); }
.activity-cell--3 { fill: color-mix(in srgb, var(--accent) 75%, var(--surface-raised)); }
.activity-cell--4 { fill: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .activity-cell--1, .activity-cell--2, .activity-cell--3, .activity-cell--4 {
    animation: cell-fade-in 0.3s ease both;
  }
  @keyframes cell-fade-in {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
  }
}

/* ─── Collectiv landing page ─────────────────────────────────────────────── */
.page--collective-landing { min-height: 100dvh; }
.collective-banner--gradient { height: 220px; border-radius: 0; }
.collective-banner--loading { height: 220px; border-radius: 0; background: var(--surface-raised); }
@media (max-width: 768px) {
  .collective-banner--gradient,
  .collective-banner--loading { height: 150px; }
}
.collective-landing__body { max-width: 1100px; margin: 0 auto; padding: 0 var(--space-md) var(--space-xl); }
.collective-landing__header { padding: var(--space-lg) 0 var(--space-md); border-bottom: 1px solid var(--border); margin-bottom: var(--space-lg); }
.coll-landing__identity { display: flex; align-items: flex-start; gap: var(--space-md); margin-bottom: var(--space-md); }
.coll-landing__avatar { flex-shrink: 0; }
.coll-landing__avatar span, .coll-landing__avatar svg { border-radius: 16px; display: block; }
.coll-landing__meta { flex: 1; min-width: 0; }
.coll-landing__name { font-size: 28px; font-weight: 800; margin-bottom: 2px; }
.coll-landing__handle { font-size: var(--font-size-small); color: var(--text-muted); font-family: var(--font-mono); display: block; margin-bottom: var(--space-xs); }
.coll-landing__desc { color: var(--text-muted); font-size: var(--font-size-base); margin-top: var(--space-xs); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.coll-landing__actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; margin-bottom: var(--space-md); }
.coll-landing__rules { margin-bottom: var(--space-md); }
@media (max-width: 640px) {
  .coll-landing__identity { flex-direction: column; }
  .coll-landing__name { font-size: 22px; }
}

/* "All Posts" entry bar */
.coll-landing__spaces-section { margin-top: var(--space-md); }
.coll-landing__all-posts { margin-bottom: var(--space-lg); }
.all-posts-entry {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.all-posts-entry:hover { border-color: var(--accent); background: var(--surface); text-decoration: none; }
.all-posts-entry:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.all-posts-entry__icon { font-size: 24px; flex-shrink: 0; }
.all-posts-entry__info { flex: 1; }
.all-posts-entry__title { font-size: 16px; font-weight: 700; display: block; }
.all-posts-entry__meta { font-size: var(--font-size-small); color: var(--text-muted); display: block; margin-top: 2px; }
.all-posts-entry__arrow { font-size: 20px; color: var(--text-muted); font-weight: 300; }

/* Spaces grid */
.coll-landing__spaces-heading { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-md); }
.spaces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: clamp(0.75rem, 2vw, 1.25rem);
}
.space-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.space-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent); text-decoration: none; }
.space-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.space-card--archived { opacity: 0.5; }
.space-card__icon { font-size: 24px; flex-shrink: 0; margin-top: 2px; }
.space-card__body { flex: 1; min-width: 0; }
.space-card__name { font-size: 16px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: var(--space-xs); }
.space-card__default-badge { color: var(--accent); font-size: 12px; }
.space-card__archived-badge { font-size: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; color: var(--text-muted); }
.space-card__desc { font-size: var(--font-size-small); color: var(--text-muted); margin-bottom: var(--space-xs); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.space-card__activity { font-size: 12px; color: var(--text-faint); }

/* ─── Space view (feed) ──────────────────────────────────────────────────── */
.page--space { min-height: 100dvh; }
.space-view { min-height: 100dvh; }
.space-view__banner { height: 140px; }
@media (max-width: 768px) { .space-view__banner { height: 100px; } }
.space-view__content {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-lg);
  max-width: 1060px;
  margin: 0 auto;
  padding: var(--space-md);
  align-items: start;
}
@media (max-width: 1024px) {
  .space-view__content { grid-template-columns: 1fr; }
  .space-view__sidebar { display: none; }
}
.space-view__main { min-width: 0; }
.space-view__header { margin-bottom: var(--space-md); padding-bottom: var(--space-md); border-bottom: 1px solid var(--border); }
.space-view__title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; margin: var(--space-sm) 0; }
.space-view__title { font-size: 24px; font-weight: 800; }
.space-view__desc { color: var(--text-muted); font-size: var(--font-size-small); margin-bottom: var(--space-sm); }
.space-view__actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.space-view__rules { margin-top: var(--space-sm); }
.space-view__empty { text-align: center; padding: var(--space-xl) 0; display: flex; flex-direction: column; align-items: center; gap: var(--space-md); }
/* Sidebar */
.space-view__sidebar { display: flex; flex-direction: column; gap: var(--space-md); position: sticky; top: 72px; }
.space-sidebar__card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-md); }
.space-sidebar__heading { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-sm); }
.space-sidebar__desc { font-size: var(--font-size-small); color: var(--text-muted); line-height: 1.6; margin-bottom: var(--space-sm); }
.space-sidebar__meta { margin-top: var(--space-sm); }
.space-sidebar__back-link { font-size: var(--font-size-small); color: var(--accent); }
.space-sidebar__list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.space-sidebar__link { display: block; padding: 6px var(--space-sm); border-radius: 6px; font-size: var(--font-size-small); color: var(--text-muted); text-decoration: none; transition: background var(--transition-fast), color var(--transition-fast); }
.space-sidebar__link:hover { background: var(--surface); color: var(--text); text-decoration: none; }

/* ─── Breadcrumb ─────────────────────────────────────────────────────────── */
.breadcrumb { margin-bottom: var(--space-xs); }
.breadcrumb__list { list-style: none; padding: 0; display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; }
.breadcrumb__item { font-size: var(--font-size-small); color: var(--text-muted); }
.breadcrumb__item--current { color: var(--text); font-weight: 600; }
.breadcrumb__link { color: var(--text-muted); text-decoration: none; }
.breadcrumb__link:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb__sep { color: var(--text-faint); }

/* ─── Post card: space badge ─────────────────────────────────────────────── */
.post-card__space-sep { color: var(--text-faint); }
.post-card__space { color: var(--text-muted); font-size: var(--font-size-small); }
.post-card__space:hover { color: var(--accent); }

/* ─── Settings: spaces section enhancements ──────────────────────────────── */
.spaces-list { display: flex; flex-direction: column; gap: var(--space-xs); margin-bottom: var(--space-md); }
.space-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background var(--transition-fast);
}
.space-item--dragging { opacity: 0.5; }
.space-item--archived { opacity: 0.6; }
.space-item__drag-handle { color: var(--text-faint); cursor: grab; padding: var(--space-xs); font-size: 16px; user-select: none; touch-action: none; }
.space-item__drag-handle:active { cursor: grabbing; }
.space-item__info { flex: 1; display: flex; align-items: center; gap: var(--space-sm); min-width: 0; }
.space-item__name { font-weight: 600; font-size: var(--font-size-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-item__reorder-btns { display: flex; gap: 2px; }
@media (hover: hover) and (pointer: fine) {
  .space-item__reorder-btns { display: none; }
  .space-item:hover .space-item__reorder-btns { display: flex; }
}
@media (hover: none) {
  .space-item__drag-handle { display: none; }
}
.space-item__actions { display: flex; gap: var(--space-xs); flex-shrink: 0; }
.badge--default { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-size: 11px; border-radius: 10px; padding: 1px 7px; font-weight: 600; border: none; }
.badge--archived { background: var(--surface-raised); color: var(--text-muted); font-size: 11px; border-radius: 10px; padding: 1px 7px; font-weight: 600; border: none; }
.create-space-form { margin-top: var(--space-md); padding: var(--space-md); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); }
.space-settings-grid { display: flex; flex-direction: column; gap: var(--space-sm); }
.radio-label { display: flex; align-items: center; gap: var(--space-sm); font-size: var(--font-size-small); cursor: pointer; }

/* ─── Spaces nav tabs (legacy / fallback) ────────────────────────────────── */
.spaces-nav { display: flex; gap: var(--space-xs); flex-wrap: wrap; margin-bottom: var(--space-md); padding-bottom: var(--space-sm); border-bottom: 1px solid var(--border); }
.space-tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: var(--font-size-small); font-weight: 600; padding: 8px 14px; border-radius: 20px 20px 0 0; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; transition: color var(--transition-fast), background var(--transition-fast); }
.space-tab--active { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface-raised); font-weight: 700; }
.space-tab:hover:not(.space-tab--active) { background: var(--surface-raised); color: var(--text); text-decoration: none; }
.space-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Collectiv listing card (structured listing post type) ──────────────── */
.listing-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-md); margin: var(--space-sm) 0; }
.listing-card__name { font-size: 18px; font-weight: 700; margin-bottom: var(--space-xs); }
.listing-card__desc { color: var(--text-muted); margin-bottom: var(--space-sm); font-size: var(--font-size-small); }
.listing-card__meta { display: flex; gap: var(--space-md); font-size: var(--font-size-small); color: var(--text-faint); margin-bottom: var(--space-sm); }
.listing-card__pitch { font-style: italic; color: var(--text-muted); margin-bottom: var(--space-md); }
.listing-card__tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.listing-card__tag { font-size: 12px; background: var(--accent-dim); color: var(--accent); padding: 2px 8px; border-radius: 99px; }
