/* ─────────────────────────────────────────────────────────────
   SeedTree — community spaces
   Topic-led spaces unlocked by a visitor's interest tags. Each
   space holds: a chat room, a live web room (Jitsi embed), and
   a knowledge submission tree where entries are promoted by
   peer voting (3-vote threshold per spec).
   ───────────────────────────────────────────────────────────── */

/* The .space-shell needs a more specific selector than page-backgrounds.css's
   `.page--art .page-inner { max-width: var(--panel-width) }` (specificity 0,2,0)
   so its own max-width wins. */
.page--art .page-inner.space-shell,
.space-shell {
  /* Tunable via Shift+T (space-tuner.js). */
  --space-panel-width: 1480px;   /* 60% wider than the 920 default */
  --chat-height: 58svh;
  --webroom-ratio: 1.6;          /* 16/10 default; tuner adjusts */
  --library-card-w: 280px;
  max-width: var(--space-panel-width);
}

/* === Members / active line ================================== */
.space-active {
  display: inline-flex; align-items: center; gap: 6px;
}
.space-active-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
  animation: space-active-pulse 1.8s var(--ease-organic) infinite;
}
@keyframes space-active-pulse {
  0%, 100% { opacity: 0.7; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .space-active-dot { animation: none; }
}

.space-head {
  display: flex; align-items: center; gap: 18px;
  margin: 6px 0 18px;
}
.space-head-glyph {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(201, 169, 97, 0.12);
  border: 1px solid rgba(201, 169, 97, 0.4);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.6rem;
  color: var(--gold-light);
}
.space-head-text { min-width: 0; flex: 1 1 auto; }
.space-head h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  color: var(--cream);
  margin: 0;
  line-height: 1.1;
}
.space-head-sub {
  font: italic 0.9rem var(--font-display);
  color: var(--gold-light);
  margin: 2px 0 0;
}
.space-meta {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin: 0 0 18px;
  font: 0.82rem var(--font-body);
  color: rgba(236, 231, 216, 0.65);
}
.space-meta strong { font-family: var(--font-display); font-weight: 400; color: var(--cream); }

/* === Tabs ================================================== */
.space-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: 8px 0 20px;
  padding: 4px;
  background: rgba(7, 20, 14, 0.5);
  border: 1px solid rgba(201, 169, 97, 0.22);
  border-radius: 999px;
}
.space-tab {
  flex: 1 1 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  font: 0.88rem var(--font-display);
  letter-spacing: 0.04em;
  color: rgba(236, 231, 216, 0.7);
  cursor: pointer;
  transition: background .2s var(--ease-organic), color .2s;
}
.space-tab:hover { color: var(--cream); background: rgba(201, 169, 97, 0.08); }
.space-tab.is-active {
  background: var(--gold);
  color: var(--forest);
  font-weight: 500;
}
.space-tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(7, 20, 14, 0.4);
  color: rgba(236, 231, 216, 0.8);
  font: 0.7rem var(--font-body);
}
.space-tab.is-active .space-tab-count { background: rgba(7, 20, 14, 0.2); color: var(--forest); }

.space-panel { display: none; }
.space-panel.is-active { display: block; }

/* === Chat ================================================== */
.chat-container {
  display: flex; flex-direction: column;
  /* No min-height — the tuner slider sets --chat-height directly so
     the user sees their change. The 200px floor handles edge cases. */
  height: var(--chat-height, 58svh);
  min-height: 200px;
  background: rgba(7, 20, 14, 0.45);
  border: 1px solid rgba(201, 169, 97, 0.22);
  border-radius: 14px;
  overflow: hidden;
}
.chat-stream {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 18px 12px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 72%;
  align-self: flex-start;
  padding: 9px 14px;
  background: rgba(13, 31, 23, 0.72);
  border: 1px solid rgba(201, 169, 97, 0.18);
  border-radius: 14px;
  border-top-left-radius: 4px;
  color: var(--cream);
}
.chat-msg.is-me {
  align-self: flex-end;
  background: rgba(201, 169, 97, 0.16);
  border-color: rgba(201, 169, 97, 0.32);
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
}
.chat-msg-head {
  display: flex; gap: 8px; align-items: baseline;
  margin-bottom: 3px;
  font: 0.72rem var(--font-body);
  color: rgba(236, 231, 216, 0.55);
}
.chat-msg-author { font-family: var(--font-display); font-style: italic; color: var(--gold-light); }
.chat-msg-body { font: 0.92rem var(--font-body); line-height: 1.5; }
.chat-msg-body a { color: var(--gold-light); }

