/* Swarm Review -- minimal, readable, no framework. */
:root {
  --bg: #16181d;
  --bg-elevated: #1e2129;
  --border: #2c303a;
  --text: #e7e8ea;
  --text-muted: #9aa0ac;
  --accent: #8b7bd8;
  --accent-strong: #a493f0;
  --pending: #d8a44b;
  --accepted: #4bbf7e;
  --rejected: #d8654b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar .whoami { color: var(--text-muted); }

.linklike {
  background: none; border: none; color: var(--accent-strong); cursor: pointer;
  font: inherit; padding: 0; text-decoration: none;
}
.linklike:hover { text-decoration: underline; }
.inline-form { display: inline; }

.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px 80px; }

.flash { padding: 10px 24px; text-align: center; }
.flash.error { background: rgba(216, 101, 75, 0.15); color: var(--rejected); }
.flash.info { background: rgba(139, 123, 216, 0.15); color: var(--accent-strong); }

h1 { margin-top: 0; }
.muted { color: var(--text-muted); }
.error { color: var(--rejected); }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #101114;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn:hover { background: var(--accent-strong); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent-strong); border: 1px solid var(--border); }
.btn.small { padding: 5px 10px; font-size: 0.85rem; }
.btn.accept { background: var(--accepted); color: #0e1a12; }
.btn.reject { background: var(--rejected); color: #1a0e0e; }
.btn.danger { background: var(--rejected); color: #1a0e0e; }
.btn.tiny { padding: 2px 8px; font-size: 0.75rem; }

/* --- auth --- */
.auth-card {
  max-width: 380px; margin: 40px auto; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 28px;
}
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--text-muted); }
input, textarea, select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 9px 10px; font: inherit;
}
textarea { resize: vertical; font-family: Georgia, 'Times New Roman', serif; font-size: 1rem; }

/* --- dashboard / stories --- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head .btn { flex-shrink: 0; }
.breadcrumb { margin: 0 0 14px; }
.chapter-list { display: flex; flex-direction: column; gap: 10px; }
.chapter-row {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; color: var(--text);
}
.chapter-row:hover { border-color: var(--accent); text-decoration: none; }
.chapter-row h3 { margin: 0 0 4px; }
.chapter-row-meta { display: flex; gap: 10px; align-items: center; white-space: nowrap; color: var(--text-muted); font-size: 0.85rem; }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.pending { background: rgba(216, 164, 75, 0.18); color: var(--pending); }
.badge.new { background: rgba(139, 123, 216, 0.22); color: var(--accent-strong); }
.badge.new-comments { background: rgba(75, 191, 126, 0.18); color: var(--accepted); }
.archive-link { margin-top: 18px; }
.archived-row { opacity: 0.85; }
.archived-row .chapter-row-meta { gap: 6px; }
.page-head-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.ts { white-space: nowrap; }

/* --- forms --- */
.chapter-form { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.form-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.hint { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }
input[type="file"] { padding: 6px 4px; }

/* --- chapter page --- */
.chapter-header { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 20px; }
.byline { margin-top: -6px; }
.summary { font-style: italic; }
.version-bar { display: flex; align-items: center; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.version-bar label { flex-direction: row; align-items: center; gap: 8px; }
.changelog { font-style: italic; }
.download-links a { margin-left: 4px; }

.chapter-body-grid { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr); gap: 28px; align-items: start; }

.reading-pane {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 32px;
}
#chapter-text {
  white-space: pre-wrap;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.08rem;
  line-height: 1.75;
}
#chapter-text p { margin: 0 0 1.1em; }
#chapter-text p:last-child { margin-bottom: 0; }
#chapter-text h1, #chapter-text h2, #chapter-text h3,
#chapter-text h4, #chapter-text h5, #chapter-text h6 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  margin: 1.3em 0 0.6em; line-height: 1.3; color: var(--text);
}
#chapter-text h1 { font-size: 1.5rem; }
#chapter-text h2 { font-size: 1.3rem; }
#chapter-text h3 { font-size: 1.15rem; }
#chapter-text blockquote {
  margin: 0 0 1.1em; padding: 4px 16px; border-left: 3px solid var(--accent);
  color: var(--text-muted); font-style: italic;
}
#chapter-text ul, #chapter-text ol { margin: 0 0 1.1em; padding-left: 1.4em; }
#chapter-text li { margin-bottom: 0.3em; }
#chapter-text hr {
  border: none; text-align: center; margin: 1.6em 0; color: var(--text-muted);
}
#chapter-text hr::before { content: "\2022 \2022 \2022"; letter-spacing: 0.4em; }
#chapter-text code {
  font-family: "SF Mono", Consolas, Monaco, monospace; font-size: 0.92em;
  background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 4px;
}
#chapter-text a { color: var(--accent-strong); }
.hl { border-radius: 3px; cursor: pointer; padding: 1px 0; }
.hl-pending { background: rgba(216, 164, 75, 0.28); box-shadow: inset 0 -2px 0 var(--pending); }
.hl-accepted { background: rgba(75, 191, 126, 0.2); box-shadow: inset 0 -2px 0 var(--accepted); }
.hl-rejected { background: rgba(216, 101, 75, 0.15); box-shadow: inset 0 -2px 0 var(--rejected); opacity: 0.75; }

