:root {
  --fg: #1a1a1a;
  --muted: #6b7280;
  --accent: #2563eb;
  --border: #e8e8e8;
  --bg: #ffffff;
  --bar: rgba(255, 255, 255, 0.85);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  font-family: var(--font);
  line-height: 1.6;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

.page-context {
  display: inline-flex;
  vertical-align: middle;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 1.25rem;
  padding: 0.3rem 0.65rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: nowrap;
}
.page-context[hidden] { display: none; }
.page-context a, .page-context span { overflow: hidden; text-overflow: ellipsis; color: inherit; }
.page-context a { text-decoration: none; }
.page-context a:hover { color: var(--fg); }
.page-context [aria-current="page"] { color: var(--fg); }
.page-context .handle-pill { color: var(--fg); font-weight: 600; }
/* Separate Message button beside the handle pill (Instagram-style). */
.page-message {
  display: inline-flex; align-items: center; gap: 0.3rem; vertical-align: middle;
  margin: 0 0 1.25rem 0.5rem; padding: 0.32rem 0.85rem;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.82rem; color: var(--fg); text-decoration: none; background: #fff;
}
.page-message:hover { border-color: var(--fg); }
.page-message span { font-size: 0.9em; }
body.presenting .page-message { display: none; }
.page-context-separator { flex: none; margin: 0 0.38rem; color: #b2b2ad !important; }

/* ---- Content typography (view + edit) ---- */
#content h1 { font-size: 2.5rem; line-height: 1.15; margin: 0 0 0.5rem; }
#content h2 { font-size: 1.4rem; margin: 2.5rem 0 0.5rem; }
#content p { margin: 0 0 1rem; }
#content .lede { font-size: 1.2rem; color: var(--muted); }
#content ul { padding-left: 1.2rem; }
#content li { margin: 0.25rem 0; }
#content a { color: var(--accent); text-decoration: none; }
#content a:hover { text-decoration: underline; }

/* ---- Hub cards ---- */
.cards { display: grid; gap: 0.75rem; margin: 1rem 0 2rem; }
.card {
  display: grid;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none !important;
  color: var(--fg) !important;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.card-kind { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.card-title { font-size: 1.05rem; font-weight: 600; color: var(--accent); }
.card-desc { font-size: 0.9rem; color: var(--muted); }

/* ---- Navigator (second-brain file tree — edit mode only) ---- */
#navigator { display: none; }
body.editing #navigator {
  display: block;
  position: fixed;
  top: 49px; left: 0; bottom: 0;       /* sits below the edit bar */
  width: 240px;
  z-index: 24;
  padding: 0.75rem;
  background: #fbfbfa;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.18s ease;
}
body.editing.nav-open #navigator { transform: translateX(0); }
@media (min-width: 1100px) {
  body.editing.nav-open main { margin-left: 240px; }
}
.nav-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 0 0.2rem 0.5rem 0.6rem;
}
#navClose { display: none; }
#navList { list-style: none; margin: 0; padding: 0; }
#navList li { margin: 0; display: flex; align-items: center; gap: 2px; }
#navList a {
  flex: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 7px;
  font-size: 0.9rem;
  color: var(--fg);
  text-decoration: none;
  min-width: 0;
}
#navList a:hover { background: #efefef; }
#navList a.current { background: #e7edff; color: var(--accent); font-weight: 500; }
.nav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge { font-size: 0.8rem; opacity: 0.8; }
/* Inline rename: the name becomes a field, matching every other edit in cercle. */
.nav-rename {
  flex: 1; min-width: 0; font: inherit; color: var(--fg);
  border: 1px solid var(--accent, #4a6cf7); border-radius: 5px;
  padding: 0.1rem 0.3rem; background: #fff;
}
a.renaming { cursor: text; }
#navList li:has(.nav-rename) .nav-actions { display: none; }

/* Row actions (duplicate / rename / delete) appear on hover, IDE-style. */
.nav-actions { display: none; flex: none; }
#navList li:hover .nav-actions { display: inline-flex; gap: 1px; }
.nav-act {
  border: 0; background: none; cursor: pointer;
  font-size: 0.78rem; line-height: 1; padding: 0.25rem 0.3rem;
  border-radius: 5px; color: var(--muted);
}
.nav-act:hover { background: #e8e8e6; color: var(--fg); }
#newPageBtn { width: 100%; margin-top: 0.5rem; text-align: left; }

/* ============================================================
   Slide deck (kind=deck)
   ============================================================ */
.kind-deck main { max-width: 900px; }
.kind-deck #content .slide {
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
}
.kind-deck #content .slide h1 { font-size: 3rem; }
.kind-deck #content .slide h2 { font-size: 2rem; margin-top: 0; }
.kind-deck #content .slide ul { text-align: left; font-size: 1.15rem; }

/* View mode: one slide at a time. */
body:not(.editing).kind-deck #content .slide { display: none; }
body:not(.editing).kind-deck #content .slide.active { display: flex; }
body.presenting { overflow: hidden; }
body.presenting main { max-width: none; padding: 0; }
body.presenting .page-context { display: none; }
body.presenting #content .slide { min-height: 100vh; width: 100vw; border-radius: 0; }
body.presenting #commentsFab { display: none; }

/* Edit mode: stack slides as cards so you can edit all of them. */
body.editing.kind-deck #content .slide {
  min-height: 40vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1rem;
}

/* Slide nav */
#deckNav { display: none; }
body:not(.editing).kind-deck #deckNav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 0.4rem 0.6rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

/* ============================================================
   Editing chrome — hidden by default, shown only under .editing.
   ============================================================ */
#editbar { display: none; }
#props { display: none; }
#mediaPanel { display: none; }
#moreBtn, .mobile-only { display: none; }
#editMore { display: contents; }

body.editing #editbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 0.6rem 1rem;
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  max-width: 100vw; overflow-x: auto; overscroll-behavior-inline: contain;
}
.brand { font-size: 0.85rem; font-weight: 600; color: var(--fg); }
#editSlug { color: var(--muted); font-weight: 400; }
.hint { font-size: 0.8rem; color: var(--muted); }
.spacer { flex: 1; }