.chat-composer {
  display: flex; gap: 8px;
  padding: 10px 12px;
  background: rgba(7, 20, 14, 0.55);
  border-top: 1px solid rgba(201, 169, 97, 0.2);
}
.chat-composer input {
  flex: 1 1 auto;
  padding: 10px 14px;
  background: rgba(236, 231, 216, 0.06);
  border: 1px solid rgba(201, 169, 97, 0.2);
  border-radius: 999px;
  color: var(--cream);
  font: 0.92rem var(--font-body);
  outline: none;
}
.chat-composer input:focus { border-color: var(--gold); }
.chat-composer button {
  padding: 8px 18px;
  background: var(--gold); color: var(--forest);
  border: 0; border-radius: 999px;
  font: 0.85rem var(--font-display); letter-spacing: 0.04em;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.chat-composer button:hover { background: var(--gold-light); transform: translateY(-1px); }
.chat-composer button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* === Chat — replies + @mentions ============================ */
.chat-msg { position: relative; }
.chat-msg-actions {
  position: absolute;
  top: -10px;
  right: 8px;
  display: none;
  gap: 4px;
}
.chat-msg:hover .chat-msg-actions,
.chat-msg:focus-within .chat-msg-actions { display: flex; }
.chat-msg-action {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: rgba(7, 20, 14, 0.85);
  border: 1px solid rgba(201, 169, 97, 0.35);
  border-radius: 999px;
  color: rgba(236, 231, 216, 0.78);
  font: italic 0.72rem var(--font-display);
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.chat-msg-action:hover { color: var(--cream); border-color: var(--gold); }

.chat-quote {
  display: block;
  padding: 6px 10px;
  margin-bottom: 6px;
  background: rgba(201, 169, 97, 0.08);
  border-left: 2px solid rgba(201, 169, 97, 0.4);
  border-radius: 4px;
  font: italic 0.82rem var(--font-display);
  color: rgba(236, 231, 216, 0.72);
}
.chat-quote-author { color: var(--gold-light); font-style: normal; }

.chat-mention {
  display: inline-block;
  padding: 1px 7px;
  background: rgba(201, 169, 97, 0.18);
  border: 1px solid rgba(201, 169, 97, 0.35);
  border-radius: 999px;
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-style: normal;
  letter-spacing: 0.02em;
}
.chat-mention.is-me {
  background: rgba(251, 213, 74, 0.16);
  border-color: rgba(251, 213, 74, 0.55);
  color: #fbd54a;
}

.chat-reply-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: rgba(201, 169, 97, 0.08);
  border-top: 1px solid rgba(201, 169, 97, 0.18);
  border-bottom: 1px solid rgba(201, 169, 97, 0.18);
  font: italic 0.84rem var(--font-display);
  color: rgba(236, 231, 216, 0.78);
}
.chat-reply-label strong { color: var(--gold-light); font-weight: 400; font-style: normal; }
.chat-reply-excerpt {
  flex: 1 1 auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: rgba(236, 231, 216, 0.6);
  font-size: 0.82rem;
}
.chat-reply-cancel {
  background: transparent; border: 0;
  color: rgba(236, 231, 216, 0.6);
  font-size: 1.1rem; line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.chat-reply-cancel:hover { color: var(--cream); }

.chat-stub-note {
  font: italic 0.78rem var(--font-display);
  color: rgba(236, 231, 216, 0.55);
  text-align: center;
  margin: 10px 0 0;
}

/* === Web room ============================================== */
.webroom-frame {
  position: relative;
  width: 100%;
  background: rgba(7, 20, 14, 0.8);
  border: 1px solid rgba(201, 169, 97, 0.28);
  border-radius: 14px;
  overflow: hidden;
}
.webroom-frame iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
  display: block;
}
.webroom-frame.is-idle {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 36px 24px;
  text-align: center;
}
.webroom-frame.is-idle .webroom-cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 26px;
  background: var(--gold); color: var(--forest);
  border-radius: 999px; border: 0;
  font: 1rem var(--font-display); letter-spacing: 0.04em;
  cursor: pointer; text-decoration: none;
  transition: background .2s, transform .2s;
}
.webroom-frame.is-idle .webroom-cta:hover { background: var(--gold-light); transform: translateY(-1px); }
.webroom-frame.is-idle .webroom-hint {
  font: italic 0.85rem var(--font-display);
  color: rgba(236, 231, 216, 0.65);
  margin-top: 14px;
}
.webroom-popout {
  display: inline-block;
  font: italic 0.82rem var(--font-display);
  color: var(--gold-light);
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: rgba(201, 169, 97, 0.5);
  margin-top: 14px;
}

