/* ── tokens ────────────────────────────────────────────────── */
:root {
  --bg:      #ffffff;
  --surface: #fafafa;
  --border:  #e7e7e9;
  --text:    #0f0f10;
  --meta:    #5e5e63;
  --muted:   #9a9aa1;
  --accent:  #1f1f23;

  --pill-draft-bg:    #f3f4f6; --pill-draft-fg:    #4b5563;
  --pill-review-bg:   #fef3c7; --pill-review-fg:   #92400e;
  --pill-changes-bg:  #fee2e2; --pill-changes-fg:  #991b1b;
  --pill-ready-bg:    #dcfce7; --pill-ready-fg:    #166534;
}

/* ── reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── topbar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar-brand {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── status pill ───────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.pill-draft        { background: var(--pill-draft-bg);   color: var(--pill-draft-fg); }
.pill-in-review    { background: var(--pill-review-bg);  color: var(--pill-review-fg); }
.pill-needs-changes{ background: var(--pill-changes-bg); color: var(--pill-changes-fg); }
.pill-ready        { background: var(--pill-ready-bg);   color: var(--pill-ready-fg); }

/* ── page layouts ──────────────────────────────────────────── */
.page-center {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* pin page: content + optional right rail */
.page-pin {
  display: grid;
  grid-template-columns: minmax(0, 720px) 320px;
  gap: 48px;
  max-width: 1088px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  align-items: start;
}
@media (max-width: 1099px) {
  .page-pin {
    grid-template-columns: 1fr;
    max-width: 720px;
  }
  .comment-rail {
    position: static;
    max-height: none;
    overflow-y: visible;
    border-top: 1px solid var(--border);
    padding-top: 32px;
    margin-top: 16px;
  }
}

/* ── prose (rendered markdown) ─────────────────────────────── */
.prose {
  font-family: ui-serif, "Charter", Georgia, "Iowan Old Style", serif;
  font-size: 18px;
  line-height: 1.75;
  color: var(--text);
}
.prose h1, .prose h2, .prose h3,
.prose h4, .prose h5, .prose h6 {
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.5em;
  font-weight: 600;
  color: var(--accent);
}
.prose h1 { font-size: 1.75em; margin-top: 0; }
.prose h2 { font-size: 1.35em; }
.prose h3 { font-size: 1.1em; }
.prose p  { margin-bottom: 1.2em; }
.prose ul, .prose ol { margin: 0 0 1.2em 1.5em; }
.prose li { margin-bottom: 0.4em; }
.prose blockquote {
  border-left: 3px solid var(--border);
  margin: 0 0 1.2em;
  padding: 0 0 0 1em;
  color: var(--meta);
  font-style: italic;
}
.prose code {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 0.82em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.35em;
}
.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1em 1.25em;
  overflow-x: auto;
  margin-bottom: 1.2em;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85em;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.2em;
  font-size: 0.9em;
}
.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 0.5em 0.75em;
  text-align: left;
}
.prose th { background: var(--surface); font-weight: 600; }
.prose a  { color: var(--accent); text-decoration: underline; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* ── block anchoring ───────────────────────────────────────── */
.block {
  position: relative;
  border-left: 3px solid transparent;
  padding-left: 12px;
  margin-left: -15px;
  border-radius: 0 4px 4px 0;
  transition: border-color 0.12s, background 0.12s;
}
.block:hover { border-left-color: var(--border); }
.block.selected {
  border-left-color: var(--accent) !important;
  background: #fafafa;
}

/* ── pin meta header ───────────────────────────────────────── */
.pin-meta {
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.pin-meta h1 {
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.3;
  margin-bottom: 10px;
}
.pin-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--meta);
}

/* ── version selector ──────────────────────────────────────── */
.version-select-wrap {
  position: relative;
  display: inline-block;
}
.version-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 28px 4px 10px;
  font-size: 13px;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  color: var(--meta);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%239a9aa1' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* ── version banner ────────────────────────────────────────── */
.version-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 16px;
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--meta);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.version-banner a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
}