/* Notion-style minimal buttons */
.btn {
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.5rem 0.85rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: #f7f7f8; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f2f2f3; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
.btn.primary:hover { background: #1d4ed8; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* In edit mode the content gets a soft editable frame */
body.editing:not(.kind-deck) #content {
  outline: 1px dashed var(--border);
  outline-offset: 1.25rem;
  border-radius: 6px;
}
body.editing #content:focus { outline: none; }
body.editing #content *:hover { cursor: text; }

.cc-selected {
  box-shadow: 0 0 0 2px var(--accent) !important;
  border-radius: 4px;
}

/* ---- Properties popover ---- */
body.editing #props[hidden] { display: none; }
body.editing #props {
  display: grid;
  gap: 0.6rem;
  position: fixed;
  top: 4rem;
  right: 1.5rem;
  width: 230px;
  z-index: 30;
  padding: 0.9rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
#props > .panel-head { margin-bottom: 0.1rem; }
#propsClose { padding: 0.35rem 0.5rem; }

body.editing #mediaPanel {
  display: grid; gap: 0.35rem; position: fixed; top: 4rem; right: 1.5rem;
  width: 320px; z-index: 38; padding: 0.75rem; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
body.editing #mediaPanel[hidden] { display: none; }
#mediaPanel .panel-head > .btn { min-width: 44px; min-height: 44px; }
.media-source {
  display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 0.75rem;
  min-height: 58px; padding: 0.55rem; border: 0; border-radius: 7px;
  background: transparent; color: var(--fg); text-align: left; cursor: pointer;
}
.media-source:hover { background: #f2f2f3; }
.media-source svg { width: 24px; height: 24px; margin: auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.media-source span, .media-source strong, .media-source small { display: block; }
.media-source strong { font-size: 0.88rem; }
.media-source small { margin-top: 0.1rem; color: var(--muted); font-size: 0.75rem; }
.props-row { display: flex; align-items: center; gap: 0.5rem; }
.props-row label { width: 48px; font-size: 0.78rem; color: var(--muted); }
.props-row select,
.props-row input[type="number"] {
  flex: 1;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.props-row input[type="color"] {
  width: 32px; height: 28px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; cursor: pointer;
}
.props-row .unit { font-size: 0.78rem; color: var(--muted); }
#clearColor { padding: 0.3rem 0.5rem; font-size: 0.75rem; }

.swatch-row { align-items: flex-start; }
.swatches { flex: 1; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.swatch {
  width: 20px; height: 20px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.swatch:hover { transform: scale(1.15); }

/* ---- Access gate page ---- */
body.gate { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.gate-card {
  max-width: 360px; width: 100%;
  padding: 2rem; margin: 1.5rem;
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow);
}
.gate-card h1 { font-size: 1.4rem; margin: 0 0 0.4rem; }
.gate-card .lede { font-size: 0.95rem; }
#gateForm { display: grid; gap: 0.8rem; margin-top: 1rem; }
#gateForm label { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
#gateForm input {
  font: inherit; padding: 0.55rem 0.6rem;
  border: 1px solid var(--border); border-radius: 8px;
}
.error { color: #dc2626; font-size: 0.85rem; margin: 0; }

/* ---- Share / access popover ---- */
#sharePanel { display: none; }
body.editing #sharePanel {
  display: block;
  position: fixed; top: 4rem; right: 1.5rem; width: min(390px, calc(100vw - 2rem)); z-index: 35;
  max-height: calc(100vh - 5.5rem); overflow-y: auto;
  padding: 1rem; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
body.editing #sharePanel[hidden] { display: none; }
#sharePanel h3 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.share-head, .circle-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.share-head h3 { margin: 0; }
.share-toggle { display: flex; align-items: center; gap: 0.55rem; margin: 0.9rem 0; font-size: 0.86rem; }
.share-status { font-size: 0.82rem; color: var(--muted); margin: 0 0 0.8rem; }
.share-row { display: grid; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.7rem; }
.share-row input, .share-row textarea {
  font: inherit; font-size: 0.85rem; padding: 0.45rem 0.5rem;
  border: 1px solid var(--border); border-radius: 7px; resize: vertical;
}
.share-note { font-size: 0.72rem; color: var(--muted); margin: 0 0 0.8rem; }
.share-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.circle-section { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.circle-heading span { color: var(--muted); font-size: 0.72rem; }
.circle-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; align-items: center; gap: 0.35rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.circle-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.86rem; }
.circle-identity { display: grid; min-width: 0; }
.circle-detail { color: var(--muted); font-size: 0.72rem; }
.circle-row .btn { padding: 0.35rem 0.45rem; font-size: 0.75rem; }
.circle-new { display: grid; grid-template-columns: 1fr auto; gap: 0.45rem; margin-top: 0.8rem; }
.circle-new input { min-width: 0; padding: 0.5rem; border: 1px solid var(--border); border-radius: 7px; font: inherit; }
.share-advanced { margin-top: 1rem; color: var(--muted); font-size: 0.82rem; }
.share-advanced summary { cursor: pointer; margin-bottom: 0.7rem; }
#circleForm fieldset { border: 0; padding: 0; margin: 0.9rem 0; }
#circleForm legend { margin-bottom: 0.5rem; font-size: 0.82rem; color: var(--muted); }
#circlePaths { display: grid; gap: 0.3rem; max-height: 45vh; overflow-y: auto; }
#circlePaths label { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem; border: 1px solid var(--border); border-radius: 6px; }
#sharedPaths { margin: 4rem 0 1rem; padding-top: 2rem; border-top: 1px solid var(--border); }
#sharedPaths h2 { margin-top: 0; }
.shared-circle { margin-top: 1.5rem; }
.shared-circle h3 { font-size: 0.85rem; color: var(--muted); }
.shared-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.65rem; }
.shared-links a { display: grid; gap: 0.2rem; padding: 0.8rem; color: inherit; text-decoration: none; border: 1px solid var(--border); border-radius: 7px; }
.shared-links a:hover { border-color: var(--fg); }
.shared-links span { color: var(--muted); font-size: 0.78rem; }

/* ---- Comments (view: floating 💬; edit: edit-bar button; one panel) ---- */
#commentsFab {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 30;
  font: inherit; font-size: 0.9rem; line-height: 1;
  padding: 0.6rem 0.7rem; border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--muted);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
#commentsFab:hover { color: var(--fg); border-color: var(--accent); }
body.editing #commentsFab { display: none; }

#commentsPanel {
  position: fixed; right: 1.25rem; bottom: 4.25rem; width: 300px; z-index: 36;
  max-height: 70vh; overflow-y: auto;
  padding: 1rem; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
body.editing #commentsPanel { top: 4rem; bottom: auto; right: 1.5rem; }
#commentsPanel[hidden] { display: none; }
#commentsPanel h3 { margin: 0 0 0.6rem; font-size: 0.95rem; }
#commentList { list-style: none; margin: 0 0 0.8rem; padding: 0; display: grid; gap: 0.6rem; }
.comment {
  font-size: 0.85rem; padding: 0.55rem 0.65rem;
  background: #fafaf8; border: 1px solid var(--border); border-radius: 8px;
}
.comment-head { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.2rem; }
.comment-anchor { border: 0; padding: 0; background: none; color: var(--accent); cursor: pointer; font-size: 0.72rem; }
.comment.resolved { opacity: 0.55; }
.comment.resolved::after { content: "Resolved"; font-size: 0.7rem; color: var(--muted); }
.comment.empty { color: var(--muted); border-style: dashed; }
.comment-resolve { margin-top: 0.4rem; font-size: 0.75rem; padding: 0.2rem 0.5rem; }

/* ---- Responsive device preview (edit mode, only when toggled on) ---- */
#deviceBar { display: none; }
body.editing #deviceBar:not([hidden]) {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  position: sticky;
  top: 49px; /* sits under #editbar */
  z-index: 18;
  padding: 0.4rem;
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
#deviceBar button {
  font: inherit; font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
#deviceBar button:hover { background: #efefef; }
#deviceBar button.active { background: #fff; border-color: var(--border); color: var(--fg); }
.btn.on { background: #e7edff; color: var(--accent); }

#newItemDialog {
  width: min(440px, calc(100vw - 2rem)); padding: 0;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
#newItemDialog::backdrop { background: rgba(0, 0, 0, 0.28); }
#newItemForm { display: grid; gap: 0.85rem; padding: 1rem; }
#newItemForm label { display: grid; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }
#newItemForm input, #newItemForm textarea, #newItemForm select {
  width: 100%; padding: 0.55rem 0.6rem; font: inherit; color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.dialog-head, .dialog-actions { display: flex; align-items: center; gap: 0.5rem; }
.dialog-head { justify-content: space-between; }
.dialog-actions { justify-content: flex-end; }
.dialog-error { min-height: 1.2em; margin: 0; color: #dc2626; font-size: 0.8rem; }

#preview { display: none; }
body.previewing #content,
body.previewing #props,
body.previewing #sharePanel { display: none !important; }
body.previewing #preview {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0;
}
#previewFrame {
  border: 1px solid #d4d4d4;
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: #fff;
  max-width: 100%;
}

/* ============================================================
   Curated blocks. Used by templates; reusable on any page.
   ============================================================ */
.kicker { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6rem; }
/* Date chip (Google-Docs style): a small bubble; inert for visitors, with a
   calendar picker in edit mode. */
.cc-date {
  display: inline-flex; align-items: center; gap: 0.35rem; margin: 0 0 1rem;
  padding: 0.25rem 0.6rem; border-radius: 999px; background: #eef1f6;
  color: #41464f; font-size: 0.82rem; line-height: 1.2;
}
.cc-date::before { content: "\1F4C5"; font-size: 0.85em; }
body.editing .cc-date { cursor: pointer; }
body.editing .cc-date:hover { background: #e3e8f2; }
/* Calendar popover (edit mode only) */
#dateCal {
  position: absolute; z-index: 40; width: 260px; padding: 0.7rem;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  font-size: 0.85rem;
}
#dateCal[hidden] { display: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.cal-head button { border: 0; background: none; cursor: pointer; font-size: 1rem; padding: 0.2rem 0.5rem; border-radius: 6px; }
.cal-head button:hover { background: #f0f0ee; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-grid span { text-align: center; color: var(--muted); font-size: 0.7rem; padding: 0.2rem 0; }
.cal-grid button { border: 0; background: none; cursor: pointer; padding: 0.35rem 0; border-radius: 6px; font: inherit; }
.cal-grid button:hover { background: #eef1f6; }
.cal-grid button.today { font-weight: 700; color: var(--accent); }
.cal-grid button.chosen { background: var(--accent); color: #fff; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.4rem; text-align: left; width: 100%; }
.cols h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.cols p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.stats { display: flex; gap: 3rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0; }
.stat { text-align: center; }
.stat .n { display: block; font-size: 2.8rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.stat .l { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
blockquote.pull { margin: 0; border: 0; padding: 0; font-family: Georgia, serif; font-style: italic; font-size: 1.7rem; line-height: 1.35; max-width: 26ch; }
blockquote.pull footer { margin-top: 1rem; font-family: system-ui, sans-serif; font-style: normal; font-size: 0.85rem; color: var(--muted); }
.schedule { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.6rem; text-align: left; }
.schedule li { display: flex; align-items: baseline; gap: 1.2rem; padding: 0.75rem 1.1rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.schedule time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4.2rem; font-size: 0.9rem; }
.collection-carousel {
  position: relative;
  width: 100%;
  margin: 2rem 0 3rem;
}
.collection-track {
  display: flex; gap: 1rem;
  overflow-x: auto; overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
  scrollbar-width: none;
  padding: 0.25rem max(0.25rem, calc((100% - 900px) / 2)) 1rem;
}
.collection-track::-webkit-scrollbar { display: none; }
.collection-list { margin: 2rem 0 3rem; }
.collection-list .collection-track { display: grid; gap: 0; padding: 0; overflow: visible; }
.collection-list .collection-card {
  width: 100%; padding: 1rem 0; border: 0; border-bottom: 1px solid var(--border);
  border-radius: 0; grid-template-columns: minmax(9rem, 0.7fr) minmax(0, 1.3fr);
  grid-template-rows: auto; align-items: baseline;
}
.collection-list .collection-card img { display: none; }
.collection-list .collection-card:hover { transform: none; border-color: var(--fg); }
.collection-card, .item-card {
  position: relative;
  flex: 0 0 clamp(260px, 36vw, 390px);
  display: grid; grid-template-rows: auto auto 1fr; gap: 0.5rem; align-content: start;
  scroll-snap-align: start;
  padding: 0.55rem; border: 1px solid var(--border); border-radius: 8px;
  color: inherit !important; text-decoration: none !important; background: #fff;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.collection-card:hover, .item-card:hover { border-color: var(--fg); transform: translateY(-2px); }
.collection-card img, .item-card img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px;
}
.item-title { font-weight: 600; }
.item-summary { color: var(--muted); font-size: 0.9rem; }
.item-date { color: var(--muted); font-size: 0.75rem; }
.collection-controls {
  display: flex; justify-content: flex-end; gap: 0.4rem;
  max-width: 800px; margin: 0 auto; padding: 0 0.25rem;
}
.collection-controls button {
  width: 2.25rem; height: 2.25rem;
  border: 1px solid var(--border); border-radius: 50%;
  background: #fff; color: var(--fg); cursor: pointer; font: inherit;
}
.collection-controls button:hover { border-color: var(--fg); }
.card-tools { position: absolute; top: 0.8rem; right: 0.8rem; display: flex; gap: 2px; padding: 2px; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.card-tools span { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 4px; cursor: pointer; }
.card-tools span:hover { background: #efefef; }
.item-gallery {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(78vw, 560px);
  gap: 0.75rem; overflow-x: auto; scroll-snap-type: inline mandatory;
  width: min(1080px, calc(100vw - 2rem));
  margin: 1.5rem 0 2rem 50%;
  transform: translateX(-50%);
  scrollbar-width: none;
}
.item-gallery::-webkit-scrollbar { display: none; }
.item-gallery img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  scroll-snap-align: center; border-radius: 6px;
}
.media-wide { margin: 2rem 0; }
.media-wide img { display: block; width: 100%; max-height: 72vh; object-fit: cover; border-radius: 6px; }
.media-grid {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 0.75rem;
  width: min(1000px, calc(100vw - 2rem)); min-height: 10rem;
  margin: 2rem 0 3rem 50%; transform: translateX(-50%);
}
.media-grid > figure { position: relative; min-width: 0; margin: 0; }
.media-grid > figure:nth-child(6n + 1), .media-grid > figure:nth-child(6n + 4) { grid-column: span 7; }
.media-grid > figure:nth-child(6n + 2), .media-grid > figure:nth-child(6n + 3) { grid-column: span 5; }
.media-grid > figure:nth-child(6n + 5), .media-grid > figure:nth-child(6n + 6) { grid-column: span 6; }
.media-grid img { display: block; width: 100%; height: 100%; min-height: 220px; object-fit: cover; border-radius: 6px; }
.media-grid figcaption { margin-top: 0.4rem; color: var(--muted); font-size: 0.78rem; }
.photo-carousel {
  width: 100%; margin: 2rem 0 3rem;
}
.photo-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(76vw, 620px);
  gap: 0.75rem; overflow-x: auto; scroll-snap-type: inline mandatory;
  scrollbar-width: none; padding-bottom: 0.75rem;
}
.photo-track::-webkit-scrollbar { display: none; }
.photo-track:empty, .media-grid:empty { min-height: 220px; border: 1px dashed var(--border); border-radius: 8px; }
body.editing .photo-track:empty::after, body.editing .media-grid:empty::after {
  content: "Add photos"; display: grid; place-items: center; min-width: min(82vw, 620px);
  color: var(--muted); font-size: 0.9rem; cursor: pointer;
}
.photo-track figure { margin: 0; scroll-snap-align: center; }
.photo-track img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; }
.photo-track figcaption { margin-top: 0.45rem; color: var(--muted); font-size: 0.82rem; }
.photo-controls { display: flex; justify-content: flex-end; gap: 0.4rem; }
.photo-controls button {
  width: 2.25rem; height: 2.25rem; border: 1px solid var(--border); border-radius: 50%;
  background: #fff; color: var(--fg); cursor: pointer; font: inherit;
}
body.editing .media-grid > figure, body.editing .photo-track > figure { position: relative; cursor: grab; }
.media-order { position: absolute; top: 0.5rem; right: 0.5rem; display: flex; gap: 0.25rem; z-index: 2; }
.media-order button {
  width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid rgba(20,20,23,.16);
  border-radius: 50%; background: rgba(255,255,255,.94); color: var(--fg); box-shadow: var(--shadow); cursor: pointer;
}
.video-embed { width: min(900px, 100%); margin: 2rem auto 3rem; }
.video-embed video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #111; border-radius: 6px; }
.video-embed figcaption { margin-top: 0.5rem; color: var(--muted); font-size: 0.82rem; }
.feature {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(280px, 1.1fr);
  gap: clamp(1.5rem, 5vw, 4rem); align-items: center;
  width: 100%;
  margin: 3rem 0 4rem;
}
.feature-copy h2 { margin-top: 0.25rem !important; font-size: clamp(1.6rem, 3vw, 2.4rem) !important; }
.feature-media { min-height: 320px; margin: 0; background: #f4f4f2; border-radius: 6px; overflow: hidden; }
.feature-media img { display: block; width: 100%; height: 100%; min-height: 320px; object-fit: cover; }
.callout {
  padding: clamp(1.5rem, 5vw, 3rem); margin: 3rem 0;
  border: 1px solid var(--fg); border-radius: 8px; background: #f7f7f4;
}
.callout h2 { margin-top: 0.25rem !important; font-size: clamp(1.5rem, 3vw, 2.2rem) !important; }
.callout p:last-child { margin-bottom: 0 !important; }
.testimonial { margin: 3rem 0; padding-left: 1.5rem; border-left: 3px solid var(--fg); }
.testimonial blockquote {
  margin: 0 0 1rem; font-family: Georgia, serif; font-size: clamp(1.4rem, 3vw, 2rem);
  font-style: normal; line-height: 1.35;
}
.testimonial figcaption { color: var(--muted); font-size: 0.85rem; }
.case-study { margin: 3rem 0; padding: 2rem; border: 1px solid var(--border); border-radius: 8px; }
.rsvp, .event-rsvp { margin: 3rem 0; padding: clamp(1.5rem, 5vw, 3rem); background: #f7f7f4; border-radius: 8px; }
.event-title { margin: 0.2rem 0 1rem; }
.event-facts { display: grid; gap: 0.5rem; margin: 0 0 1.25rem; }
.event-facts > div { display: grid; grid-template-columns: 5rem 1fr; gap: 0.6rem; align-items: baseline; }
.event-facts dt { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.event-facts dd { margin: 0; }
.event-facts .cc-date { margin: 0; }
.rsvp-actions { display: grid; gap: 0.7rem; }
.rsvp-name { font: inherit; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; max-width: 16rem; }
.rsvp-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.rsvp-btn { padding: 0.5rem 0.9rem; font: inherit; cursor: pointer; border: 1px solid var(--border); border-radius: 999px; background: #fff; }
.rsvp-btn:hover { border-color: var(--fg); }
.rsvp-btn.chosen { background: var(--fg); color: #fff; border-color: var(--fg); }
.rsvp-you { margin: 0; color: var(--muted); font-size: 0.85rem; }
.rsvp-guests { margin: 0.2rem 0 0; color: #55555c; font-size: 0.88rem; }
.rsvp-hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
body.editing .rsvp-actions::after { content: "Guests will RSVP here once you save."; color: var(--muted); font-size: 0.85rem; }
body.editing .media-grid:empty, body.editing .feature-media:empty, body.editing .video-embed:empty {
  outline: 1px dashed #a3a3a3; outline-offset: -1px;
}
@media (max-width: 600px) {
  body.editing #editbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.2rem;
    padding: 0.35rem; overflow: visible; backdrop-filter: none;
  }
  body.editing #editbar .brand, body.editing #editbar .hint, body.editing #editbar .spacer { display: none; }
  body.editing #editbar > .btn { min-width: 0; min-height: 44px; padding: 0.45rem 0.2rem; font-size: 0.78rem; }
  body.editing #moreBtn, .mobile-only { display: flex; }
  body.editing #editMore {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem;
    position: fixed; inset: auto 0 0; z-index: 40; width: 100%; max-height: 78vh;
    padding: 0.75rem max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    overflow-y: auto; background: #fff; border: 1px solid var(--border);
    border-radius: 8px 8px 0 0; box-shadow: var(--shadow);
  }
  body.editing:not(.mobile-more-open) #editMore { display: none; }
  #editMore .panel-head { grid-column: 1 / -1; min-height: 44px; }
  #editMore .panel-head > .btn { min-width: 44px; min-height: 44px; }
  #editMore > .btn { display: flex; align-items: center; justify-content: center; min-height: 48px; }
  #editMore > [hidden] { display: none; }
  body.editing.nav-open, body.editing.mobile-more-open { overflow: hidden; }
  body.editing #navigator {
    inset: 0; width: 100%; z-index: 41; padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
    border: 0; transform: translateX(-100%); background: #fbfbfa;
  }
  body.editing.nav-open #navigator { transform: translateX(0); }
  #navClose { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
  .nav-head { min-height: 44px; padding-bottom: 0.5rem; }
  #navList a { min-height: 48px; padding-block: 0.65rem; }
  #navList li .nav-actions { display: inline-flex; gap: 1px; }
  .nav-act { min-width: 44px; min-height: 44px; }
  #newPageBtn { min-height: 48px; }
  body.editing #props,
  body.editing #sharePanel,
  body.editing #mediaPanel,
  body.editing #commentsPanel {
    inset: auto 0 0; width: 100%; max-height: 82vh; overflow-y: auto;
    padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    border-radius: 8px 8px 0 0; z-index: 39;
  }
  body.editing #props { grid-template-columns: 1fr; }
  #props .btn, #sharePanel .btn, #agentPanel .btn, #commentsPanel .btn { min-height: 44px; }
  .props-row { min-height: 44px; }
  .props-row select, .props-row input[type="number"] { min-height: 44px; }
  .props-row input[type="color"] { width: 44px; height: 44px; }
  .swatch { width: 32px; height: 32px; }
  body.editing #deviceBar:not([hidden]) { justify-content: flex-start; overflow-x: auto; }
  #deviceBar button { flex: none; min-height: 44px; }
  .collection-card, .item-card { flex-basis: 82vw; }
  .collection-controls { padding-inline: 0.25rem; }
  .item-gallery { grid-auto-columns: 86vw; }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .media-grid > figure { grid-column: span 1 !important; }
  .media-grid > figure:nth-child(3n + 1) { grid-column: 1 / -1 !important; }
  .media-grid img { min-height: 150px; }
  .feature { grid-template-columns: 1fr; }
  .feature-media { min-height: 240px; }
  .collection-list .collection-card { grid-template-columns: 1fr; gap: 0.25rem; }
  .rsvp-form { grid-template-columns: 1fr; }
}

/* Slide variants: a serif cover and an inverted statement slide. */
.kind-deck #content .slide.cover h1 { font-family: Georgia, serif; font-weight: 400; font-size: 3.6rem; letter-spacing: -0.02em; }
.kind-deck #content .slide.invert { background: var(--fg); color: var(--bg); border-radius: 16px; }
.kind-deck #content .slide.invert .kicker { color: rgba(255,255,255,0.55); }
.kind-deck #content .slide .kicker { align-self: center; }

/* ---- Block tools (edit mode) ---- */
#blockBar { display: none; }
body.editing #blockBar:not([hidden]) {
  display: flex; flex-direction: column; gap: 1px;
  position: absolute; z-index: 26;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 2px;
}
#blockBar button {
  border: 0; background: none; cursor: pointer; border-radius: 6px;
  font-size: 0.8rem; line-height: 1; padding: 0.3rem; color: var(--muted);
}
#blockBar [data-act="style"] { display: none; }
#blockBar button:hover { background: #f2f2f3; color: var(--fg); }
#blockPalette { display: none; }
body.editing #blockPalette:not([hidden]) {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px;
  position: absolute; z-index: 27; width: 220px; padding: 4px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
}
#blockPalette button {
  border: 0; background: none; cursor: pointer; border-radius: 6px;
  font: inherit; padding: 0.55rem 0.6rem; text-align: left;
}
#blockPalette button strong, #blockPalette button span { display: block; }
#blockPalette button strong { font-size: 0.82rem; }
#blockPalette button span { margin-top: 0.1rem; color: var(--muted); font-size: 0.7rem; line-height: 1.25; }
#blockPalette button:hover { background: #eef0fd; color: var(--accent); }
@media (max-width: 600px) {
  body.editing #blockBar:not([hidden]) {
    position: fixed; top: auto !important; left: 50% !important; bottom: 0.75rem;
    transform: translateX(-50%); flex-direction: row; padding: 4px;
  }
  body.editing #blockBar button { width: 2.4rem; height: 2.4rem; font-size: 1rem; }
  body.editing #blockBar [data-act="style"] { display: block; font-size: 0.75rem; font-weight: 600; }
  body.editing #blockPalette:not([hidden]) {
    position: fixed; top: auto !important; left: 0.75rem !important; right: 0.75rem;
    bottom: 4rem; width: auto; max-height: 45vh; overflow-y: auto;
  }
}

/* Optional-field affordance + dialog hints (circles, signup) */
.opt { font-size: 0.72rem; font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; }
.dialog-hint { display: block; margin-top: 0.3rem; font-size: 0.74rem; color: var(--muted); line-height: 1.4; }
#circleMembers { width: 100%; font: inherit; font-size: 0.85rem; padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 7px; resize: vertical; }
.circle-member-preview { display: flex; flex-wrap: wrap; gap: 0.3rem; min-height: 0.25rem; }
.circle-member-preview span { padding: 0.25rem 0.45rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.75rem; }

/* Product people surface, separate from people's page styles. */
.people-page { margin: 0; background: #fcfcfa; color: #141417; font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
.people-head { height: 56px; padding: 0 1.25rem; border-bottom: 1px solid #deded9; display: flex; align-items: center; justify-content: space-between; font-size: 0.82rem; }
.people-brand { color: inherit; font-weight: 650; text-decoration: none; }
.people-main { width: min(1080px, calc(100% - 2.5rem)); max-width: none; margin: 0 auto; padding: 4rem 0 6rem; }
.people-intro { max-width: 680px; margin-bottom: 4rem; }
.people-intro h1 { margin: 0.3rem 0 2rem; font-family: Georgia, serif; font-size: 5.2rem; font-weight: 400; line-height: 0.98; }
#peopleSearch label { display: block; margin-bottom: 0.45rem; color: #68686f; font-size: 0.78rem; }
.people-search-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }
.people-search-row input { min-width: 0; height: 48px; padding: 0 0.8rem; border: 1px solid #cfcfca; border-radius: 6px; background: #fff; font: inherit; }
.people-section-head { margin: 2.5rem 0 0.8rem; display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid #deded9; }
.people-section-head h2 { margin: 0 0 0.6rem; font-family: Georgia, serif; font-size: 1.6rem; font-weight: 400; }
.people-section-head span { color: #77777f; font-size: 0.8rem; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.75rem; }
.person-card { min-width: 0; border: 1px solid #deded9; border-radius: 7px; background: #fff; overflow: hidden; }
.person-link { display: grid; gap: 0.9rem; min-height: 150px; padding: 1rem; color: inherit; text-decoration: none; }
.person-link:hover strong { color: #3a4bd8; }
.person-identity { display: flex; align-items: center; gap: 0.65rem; }
.person-identity > span:last-child { display: grid; min-width: 0; }
.person-identity strong, .person-identity small { overflow: hidden; text-overflow: ellipsis; }
.person-identity small, .person-meta { color: #77777f; font-size: 0.75rem; }
.person-mark { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: #f0cd4e; font-family: Georgia, serif; font-size: 1.25rem; }
.person-mark.has-photo { overflow: hidden; background: #ecece8; }
.person-mark img { width: 100%; height: 100%; object-fit: cover; }
.me-strip { display: flex; align-items: center; gap: 0.75rem; margin: 0 0 2rem; padding: 0.75rem 0; border-bottom: 1px solid #deded9; }
.me-label { display: grid; flex: 1; min-width: 0; }
.me-label small { color: #77777f; font-size: 0.75rem; }
.person-link p { margin: 0; color: #55555c; font-size: 0.88rem; line-height: 1.5; }
.person-meta { align-self: end; }
.people-link { color: inherit; text-decoration: none; }
.person-foot { padding: 0 1rem 1rem; }
.follow-btn { padding: 0.35rem 0.9rem; font-size: 0.82rem; border-radius: 999px; }
.follow-btn.is-following { background: #f2f2f3; color: var(--fg); }

/* Home feed */
.feed-lede { color: #55555c; font-size: 0.95rem; margin: 0; }
.feed-list { display: grid; gap: 0.75rem; max-width: 680px; }
.feed-card { display: grid; gap: 0.7rem; padding: 1rem; border: 1px solid #deded9; border-radius: 9px; background: #fff; color: inherit; text-decoration: none; }
.feed-card:hover { border-color: #c7c7c2; }
.feed-card:hover strong { color: #3a4bd8; }
.feed-top { display: flex; align-items: center; gap: 0.65rem; }
.feed-top > span:last-child { display: grid; min-width: 0; }
.feed-top strong, .feed-top small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-top small { color: #77777f; font-size: 0.75rem; }
.feed-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.feed-tag { font-size: 0.74rem; padding: 0.18rem 0.55rem; border-radius: 999px; background: #f0eee8; color: #55555c; }
.feed-tag.via-follow { background: #eaf0ff; color: #3a4bd8; }
.feed-time { color: #9a9aa0; font-size: 0.74rem; }

/* Messages (Phase 1) */
.msg-main { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 2rem; }
.msg-shell { display: grid; grid-template-columns: 320px 1fr; gap: 0; height: calc(100vh - 56px - 3.5rem); border: 1px solid #deded9; border-radius: 10px; overflow: hidden; background: #fff; }
.msg-inbox { border-right: 1px solid #ededea; overflow-y: auto; }
.msg-inbox-empty { padding: 1rem; color: #9a9aa0; font-size: 0.9rem; }
.msg-inbox-row { display: flex; gap: 0.6rem; align-items: center; width: 100%; padding: 0.8rem; border: 0; border-bottom: 1px solid #f1f1ee; background: none; text-align: left; cursor: pointer; }
.msg-inbox-row:hover { background: #f7f7f5; }
.msg-inbox-row.active { background: #eef1f6; }
.msg-inbox-body { display: grid; min-width: 0; flex: 1; }
.msg-inbox-body strong { font-size: 0.9rem; }
.msg-inbox-body small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #77777f; font-size: 0.8rem; }
.msg-inbox-row.unread .msg-inbox-body strong { font-weight: 700; }
.msg-inbox-meta { display: grid; justify-items: end; gap: 0.2rem; color: #9a9aa0; font-size: 0.7rem; }
.msg-badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 0.4rem; font-size: 0.7rem; }
.msg-thread { display: flex; flex-direction: column; min-width: 0; }
.msg-thread-head { display: flex; gap: 0.6rem; align-items: center; padding: 0.7rem 1rem; border-bottom: 1px solid #ededea; }
.msg-head-who { display: grid; color: inherit; text-decoration: none; }
.msg-head-who small { color: #77777f; font-size: 0.75rem; }
.msg-back { display: none; border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 0.3rem; }
.msg-list { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.msg-bubble { max-width: 72%; padding: 0.5rem 0.8rem; border-radius: 14px; font-size: 0.92rem; line-height: 1.35; overflow-wrap: anywhere; }
.msg-bubble.theirs { align-self: flex-start; background: #f0eee8; }
.msg-bubble.mine { align-self: flex-end; background: var(--accent); color: #fff; }
.msg-empty { margin: auto; color: #9a9aa0; padding: 2rem; text-align: center; max-width: 30ch; }
.msg-compose { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid #ededea; }
.msg-compose input { flex: 1; min-width: 0; height: 42px; padding: 0 0.9rem; border: 1px solid #cfcfca; border-radius: 999px; font: inherit; }
.msg-note { margin: 0; padding: 0 1rem 0.6rem; color: #9a9aa0; font-size: 0.72rem; }
@media (max-width: 720px) {
  .msg-shell { grid-template-columns: 1fr; }
  .msg-thread { display: none; }
  .msg-back { display: block; }
  body.msg-open .msg-inbox { display: none; }
  body.msg-open .msg-thread { display: flex; }
}

/* Block comments (Google-Docs-style mode: no button, hover a block to comment) */
#content > [data-id].has-comments { box-shadow: inset 3px 0 0 -1px #f0cd4e; }
.block-comment-tab {
  position: absolute; z-index: 33; border: 1px solid var(--border); background: #fff;
  border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.8rem; line-height: 1.4;
  cursor: pointer; box-shadow: var(--shadow);
}
.block-comment-tab.has { border-color: #e3c43e; }
.block-comment-pop {
  position: absolute; z-index: 34; width: min(300px, calc(100vw - 2rem));
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 0.8rem; display: grid; gap: 0.6rem;
}
/* display:grid above overrides the [hidden] attribute, so restore it. */
.block-comment-pop[hidden], .block-comment-tab[hidden] { display: none; }
.bc-list { display: grid; gap: 0.5rem; max-height: 240px; overflow-y: auto; }
.bc-empty { margin: 0; color: var(--muted); font-size: 0.85rem; }
.bc-item { border-bottom: 1px solid #f1f1ee; padding-bottom: 0.4rem; }
.bc-head { color: var(--muted); font-size: 0.72rem; }
.bc-body { font-size: 0.9rem; }
.bc-form { display: grid; gap: 0.4rem; }
.bc-author, .bc-text { font: inherit; padding: 0.4rem; border: 1px solid var(--border); border-radius: 8px; }
.bc-text { resize: vertical; }
@media (max-width: 600px) {
  .block-comment-pop { position: fixed; inset: auto 0 0; width: 100%; border-radius: 12px 12px 0 0; }
  .block-comment-tab { left: auto !important; right: 0.5rem; }
}

/* Founder dashboard */
.dash-token { max-width: 520px; margin-bottom: 2.5rem; }
.dash-token label { display: block; margin-bottom: 0.45rem; color: #68686f; font-size: 0.78rem; }
.dash-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.dash-card { display: grid; gap: 0.3rem; padding: 1.1rem; border: 1px solid #deded9; border-radius: 9px; background: #fff; }
.dash-value { font-family: Georgia, serif; font-size: 2.1rem; line-height: 1; }
.dash-label { color: #77777f; font-size: 0.78rem; }
.dash-events { display: grid; gap: 0.2rem; max-width: 520px; }
.dash-event { display: flex; justify-content: space-between; padding: 0.5rem 0.3rem; border-bottom: 1px solid #ededea; font-size: 0.9rem; }
.dash-event span { color: #55555c; }
.person-pages { border-top: 1px solid #deded9; display: grid; }
.person-pages a { padding: 0.65rem 1rem; color: inherit; text-decoration: none; font-size: 0.78rem; border-bottom: 1px solid #eeeeea; }
.person-pages a:last-child { border-bottom: 0; }
.person-pages a:hover { color: #3a4bd8; }
.people-empty { color: #77777f; font-size: 0.85rem; }

/* Curated template catalog */
.templates-main { width: min(1180px, calc(100% - 2.5rem)); max-width: none; margin: 0 auto; padding: 4rem 0 6rem; }
.templates-intro { max-width: 680px; margin-bottom: 2.5rem; }
.templates-intro h1 { margin: 0.25rem 0 1rem; font-family: Georgia, serif; font-size: 5.2rem; font-weight: 400; line-height: 0.98; }
.templates-intro > p:last-child { max-width: 52ch; color: #68686f; }
.template-filters { display: flex; gap: 0.35rem; margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.template-filter { flex: none; padding: 0.4rem 0.8rem; border: 1px solid #deded9; border-radius: 999px; background: transparent; color: #68686f; font: inherit; font-size: 0.78rem; cursor: pointer; }
.template-filter.active { border-color: #141417; background: #141417; color: #fff; }
.templates-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.template-card { min-width: 0; overflow: hidden; border: 1px solid #deded9; border-radius: 8px; background: #fff; }
.template-preview { display: block; height: 360px; overflow: hidden; border-bottom: 1px solid #deded9; background: #f3f3ef; }
.template-preview iframe { width: 200%; height: 720px; border: 0; transform: scale(.5); transform-origin: top left; pointer-events: none; }
.template-copy { padding: 1rem; }
.template-kind { color: #8a8a91; font-size: 0.68rem; text-transform: uppercase; }
.template-copy h2 { margin: 0.25rem 0 0.4rem; font-family: Georgia, serif; font-size: 1.55rem; font-weight: 400; }
.template-copy p { min-height: 3em; margin: 0; color: #68686f; font-size: 0.86rem; line-height: 1.5; }
.template-actions { display: flex; gap: 0.45rem; margin-top: 1rem; }
.template-actions .btn { margin: 0; padding: 0.5rem 0.9rem; }
.template-use-dialog { width: min(440px, calc(100% - 2rem)); }
.template-path { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 7px; }
.template-path span { flex: none; padding-left: 0.6rem; color: var(--muted); font-size: 0.85rem; }
.template-path input { min-width: 0; border: 0 !important; }
.new-page-dialog { width: min(620px, calc(100% - 2rem)); }
.new-page-templates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; max-height: 45vh; overflow-y: auto; }
.new-page-template { display: flex !important; align-items: center; gap: 0.55rem; padding: 0.65rem; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; }
.new-page-template:has(input:checked) { border-color: var(--accent); background: #f3f5ff; }
.new-page-template span { display: grid; }
.new-page-template small { color: var(--muted); font-size: 0.7rem; }

@media (max-width: 600px) {
  .people-main { width: calc(100% - 2rem); padding: 2.5rem 0 5rem; }
  .people-intro { margin-bottom: 2.5rem; }
  .people-intro h1 { font-size: 2.6rem; }
  .people-search-row { grid-template-columns: 1fr; }
  .people-search-row .btn { height: 48px; }
  .people-grid { grid-template-columns: 1fr; }
  .templates-main { width: calc(100% - 2rem); padding: 2.5rem 0 5rem; }
  .templates-intro h1 { font-size: 2.8rem; }
  .templates-grid { grid-template-columns: 1fr; }
  .template-preview { height: 280px; }
  .template-preview iframe { height: 560px; }
  .new-page-templates { grid-template-columns: 1fr; }
  .template-actions .btn { min-height: 44px; display: inline-flex; align-items: center; }
  .circle-row { grid-template-columns: auto minmax(0,1fr) auto; }
  .circle-row > button:last-child { grid-column: 2 / -1; justify-self: start; }
}

/* Owner pen (view mode): one tap to edit, no menu in the way */
#ownerPill {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 31;
  width: 2.9rem; height: 2.9rem; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; text-decoration: none;
  font-size: 1.1rem; line-height: 1; border: 1px solid var(--border);
  background: var(--fg); color: #fff; box-shadow: var(--shadow);
}
#ownerPill[hidden] { display: none; }
body:not(.editing) #commentsFab { bottom: 4.6rem; }   /* stack above the pen */

/* Share control (view mode): the cercle mark, top-right, Google-Docs style */
#shareFab {
  position: fixed; right: 1.25rem; top: 1rem; z-index: 31;
  width: 2.6rem; height: 2.6rem; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; color: var(--fg);
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow);
}
#shareFab[hidden] { display: none; }
#sharePop {
  position: fixed; right: 1.25rem; top: 4rem; z-index: 32; width: min(340px, calc(100vw - 2rem));
  display: grid; gap: 0.6rem; padding: 1rem;
  background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
#sharePop[hidden] { display: none; }
#sharePop .share-head { display: flex; align-items: center; justify-content: space-between; }
#sharePop h3 { margin: 0; font-size: 1rem; }
#shareVisibility { font: inherit; padding: 0.4rem; border: 1px solid var(--border); border-radius: 8px; }
#shareCircles { display: grid; gap: 0.2rem; }
.share-row.check { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.3rem; border-radius: 8px; cursor: pointer; }
.share-row.check:hover { background: #f6f6f5; }
.share-row.check input { flex: none; }
.share-row.check .share-count { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.share-foot { display: grid; border-top: 1px solid var(--border); padding-top: 0.4rem; }
.owner-action { padding: 0.6rem 0.4rem; border-radius: 8px; color: var(--fg); text-decoration: none; font-size: 0.92rem; }
.owner-action:hover { background: #f2f2f3; }

/* Agentic edit panel (edit mode popover) */
#agentPanel { display: none; }
body.editing #agentPanel {
  display: block; position: fixed; top: 4rem; right: 1.5rem; width: 320px; z-index: 36;
  padding: 1rem; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
body.editing #agentPanel[hidden] { display: none; }
#agentPanel h3 { margin: 0; font-size: 0.95rem; }
#agentPrompt { width: 100%; font: inherit; font-size: 0.9rem; padding: 0.5rem; margin: 0.6rem 0;
  border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
@media (max-width: 600px) {
  body.editing #agentPanel {
    inset: auto 0 0; width: 100%; max-height: 82vh; overflow-y: auto;
    padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    border-radius: 8px 8px 0 0; z-index: 39;
  }
}