/* === Knowledge ============================================= */
.knowledge-tabs {
  display: flex; gap: 6px;
  margin: 0 0 14px;
}
.knowledge-tab {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(201, 169, 97, 0.25);
  border-radius: 999px;
  color: rgba(236, 231, 216, 0.7);
  cursor: pointer;
  font: 0.82rem var(--font-display);
  letter-spacing: 0.04em;
  transition: color .2s, background .2s, border-color .2s;
}
.knowledge-tab:hover { color: var(--cream); border-color: var(--gold); }
.knowledge-tab.is-active { background: rgba(201, 169, 97, 0.15); color: var(--gold-light); border-color: var(--gold); }

.knowledge-section { display: none; }
.knowledge-section.is-active { display: block; }

.knowledge-list { display: grid; gap: 12px; }
.knowledge-card {
  padding: 16px 18px;
  background: rgba(13, 31, 23, 0.6);
  border: 1px solid rgba(201, 169, 97, 0.22);
  border-radius: 12px;
}
.knowledge-card.is-pending { background: rgba(7, 20, 14, 0.5); }
.knowledge-card.is-approved { border-color: rgba(74, 222, 128, 0.45); }

.knowledge-card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.knowledge-card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--cream);
  margin: 0;
  font-weight: 400;
}
.knowledge-card-by {
  font: 0.75rem var(--font-body);
  color: rgba(236, 231, 216, 0.5);
}
.knowledge-card-body {
  font: 0.9rem var(--font-body);
  line-height: 1.6;
  color: rgba(236, 231, 216, 0.86);
  margin: 0 0 10px;
}
.knowledge-card-sources {
  font: 0.78rem var(--font-body);
  color: rgba(236, 231, 216, 0.55);
}
.knowledge-card-sources a {
  color: var(--gold-light);
  text-decoration: underline;
  text-decoration-color: rgba(201, 169, 97, 0.45);
  text-underline-offset: 3px;
  margin-right: 10px;
}

.knowledge-vote {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(201, 169, 97, 0.16);
}
.knowledge-vote-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(201, 169, 97, 0.4);
  border-radius: 999px;
  color: var(--gold-light);
  cursor: pointer;
  font: 0.85rem var(--font-display);
  letter-spacing: 0.04em;
  transition: color .2s, background .2s, border-color .2s, transform .2s;
}
.knowledge-vote-btn:hover { color: var(--cream); background: rgba(201, 169, 97, 0.12); transform: translateY(-1px); }
.knowledge-vote-btn.is-voted {
  background: rgba(201, 169, 97, 0.18);
  color: var(--gold);
  border-color: var(--gold);
  cursor: default;
}
.knowledge-vote-progress {
  flex: 1 1 auto;
  display: flex; align-items: center; gap: 10px;
  font: italic 0.82rem var(--font-display);
  color: rgba(236, 231, 216, 0.6);
}
.knowledge-vote-bar {
  flex: 1 1 auto;
  height: 6px;
  background: rgba(7, 20, 14, 0.5);
  border: 1px solid rgba(201, 169, 97, 0.18);
  border-radius: 999px;
  overflow: hidden;
}
.knowledge-vote-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-light), var(--gold));
  transition: width .35s var(--ease-organic);
}
.knowledge-vote-bar-fill.is-complete { background: linear-gradient(90deg, #4ade80, #8ddf9a); }

.knowledge-empty {
  padding: 32px 22px;
  text-align: center;
  background: rgba(7, 20, 14, 0.45);
  border: 1px dashed rgba(201, 169, 97, 0.22);
  border-radius: 14px;
  font: italic 0.92rem var(--font-display);
  color: rgba(236, 231, 216, 0.6);
}

/* === Knowledge — Overview (LLM synthesis) ================== */

.overview-shell {
  padding: 22px 24px 20px;
  background: rgba(7, 20, 14, 0.55);
  border: 1px solid rgba(201, 169, 97, 0.25);
  border-radius: 14px;
}
.overview-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}
.overview-headtext { min-width: 0; flex: 1 1 auto; }
.overview-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--cream);
  margin: 0 0 4px;
  font-weight: 400;
}
.overview-sub {
  font: italic 0.85rem var(--font-display);
  color: var(--gold-light);
  margin: 0;
}
.overview-refresh {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  background: rgba(201, 169, 97, 0.1);
  border: 1px solid rgba(201, 169, 97, 0.35);
  border-radius: 50%;
  color: var(--gold-light);
  font-size: 1.05rem; line-height: 1;
  cursor: pointer;
  transition: color .2s, background .2s, transform .35s var(--ease-organic);
}
.overview-refresh:hover { color: var(--cream); background: rgba(201, 169, 97, 0.2); }
.overview-refresh.is-spinning { transform: rotate(360deg); transition: transform 800ms var(--ease-organic); }

