:root {
  --bg: #0f1117;
  --panel: #161a23;
  --border: #2a2f3c;
  --text: #e6e8ee;
  --dim: #9aa0ab;
  --accent: #5aa9ff;
  --accent-dim: #2b3a52;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* Flex column so a page with a footer can push it to the bottom without
     hard-coding "viewport minus the height of the chrome". */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 600;
}

/* Collection pills - one per configured share. Deliberately not called
   .share-btn: uBlock's "EasyList - Social Widgets" hides that generic class as
   if it were a social-media share widget, which deleted this whole nav for
   anyone running a content blocker. Keep the name neutral. */
#collections { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.collection-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--dim);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.collection-btn:hover { color: var(--text); border-color: var(--accent); }
.collection-btn.active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent);
}

/* Far-right topbar link. Plain text (no box) to stay visually distinct
   from the collection buttons; margin-left: auto pushes it to the right edge. */
.nc-link {
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}
.nc-link:hover { text-decoration: underline; }

/* Log out - a plain form button so it works without JS. */
.logout-form { margin: 0; }
.logout-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--dim);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.logout-btn:hover { color: var(--text); border-color: var(--accent); }
/* Email local-part inside the logout button: brighter than "(log out)". */
.logout-btn .who { color: var(--text); }

main { padding: 1rem 1.25rem; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--dim);
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border); }

.listing {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.6rem;
}

.listing li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.listing a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  color: var(--text);
  text-decoration: none;
}
.listing a:hover { background: var(--accent-dim); }
.listing .icon { font-size: 1.3rem; }
.listing .meta {
  margin-left: auto;
  color: var(--dim);
  font-size: 0.8rem;
  white-space: nowrap;
}

.empty {
  color: var(--dim);
  padding: 1rem;
  font-style: italic;
}

/* --- Preview panel --- */
.preview {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.preview-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}
.preview-head a { color: var(--accent); text-decoration: none; }
.preview-head .title { color: var(--dim); font-size: 0.9rem; }
.preview-body { padding: 1rem; }

.preview-body img {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  margin: 0 auto;
  border-radius: 6px;
}
.preview-body iframe {
  width: 100%;
  height: 70vh;
  border: none;
  background: #fff;
}
.preview-body pre {
  background: var(--bg);
  padding: 1rem;
  border-radius: 6px;
  overflow: auto;
  max-height: 70vh;
  font-size: 0.85rem;
}

/* Rendered markdown */
.md { max-height: 70vh; overflow: auto; }
.md h1, .md h2, .md h3 { margin-top: 1rem; }
.md a { color: var(--accent); }
.md code {
  background: var(--bg);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.md pre {
  background: var(--bg);
  padding: 0.8rem;
  border-radius: 6px;
  overflow: auto;
}
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; }
.md th, .md td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; }

.download {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
}
.download:hover { background: var(--accent-dim); }

.hidden { display: none; }

/* Skeletal footer. Public pages only for now (home links to contact); the
   member pages end at the content. */
.footer {
  padding: 1rem 1.25rem 1.5rem;
  color: var(--dim);
  font-size: 0.9rem;
}
.footer a {
  color: var(--accent);
  text-decoration: none;
}
.footer a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .listing { grid-template-columns: 1fr; }
}