/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --ink:        #1a1410;
  --ink-soft:   #3d2f22;
  --parchment:  #f5ede0;
  --parch-dark: #e8dac8;
  --parch-deep: #d4c4ac;
  --gold:       #c9922a;
  --gold-light: #e8b84b;
  --gold-dim:   #8a641d;
  --crimson:    #8b2020;
  --muted:      #7a6a58;
  --user-tint:  #f0e8d8;
  --ai-tint:    #e8f0f5;
  --ai-border:  #9ab5c8;
  --shadow:     rgba(26,20,16,0.18);
  --radius:     6px;
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--ink);
  background-image:
    radial-gradient(ellipse at 20% 0%, #2d1f0e 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, #1a2530 0%, transparent 60%);
  color: var(--ink);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 18px;
  line-height: 1.7;
  min-height: 100vh;
}

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

/* ── Site Header ─────────────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(to bottom, #0d0906, #1a1008);
  border-bottom: 2px solid var(--gold-dim);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
}
.site-logo { display: flex; align-items: baseline; gap: 0.6rem; text-decoration: none; }
.site-logo:hover { text-decoration: none; }
.logo-symbol { color: var(--gold); font-size: 1.2rem; }
.logo-text { font-family: 'Cinzel', serif; color: var(--gold-light); font-size: 1.4rem; letter-spacing: 0.05em; }
.logo-sub { color: var(--muted); font-size: 0.8rem; font-style: italic; }
.site-nav { display: flex; align-items: center; gap: 1.5rem; }
.site-nav a { color: var(--parch-dark); font-size: 0.95rem; letter-spacing: 0.02em; text-decoration: none; }
.site-nav a:hover { color: var(--gold-light); }
.btn-nav {
  background: var(--gold-dim); color: var(--parchment) !important;
  padding: 0.35rem 1rem; border-radius: var(--radius);
  font-family: 'Cinzel', serif; font-size: 0.8rem; letter-spacing: 0.06em;
  transition: background 0.2s;
}
.btn-nav:hover { background: var(--gold) !important; text-decoration: none !important; }

/* ── Main ────────────────────────────────────────────────────────────────── */
.site-main { max-width: 1200px; margin: 0 auto; padding: 2.5rem 2rem 4rem; }

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 2.5rem; text-align: center; }
.page-title {
  font-family: 'Cinzel', serif; font-size: 2.2rem;
  color: var(--gold-light); letter-spacing: 0.06em;
  text-shadow: 0 2px 12px rgba(201,146,42,0.3);
}
.page-sub { color: var(--parch-dark); margin-top: 0.4rem; font-style: italic; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: var(--parchment); border: none; cursor: pointer;
  padding: 0.6rem 1.5rem; border-radius: var(--radius);
  font-family: 'Cinzel', serif; font-size: 0.85rem; letter-spacing: 0.06em;
  transition: all 0.2s; text-decoration: none;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: var(--ink); text-decoration: none; }
.btn-large { padding: 0.9rem 2.5rem; font-size: 1rem; }
.btn-danger-sm {
  background: none; border: 1px solid var(--crimson); color: var(--crimson);
  padding: 0.3rem 0.8rem; border-radius: var(--radius);
  font-size: 0.8rem; cursor: pointer; font-family: 'Crimson Pro', serif;
  transition: all 0.2s;
}
.btn-danger-sm:hover { background: var(--crimson); color: var(--parchment); }

/* ── Story List ──────────────────────────────────────────────────────────── */
.story-list { display: flex; flex-direction: column; gap: 1.2rem; }
.story-card {
  background: var(--parchment);
  border: 1px solid var(--parch-deep);
  border-left: 4px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 1.5rem 1.8rem;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 10px var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.story-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px var(--shadow); }
.story-card-body { flex: 1; }
.story-meta-top { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.4rem; }
.story-status { font-size: 0.75rem; font-family: 'Cinzel', serif; letter-spacing: 0.08em;
  padding: 0.15rem 0.6rem; border-radius: 3px; text-transform: uppercase; }