.overview-stale-badge {
  display: inline-block;
  margin: 6px 0 0;
  padding: 4px 10px;
  background: rgba(232, 114, 156, 0.12);
  border: 1px solid rgba(232, 114, 156, 0.4);
  border-radius: 999px;
  font: italic 0.74rem var(--font-display);
  color: rgba(243, 192, 207, 0.95);
  letter-spacing: 0.04em;
}

.overview-body {
  margin: 16px 0 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(236, 231, 216, 0.88);
}
.overview-body p { margin: 0 0 12px; }
.overview-body strong { color: var(--cream); font-weight: 500; font-family: var(--font-display); }
.overview-cite {
  display: inline;
  font: 0.68rem var(--font-body);
  vertical-align: super;
  margin: 0 1px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1px solid rgba(201, 169, 97, 0.5);
  background: rgba(201, 169, 97, 0.16);
  color: var(--gold-light);
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.overview-cite:hover { background: var(--gold); color: var(--forest); }

.overview-empty {
  padding: 20px 0 4px;
  font: italic 0.92rem var(--font-display);
  color: rgba(236, 231, 216, 0.6);
  text-align: center;
}

.overview-citations {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(201, 169, 97, 0.18);
}
.overview-citations-title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: var(--gold-light);
  margin: 0 0 8px;
  font-weight: 400;
  font-style: italic;
}
.overview-citations-list {
  list-style: none;
  counter-reset: cite;
  padding: 0;
  margin: 0;
  display: grid; gap: 6px;
}
.overview-citations-list li {
  counter-increment: cite;
  padding-left: 30px;
  position: relative;
  font: 0.82rem var(--font-body);
  color: rgba(236, 231, 216, 0.75);
  line-height: 1.5;
}
.overview-citations-list li::before {
  content: '[' counter(cite) ']';
  position: absolute; left: 0; top: 0;
  font: 0.78rem var(--font-body);
  color: var(--gold-light);
}
.overview-citations-list li.is-highlight {
  background: rgba(201, 169, 97, 0.1);
  border-radius: 6px;
  padding: 4px 8px 4px 30px;
}
.overview-citations-list a {
  color: var(--gold-light);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(201, 169, 97, 0.4);
}

.overview-stub-note {
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(7, 20, 14, 0.55);
  border-left: 2px solid var(--gold);
  border-radius: 0 8px 8px 0;
  font: italic 0.8rem var(--font-display);
  color: rgba(236, 231, 216, 0.6);
}