/* ── space index ───────────────────────────────────────────── */
.space-header {
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.space-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}
.space-header .slug {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.pin-list { list-style: none; padding: 0; }
.pin-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.pin-list-item:last-child { border-bottom: none; }
.pin-list-item a {
  font-weight: 500;
  font-size: 15px;
}
.pin-list-item a:hover { text-decoration: underline; }
.pin-list-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* ── comment rail ──────────────────────────────────────────── */
.comment-rail {
  position: sticky;
  top: 64px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.comment-form-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}

.rail-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.rail-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

#comment-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  color: var(--text);
  background: var(--bg);
  box-sizing: border-box;
  margin-bottom: 8px;
}
#comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.comment-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.comment-form-row input[type="text"] {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  min-width: 0;
}
.comment-form-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
.comment-form-row button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.comment-form-row button[type="submit"]:hover { opacity: 0.85; }

/* ── comment cards ─────────────────────────────────────────── */
.comment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
}
.comment-card.is-resolved { opacity: 0.6; }
.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.comment-author {
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
}
.comment-anchor {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  border-left: 2px solid var(--border);
  padding-left: 8px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comment-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  white-space: pre-wrap;
}
.comment-foot {
  display: flex;
  justify-content: flex-end;
}
.btn-resolve {
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
}
.btn-resolve:hover { color: var(--accent); border-color: var(--accent); }

/* ── landing ───────────────────────────────────────────────── */
.landing-hero {
  padding: 80px 0 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}
.landing-hero .mark {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent);
  display: block;
  margin-bottom: 16px;
}
.landing-hero p {
  font-size: 1.05rem;
  color: var(--meta);
  max-width: 520px;
  line-height: 1.65;
}
.landing-section h2 {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.curl-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 24px;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  margin-bottom: 32px;
}
.landing-links {
  font-size: 13px;
  color: var(--meta);
  display: flex;
  gap: 20px;
}
.landing-links a {
  color: var(--accent);
  text-decoration: underline;
}

/* ── empty state ───────────────────────────────────────────── */
.empty {
  padding: 40px 0;
  color: var(--muted);
  font-size: 14px;
}

/* ── back link ─────────────────────────────────────────────── */
.back {
  font-size: 13px;
  color: var(--meta);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.back:hover { color: var(--accent); }

/* ── status controls ───────────────────────────────────────── */
.status-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.status-btn {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--meta);
  cursor: pointer;
  font-family: inherit;
}
.status-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── error page ────────────────────────────────────────────── */
.error-page {
  text-align: center;
  padding: 80px 0;
}
.error-code {
  font-size: 4rem;
  font-weight: 700;
  color: var(--muted);
  display: block;
  margin-bottom: 16px;
}
.error-msg {
  font-size: 1rem;
  color: var(--meta);
  margin-bottom: 24px;
}
.error-page a { color: var(--accent); text-decoration: underline; }

/* ── invites table ─────────────────────────────────────────── */
.invites-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.invites-table th {
  text-align: left;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
}
.invites-table td { padding: 10px 0; border-bottom: 1px solid var(--border); }
.invites-table tr:last-child td { border-bottom: none; }

/* ── quote chip ────────────────────────────────────────────── */
.quote-chip {
  font-size: 12px;
  color: var(--meta);
  font-style: italic;
  background: var(--surface);
  border-left: 2px solid var(--accent);
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
  margin-bottom: 8px;
  word-wrap: break-word;
}
.quote-chip[hidden] { display: none; }

/* ── name-form ─────────────────────────────────────────────── */
#name-form .comment-form-row input[type="text"] { flex: 1; }

/* ── change-name link button ───────────────────────────────── */
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 11px;
  padding: 0 0 0 4px;
}
.link-btn:hover { color: var(--accent); }

/* ── inline comment highlights ─────────────────────────────── */
.comment-highlight {
  background: #fff3a3;
  border-bottom: 1px solid #f0d040;
  cursor: pointer;
  border-radius: 2px;
  padding: 0 1px;
}
.comment-highlight.is-active { background: #ffe066; }
.comment-card.is-active {
  border-color: var(--accent);
  background: #fffbe6;
}