.status-active { background: #d4edda; color: #276040; border: 1px solid #a3c4a8; }
.story-date { color: var(--muted); font-size: 0.85rem; }
.story-title { font-family: 'Cinzel', serif; font-size: 1.3rem; margin-bottom: 0.4rem; }
.story-title a { color: var(--ink); text-decoration: none; }
.story-title a:hover { color: var(--gold); }
.story-setting-preview { color: var(--ink-soft); font-style: italic; font-size: 0.95rem; margin-bottom: 0.6rem; }
.story-stats { display: flex; gap: 1.5rem; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; }
.story-stats span:nth-child(3) { color: var(--gold-dim); font-family: 'Cinzel', serif; font-size: 0.8rem; }
.story-card-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; padding-left: 2rem; }

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 5rem 2rem;
  background: var(--parchment); border-radius: var(--radius);
  border: 1px dashed var(--parch-deep);
}
.empty-icon { font-size: 3rem; color: var(--gold-dim); margin-bottom: 1rem; }
.empty-state h2 { font-family: 'Cinzel', serif; color: var(--ink-soft); margin-bottom: 0.5rem; }
.empty-state p { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Form ────────────────────────────────────────────────────────────────── */
.story-form { max-width: 860px; margin: 0 auto; }
.form-section {
  background: var(--parchment); border-radius: var(--radius);
  border: 1px solid var(--parch-deep); border-top: 3px solid var(--gold-dim);
  padding: 2rem; margin-bottom: 1.5rem;
  box-shadow: 0 2px 10px var(--shadow);
}
.section-title {
  font-family: 'Cinzel', serif; font-size: 1.1rem;
  color: var(--gold-dim); margin-bottom: 1rem; letter-spacing: 0.05em;
}
.section-hint { color: var(--muted); font-style: italic; font-size: 0.9rem; margin-bottom: 1rem; margin-top: -0.5rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
label { font-size: 0.85rem; font-family: 'Cinzel', serif; letter-spacing: 0.04em; color: var(--ink-soft); }
input[type="text"], textarea {
  background: white; border: 1px solid var(--parch-deep);
  border-radius: var(--radius); padding: 0.6rem 0.8rem;
  font-family: 'Crimson Pro', Georgia, serif; font-size: 1rem; color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s; resize: vertical;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201,146,42,0.15);
}

/* AI character blocks */
.ai-char-block {
  background: #f9f4ee; border: 1px solid var(--parch-deep);
  border-left: 3px solid var(--ai-border);
  border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem;
}
.ai-char-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.ai-char-label { font-family: 'Cinzel', serif; font-size: 0.85rem; color: var(--muted); }
.btn-remove {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.8rem; padding: 0.2rem 0.5rem;
  border-radius: 3px; transition: color 0.2s;
}
.btn-remove:hover { color: var(--crimson); }
.btn-add-char {
  background: none; border: 2px dashed var(--parch-deep);
  color: var(--muted); cursor: pointer; width: 100%;
  padding: 0.7rem; border-radius: var(--radius);
  font-family: 'Cinzel', serif; font-size: 0.85rem; letter-spacing: 0.04em;
  transition: all 0.2s;
}
.btn-add-char:hover { border-color: var(--gold-dim); color: var(--gold-dim); }
.form-submit { text-align: center; padding: 1rem 0 2rem; }

/* ── Thread Layout ───────────────────────────────────────────────────────── */
.thread-header {
  background: linear-gradient(to bottom, #1a1008, #221508);
  border-bottom: 2px solid var(--gold-dim);
  padding: 2rem 0; margin: -2.5rem -2rem 2rem;
}
.thread-header-inner { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.back-link { color: var(--muted); font-size: 0.85rem; display: inline-block; margin-bottom: 0.5rem; }
.back-link:hover { color: var(--gold); }
.thread-title { font-family: 'Cinzel', serif; font-size: 2rem; color: var(--gold-light);
  letter-spacing: 0.05em; text-shadow: 0 2px 12px rgba(201,146,42,0.3); margin-bottom: 0.7rem; }
.thread-setting { color: var(--parch-dark); font-style: italic; font-size: 0.95rem;
  max-width: 700px; margin-bottom: 1rem; }
.thread-cast { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.cast-label { font-size: 0.8rem; color: var(--muted); font-family: 'Cinzel', serif; }
.cast-user, .cast-ai {
  font-size: 0.82rem; padding: 0.2rem 0.7rem; border-radius: 20px;
}
.cast-user { background: rgba(201,146,42,0.2); color: var(--gold-light); border: 1px solid var(--gold-dim); }
.cast-ai { background: rgba(100,150,180,0.2); color: #9ab5c8; border: 1px solid #4a7a9a; }
.cast-user em { font-style: italic; opacity: 0.75; }

.thread-layout { display: grid; grid-template-columns: 1fr 300px; gap: 2rem; align-items: start; }

/* ── Posts ───────────────────────────────────────────────────────────────── */
.post-list { display: flex; flex-direction: column; gap: 0; }
.post {
  display: flex; gap: 1rem; padding: 1.5rem;
  border-bottom: 1px solid var(--parch-deep);
  transition: background 0.2s;
}
.post-user { background: var(--user-tint); }
.post-ai { background: var(--ai-tint); }
.post:first-child { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.post:last-child { border-bottom: none; border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }

.post-avatar { flex-shrink: 0; }
.avatar-ring {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 1.1rem; font-weight: 700;
  border: 2px solid;
}
.ring-user { background: #f0e0c0; border-color: var(--gold-dim); color: var(--gold-dim); }
.ring-ai   { background: #d0e4f0; border-color: var(--ai-border); color: #4a7a9a; }

.post-body { flex: 1; min-width: 0; }
.post-meta { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.post-author { font-family: 'Cinzel', serif; font-size: 0.9rem; font-weight: 600; color: var(--ink); }
.post-role { color: var(--muted); font-style: italic; font-size: 0.82rem; }
.post-tag { font-size: 0.7rem; padding: 0.1rem 0.5rem; border-radius: 3px;
  font-family: 'Cinzel', serif; letter-spacing: 0.06em; text-transform: uppercase; }
.tag-user { background: rgba(201,146,42,0.15); color: var(--gold-dim); border: 1px solid rgba(201,146,42,0.3); }
.tag-ai   { background: rgba(100,150,180,0.15); color: #4a7a9a; border: 1px solid rgba(100,150,180,0.3); }
.post-num { margin-left: auto; color: var(--muted); font-size: 0.78rem; }
.post-content { color: var(--ink-soft); font-size: 1rem; line-height: 1.85; }

/* ── Reply Box ───────────────────────────────────────────────────────────── */
.reply-box {
  background: var(--parchment); border: 1px solid var(--parch-deep);
  border-top: 3px solid var(--gold-dim);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.2rem 1.5rem;
}
.reply-header { margin-bottom: 0.7rem; font-size: 0.85rem; color: var(--muted); }
.reply-header strong { color: var(--ink); }
.reply-box textarea { width: 100%; margin-bottom: 0.7rem; }
.reply-actions { display: flex; justify-content: flex-end; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.thread-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 70px;          /* clears the sticky site header */
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}
.sidebar-card {
  background: var(--parchment); border: 1px solid var(--parch-deep);
  border-top: 3px solid var(--gold-dim);
  border-radius: var(--radius); padding: 1.2rem;
  box-shadow: 0 2px 8px var(--shadow);
}
.sidebar-title { font-family: 'Cinzel', serif; font-size: 0.9rem; color: var(--gold-dim);
  letter-spacing: 0.05em; margin-bottom: 0.6rem; }
.sidebar-hint { color: var(--muted); font-size: 0.82rem; font-style: italic; margin-bottom: 1rem; }

.ai-trigger-card {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--parch-deep);
}
.ai-trigger-card:last-of-type { border-bottom: none; }
.trigger-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: #d0e4f0; border: 2px solid var(--ai-border); color: #4a7a9a;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-weight: 700; font-size: 0.9rem;
}
.trigger-info { flex: 1; min-width: 0; }
.trigger-name { font-family: 'Cinzel', serif; font-size: 0.82rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trigger-role { color: var(--muted); font-size: 0.75rem; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trigger-form { flex-shrink: 0; }
.btn-trigger {
  background: linear-gradient(135deg, #3a6a8a, #4a7a9a);
  color: white; border: none; cursor: pointer;
  padding: 0.3rem 0.8rem; border-radius: var(--radius);
  font-family: 'Cinzel', serif; font-size: 0.75rem; letter-spacing: 0.04em;
  transition: all 0.2s;
}
.btn-trigger:hover { background: linear-gradient(135deg, #4a7a9a, #5a8aaa); }

.sidebar-cast-detail .cast-detail-user,
.sidebar-cast-detail .cast-detail-ai {
  padding: 0.7rem 0; border-bottom: 1px solid var(--parch-deep);
}
.sidebar-cast-detail :last-child { border-bottom: none; }
.cast-name { font-family: 'Cinzel', serif; font-size: 0.85rem; color: var(--ink); }
/* ── Character bio edit ─────────────────────────────────────────────────── */
.cast-name-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.4rem;
}
.btn-edit-char {
  background: none; border: none; color: var(--muted);
  font-size: 0.85rem; cursor: pointer; padding: 0.1rem 0.3rem;
  border-radius: 3px; opacity: 0.3; line-height: 1;
  transition: opacity 0.2s, color 0.2s;
}
.cast-detail-ai:hover .btn-edit-char { opacity: 1; }
.btn-edit-char:hover { color: var(--gold-dim); }
.cast-personality {
  color: var(--muted); font-style: italic; font-size: 0.8rem;
  margin-top: 0.15rem;
}
.cast-edit-form {
  padding: 0.7rem 0 0.8rem;
  border-bottom: 1px solid var(--parch-deep);
  margin-bottom: 0.5rem;
}
.cast-edit-title {
  font-family: 'Cinzel', serif; font-size: 0.78rem;
  color: var(--gold-dim); letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
}
.cast-edit-field {
  display: flex; flex-direction: column; gap: 0.2rem;
  margin-bottom: 0.45rem;
}
.cast-edit-field label {
  font-size: 0.7rem; font-family: 'Cinzel', serif;
  color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase;
}
.cast-edit-field input,
.cast-edit-field textarea {
  font-size: 0.85rem; padding: 0.35rem 0.5rem;
  font-family: 'Crimson Pro', serif;
  border: 1px solid var(--parch-deep);
  border-radius: var(--radius); background: white;
  color: var(--ink); resize: vertical;
}
.cast-edit-field input:focus,
.cast-edit-field textarea:focus {
  outline: none; border-color: var(--gold-dim);
}
.cast-edit-actions {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem;
}
.cast-edit-status {
  font-size: 0.75rem; color: var(--muted); font-style: italic;
}

.cast-badge-you {
  font-size: 0.65rem; background: rgba(201,146,42,0.15); color: var(--gold-dim);
  padding: 0.1rem 0.4rem; border-radius: 3px; vertical-align: middle;
  margin-left: 0.3rem; letter-spacing: 0.04em;
}
.cast-role { color: var(--muted); font-style: italic; font-size: 0.8rem; }
.cast-desc { color: var(--ink-soft); font-size: 0.82rem; margin-top: 0.2rem; }

/* ── Loading Overlay ─────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(10,6,4,0.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.loading-box {
  background: var(--parchment); border: 2px solid var(--gold-dim);
  border-radius: var(--radius); padding: 2.5rem 3rem; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.loading-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--parch-deep);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-family: 'Cinzel', serif; color: var(--ink-soft); font-size: 0.95rem; letter-spacing: 0.04em; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center; padding: 1.5rem;
  color: #4a3a2a; font-size: 0.8rem; font-style: italic;
  border-top: 1px solid #2a1e12;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .thread-layout { grid-template-columns: 1fr; }
  .thread-sidebar { order: -1; }
  .form-row { grid-template-columns: 1fr; }
  .story-card { flex-direction: column; gap: 1rem; }
  .story-card-actions { flex-direction: row; padding-left: 0; }
}

/* ── Forum Quote Blocks ──────────────────────────────────────────────────── */
/* Lines wrapped in * * are rendered as styled quote blocks via JS */
.quote-block {
  display: block;
  margin: 0.7rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--gold-dim);
  background: rgba(201,146,42,0.07);
  color: var(--ink-soft);
  font-style: italic;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── Narrator Posts ──────────────────────────────────────────────────────── */
.post-narrator {
  background: linear-gradient(to right, #1a1410, #221a0e);
  border-left: 4px solid var(--gold);
}
.ring-narrator {
  background: #2a1e08; border-color: var(--gold);
  color: var(--gold); font-size: 1rem;
}
.tag-narrator {
  background: rgba(201,146,42,0.25); color: var(--gold-light);
  border: 1px solid var(--gold-dim);
}
.post-narrator .post-author { color: var(--gold-light); }
.post-narrator .post-content { color: var(--parch-dark); font-style: italic; }

/* ── GM Floating Button ──────────────────────────────────────────────────── */
.gm-fab {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 300;
  background: linear-gradient(135deg, #1a3a1a, #2a5a2a);
  border: 2px solid #4a8a4a; color: #a0d4a0;
  width: 58px; height: 58px; border-radius: 50%;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: all 0.2s;
}
.gm-fab:hover { background: linear-gradient(135deg, #2a5a2a, #3a7a3a); border-color: #6aaa6a; color: #c0f0c0; transform: scale(1.05); }
.gm-fab.active { background: linear-gradient(135deg, #3a7a3a, #4a9a4a); border-color: #8aca8a; }
.gm-fab-icon { font-size: 1.3rem; line-height: 1; }
.gm-fab-label { font-family: 'Cinzel', serif; font-size: 0.55rem; letter-spacing: 0.1em; }

/* ── GM Backdrop ─────────────────────────────────────────────────────────── */
.gm-backdrop {
  display: none; position: fixed; inset: 0; z-index: 290;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(2px);
}
.gm-backdrop.open { display: block; }

/* ── GM Panel ────────────────────────────────────────────────────────────── */
.gm-panel {
  position: fixed; top: 0; right: -420px; width: 400px; height: 100vh;
  z-index: 295; display: flex; flex-direction: column;
  background: #0d1a0d;
  border-left: 2px solid #4a8a4a;
  box-shadow: -6px 0 30px rgba(0,0,0,0.6);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.gm-panel.open { right: 0; }

.gm-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem;
  background: linear-gradient(to bottom, #0a120a, #0d1a0d);
  border-bottom: 1px solid #2a4a2a;
  flex-shrink: 0;
}
.gm-panel-title {
  font-family: 'Cinzel', serif; font-size: 0.95rem;
  color: #8aca8a; letter-spacing: 0.06em; display: flex; align-items: center; gap: 0.5rem;
}
.gm-title-icon { color: #4a8a4a; }
.gm-close {
  background: none; border: none; color: #4a6a4a; cursor: pointer;
  font-size: 1rem; padding: 0.2rem 0.4rem; border-radius: 3px;
  transition: color 0.2s;
}
.gm-close:hover { color: #8aca8a; }

/* ── GM Tabs ─────────────────────────────────────────────────────────────── */
.gm-tabs {
  display: flex; border-bottom: 1px solid #2a4a2a; flex-shrink: 0;
}
.gm-tab {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 0.7rem; color: #4a7a4a;
  font-family: 'Cinzel', serif; font-size: 0.78rem; letter-spacing: 0.04em;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.gm-tab:hover { color: #8aca8a; background: rgba(74,138,74,0.1); }
.gm-tab.active { color: #8aca8a; border-bottom-color: #4a8a4a; background: rgba(74,138,74,0.08); }

/* ── GM Chat Tab ─────────────────────────────────────────────────────────── */
.gm-tab-content {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}

.gm-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.8rem;
  scrollbar-width: thin; scrollbar-color: #2a4a2a #0d1a0d;
}
.gm-welcome { color: #4a7a4a; font-style: italic; font-size: 0.88rem; line-height: 1.6; }
.gm-welcome p { margin-bottom: 0.5rem; }

.gm-msg { display: flex; flex-direction: column; gap: 0.25rem; }
.gm-msg-label { font-family: 'Cinzel', serif; font-size: 0.7rem; letter-spacing: 0.06em; }
.gm-msg-text { font-size: 0.9rem; line-height: 1.6; padding: 0.6rem 0.8rem; border-radius: var(--radius); }

.gm-msg-user .gm-msg-label { color: #6a9a6a; text-align: right; }
.gm-msg-user .gm-msg-text {
  background: #1a2e1a; color: #c0d8c0;
  border: 1px solid #2a4a2a; align-self: flex-end; max-width: 88%;
}
.gm-msg-assistant .gm-msg-label { color: #4a8a4a; }
.gm-msg-assistant .gm-msg-text {
  background: #0f1e0f; color: #a0c8a0;
  border: 1px solid #1a3a1a; max-width: 96%;
}

.gm-input-row {
  display: flex; gap: 0.5rem; padding: 0.8rem 1rem 0.4rem;
  border-top: 1px solid #1a3a1a; flex-shrink: 0;
}
.gm-input-row textarea {
  flex: 1; background: #0f1e0f; border: 1px solid #2a4a2a;
  color: #c0d8c0; border-radius: var(--radius); padding: 0.5rem 0.7rem;
  font-family: 'Crimson Pro', serif; font-size: 0.95rem; resize: none;
}
.gm-input-row textarea:focus { outline: none; border-color: #4a8a4a; }
.btn-gm-send {
  background: #1a4a1a; border: 1px solid #4a8a4a; color: #8aca8a;
  padding: 0.4rem 0.9rem; border-radius: var(--radius);
  font-family: 'Cinzel', serif; font-size: 0.75rem; cursor: pointer;
  transition: all 0.2s; align-self: flex-end;
}
.btn-gm-send:hover { background: #2a6a2a; }
.btn-gm-send:disabled { opacity: 0.5; cursor: not-allowed; }

.gm-chat-actions { padding: 0.3rem 1rem 0.8rem; flex-shrink: 0; }
.btn-gm-clear {
  background: none; border: none; color: #3a5a3a;
  font-size: 0.78rem; cursor: pointer; padding: 0;
  font-family: 'Crimson Pro', serif; font-style: italic;
  transition: color 0.2s;
}
.btn-gm-clear:hover { color: #6a9a6a; }

/* ── GM Inject Tab ───────────────────────────────────────────────────────── */
#tab-inject {
  padding: 1rem; gap: 0.8rem; flex-direction: column;
}
.gm-inject-info {
  color: #4a7a4a; font-size: 0.88rem; line-height: 1.6;
  background: #0a120a; padding: 0.8rem; border-radius: var(--radius);
  border: 1px solid #1a3a1a;
}
.gm-inject-info strong { color: #8aca8a; }
#gm-directive {
  background: #0f1e0f; border: 1px solid #2a4a2a; color: #c0d8c0;
  border-radius: var(--radius); padding: 0.7rem;
  font-family: 'Crimson Pro', serif; font-size: 1rem; resize: vertical;
  width: 100%;
}
#gm-directive:focus { outline: none; border-color: #4a8a4a; }
.btn-gm-inject {
  background: linear-gradient(135deg, #1a4a1a, #2a6a2a);
  border: 1px solid #4a8a4a; color: #a0d4a0;
  padding: 0.7rem; border-radius: var(--radius); cursor: pointer;
  font-family: 'Cinzel', serif; font-size: 0.85rem; letter-spacing: 0.05em;
  transition: all 0.2s; width: 100%;
}
.btn-gm-inject:hover { background: linear-gradient(135deg, #2a6a2a, #3a8a3a); }
.btn-gm-inject:disabled { opacity: 0.5; cursor: not-allowed; }

.inject-status { font-size: 0.85rem; font-style: italic; min-height: 1.2rem; }
.inject-pending { color: #6a9a6a; }
.inject-success { color: #8aca8a; }
.inject-error   { color: #aa4a4a; }

/* ── Responsive GM ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .gm-panel { width: 100vw; right: -100vw; }
}

/* ── Narrator Posts ──────────────────────────────────────────────────────── */
.post-narrator {
  background: linear-gradient(to right, #1a1408, #1e1a0e);
  border-left: 4px solid var(--gold-dim);
}
.ring-narrator {
  background: #2a1e08;
  border-color: var(--gold);
  color: var(--gold);
  font-size: 1rem;
}
.tag-narrator {
  background: rgba(201,146,42,0.2);
  color: var(--gold-light);
  border: 1px solid var(--gold-dim);
}
.post-narrator .post-author { color: var(--gold-light); font-style: italic; }
.post-narrator .post-content { color: var(--parch-dark); font-style: italic; line-height: 1.9; }

/* ── GM Floating Action Button ───────────────────────────────────────────── */
.gm-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 300;
  background: linear-gradient(135deg, #1a2a3a, #243545);
  border: 2px solid #4a7a9a;
  color: #9ab5c8;
  border-radius: 50px;
  padding: 0.7rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: all 0.25s;
}
.gm-fab:hover { background: linear-gradient(135deg, #243545, #2e4055); border-color: #6a9ab8; color: #c0d8e8; transform: translateY(-2px); }
.gm-fab-active { background: linear-gradient(135deg, #2e4055, #3a5070) !important; border-color: var(--gold-dim) !important; color: var(--gold-light) !important; }
.gm-fab-icon { font-size: 1rem; }

/* ── GM Overlay ──────────────────────────────────────────────────────────── */
.gm-overlay { display: none; position: fixed; inset: 0; z-index: 310; background: rgba(0,0,0,0); transition: background 0.3s; }
.gm-overlay-open { display: block; background: rgba(0,0,0,0.4); }

/* ── GM Sidebar Panel ────────────────────────────────────────────────────── */
.gm-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  z-index: 320;
  background: #0f1318;
  border-left: 2px solid #4a7a9a;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 32px rgba(0,0,0,0.6);
}
.gm-panel-open { transform: translateX(0); }

.gm-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid #2a3a4a;
  background: #0a0f14;
  flex-shrink: 0;
}
.gm-panel-title {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  color: #9ab5c8;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.gm-panel-icon { color: var(--gold-dim); }
.gm-panel-actions { display: flex; gap: 0.5rem; align-items: center; }
.gm-btn-clear {
  background: none; border: 1px solid #2a3a4a; color: #6a8a9a;
  padding: 0.25rem 0.6rem; border-radius: 4px; cursor: pointer;
  font-size: 0.75rem; font-family: 'Cinzel', serif; transition: all 0.2s;
}
.gm-btn-clear:hover { border-color: var(--gold-dim); color: var(--gold-dim); }
.gm-btn-close {
  background: none; border: none; color: #6a8a9a;
  font-size: 1.1rem; cursor: pointer; padding: 0.2rem 0.4rem;
  transition: color 0.2s; line-height: 1;
}
.gm-btn-close:hover { color: var(--crimson); }

/* ── GM Tabs ─────────────────────────────────────────────────────────────── */
.gm-tabs {
  display: flex;
  border-bottom: 1px solid #2a3a4a;
  flex-shrink: 0;
}
.gm-tab {
  flex: 1; background: none; border: none;
  padding: 0.7rem; cursor: pointer;
  font-family: 'Cinzel', serif; font-size: 0.78rem;
  letter-spacing: 0.05em; color: #6a8a9a;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.gm-tab:hover { color: #9ab5c8; }
.gm-tab.active { color: #9ab5c8; border-bottom-color: #4a7a9a; background: rgba(74,122,154,0.08); }

/* ── GM Tab Content ──────────────────────────────────────────────────────── */
.gm-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

/* Chat tab */
#tab-chat {
  display: flex;
  flex-direction: column;
}
.gm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.gm-empty { color: #4a6a7a; font-style: italic; font-size: 0.88rem; text-align: center; padding: 1rem; }
.gm-msg {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 92%;
  white-space: pre-wrap;
}
.gm-msg-user {
  background: #1a2a3a;
  color: #c0d8e8;
  border: 1px solid #2a4a5a;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.gm-msg-assistant {
  background: #12191f;
  color: #9ab5c8;
  border: 1px solid #1e2e3a;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.gm-msg-thinking {
  background: #0f1a22;
  color: #4a6a7a;
  font-style: italic;
  border: 1px dashed #1e2e3a;
  align-self: flex-start;
  font-size: 0.82rem;
}
.gm-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem;
  border-top: 1px solid #1e2e3a;
  flex-shrink: 0;
  background: #0a0f14;
}
.gm-input-row textarea {
  flex: 1;
  background: #12191f;
  border: 1px solid #2a3a4a;
  border-radius: 6px;
  color: #c0d8e8;
  font-family: 'Crimson Pro', serif;
  font-size: 0.95rem;
  padding: 0.5rem 0.7rem;
  resize: none;
  min-height: 42px;
}
.gm-input-row textarea:focus { outline: none; border-color: #4a7a9a; }
.btn-gm-send {
  background: linear-gradient(135deg, #1a3a5a, #2a4a6a);
  border: 1px solid #4a7a9a;
  color: #9ab5c8;
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  transition: all 0.2s;
  align-self: flex-end;
}
.btn-gm-send:hover { background: linear-gradient(135deg, #2a4a6a, #3a5a7a); color: #c0d8e8; }

/* Inject tab */
#tab-inject {
  flex-direction: column;
  padding: 1rem;
  gap: 0.6rem;
}
.gm-inject-hint { color: #6a8a9a; font-size: 0.85rem; line-height: 1.5; font-style: italic; }
.gm-inject-hint strong { color: var(--gold-dim); }
#tab-inject textarea {
  background: #12191f;
  border: 1px solid #2a3a4a;
  border-radius: 6px;
  color: #c0d8e8;
  font-family: 'Crimson Pro', serif;
  font-size: 0.95rem;
  padding: 0.6rem 0.8rem;
  resize: vertical;
  min-height: 120px;
}
#tab-inject textarea:focus { outline: none; border-color: #4a7a9a; }
.inject-preview {
  background: #0a0f14;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 0.8rem;
  color: var(--parch-dark);
  font-style: italic;
  font-size: 0.88rem;
  line-height: 1.7;
  margin-top: 0.5rem;
}

/* ── Responsive GM ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .gm-panel { width: 100%; border-left: none; border-top: 2px solid #4a7a9a; top: auto; height: 70vh; transform: translateY(100%); }
  .gm-panel-open { transform: translateY(0); }
  .gm-fab { bottom: 1.2rem; right: 1.2rem; }
}

/* ── Scroll To Top Button ─────────────────────────────────────────────────── */
.scroll-top-btn {
  position: fixed;
  bottom: 5.5rem;       /* sits above the GM fab */
  right: 2rem;
  z-index: 299;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  border: none;
  color: var(--parchment);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}
.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.scroll-top-btn:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--ink);
}

/* ── Mobile: unstick sidebar on small screens ─────────────────────────────── */
@media (max-width: 768px) {
  .thread-sidebar {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .scroll-top-btn { bottom: 7rem; right: 1.2rem; }
}

/* ── Add Character Sidebar Form ──────────────────────────────────────────── */
.add-char-toggle { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--parch-deep); }
.btn-add-char-sidebar {
  background: none; border: 1px dashed var(--parch-deep); color: var(--muted);
  width: 100%; padding: 0.45rem; border-radius: var(--radius);
  font-family: 'Cinzel', serif; font-size: 0.78rem; letter-spacing: 0.04em;
  cursor: pointer; transition: all 0.2s;
}
.btn-add-char-sidebar:hover { border-color: var(--gold-dim); color: var(--gold-dim); }
.add-char-form { margin-top: 0.8rem; border-top: 1px solid var(--parch-deep); padding-top: 0.8rem; }
.add-char-form-title { font-family: 'Cinzel', serif; font-size: 0.8rem; color: var(--gold-dim);
  margin-bottom: 0.6rem; letter-spacing: 0.04em; }
.add-char-field { display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 0.5rem; }
.add-char-field label { font-size: 0.72rem; font-family: 'Cinzel', serif; color: var(--muted); }
.add-char-field input, .add-char-field textarea {
  font-size: 0.88rem; padding: 0.35rem 0.5rem;
}
.add-char-form-hint { font-size: 0.78rem; color: var(--muted); font-style: italic; margin: 0.4rem 0; }
.add-char-form-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }

/* ── Post As Selector ────────────────────────────────────────────────────── */
.post-as-list { display: flex; flex-direction: column; gap: 0.3rem; }
.post-as-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.6rem; border-radius: var(--radius);
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s;
}
.post-as-item:hover { background: var(--parch-dark); border-color: var(--parch-deep); }
.post-as-active { background: rgba(201,146,42,0.1) !important; border-color: var(--gold-dim) !important; }
.post-as-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 0.75rem; font-weight: 700;
  border: 2px solid;
}
.post-as-name { font-size: 0.85rem; color: var(--ink); }
.post-as-name em { color: var(--muted); font-size: 0.78rem; }

/* ── Branch Buttons on Posts ─────────────────────────────────────────────── */
.post-branch-wrap { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.btn-branch-trigger {
  background: none; border: none; color: var(--muted);
  font-size: 0.75rem; cursor: pointer; padding: 0.1rem 0.4rem;
  border-radius: 3px; transition: color 0.2s; font-family: 'Cinzel', serif;
  letter-spacing: 0.03em; opacity: 0; transition: opacity 0.2s;
}
.post:hover .btn-branch-trigger { opacity: 1; }
.btn-branch-trigger:hover { color: var(--gold); }
.branch-form { display: none; align-items: center; gap: 0.4rem; }
.inline-branch-form { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.branch-title-input {
  font-size: 0.8rem; padding: 0.25rem 0.5rem;
  border: 1px solid var(--parch-deep); border-radius: var(--radius);
  font-family: 'Crimson Pro', serif; width: 160px;
}
.btn-branch-confirm {
  background: var(--gold-dim); color: var(--parchment); border: none;
  padding: 0.25rem 0.6rem; border-radius: var(--radius);
  font-family: 'Cinzel', serif; font-size: 0.72rem; cursor: pointer;
  transition: background 0.2s;
}
.btn-branch-confirm:hover { background: var(--gold); }
.btn-branch-cancel {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.9rem; padding: 0 0.3rem;
}

/* ── Branch Display ──────────────────────────────────────────────────────── */
.branch-origin { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.3rem; }
.branch-origin a { color: var(--gold-dim); }
.branch-list-header { margin-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.branch-list-label { font-size: 0.78rem; color: var(--muted); font-family: 'Cinzel', serif; }
.branch-pill {
  font-size: 0.75rem; padding: 0.15rem 0.6rem; border-radius: 20px;
  background: rgba(201,146,42,0.1); color: var(--gold-dim);
  border: 1px solid var(--gold-dim); text-decoration: none;
  transition: background 0.2s;
}
.branch-pill:hover { background: rgba(201,146,42,0.2); text-decoration: none; }
.branch-group { margin-left: 2rem; margin-top: -0.5rem; margin-bottom: 0.5rem; border-left: 2px solid var(--gold-dim); padding-left: 1rem; }
.story-card-branch { border-left-color: #6a8a5a; opacity: 0.92; }
.branch-tag { font-size: 0.72rem; font-family: 'Cinzel', serif; letter-spacing: 0.06em;
  padding: 0.15rem 0.55rem; border-radius: 3px; text-transform: uppercase;
  background: rgba(100,140,80,0.15); color: #5a7a4a; border: 1px solid #8aaa7a; }
.branch-point-preview { font-size: 0.85rem; color: var(--muted); font-style: italic; }

/* ── Delete Post Button ───────────────────────────────────────────────────── */
.delete-post-form { display: inline-flex; }
.btn-delete-post {
  background: none; border: 1px solid transparent; color: var(--muted);
  font-size: 0.78rem; cursor: pointer; padding: 0.1rem 0.35rem;
  border-radius: 3px; line-height: 1; opacity: 0.25;
  transition: opacity 0.2s, color 0.2s, background 0.2s, border-color 0.2s;
}
.post:hover .btn-delete-post { opacity: 1; border-color: #c4a0a0; }
.btn-delete-post:hover { color: var(--parchment); background: var(--crimson); border-color: var(--crimson); }

/* ── New Branch Banner ────────────────────────────────────────────────────── */
.new-branch-banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: linear-gradient(135deg, #1a2410, #1e2a12);
  border: 1px solid #4a7a3a;
  border-left: 4px solid #6aaa4a;
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.8rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  animation: branchFadeIn 0.5s ease;
}
@keyframes branchFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.new-branch-icon {
  font-size: 1.8rem;
  color: #6aaa4a;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.new-branch-title {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: #a0d080;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}
.new-branch-title strong { color: #c0e8a0; }
.new-branch-hint {
  font-size: 0.9rem;
  color: #6a8a5a;
  font-style: italic;
  line-height: 1.5;
}
.new-branch-hint a { color: #8aaa6a; }
.new-branch-hint a:hover { color: #a0cc80; }

/* ── Branch carry-last checkbox ──────────────────────────────────────────── */
.carry-last-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: 'Cinzel', serif;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  white-space: nowrap;
}
.carry-last-label input { cursor: pointer; accent-color: var(--gold-dim); }

/* ── Export Buttons ──────────────────────────────────────────────────────── */
.thread-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.thread-header-top .thread-title {
  margin-bottom: 0;
  flex: 1;
}
.thread-header-top-buttons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding-top: 0.4rem;
}
.btn-export {
  display: inline-block;
  background: none;
  border: 1px solid var(--gold-dim);
  color: var(--gold-dim);
  padding: 0.3rem 0.9rem;
  border-radius: var(--radius);
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-export:hover {
  background: rgba(201,146,42,0.12);
  color: var(--gold-light);
  text-decoration: none;
}
.btn-export-prose {
  background: rgba(201,146,42,0.06) !important;
  border-color: var(--gold-dim) !important;
  color: var(--gold-dim) !important;
  margin-left: 0.4rem;
}
.btn-export-prose:hover {
  background: rgba(201,146,42,0.18) !important;
  color: var(--gold-light) !important;
}

/* ── Landing Page ────────────────────────────────────────────────────────── */
.landing-body { display: flex; flex-direction: column; min-height: 100vh; }
.landing-wrap {
  max-width: 860px; margin: 0 auto; padding: 4rem 2rem 3rem;
  flex: 1; display: flex; flex-direction: column; gap: 3rem;
}
.landing-hero { text-align: center; }
.landing-symbol { font-size: 3rem; color: var(--gold); margin-bottom: 0.5rem;
  text-shadow: 0 0 30px rgba(201,146,42,0.5); }
.landing-title {
  font-family: 'Cinzel', serif; font-size: 3.5rem; color: var(--gold-light);
  letter-spacing: 0.08em; text-shadow: 0 2px 20px rgba(201,146,42,0.4);
  margin-bottom: 0.3rem;
}
.landing-tagline {
  font-family: 'Cinzel', serif; font-size: 1rem; color: var(--muted);
  letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 1.5rem;
}
.landing-desc {
  color: var(--parch-dark); font-size: 1.1rem; line-height: 1.8;
  max-width: 600px; margin: 0 auto; font-style: italic;
}
.landing-features {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem;
}
.landing-feature {
  background: rgba(245,237,224,0.06); border: 1px solid rgba(201,146,42,0.2);
  border-top: 3px solid var(--gold-dim); border-radius: var(--radius);
  padding: 1.5rem; text-align: center;
}
.lf-icon { font-size: 1.8rem; margin-bottom: 0.6rem; filter: drop-shadow(0 0 6px rgba(201,146,42,0.4)); }
.lf-title { font-family: 'Cinzel', serif; font-size: 0.9rem; color: var(--gold-light);
  letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.lf-desc { color: var(--muted); font-size: 0.88rem; line-height: 1.6; font-style: italic; }
.landing-gate {
  background: var(--parchment); border: 1px solid var(--parch-deep);
  border-top: 3px solid var(--gold-dim); border-radius: var(--radius);
  padding: 2.5rem; text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.landing-gate-title {
  font-family: 'Cinzel', serif; font-size: 1.3rem; color: var(--gold-dim);
  letter-spacing: 0.06em; margin-bottom: 0.5rem;
}
.landing-gate-desc { color: var(--muted); font-style: italic; margin-bottom: 1.5rem; }
.landing-code-form { display: flex; gap: 0.8rem; justify-content: center;
  align-items: center; flex-wrap: wrap; margin-bottom: 1.2rem; }
.landing-code-input {
  font-family: 'Cinzel', serif; font-size: 1.2rem; letter-spacing: 0.15em;
  text-align: center; text-transform: uppercase;
  width: 220px; padding: 0.7rem 1rem;
  border: 2px solid var(--parch-deep); border-radius: var(--radius);
  background: white; color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.landing-code-input:focus {
  outline: none; border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201,146,42,0.15);
}
.landing-login-hint { font-size: 0.88rem; color: var(--muted); }
.landing-login-hint a { color: var(--gold-dim); }

@media (max-width: 600px) {
  .landing-features { grid-template-columns: 1fr; }
  .landing-title { font-size: 2.5rem; }
}

/* ── Admin Panel ─────────────────────────────────────────────────────────── */
.btn-nav-admin {
  background: linear-gradient(135deg, #1a3a1a, #2a5a2a) !important;
  border: 1px solid #4a8a4a !important; color: #a0d4a0 !important;
}
.btn-nav-admin:hover { background: linear-gradient(135deg, #2a5a2a, #3a7a3a) !important; }
.admin-section {
  background: var(--parchment); border: 1px solid var(--parch-deep);
  border-top: 3px solid var(--gold-dim); border-radius: var(--radius);
  padding: 1.8rem; margin-bottom: 2rem;
  box-shadow: 0 2px 10px var(--shadow);
}
.admin-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.2rem; padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--parch-deep);
}
.admin-section-title { font-family: 'Cinzel', serif; font-size: 1.1rem; color: var(--gold-dim); }
.admin-stat { font-size: 0.85rem; color: var(--muted); font-style: italic; }
.admin-generate { margin-bottom: 1.2rem; }
.admin-generate-form { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.admin-generate-label { font-family: 'Cinzel', serif; font-size: 0.85rem; color: var(--ink-soft); }
.admin-select {
  padding: 0.4rem 0.7rem; border: 1px solid var(--parch-deep);
  border-radius: var(--radius); font-family: 'Crimson Pro', serif;
  font-size: 0.95rem; background: white; color: var(--ink);
}
.admin-code-block {
  border: 1px solid var(--parch-deep); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 1rem;
}
.admin-code-block-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 1rem; background: var(--parch-dark);
  font-family: 'Cinzel', serif; font-size: 0.82rem; color: var(--ink-soft);
}
.btn-copy-codes {
  background: none; border: 1px solid var(--parch-deep); color: var(--ink-soft);
  padding: 0.2rem 0.6rem; border-radius: 3px; cursor: pointer;
  font-size: 0.78rem; transition: all 0.2s;
}
.btn-copy-codes:hover { border-color: var(--gold-dim); color: var(--gold-dim); }
.admin-code-list {
  max-height: 280px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.admin-code-list-used { grid-template-columns: 1fr; }
.admin-code-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.8rem; border-bottom: 1px solid var(--parch-deep);
}
.admin-code-row:last-child { border-bottom: none; }
.admin-code-text {
  font-family: 'Cinzel', serif; font-size: 0.85rem; letter-spacing: 0.08em;
  color: var(--ink); flex: 1;
}
.admin-code-used { color: var(--muted); text-decoration: line-through; }
.admin-code-usedby { font-size: 0.8rem; color: var(--muted); font-style: italic; flex: 1; }
.admin-code-date { font-size: 0.78rem; color: var(--muted); }
.admin-code-delete { display: flex; }
.admin-used-codes {
  margin-top: 0.8rem;
  border: 1px solid var(--parch-deep); border-radius: var(--radius); overflow: hidden;
}
.admin-used-codes summary {
  padding: 0.6rem 1rem; cursor: pointer; font-family: 'Cinzel', serif;
  font-size: 0.82rem; color: var(--muted); background: var(--parch-dark);
  list-style: none;
}
.admin-used-codes summary:hover { color: var(--ink-soft); }
.admin-user-list { display: flex; flex-direction: column; gap: 0; }
.admin-user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 0; border-bottom: 1px solid var(--parch-deep); gap: 1rem;
  flex-wrap: wrap;
}
.admin-user-row:last-child { border-bottom: none; }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-email { font-family: 'Cinzel', serif; font-size: 0.9rem; color: var(--ink);
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.admin-user-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; font-style: italic; }
.admin-user-meta code { font-family: 'Cinzel', serif; font-size: 0.78rem;
  background: rgba(201,146,42,0.1); padding: 0.1rem 0.4rem; border-radius: 3px; }
.admin-badge {
  font-size: 0.65rem; padding: 0.1rem 0.45rem; border-radius: 3px;
  font-family: 'Cinzel', serif; letter-spacing: 0.05em;
  background: rgba(74,138,74,0.15); color: #3a7a3a; border: 1px solid #8aaa7a;
}
.admin-badge-you { background: rgba(201,146,42,0.15); color: var(--gold-dim);
  border-color: var(--gold-dim); }
.admin-user-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.btn-admin-action {
  background: none; border: 1px solid var(--parch-deep); color: var(--ink-soft);
  padding: 0.3rem 0.7rem; border-radius: var(--radius);
  font-size: 0.78rem; font-family: 'Cinzel', serif; cursor: pointer;
  transition: all 0.2s; letter-spacing: 0.03em;
}
.btn-admin-action:hover { border-color: var(--gold-dim); color: var(--gold-dim); }
.admin-inline-form summary { list-style: none; }
.admin-inline-form summary::-webkit-details-marker { display: none; }
.admin-pw-form { display: flex; gap: 0.4rem; margin-top: 0.5rem; align-items: center; }
.admin-pw-input {
  font-size: 0.88rem; padding: 0.3rem 0.5rem;
  border: 1px solid var(--parch-deep); border-radius: var(--radius);
  font-family: 'Crimson Pro', serif; width: 200px;
}

/* ── Auth Pages ───────────────────────────────────────────────────────────── */
.auth-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 70vh; padding: 2rem;
}
.auth-card {
  background: var(--parchment);
  border: 1px solid var(--parch-deep);
  border-top: 3px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 2.5rem 2.5rem 2rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  text-align: center;
}
.auth-logo { font-size: 2rem; color: var(--gold); margin-bottom: 0.3rem; }
.auth-title { font-family: 'Cinzel', serif; font-size: 1.6rem; color: var(--gold-light);
  letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.auth-sub { color: var(--muted); font-style: italic; margin-bottom: 1.5rem; font-size: 0.95rem; }
.auth-form { text-align: left; }
.auth-form .form-group { margin-bottom: 1rem; }
.auth-remember { display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem; color: var(--muted); margin-bottom: 1.2rem; cursor: pointer; }
.auth-footer { margin-top: 1.2rem; font-size: 0.88rem; color: var(--muted); }
.auth-footer a { color: var(--gold-dim); }
.auth-flash {
  padding: 0.6rem 0.9rem; border-radius: var(--radius);
  font-size: 0.88rem; margin-bottom: 1rem; text-align: left;
}
.auth-flash-error { background: #fde8e8; border: 1px solid #e0a0a0; color: var(--crimson); }
.auth-flash-success { background: #e8f5e8; border: 1px solid #a0c0a0; color: #3a6a3a; }

/* ── Nav user info ────────────────────────────────────────────────────────── */
.nav-user { color: var(--parch-deep); font-size: 0.82rem; font-style: italic; }
.nav-logout { color: var(--muted) !important; font-size: 0.85rem; }
.nav-logout:hover { color: var(--crimson) !important; }

/* ── Story status colors ─────────────────────────────────────────────────── */
.status-on_hold  { background: #fff3cd; color: #856404; border: 1px solid #ffe08a; }
.status-complete { background: #cce5ff; color: #004085; border: 1px solid #99caff; }
.status-archived { background: #e8e8e8; color: #5a5a5a; border: 1px solid #c0c0c0; }
.story-status-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.6rem; }
.story-status-select {
  font-family: 'Cinzel', serif; font-size: 0.78rem; letter-spacing: 0.04em;
  padding: 0.3rem 0.7rem; border-radius: var(--radius);
  border: 1px solid var(--gold-dim); background: rgba(201,146,42,0.08);
  color: var(--gold-light); cursor: pointer; transition: all 0.2s;
}
.story-status-select:focus { outline: none; border-color: var(--gold); }
.status-sel-active   { background: rgba(39,96,64,0.15)  !important; border-color: #4a8a5a !important; color: #a0d4a0 !important; }
.status-sel-on_hold  { background: rgba(133,100,4,0.15) !important; border-color: #c0a020 !important; color: #e8d080 !important; }
.status-sel-complete { background: rgba(0,64,133,0.15)  !important; border-color: #4a7aaa !important; color: #90c0e8 !important; }
.status-sel-archived { background: rgba(90,90,90,0.15)  !important; border-color: #808080 !important; color: #b0b0b0 !important; }
.status-save-msg { font-size: 0.75rem; color: var(--gold-dim); font-style: italic; min-height: 1rem; }

/* ── Character style panel ───────────────────────────────────────────────── */
.char-style-panel { padding: 0.6rem 0 0.8rem; border-bottom: 1px solid var(--parch-deep); margin-bottom: 0.3rem; }
.char-style-row { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.5rem; }
.char-style-label { font-family: 'Cinzel', serif; font-size: 0.7rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.char-tone-wrap { display: flex; align-items: center; gap: 0.4rem; }
.char-tone-min, .char-tone-max { font-size: 0.68rem; color: var(--muted); font-style: italic; white-space: nowrap; }
.char-tone-slider { flex: 1; accent-color: var(--gold-dim); cursor: pointer; height: 4px; }
.char-tone-label { font-size: 0.72rem; color: var(--gold-dim); font-family: 'Cinzel', serif; min-width: 70px; text-align: right; letter-spacing: 0.03em; }
.char-style-note { width: 100%; font-size: 0.82rem; font-family: 'Crimson Pro', serif; background: white; border: 1px solid var(--parch-deep); border-radius: var(--radius); padding: 0.35rem 0.5rem; resize: vertical; color: var(--ink); line-height: 1.5; }
.char-style-note:focus { outline: none; border-color: var(--gold-dim); }
.char-style-save-msg { font-size: 0.72rem; color: var(--gold-dim); font-style: italic; min-height: 0.9rem; text-align: right; }

/* ── Post edit textarea ──────────────────────────────────────────────────── */
.post-editor { width: 100%; margin-top: 0.5rem; }
.post-edit-textarea {
  width: 100%; min-height: 160px;
  font-family: 'Crimson Pro', Georgia, serif; font-size: 1rem; line-height: 1.85;
  color: var(--ink); background: white; border: 1px solid var(--gold-dim);
  border-radius: var(--radius); padding: 0.7rem 0.9rem; resize: vertical;
  box-shadow: 0 0 0 3px rgba(201,146,42,0.1); box-sizing: border-box;
}
.post-edit-textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,146,42,0.2); }
.post-edit-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.5rem; }
.post-edit-status { font-size: 0.8rem; color: var(--muted); font-style: italic; }

/* ── Draft badge ─────────────────────────────────────────────────────────── */
.draft-badge { margin-left: auto; font-size: 0.75rem; color: var(--gold-dim); font-style: italic; opacity: 0.75; }

/* ── AI error banner ─────────────────────────────────────────────────────── */
.ai-error-banner {
  background: #3a1010; border: 1px solid #8b2020; border-left: 4px solid var(--crimson);
  color: #e8a0a0; border-radius: var(--radius); padding: 0.9rem 1.3rem;
  margin-bottom: 1.5rem; font-size: 0.92rem;
}

/* ── EPUB modal ──────────────────────────────────────────────────────────── */
.epub-modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.epub-modal {
  background: var(--parchment); border: 1px solid var(--parch-deep);
  border-top: 3px solid var(--gold-dim); border-radius: var(--radius);
  width: 100%; max-width: 480px; box-shadow: 0 12px 48px rgba(0,0,0,0.6); overflow: hidden;
}
.epub-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; background: linear-gradient(to bottom, #f0e8d8, var(--parchment));
  border-bottom: 1px solid var(--parch-deep);
}
.epub-modal-title { font-family: 'Cinzel', serif; font-size: 0.95rem; color: var(--gold-dim); letter-spacing: 0.05em; }
.epub-modal-body { padding: 1.3rem; }
.epub-modal-desc { font-size: 0.88rem; color: var(--ink-soft); font-style: italic; line-height: 1.6; margin-bottom: 1.2rem; }
.epub-cover-section { display: flex; flex-direction: column; gap: 0.5rem; }
.epub-cover-label { font-family: 'Cinzel', serif; font-size: 0.82rem; color: var(--ink-soft); letter-spacing: 0.04em; }
.epub-optional { font-family: 'Crimson Pro', serif; font-weight: 300; font-style: italic; color: var(--muted); font-size: 0.85em; }
.epub-cover-hint { font-size: 0.8rem; color: var(--muted); line-height: 1.5; font-style: italic; background: rgba(201,146,42,0.06); border: 1px solid rgba(201,146,42,0.15); border-radius: var(--radius); padding: 0.5rem 0.7rem; }
.epub-cover-hint strong { color: var(--ink-soft); font-style: normal; }
.epub-cover-upload { border: 2px dashed var(--parch-deep); border-radius: var(--radius); padding: 1.5rem 1rem; text-align: center; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; transition: all 0.2s; }
.epub-cover-upload:hover { border-color: var(--gold-dim); background: rgba(201,146,42,0.04); }
.epub-cover-upload-icon { font-size: 1.8rem; }
.epub-cover-upload-text { font-size: 0.88rem; color: var(--ink-soft); }
.epub-cover-upload-sub { font-size: 0.75rem; color: var(--muted); font-style: italic; }
.epub-cover-preview { display: flex; align-items: center; gap: 1rem; padding: 0.6rem; border: 1px solid var(--parch-deep); border-radius: var(--radius); background: white; }
.epub-cover-preview img { width: 60px; height: 90px; object-fit: cover; border-radius: 3px; border: 1px solid var(--parch-deep); }
.epub-cover-remove { background: none; border: 1px solid var(--crimson); color: var(--crimson); padding: 0.25rem 0.6rem; border-radius: 3px; cursor: pointer; font-size: 0.75rem; transition: all 0.2s; margin-left: auto; }
.epub-cover-remove:hover { background: var(--crimson); color: white; }

/* ── Lorebook button ─────────────────────────────────────────────────────── */
.btn-lorebook {
  background: rgba(120,80,160,0.12) !important;
  border-color: #8a64aa !important;
  color: #c0a0e0 !important;
  margin-right: 0.4rem;
}
.btn-lorebook:hover {
  background: rgba(120,80,160,0.25) !important;
  color: #d8c0f0 !important;
  text-decoration: none !important;
}