.knowledge-submit-cta {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 6px;
  padding: 10px 18px;
  background: var(--gold); color: var(--forest);
  border: 0; border-radius: 999px;
  font: 0.9rem var(--font-display); letter-spacing: 0.04em;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.knowledge-submit-cta:hover { background: var(--gold-light); transform: translateY(-1px); }

/* Knowledge submit form mirrors intake-form styling */
.knowledge-form { margin-top: 6px; }

/* === Library ================================================ */
.library-toolbar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 0 0 16px;
}
.library-search {
  flex: 1 1 200px;
  min-width: 200px;
  padding: 9px 14px;
  background: rgba(7, 20, 14, 0.55);
  border: 1px solid rgba(201, 169, 97, 0.25);
  border-radius: 999px;
  color: var(--cream);
  font: 0.9rem var(--font-body);
  outline: none;
}
.library-search:focus { border-color: var(--gold); }
.library-filter {
  padding: 9px 28px 9px 14px;
  background: rgba(7, 20, 14, 0.55);
  border: 1px solid rgba(201, 169, 97, 0.25);
  border-radius: 999px;
  color: var(--cream);
  font: 0.85rem var(--font-body);
  appearance: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(201,169,97,0.5) 50%),
    linear-gradient(135deg, rgba(201,169,97,0.5) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 10px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.library-add-cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 26px;
  background: var(--gold); color: var(--forest);
  border: 0; border-radius: 999px;
  font: 1rem var(--font-display); font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(201, 169, 97, 0.45),
              0 6px 18px rgba(201, 169, 97, 0.28);
  transition: background .2s var(--ease-organic),
              transform .2s,
              box-shadow .2s;
}
.library-add-cta:hover {
  background: var(--gold-light);
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(201, 169, 97, 0.65),
              0 10px 24px rgba(201, 169, 97, 0.4);
}
.library-add-cta:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

.library-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--library-card-w, 280px), 1fr));
  gap: 14px;
}

.library-card {
  display: flex; flex-direction: column;
  padding: 16px 18px;
  background: rgba(13, 31, 23, 0.62);
  border: 1px solid rgba(201, 169, 97, 0.22);
  border-radius: 12px;
  transition: border-color .2s, background .2s, transform .2s;
}
.library-card:hover { border-color: rgba(201, 169, 97, 0.5); background: rgba(25, 54, 42, 0.7); transform: translateY(-1px); }