.comments-pane { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 40px); overflow-y: auto; }
.comments-pane h2 { margin: 0; font-size: 1.05rem; }

.comment {
  background: var(--bg-elevated); border: 1px solid var(--border); border-left: 4px solid var(--pending);
  border-radius: var(--radius); padding: 12px 14px; transition: box-shadow 0.3s;
}
.comment.status-accepted { border-left-color: var(--accepted); }
.comment.status-rejected { border-left-color: var(--rejected); opacity: 0.8; }
.comment.flash-highlight { box-shadow: 0 0 0 2px var(--accent-strong); }
.comment-meta { display: flex; justify-content: flex-start; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.status-badge { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.status-badge.status-pending { background: rgba(216, 164, 75, 0.18); color: var(--pending); }
.status-badge.status-accepted { background: rgba(75, 191, 126, 0.18); color: var(--accepted); }
.status-badge.status-rejected { background: rgba(216, 101, 75, 0.18); color: var(--rejected); }
.edited-tag { font-size: 0.78rem; }
.quoted { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--border); color: var(--text-muted); font-size: 0.88rem; font-style: italic; }
.comment-body { margin: 0 0 8px; white-space: pre-wrap; }
.comment.retracted { opacity: 0.7; }
.comment-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.edit-comment { margin: 4px 0 8px; }
.edit-comment summary { cursor: pointer; color: var(--text-muted); font-size: 0.85rem; }
.edit-comment form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.edit-comment textarea { min-height: 60px; font-size: 0.9rem; }
.reply { margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--border); font-size: 0.9rem; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.reply.retracted { opacity: 0.7; }
.reply-form { display: flex; gap: 6px; margin-top: 8px; }
.reply-form input { flex: 1; padding: 6px 8px; font-size: 0.85rem; }

.new-comment-box {
  background: var(--bg-elevated); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.new-comment-box.hidden { display: none; }
.new-comment-box textarea { min-height: 80px; }
.quoted-preview { margin: 0; font-style: italic; color: var(--text-muted); font-size: 0.85rem; }
.row { display: flex; gap: 8px; }

.general-comment summary { cursor: pointer; color: var(--text-muted); font-size: 0.9rem; }
.general-comment form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.selection-toast {
  position: absolute; z-index: 50; background: var(--accent); color: #101114;
  border: none; border-radius: 999px; padding: 6px 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.selection-toast.hidden { display: none; }

@media (max-width: 860px) {
  .chapter-body-grid { grid-template-columns: 1fr; }
  .comments-pane { position: static; max-height: none; }
}

/* --- admin panel --- */
.admin-section { margin: 0 0 32px; }
.admin-section h2 { font-size: 1.1rem; margin-bottom: 10px; }
.invite-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; max-width: 480px;
}
.invite-card.closed { border-color: var(--rejected); }
.invite-code {
  font-family: "SF Mono", Consolas, Monaco, monospace; font-size: 1.4rem; font-weight: 700;
  letter-spacing: 0.08em; margin: 4px 0 10px; color: var(--accent-strong);
}
.invite-history { margin-top: 12px; max-width: 480px; }
.invite-history summary { cursor: pointer; color: var(--text-muted); font-size: 0.9rem; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.85rem; }
.admin-table th, .admin-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.admin-user-list { display: flex; flex-direction: column; gap: 10px; }
.admin-user-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.admin-user-row.locked { border-color: var(--rejected); }
.admin-user-main .small-meta { margin: 4px 0 0; font-size: 0.82rem; }
.badge.admin-badge { background: rgba(139, 123, 216, 0.22); color: var(--accent-strong); margin-left: 6px; }
.badge.locked-badge { background: rgba(216, 101, 75, 0.18); color: var(--rejected); margin-left: 6px; }
.admin-user-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.admin-inline-form summary { cursor: pointer; color: var(--text-muted); font-size: 0.85rem; padding: 5px 0; }
.admin-inline-form form { display: flex; gap: 6px; margin-top: 6px; }
.admin-inline-form input { padding: 6px 8px; font-size: 0.85rem; }
