:root {
  /* Surfaces */
  --bg: #ffffff;            /* main page area (white) */
  --panel: #f4f5f7;         /* sidebar / topbar (light grey) */
  --panel-2: #e9ebef;       /* hover + secondary surfaces */
  --card: #ffffff;          /* cards on the white page */
  --code-bg: #f4f5f7;       /* code blocks */

  /* Lines + text */
  --border: #e6e8ec;        /* soft hairline */
  --border-strong: #d7dbe1; /* control borders */
  --text: #353a44;          /* soft slate, not pure black */
  --heading: #1a1e27;
  --muted: #8b919e;

  /* Accents */
  --accent: #6366f1;        /* indigo */
  --accent-hover: #5054e4;
  --accent-2: #8b5cf6;      /* violet */
  --accent-soft: rgba(99, 102, 241, 0.10);
  --danger: #e5484d;
  --tag-bg: #eef0f4;
  --chip-text: #5b54d6;

  /* Shape + depth */
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.06), 0 2px 6px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-head { margin-bottom: 14px; }
.brand {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 12px;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.sidebar-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.sidebar-actions .btn {
  text-align: center;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 9px;
  letter-spacing: -0.01em;
}

.world-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 12px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.world-switch:hover { text-decoration: none; border-color: var(--accent); }
.world-switch .world-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.world-switch .world-name { font-weight: 600; flex: 1; }
.world-switch .world-chevron { color: var(--muted); }

/* Worlds manager */
.world-list { list-style: none; padding: 0; margin: 0; }
.world-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.world-list li:last-child { border-bottom: none; }
.world-list .world-info { flex: 1; min-width: 180px; }
.world-list .world-title { font-weight: 600; font-size: 16px; color: var(--heading); }
.world-list li.is-active { background: var(--accent-soft); border-radius: var(--radius); }
.world-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.rename-form { display: flex; gap: 8px; flex-basis: 100%; margin-top: 4px; }
.rename-form input[type=text] { width: auto; flex: 1; max-width: 320px; }

.type-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 14px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.type-filter > .muted {
  flex-basis: 100%;   /* label on its own line so chips get the full width to wrap */
  margin-bottom: 2px;
}
.chip {
  font-size: 12px;
  background: var(--tag-bg);
  padding: 3px 11px;
  border-radius: 999px;
  color: var(--chip-text);
  font-weight: 500;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;   /* a long single-word type breaks instead of clipping */
  line-height: 1.35;
}
.chip:hover { text-decoration: none; background: #e3e6ee; }
.chip-active { background: var(--accent); color: #fff; }

/* ---------------- Tree ---------------- */
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree > ul { padding-left: 0; }
.tree li { margin: 1px 0; }
.tree summary {
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  list-style-position: inside;
}
.tree summary:hover, .tree .leaf:hover { background: var(--panel-2); }
.tree .leaf {
  display: inline-block;
  padding: 4px 6px 4px 20px;
  border-radius: 8px;
  width: calc(100% - 4px);
}
.tag {
  font-size: 11px;
  color: var(--muted);
  background: var(--tag-bg);
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 500;
}
.tag-lg { font-size: 13px; padding: 4px 11px; }

.tree-main { margin-top: 8px; }
.tree-main ul { padding-left: 18px; }

/* ---------------- Content ---------------- */
.content { flex: 1; padding: 32px 40px; }
/* The reading column stays a comfortable width but sits CENTERED in the space
   next to the sidebar, so a wide/ultrawide screen has equal margins on both
   sides rather than a void on the right. Wide pages (the claim dashboard) opt
   out via .content-wide below. */
.content-inner { max-width: 960px; margin: 0 auto; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 27px; letter-spacing: -0.01em; }
.page-head-actions { display: flex; align-items: center; gap: 10px; }

h1, h2 { color: var(--heading); font-weight: 680; }
h1 { letter-spacing: -0.01em; }
h2 { font-size: 18px; }
.block > h2:first-child, .block-head h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-top: 0;
}

.muted { color: var(--muted); font-size: 13px; }
.sep { color: var(--muted); margin: 0 6px; }
.breadcrumb { font-size: 13px; margin-bottom: 16px; color: var(--muted); }
.breadcrumb .current { color: var(--text); }

.block { margin-top: 22px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; }

/* ---------------- Buttons / forms ---------------- */
.btn {
  display: inline-block;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.04s ease;
}
.btn:hover { background: var(--panel); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-small { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover { background: var(--accent-hover); }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  font-family: inherit;
}
.link-btn:hover { color: var(--text); }
.link-btn.danger { color: var(--danger); }
.inline { display: inline; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; }
.field label { font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }

input[type=text], input[type=number], input[type=file], textarea, select {
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
textarea {
  resize: vertical;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
input::placeholder, textarea::placeholder { color: #aab0bb; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.card-form, .block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card-form { padding: 24px; }

.placement-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}
.placement-form input, .placement-form select { width: auto; flex: 0 1 auto; }
.placement-form input[type=number] { width: 130px; }

.flat-list { list-style: none; padding: 0; margin: 0; }
.flat-list li {
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.flat-list li:last-child { border-bottom: none; }

.placement-list { list-style: none; padding: 0; }
.placement-list li { padding: 4px 0; }
.pos { color: var(--accent-2); font-size: 13px; }

/* ---------------- Markdown body ---------------- */
.markdown-body { line-height: 1.7; }
.markdown-body :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 1.2em 0 0.5em; }
.markdown-body h2 { border: none; padding: 0; }
.markdown-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: var(--radius);
  overflow-x: auto;
}
.markdown-body code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 0;
  padding: 2px 0 2px 16px;
  color: var(--muted);
}
.markdown-body table { border-collapse: collapse; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 7px 11px; }
.markdown-body th { background: var(--panel); font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: var(--radius); }

/* ---------------- Events (on a page) ---------------- */
.event-list { list-style: none; padding: 0; margin: 0; }
.event-list li {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.event-list li:last-child { border-bottom: none; }
.event-list .year {
  flex: 0 0 80px;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.event-body { flex: 1; }
.event-title { font-weight: 600; color: var(--heading); }
.event-desc { color: var(--muted); font-size: 13px; margin-top: 2px; }
.event-desc :first-child { margin-top: 0; }
.event-desc :last-child { margin-bottom: 0; }

.add-event { margin-top: 14px; }
.add-event > summary { cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 500; }
.add-event .card-form { margin-top: 12px; }

/* ---------------- Timeline view ---------------- */
.timeline-list { list-style: none; padding: 0; margin: 0 0 28px; }
.timeline-list li {
  display: flex;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-list .tl-pos {
  flex: 0 0 130px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}
.timeline-list li.era {
  border-left: 3px solid var(--accent-2);
  padding-left: 14px;
  margin-left: -17px;
  background: rgba(139, 92, 246, 0.06);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.timeline-list li.era .tl-pos { color: var(--accent-2); }
.tl-body { flex: 1; }
.tl-kind {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 1px 6px;
  margin-right: 8px;
  vertical-align: middle;
}
.attached { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions { margin-top: 10px; display: flex; gap: 14px; align-items: center; font-size: 13px; }

.add-row { display: flex; gap: 20px; flex-wrap: wrap; }
.add-row .block { flex: 1; min-width: 280px; margin-top: 0; }

/* ---------------- Misc ---------------- */
.flash {
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.30);
  color: var(--text);
  padding: 11px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.empty {
  text-align: center;
  padding: 70px 0;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty .btn { margin-top: 12px; }
.danger-zone { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Unified, minimalist feature buttons (Display tree / Read-only preview) */
.btn-feature {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 10px;
  padding: 10px 14px;
  background: #1e232c;
  color: #fff;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 550;
  font-size: 14px;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-sm);
}
.btn-feature:hover { background: #11151c; text-decoration: none; }
.btn-ic { width: 17px; height: 17px; flex: 0 0 auto; }

/* ---------------- Tree diagram page ---------------- */
body.tree { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
body.tree .preview-topbar { flex: 0 0 auto; }
.tree-hint { font-size: 12.5px; }
.tree-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#tree-canvas { flex: 1 1 auto; min-height: 0; background: #fbfbfd; }
.tree-empty {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* ---------------- Stream day (map + pins) ---------------- */
.rename-inline { margin-top: 6px; }
.rename-inline > summary { cursor: pointer; font-size: 12px; }
.rename-inline .placement-form { margin-top: 8px; }

.stream-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.replace-map { margin-left: auto; }
.replace-map > summary { list-style: none; display: inline-block; }
.replace-map .placement-form { margin-top: 10px; }

.stream-map-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.stream-map-wrap.arming { cursor: crosshair; }
.stream-map {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Pin markers — numbered circles centered on the chosen spot */
.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(16, 24, 40, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pin:hover { background: var(--accent-hover); z-index: 5; transform: translate(-50%, -50%) scale(1.12); }

/* Hover tooltip */
.pin-tip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 20px));
  max-width: 240px;
  background: #1a1e27;
  color: #fff;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  z-index: 20;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  white-space: pre-wrap;
}
.pin-tip-label { font-weight: 700; margin-bottom: 2px; }

/* Inline editor popup */
.pin-editor {
  position: absolute;
  transform: translate(-50%, 12px);
  width: 280px;
  max-width: 80vw;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 14px;
  z-index: 30;
  line-height: 1.5;
}
.pin-editor .field { margin-bottom: 10px; }
.pin-editor-actions { display: flex; align-items: center; gap: 10px; }
.pin-editor-actions .danger { margin-left: auto; }

/* Notes document */
.notes-doc { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.notes-doc li {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.notes-doc li:last-child { border-bottom: none; }
.note-num {
  flex: 0 0 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.note-body { flex: 1; min-width: 0; }
.note-label { font-weight: 600; color: var(--heading); }
.note-text { white-space: pre-wrap; }

/* ===================== Storyboards (narrative sequence, sticky-note cards) ==== */
.storyboard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding: 6px 4px 18px;
}
.sticky-card {
  width: 220px;
  min-height: 130px;
  padding: 14px 14px 12px;
  background: #fff8d6;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: rotate(-1deg);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.sticky-card:nth-child(3n+2) { background: #ffe3ef; transform: rotate(0.8deg); }
.sticky-card:nth-child(3n)   { background: #dff3ff; transform: rotate(-0.6deg); }
.sticky-card:hover { box-shadow: 0 8px 18px rgba(16, 24, 40, 0.16); transform: rotate(0deg) translateY(-2px); }
.sticky-card.dragging { opacity: 0.4; }
.sticky-card.drag-over { outline: 2px dashed var(--accent); outline-offset: 3px; }
.sticky-card-num { font-size: 11px; font-weight: 700; color: rgba(0, 0, 0, 0.35); }
.sticky-card-title { font-weight: 700; color: var(--heading); line-height: 1.3; }
.sticky-card-preview { font-size: 13px; color: rgba(0, 0, 0, 0.6); flex: 1; }
.sticky-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.pov-chip, .page-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.65);
}
.page-chip { background: var(--accent); color: #fff; }
.page-chip:hover { text-decoration: none; background: var(--accent-hover); }
.storyboard-empty { color: var(--muted); font-size: 14px; }

.add-card-tile {
  width: 220px;
  min-height: 130px;
  border: 2px dashed var(--border-strong);
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.add-card-tile:hover { border-color: var(--accent); color: var(--accent); }

.card-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.card-modal-backdrop[hidden] { display: none; }
.card-modal {
  width: 420px;
  max-width: 90vw;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
}
.card-modal h2 { margin: 0 0 14px; font-size: 18px; }
.card-modal .form-actions { justify-content: space-between; align-items: center; }

.page-picker { position: relative; }
.page-picker-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 180px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.page-picker-results[hidden] { display: none; }
.page-picker-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 11px;
  background: none;
  border: none;
  font-size: 13.5px;
  cursor: pointer;
}
.page-picker-result:hover { background: var(--panel); }
.page-picker-selected {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* ===================== Claims (claim-a-spot dashboard) ======================= */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: #1a7f37;
  padding: 3px 10px;
  border-radius: 999px;
}
.live-badge[hidden] { display: none; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c93b40; }

.claim-hint {
  margin: 4px 0 18px;
  font-size: 13.5px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--panel);
}
.claim-hint code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

.claim-layout { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.claim-map-col { flex: 1 1 340px; min-width: 280px; }
.claim-spots-col { flex: 1 1 360px; min-width: 280px; }
.claim-map {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.claim-map-empty {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}
.claim-map-col .replace-map { margin-top: 10px; }

/* The claim dashboard opts out of the 960px reading width so the map + grid can
   use a wide / ultrawide screen. */
.content.content-wide .content-inner { max-width: none; }

.spot-grid {
  display: grid;
  /* Column size scales with the viewport: small on a laptop, larger on an
     ultrawide (capped so boxes stay tidy), then more columns past the cap. */
  grid-template-columns: repeat(auto-fill, minmax(clamp(84px, 8vw, 200px), 1fr));
  gap: clamp(8px, 0.7vw, 16px);
}
.spot-cell { position: relative; }
.spot-card {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  font: inherit;
  transition: background 0.18s ease, color 0.18s ease, transform 0.1s ease;
}
.spot-card:hover { transform: translateY(-1px); border-color: var(--accent); }
.spot-card .spot-num { font-size: clamp(18px, 1.9vw, 34px); font-weight: 700; color: var(--heading); }
.spot-card .spot-user { font-size: clamp(11px, 0.85vw, 15px); line-height: 1.15; text-align: center; word-break: break-word; }
.spot-card.claimed {
  background: #dcf5e3;
  border-color: #1a7f37;
  color: #14622b;
  /* leave room at the bottom for the create/open-page pill */
  justify-content: center;
  padding-bottom: 22px;
}
.spot-card.claimed .spot-num { color: #14622b; }
.spot-card.claimed .spot-user { color: #14622b; font-weight: 600; }

/* Create-page / open-page action — only visible once a spot is claimed. */
.spot-page-form, .spot-page-link {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  display: none;
}
.spot-card.claimed ~ .spot-page-form,
.spot-card.claimed ~ .spot-page-link { display: block; }
.spot-create-page, .spot-page-link {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #14622b;
  border: 1px solid #1a7f37;
  cursor: pointer;
  text-decoration: none;
}
.spot-create-page:hover, .spot-page-link:hover { background: #fff; }

/* ===================== Public wiki (read-only, hostable) ===================== */
body.public {
  background: #faf9f7;
  color: #2a2c33;
}
.public-header {
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.public-header-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.public-brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.01em;
}
.public-brand:hover { text-decoration: none; color: var(--accent); }
.public-tagline { color: var(--muted); font-size: 13px; }

.public-main { max-width: 820px; margin: 0 auto; padding: 36px 24px 80px; }

.wiki-article {
  font-size: 17px;
  line-height: 1.75;
}
.public-breadcrumb { font-size: 13.5px; color: var(--muted); margin-bottom: 22px; }
.public-breadcrumb .sep { margin: 0 6px; color: #c8c8c8; }

.article-head { margin-bottom: 24px; }
.article-head h1 {
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.article-type {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.article-type.sm { font-size: 10px; padding: 1px 8px; margin-left: 6px; }
.article-summary {
  font-size: 19px;
  color: #5a5d66;
  font-style: italic;
  margin: 10px 0 0;
}

.article-body { font-size: 17px; }
.article-body h1, .article-body h2, .article-body h3 {
  letter-spacing: -0.01em;
  margin-top: 1.5em;
}
.article-body h2 { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.article-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.article-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 26px 0 0; }

.article-section { margin-top: 40px; }
.article-section h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.article-children { list-style: none; padding: 0; margin: 0; }
.article-children li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.article-children li:last-child { border-bottom: none; }
.article-children a { font-weight: 600; font-size: 17px; }

.article-events { list-style: none; padding: 0; margin: 0; }
.article-events li { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.article-events li:last-child { border-bottom: none; }
.article-events .year { flex: 0 0 84px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

.public-toc ul { list-style: none; margin: 0; padding-left: 18px; }
.public-toc > ul { padding-left: 0; }
.public-toc li { margin: 7px 0; }
.public-toc a { font-size: 17px; font-weight: 500; }

.public-footer {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* ===================== Notification drawer (incoming suggestions) ============ */
.notif { position: fixed; top: 14px; right: 18px; z-index: 200; }
.notif-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #1a1e27;     /* clean ring/outline accent */
  background: var(--card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  color: #14171d;                /* minimalist black bell */
}
.notif-bell:hover { background: #f0f1f4; }
.notif-bell.has-new { box-shadow: 0 0 0 3px rgba(26, 30, 39, 0.10), var(--shadow-sm); }
.notif-bell-ic { width: 21px; height: 21px; }
.notif-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
}
.notif-drawer {
  position: absolute;
  top: 50px;
  right: 0;
  width: 340px;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.notif-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.notif-status { font-size: 12px; margin-left: auto; }
.notif-mute {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.75;
}
.notif-mute:hover { opacity: 1; }
.notif-list { padding: 4px 0; }
.notif-empty { padding: 18px 14px; }
.notif-item { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.notif-when { margin-left: auto; font-size: 12px; }
.notif-text { margin: 6px 0 9px; white-space: pre-wrap; word-break: break-word; }
.notif-actions { display: flex; align-items: center; gap: 12px; }
.notif-foot { padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; }

/* ---------------- Status, summary, tags ---------------- */
.summary-line { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head-main { min-width: 0; }
.page-head-main .summary-line { margin-top: 6px; }

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
  flex: 0 0 auto;
}
.status-canon.status-badge   { background: #e7f6ec; color: #1a7f37; }
.status-open_thread.status-badge { background: #fdf0e0; color: #b45309; }
.status-speculative.status-badge { background: #eceefb; color: #4f46e5; }
.status-dot.status-canon       { background: #21a35a; }
.status-dot.status-open_thread { background: #e08a1e; }
.status-dot.status-speculative { background: #6366f1; }

.tags-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }

.hidden-indicator {
  font-size: 13px;
  color: #b45309;
  background: #fdf0e0;
  border: 1px solid #f4d8b0;
  border-radius: var(--radius);
  padding: 7px 12px;
  margin: 12px 0;
}

/* Rich list view (filter-by-type) */
.flat-list-rich li { align-items: flex-start; padding: 12px 4px; }
.li-main { flex: 1; min-width: 0; }
.li-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.li-main .summary-line { margin-top: 4px; }
.li-main .tags-row { margin: 8px 0 0; }

/* Hidden-content section + reveal toggle */
.hidden-section {
  margin: 6px 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--panel);
}
.hidden-section > summary { cursor: pointer; font-weight: 500; }
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 14px;
  color: var(--text);
}
.checkbox input { width: auto; }

/* Cover image (featured picture at the top of a page) */
.page-cover {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.cover-preview-row { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.cover-preview {
  width: 140px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Markdown editor: @mention autocomplete + inline image upload */
.md-editor { position: relative; }
.md-toolbar { display: flex; align-items: center; gap: 10px; margin-top: 6px; }

.mention-dropdown {
  position: absolute;
  z-index: 60;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
}
.mention-dropdown[hidden] { display: none; }
.mention-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 11px;
  background: none;
  border: none;
  font-size: 13.5px;
  cursor: pointer;
}
.mention-result:hover { background: var(--panel); }

/* ---------------- Creator login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 340px;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
}
.login-brand { margin: 0 0 2px; font-size: 22px; }
.login-card > .muted { margin-top: 0; margin-bottom: 16px; }
.login-card .form-actions { margin-top: 16px; }
.logout-form { margin-top: 10px; }

/* ---------------- Import ---------------- */
.import-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.import-summary .status-badge { font-size: 13px; padding: 4px 12px; }

.import-card .import-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.import-errors { border-color: #f4d8b0; background: #fdf7ee; }

.diff-table { width: 100%; border-collapse: collapse; margin: 6px 0 14px; }
.diff-table th, .diff-table td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13.5px;
}
.diff-table thead th { background: var(--panel); color: var(--muted); font-weight: 600; }
.diff-table tbody th { background: var(--panel); width: 90px; color: var(--muted); font-weight: 600; }
.diff-table tr.changed td { background: #fff8ec; }
.diff-table tr.changed tbody th, .diff-table tr.changed > th { color: #b45309; }

.diff-bodies { display: flex; gap: 14px; margin-top: 8px; }
.diff-bodies > div { flex: 1; min-width: 0; }
.diff-bodies pre, .body-preview {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
  font-size: 12.5px;
}
.decision-field { max-width: 460px; }

/* ===================== Read-only preview (wiki) ===================== */
body.preview { background: var(--bg); }

.preview-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.pt-world { font-weight: 700; font-size: 16px; color: var(--heading); }
.pt-tabs { display: flex; gap: 6px; }
.pt-tab {
  padding: 6px 18px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.pt-tab:hover { text-decoration: none; background: var(--panel-2); color: var(--text); }
.pt-tab.active { background: var(--accent); color: #fff; }
.pt-exit { margin-left: auto; }

.preview-layout {
  display: flex;
  gap: 0;
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto;
}

.toc {
  flex: 0 0 250px;
  position: sticky;
  top: 57px;
  align-self: flex-start;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  padding: 26px 18px;
  border-right: 1px solid var(--border);
}
.toc-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}
.toc-tree ul { list-style: none; margin: 0; padding-left: 12px; }
.toc-tree > ul { padding-left: 0; }
.toc-tree li { margin: 4px 0; }
.toc-tree a { color: var(--text); font-size: 13.5px; }
.toc-tree a:hover { color: var(--accent); }

.wiki {
  flex: 1;
  min-width: 0;
  padding: 34px 48px 120px;
  max-width: 800px;
}
.wiki-page { scroll-margin-top: 70px; padding-bottom: 18px; }
.wiki-page + .wiki-page { border-top: 1px solid var(--border); margin-top: 28px; padding-top: 28px; }
.wiki-page-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.wiki-title { margin: 0; color: var(--heading); }
.wiki-page.depth-0 .wiki-title { font-size: 30px; letter-spacing: -0.01em; }
.wiki-page.depth-1 { margin-left: 8px; }
.wiki-page.depth-2 { margin-left: 16px; }
.wiki-page.depth-3 { margin-left: 24px; }
.wiki-page.depth-4 { margin-left: 32px; }
.wiki-page .markdown-body {
  background: none;
  border: none;
  border-radius: 0;
  padding: 6px 0 0;
  box-shadow: none;
}
.wiki-subhead {
  margin: 16px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.wiki-events { border-left: 2px solid var(--border); padding-left: 16px; margin-top: 16px; }

.wiki-timeline { scroll-margin-top: 70px; }
.wiki-timeline + .wiki-timeline { margin-top: 36px; }

@media (max-width: 820px) {
  .toc { display: none; }
  .wiki { padding: 24px 20px 100px; }
}