.library-type {
  align-self: flex-start;
  font: 0.62rem var(--font-body);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(201, 169, 97, 0.32);
  color: rgba(236, 231, 216, 0.72);
  background: rgba(7, 20, 14, 0.4);
  margin-bottom: 10px;
}
.library-type[data-type="article"] { color: #8ddf9a; border-color: rgba(141, 223, 154, 0.4); }
.library-type[data-type="book"]    { color: #f0c040; border-color: rgba(240, 192, 64, 0.4); }
.library-type[data-type="video"]   { color: #e8729c; border-color: rgba(232, 114, 156, 0.4); }
.library-type[data-type="podcast"] { color: #b399f0; border-color: rgba(179, 153, 240, 0.4); }
.library-type[data-type="tool"]    { color: #7ec0e7; border-color: rgba(126, 192, 231, 0.4); }
.library-type[data-type="thread"]  { color: #fbd54a; border-color: rgba(251, 213, 74, 0.4); }

.library-card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--cream);
  margin: 0 0 6px;
  font-weight: 400;
  line-height: 1.25;
}
.library-card-title a {
  color: var(--cream);
  text-decoration: none;
}
.library-card-title a:hover { color: var(--gold-light); }
.library-card-desc {
  font: 0.86rem var(--font-body);
  line-height: 1.55;
  color: rgba(236, 231, 216, 0.78);
  margin: 0 0 10px;
}
.library-card-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 10px;
}
.library-tag {
  font: 0.7rem var(--font-body);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(7, 20, 14, 0.4);
  border: 1px solid rgba(201, 169, 97, 0.2);
  color: rgba(236, 231, 216, 0.68);
}
.library-card-foot {
  margin-top: auto;
  padding-top: 10px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  border-top: 1px solid rgba(201, 169, 97, 0.14);
  font: italic 0.78rem var(--font-display);
  color: rgba(236, 231, 216, 0.55);
}
.library-card-open {
  color: var(--gold-light);
  text-decoration: none;
}
.library-card-open:hover { color: var(--cream); }

.library-empty {
  padding: 32px 22px;
  text-align: center;
  background: rgba(7, 20, 14, 0.45);
  border: 1px dashed rgba(201, 169, 97, 0.22);
  border-radius: 14px;
  font: italic 0.92rem var(--font-display);
  color: rgba(236, 231, 216, 0.6);
}

.library-form-wrap {
  margin-top: 18px;
  padding: 22px 24px;
  background: rgba(7, 20, 14, 0.55);
  border: 1px solid rgba(201, 169, 97, 0.28);
  border-radius: 14px;
}

/* === Space TUNE mode ======================================== */
.space-tune-pill {
  position: fixed; bottom: 14px; left: 14px; z-index: 9998;
  background: rgba(7, 20, 14, 0.85); color: var(--cream);
  border: 1px solid rgba(201, 169, 97, 0.45);
  border-radius: 999px; padding: 6px 14px;
  font: 12px/1 var(--font-body); letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer;
}
body.space-tuning .space-tune-pill { background: var(--gold); color: var(--forest); border-color: var(--gold); }

.space-tune-hud {
  position: fixed; bottom: 58px; left: 14px; z-index: 9998;
  background: rgba(7, 20, 14, 0.96); color: var(--cream);
  border: 1px solid rgba(201, 169, 97, 0.45);
  border-radius: 8px; padding: 12px 14px;
  font: 12px/1.5 var(--font-body);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: none; width: 260px;
}
body.space-tuning .space-tune-hud { display: block; }
.space-tune-hud h4 { font: italic 13px var(--font-display); color: var(--gold-light); margin: 0 0 10px; }
.space-tune-hud .row { display: grid; grid-template-columns: 64px 1fr 50px; gap: 6px; align-items: center; margin: 5px 0; }
.space-tune-hud label { color: rgba(236, 231, 216, 0.75); font-size: 11px; }
.space-tune-hud input[type=range] { accent-color: var(--gold); }
.space-tune-hud input[type=number] {
  width: 100%; padding: 2px 4px;
  background: rgba(236, 231, 216, 0.08);
  border: 1px solid rgba(216, 190, 126, 0.25);
  border-radius: 3px; color: var(--cream); font: 11px var(--font-body);
}
.space-tune-hud .actions {
  display: flex; gap: 6px; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid rgba(216, 190, 126, 0.18);
}
.space-tune-hud .actions button {
  flex: 1; padding: 6px;
  background: rgba(201, 169, 97, 0.15);
  border: 1px solid rgba(201, 169, 97, 0.4);
  border-radius: 4px; color: var(--cream);
  font: 11px var(--font-body); letter-spacing: 0.04em;
  cursor: pointer;
}
.space-tune-hud .actions button:hover { background: rgba(201, 169, 97, 0.28); }
.space-tune-hud .hint { font-style: italic; color: rgba(236, 231, 216, 0.5); font-size: 10.5px; margin-top: 8px; }

/* Bias the webroom aspect ratio off the tunable */
.webroom-frame {
  aspect-ratio: var(--webroom-ratio, 1.6);
}

.space-stub-note {
  margin: 22px 0 6px;
  padding: 12px 16px;
  border-left: 2px solid var(--gold);
  background: rgba(7, 20, 14, 0.5);
  font: italic 0.82rem var(--font-display);
  color: rgba(236, 231, 216, 0.7);
  border-radius: 0 8px 8px 0;
}

@media (max-width: 540px) {
  .space-head-glyph { width: 44px; height: 44px; font-size: 1.25rem; }
  .chat-msg { max-width: 86%; }
}

/* === Spaces index ========================================== */
.spaces-section { margin: 28px 0 20px; }
.spaces-section h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--gold-light);
  margin: 0 0 4px;
}
.spaces-section-sub {
  font: italic 0.86rem var(--font-display);
  color: rgba(236, 231, 216, 0.62);
  margin: 0 0 18px;
}
.spaces-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.space-card {
  display: block;
  text-decoration: none;
  padding: 18px 20px;
  background: rgba(7, 20, 14, 0.55);
  border: 1px solid rgba(201, 169, 97, 0.25);
  border-radius: 14px;
  color: var(--cream);
  transition: background .25s var(--ease-organic), border-color .25s, transform .2s;
}
.space-card:hover { background: rgba(25, 54, 42, 0.7); border-color: var(--gold); transform: translateY(-2px); }
.space-card.is-locked { opacity: 0.7; }
.space-card-tag {
  display: inline-block;
  font: 0.62rem var(--font-body);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(236, 231, 216, 0.55);
  margin-bottom: 6px;
}
.space-card-tag.matched { color: var(--gold-light); }
.space-card-title {
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--cream);
  margin: 0 0 6px;
}
.space-card-sub {
  font: 0.88rem var(--font-body);
  line-height: 1.55;
  color: rgba(236, 231, 216, 0.75);
  margin: 0 0 10px;
}
.space-card-meta {
  display: flex; gap: 12px;
  font: italic 0.78rem var(--font-display);
  color: rgba(236, 231, 216, 0.55);
}
