:root {
  --bg: #0b0b0f;
  --surface: #17181c;
  --surface-2: #1f2127;
  --line: #2a2d35;
  --text: #f3f4f6;
  --muted: #9aa0ac;
  --blurple: #5865f2;
  --blurple-hi: #6f7bf7;
  --danger: #f0616d;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
/* Reserva sempre o espaço da barra de rolagem, então a largura útil não muda
   entre uma aba com scroll e outra sem — sem "pulo" horizontal do conteúdo. */
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg); /* flat — o brilho radial atrás da timeline ficava estranho */
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.hidden { display: none !important; }

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.muted { color: var(--muted); margin: 0; font-size: 0.95rem; }

.glyph {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--blurple), #3b45c9);
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 8px 24px rgba(88, 101, 242, 0.45);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 24px;
  padding: 13px 18px;
  border: none;
  border-radius: 12px;
  background: var(--blurple);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover { background: var(--blurple-hi); }
.btn:active { transform: translateY(1px); }

.btn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.badge {
  display: inline-block;
  margin-bottom: 16px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(88, 101, 242, 0.15);
  color: var(--blurple-hi);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.glyph-muted {
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: none;
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  margin: 0 auto 18px;
  display: block;
  object-fit: cover;
  background: var(--surface-2);
  border: 3px solid var(--blurple);
  box-shadow: 0 8px 24px rgba(88, 101, 242, 0.35);
}

#username { margin-top: 2px; font-variant-ligatures: none; }

.error {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(240, 97, 109, 0.12);
  color: var(--danger);
  font-size: 0.9rem;
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 8px auto;
  border: 3px solid var(--line);
  border-top-color: var(--blurple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .btn:active { transform: none; }
}

/* ------------------------------ top bar --------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(11, 11, 15, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 50;
}
.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
  opacity: 0.85;
}
.topbar-actions { display: flex; gap: 8px; }
.menu { position: relative; }

.iconbtn {
  position: relative;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.iconbtn:hover { color: var(--text); background: var(--surface-2); border-color: #3a3e48; }

.count {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border: 2px solid var(--bg);
}

/* ------------------------------ panels ---------------------------------- */
.panel {
  position: absolute;
  top: 52px; right: 0;
  width: 320px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.panel-head {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--line);
}
.panel-body { max-height: 380px; overflow-y: auto; }
.panel-empty { padding: 24px 16px; color: var(--muted); text-align: center; font-size: 0.9rem; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row-unread { background: rgba(88, 101, 242, 0.07); }
.row-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--surface-2); object-fit: cover; }
.row-info { flex: 1; min-width: 0; text-align: left; }
.row-name { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.row-link { color: var(--text); text-decoration: none; font-weight: 600; }
.row-link:hover { text-decoration: underline; }
.row-name a.row-name { text-decoration: none; }
.row-sub { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.row-btns { display: flex; gap: 6px; flex: none; }

.mini {
  padding: 6px 12px;
  border: none;
  border-radius: 9px;
  background: var(--blurple);
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.mini:hover { background: var(--blurple-hi); }
.mini-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.mini-ghost:hover { background: var(--surface-2); color: var(--text); }

/* --------------------------- profile actions ---------------------------- */
.actions-row { display: flex; gap: 10px; margin-top: 22px; }
.actions-row .btn { margin-top: 0; }
.btn-dim { opacity: 0.7; }

/* keep profile cards clear of the fixed top bar */
.stage { padding-top: 84px; }

/* ------------------------------ home feed -------------------------------- */
.home {
  width: 100%;
  max-width: 960px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
  align-self: start; /* pin the timeline to the top, don't vertically center it */
}
.timeline { min-width: 0; }

/* profile pinned to the right while the timeline scrolls */
.sidebar { position: sticky; top: 84px; }
.profile-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.avatar-sm {
  width: 72px; height: 72px;
  border-radius: 50%;
  margin: 0 auto 12px;
  display: block;
  object-fit: cover;
  background: var(--surface-2);
  border: 3px solid var(--blurple);
}
.pc-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.pc-handle { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.profile-card .btn { margin-top: 18px; }

@media (max-width: 720px) {
  .home { grid-template-columns: 1fr; }
  .sidebar { position: static; order: -1; }
}

.muted-sm { color: var(--muted); font-size: 0.8rem; }
.muted-sm.over { color: var(--danger); }

.composer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px 14px;
  margin-bottom: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer:focus-within {
  border-color: var(--blurple);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.18);
}
/* contenteditable input used by the composer and the inline editor */
.mention-box {
  width: 100%;
  min-height: 60px;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.mention-box:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

/* a mention rendered as one atomic, clickable pill inside the input */
.chip {
  display: inline-block;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(88, 101, 242, 0.18);
  color: var(--blurple-hi);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: all;
}
.chip:hover { background: rgba(88, 101, 242, 0.32); }

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
/* the Post button is a compact CTA, not a full-width bar */
.composer-foot .btn {
  width: auto;
  margin-top: 0;
  padding: 9px 22px;
  border-radius: 999px;
}
.composer-foot .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1;
  padding: 12px 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--blurple); }

.feed { display: flex; flex-direction: column; }
.feed-empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* "N new posts" bar — full-width, centered, sticks to the top while scrolling */
.new-posts {
  position: sticky;
  top: 76px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(rgba(88, 101, 242, 0.1), rgba(88, 101, 242, 0.1)),
    var(--surface);
  color: var(--blurple-hi);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
  animation: newPostsIn 0.25s ease;
}
.new-posts:hover {
  border-color: var(--blurple);
  background:
    linear-gradient(rgba(88, 101, 242, 0.18), rgba(88, 101, 242, 0.18)),
    var(--surface);
}
.new-posts:active { transform: translateY(1px); }

/* transform-only entrance — never animates opacity, so the bar can't get
   stuck invisible when it's toggled on/off. */
@keyframes newPostsIn {
  from { transform: translateY(-6px); }
  to   { transform: translateY(0); }
}

.np-avatars { display: inline-flex; }
.np-avatar {
  width: 25px; height: 25px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(88, 101, 242, 0.25);
}
.np-avatar + .np-avatar { margin-left: -10px; }

/* Merged status bar: [new posts | · | typing]. SEMPRE renderizada na feed com
   altura fixa — a timeline nunca pula quando algo aparece/some. Grid de colunas
   fixas: cada metade ancora em direção ao ponto central, então a posição do
   texto não se move conforme muda quem está digitando. A barra INTEIRA é
   clicável para atualizar quando há posts novos. */
.feed-bar {
  position: sticky;
  top: 76px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  margin: 0 0 12px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.feed-bar.is-idle { border-color: rgba(255, 255, 255, 0.05); background: rgba(255, 255, 255, 0.015); }
.feed-bar.has-new { cursor: pointer; background: linear-gradient(rgba(88, 101, 242, 0.08), rgba(88, 101, 242, 0.08)), var(--surface); }
.feed-bar.has-new:hover {
  border-color: var(--blurple);
  background: linear-gradient(rgba(88, 101, 242, 0.16), rgba(88, 101, 242, 0.16)), var(--surface);
}
.feed-bar-inner {
  display: inline-flex; align-items: center; gap: 10px;
  min-width: 0; overflow: hidden; white-space: nowrap;
  pointer-events: none; /* o clique é da barra inteira */
}
.feed-bar-label { overflow: hidden; text-overflow: ellipsis; }
/* Azul (convite a clicar) só quando há posts novos; só digitação fica neutro. */
.feed-bar.has-new .feed-bar-label { color: var(--blurple-hi); }
.feed-bar:not(.has-new) .feed-bar-label { color: var(--muted); }
.typing-label { font-weight: 600; }
/* Animated three dots */
.typing-dots { display: inline-flex; gap: 3px; align-items: flex-end; height: 1em; }
.typing-dots span {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; opacity: 0.35;
  animation: typingBlink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBlink {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .feed-bar { animation: none; }
  .typing-dots span { animation: none; opacity: 0.6; }
}

.post {
  display: flex;
  gap: 12px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line);
  position: relative; /* anchors the "…" menu */
}
.post-body { min-width: 0; flex: 1; }

/* Footer: votes + reply */
.post-footer { display: flex; align-items: center; gap: 18px; margin-top: 10px; }
.vote-group { display: inline-flex; align-items: center; gap: 6px; }
.vote-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: none; border: none; border-radius: 8px;
  color: var(--muted); cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.vote-btn svg, .foot-btn svg { display: block; flex: none; }
.vote-btn:hover { background: var(--surface-2); color: var(--text); }
.vote-up.voted { color: #3ba55d; background: rgba(59, 165, 93, 0.14); }
.vote-down.voted { color: var(--danger); background: rgba(240, 97, 109, 0.14); }
.vote-score { min-width: 14px; text-align: center; font-weight: 700; font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.vote-score.pos { color: #3ba55d; }
.vote-score.neg { color: var(--danger); }
.foot-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; font: inherit; font-size: 0.85rem; font-weight: 600;
  color: var(--muted); cursor: pointer; padding: 6px 8px; border-radius: 8px;
  transition: background 0.12s ease, color 0.12s ease;
}
.foot-btn:hover { background: var(--surface-2); color: var(--text); }

/* "…" menu (top-right of each post) */
.post-menu { position: absolute; top: 12px; right: 4px; }
.post-menu-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: none; border: none; border-radius: 8px;
  color: var(--muted); cursor: pointer;
}
.post-menu-btn:hover { background: var(--surface-2); color: var(--text); }
.post-menu-drop {
  position: absolute; top: 34px; right: 0; z-index: 30;
  min-width: 150px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.menu-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: none; border-radius: 8px;
  background: none; font: inherit; font-size: 0.9rem; font-weight: 600;
  color: var(--text); text-align: left; cursor: pointer;
}
.menu-row:hover { background: var(--surface-2); }
.menu-row.danger { color: var(--danger); }
.menu-row.danger:hover { background: rgba(240, 97, 109, 0.12); }
.menu-row svg { flex: none; color: var(--muted); }
.menu-row.danger svg { color: var(--danger); }

/* ----- "See replies" button ----- */
.see-replies { gap: 8px; }
.see-replies.hidden { display: none; }
.sr-avatars { display: inline-flex; align-items: center; }
.sr-icon { display: inline-flex; margin-right: 6px; }
.sr-avatar {
  width: 18px; height: 18px; border-radius: 50%;
  object-fit: cover; background: var(--surface-2);
  border: 2px solid var(--surface);
}
.sr-avatar + .sr-avatar { margin-left: -7px; }

/* ----- inline reply composer ----- */
.reply-box { display: flex; align-items: flex-end; gap: 8px; margin-top: 10px; }
.reply-box.hidden { display: none; }
.reply-input {
  flex: 1; min-height: 38px; max-height: 140px; overflow-y: auto;
  padding: 9px 12px; font-size: 0.9rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.reply-input:focus { outline: none; border-color: var(--blurple); }

/* ----- replies thread: compact rows, smaller type, no votes ----- */
.post-replies {
  margin-top: 10px; padding-left: 14px;
  border-left: 2px solid var(--line);
  display: flex; flex-direction: column;
}
.post-replies.hidden { display: none; }
.reply { display: flex; gap: 8px; padding: 6px 0; position: relative; }
.reply + .reply { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.reply-avatar { width: 26px; height: 26px; border-radius: 50%; flex: none; object-fit: cover; background: var(--surface-2); }
.reply-body { min-width: 0; flex: 1; }
.reply-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.reply-name { color: var(--text); font-weight: 700; font-size: 0.84rem; text-decoration: none; }
.reply-name:hover { text-decoration: underline; }
.reply-handle, .reply-time { color: var(--muted); font-size: 0.75rem; }
.reply-content { font-size: 0.88rem; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.reply-loading { padding: 8px 0; color: var(--muted); font-size: 0.85rem; }
.reply-menu { position: static; margin-left: auto; }
.reply-menu .post-menu-btn { width: 24px; height: 24px; }
.reply-menu .post-menu-drop { top: 26px; }
.reply .post-menu-drop { right: 0; }
.post-avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; object-fit: cover; background: var(--surface-2); }
.post-body { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.post-name { color: var(--text); font-weight: 700; text-decoration: none; }
.post-name:hover { text-decoration: underline; }
.post-handle, .post-time, .post-dot { color: var(--muted); font-size: 0.88rem; text-decoration: none; }
a.post-time:hover { text-decoration: underline; }  /* permalink affordance */
.post-edited { color: var(--muted); font-size: 0.78rem; }
/* Permalink / single-post view */
.back-to-feed {
  display: inline-block; margin-bottom: 12px; color: var(--muted);
  font-size: 0.9rem; font-weight: 600; text-decoration: none;
}
.back-to-feed:hover { color: var(--text); }
.post-single { border-color: var(--blurple); }
.post-content { margin-top: 4px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.post-deleted { color: var(--muted); font-style: italic; }
.mention { color: var(--blurple-hi); text-decoration: none; font-weight: 500; }
.mention:hover { text-decoration: underline; }

.post-actions { display: flex; gap: 16px; margin-top: 8px; }
.linkbtn {
  border: none; background: none; padding: 0;
  color: var(--muted); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.linkbtn:hover { color: var(--text); }
.linkbtn.danger:hover { color: var(--danger); }

.edit-input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-top: 6px;
  min-height: 72px;
}
.edit-bar { display: flex; gap: 8px; margin-top: 8px; }
.btn-sm { width: auto; margin-top: 0; padding: 8px 16px; font-size: 0.85rem; }

/* --------------------------- avatar menu --------------------------------- */
.avatarbtn {
  width: 42px; height: 42px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  overflow: hidden; background: var(--surface); cursor: pointer;
}
.avatarbtn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.panel-sm { width: 200px; }
.menu-item {
  display: block; width: 100%; text-align: left;
  padding: 12px 16px; border: none; background: none;
  color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer; text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }

/* ----------------------- live notification toasts ------------------------ */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(340px, calc(100vw - 36px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blurple);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  background: var(--surface);
}
.toast-text { font-size: 0.9rem; line-height: 1.35; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.2s ease; transform: none; }
  .toast.show { transform: none; }
}

/* ------------------------------ stories ---------------------------------- */
/* green + button in the top bar */
.addbtn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: #43b581;
  color: #fff;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease;
}
.addbtn:hover { background: #3ca374; }
.addbtn:active { transform: translateY(1px); }

/* create-story form */
.story-form { max-width: 520px; text-align: left; }
.story-form h1 { text-align: left; }
.story-form .muted { margin-bottom: 18px; }
.cover-drop {
  display: grid; place-items: center;
  width: 180px; aspect-ratio: 2 / 3;
  margin: 0 0 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.cover-drop:hover { border-color: var(--blurple); }
.cover-preview { width: 100%; height: 100%; object-fit: cover; }
.drop-hint { color: var(--muted); font-size: 0.85rem; padding: 0 12px; text-align: center; }
.field-input {
  width: 100%;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.field-input:focus { outline: none; border-color: var(--blurple); }
textarea.field-input { resize: vertical; line-height: 1.5; }
.tag-fields { display: flex; flex-direction: column; }

/* tag autocomplete rows (reuses .mention-pop container) */
.tag-suggest {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 9px 12px;
  border: none; background: none; cursor: pointer; text-align: left;
  border-bottom: 1px solid var(--line);
}
.tag-suggest:last-child { border-bottom: none; }
.tag-suggest:hover { background: var(--surface-2); }
.tag-suggest-name { color: var(--text); font-size: 0.9rem; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.tag-suggest-badge {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: #e0a53d; background: rgba(224, 165, 61, 0.14); padding: 2px 6px; border-radius: 5px;
}
.tag-suggest-count { color: var(--muted); font-size: 0.78rem; flex: none; }

/* tags shown on the story page — the author's exact strings (§4.3) */
.story-tags .tag-group { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.tag-group-label { flex: none; width: 110px; color: var(--muted); font-size: 0.8rem; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.work-tag {
  display: inline-block; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 0.85rem;
  text-decoration: none; transition: border-color 0.15s, color 0.15s;
}
a.work-tag:hover { border-color: var(--blurple); color: var(--blurple-hi); }
.work-tag-wrap { display: inline-flex; align-items: center; gap: 2px; }
.work-tag-report {
  border: none; background: none; cursor: pointer; padding: 2px 4px;
  color: var(--muted); font-size: 0.8rem; line-height: 1; border-radius: 6px;
}
.work-tag-report:hover { color: var(--danger); }
.work-tag-report:disabled { color: var(--muted); cursor: default; opacity: 0.6; }

/* stories-list search bar + filter panel */
.stories-search { margin-bottom: 22px; }
.search-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 18px;
  border-radius: 16px;
  background: rgba(20, 21, 27, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.15s ease;
}
.search-bar:focus-within { border-color: rgba(111, 123, 247, 0.55); }
.search-icon { color: var(--muted); line-height: 0; flex: none; }
.search-icon svg { width: 18px; height: 18px; }
.search-input {
  flex: 1; min-width: 0;
  border: none; background: none; outline: none;
  color: var(--text); font: inherit; font-size: 0.98rem;
  padding: 8px 0;
}
.search-input::placeholder { color: var(--muted); opacity: 0.75; }
.filter-btn {
  display: inline-flex; align-items: center; gap: 7px;
  flex: none;
  padding: 9px 15px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: none;
  color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.filter-btn:hover { background: rgba(255, 255, 255, 0.06); }
.filter-btn svg { width: 16px; height: 16px; }
.filter-badge {
  display: inline-grid; place-items: center;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px;
  background: var(--blurple); color: #fff;
  font-size: 0.72rem; font-weight: 700;
}
.search-go { width: auto; margin-top: 0; flex: none; border-radius: 11px; }

.filter-panel {
  margin-top: 10px;
  padding: 20px;
  border-radius: 16px;
  background: rgba(20, 21, 27, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(12px);
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}
.filter-field { display: flex; flex-direction: column; gap: 7px; }
.filter-field .field-input { margin-bottom: 0; }
.filter-label {
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted);
}
.filter-field-exclude .filter-label { color: var(--danger); }
.filter-field-exclude .field-input:focus { border-color: var(--danger); }
.filter-actions { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.filter-actions .btn-sm { width: auto; margin-top: 0; }
.filter-hint { color: var(--muted); font-size: 0.8rem; margin-left: auto; }
.stories-clear { color: var(--muted); text-decoration: underline; font-size: 0.85rem; }
.stories-clear:hover { color: var(--text); }

/* active filter chips */
.active-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: -6px 0 20px; }
.afilter {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  background: rgba(88, 101, 242, 0.13);
  border: 1px solid rgba(111, 123, 247, 0.35);
  color: #c3caff; font-size: 0.84rem; font-weight: 600;
}
.afilter-kind {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(88, 101, 242, 0.25);
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.afilter:not(:has(.afilter-kind)) { padding-left: 12px; }
.afilter-not { background: rgba(240, 97, 109, 0.1); border-color: rgba(240, 97, 109, 0.4); color: #f4a2a9; }
.afilter-not .afilter-kind { background: rgba(240, 97, 109, 0.22); }

/* result sections: exact matches vs related */
.results-section { margin-top: 30px; }
.results-head { display: flex; align-items: baseline; gap: 10px; }
.results-title {
  margin: 0;
  font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em;
}
.results-count {
  padding: 1px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 0.78rem; font-weight: 700;
}
.results-sub { margin: 5px 0 16px; color: var(--muted); font-size: 0.87rem; }
.results-more { margin: 14px 0 0; color: var(--muted); font-size: 0.84rem; }
.results-related { margin-top: 42px; padding-top: 28px; border-top: 1px solid var(--line); }
.results-related .results-title { color: #c3caff; }

@media (max-width: 700px) {
  .filter-grid { grid-template-columns: 1fr; }
  .search-bar { flex-wrap: wrap; padding: 10px; }
  .search-input { flex-basis: 100%; order: -1; padding: 6px 8px; }
}

/* single story page (view + edit share this layout) */
html, body { overflow-x: clip; } /* lets the full-bleed backdrop span the viewport without a scrollbar */

.story-page { position: relative; z-index: 1; width: 100%; max-width: 1120px; align-self: start; text-align: left; }

/* full-bleed blurred cover backdrop behind the hero (the "movie page" look) */
.story-backdrop, .story-veil {
  position: absolute; top: -84px; left: 50%; width: 100vw; margin-left: -50vw;
  height: 560px; z-index: 0; pointer-events: none;
}
.story-backdrop {
  background-size: cover; background-position: center 22%;
  filter: blur(52px) saturate(1.3);
  opacity: 0.5;
  transform: scale(1.12);
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent 98%);
  mask-image: linear-gradient(to bottom, #000 45%, transparent 98%);
}
.story-veil {
  background: linear-gradient(
    to bottom,
    rgba(11, 11, 15, 0.45) 0%,
    rgba(11, 11, 15, 0.74) 52%,
    var(--bg) 92%
  );
}

.story-hero {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 42px;
  align-items: start;
  padding-top: 28px;
}
/* view mode: cover | info | rating rail */
.story-hero.has-rating { grid-template-columns: 250px minmax(0, 1fr) 280px; gap: 40px; }
.story-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid; place-items: center;
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.62);
}
.story-cover.editable { cursor: pointer; }
.story-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* when a cover exists, show it whole at its own aspect ratio — no crop/zoom */
.story-cover.has-image { aspect-ratio: auto; background: transparent; }
.story-cover.has-image img { height: auto; object-fit: contain; }
.cover-fallback { font-size: 3.4rem; font-weight: 700; color: var(--muted); }
.cover-hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 9px; text-align: center;
  background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 0.8rem;
}

.story-main { min-width: 0; padding-top: 6px; }
.story-titlerow { display: flex; align-items: center; gap: 14px; }
.story-title {
  margin: 0;
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 2.7rem; line-height: 1.06; letter-spacing: -0.01em;
}
.pencil {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.pencil:hover { color: var(--text); background: var(--surface-2); border-color: #3a3e48; }
.pencil svg { width: 18px; height: 18px; }

.story-meta { display: flex; align-items: center; gap: 10px; margin-top: 18px; color: var(--muted); font-size: 0.95rem; }
.story-author-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.story-by-link { color: var(--text); text-decoration: none; font-weight: 600; }
.story-by-link:hover { color: var(--blurple-hi); }
.story-dot { opacity: 0.55; }

.story-section { margin-top: 30px; }
.story-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px;
}
.story-synopsis {
  margin: 0; max-width: 62ch;
  font-size: 1.05rem; line-height: 1.72; color: #d6dae2;
  white-space: pre-wrap; word-wrap: break-word;
}
.story-title-input {
  width: 100%;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 2.2rem; font-weight: 700; letter-spacing: -0.01em;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(20, 21, 26, 0.72); color: var(--text);
}
.story-synopsis-input {
  width: 100%; min-height: 180px; padding: 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(20, 21, 26, 0.72); color: var(--text);
  font: inherit; font-size: 1.02rem; line-height: 1.7; resize: vertical;
}
.story-title-input:focus, .story-synopsis-input:focus { outline: none; border-color: var(--blurple); }

/* chapters + edit footer */
.story-chapters { position: relative; z-index: 1; margin-top: 44px; padding-top: 26px; border-top: 1px solid var(--line); }
.story-chapters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.story-chapters-head .story-label { margin-bottom: 0; }
.story-chapters-head .btn-sm { width: auto; margin-top: 0; }
.chapters-empty {
  padding: 30px; text-align: center;
  color: var(--muted); font-size: 0.95rem;
  border: 1px dashed var(--line); border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}
.story-editbar { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; margin-top: 22px; }
.story-editbar .btn-sm { width: auto; margin-top: 0; }

@media (max-width: 640px) {
  .story-hero { grid-template-columns: 1fr; gap: 24px; }
  .story-cover { max-width: 220px; }
  .story-title { font-size: 2.1rem; }
}

/* ===== stars & ratings (story page; data is a design mockup for now) ===== */
:root { --star: #f6c453; --star-dim: rgba(255, 255, 255, 0.16); }

.stars { display: inline-flex; gap: 2px; line-height: 0; }
.star {
  position: relative;
  width: 1em; height: 1em;
  font-size: 17px;
  display: inline-block;
  color: var(--star-dim);
}
.star svg { width: 1em; height: 1em; fill: currentColor; display: block; }
.star-fill {
  position: absolute; inset: 0;
  overflow: hidden;
  color: var(--star);
  filter: drop-shadow(0 0 6px rgba(246, 196, 83, 0.35));
}
.stars-sm .star { font-size: 13px; }

/* interactive-looking picker */
.stars-pick { gap: 4px; }
.star-btn {
  border: none; background: none; padding: 0; margin: 0;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.22);
  transition: color 0.12s ease, transform 0.12s ease;
}
.star-btn.is-hot { color: var(--star); transform: scale(1.12); filter: drop-shadow(0 0 8px rgba(246, 196, 83, 0.45)); }

/* rating strip under the byline */
.story-rating-strip {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px;
}
.story-rating-strip .star { font-size: 19px; }
.strip-avg { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.strip-count { color: var(--muted); font-size: 0.88rem; }

/* rating rail (right column of the hero) */
.rating-panel {
  position: relative;
  padding: 22px 22px 18px;
  border-radius: 18px;
  background: rgba(20, 21, 27, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.rating-headline { display: flex; align-items: center; gap: 14px; margin-top: 2px; }
.rating-avg {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 3rem; font-weight: 700; line-height: 1;
  letter-spacing: -0.02em;
}
.rating-headline-right { display: flex; flex-direction: column; gap: 6px; }
.rating-count { color: var(--muted); font-size: 0.82rem; }

.rating-histo { margin-top: 18px; display: flex; flex-direction: column; gap: 7px; }
.histo-row {
  display: grid;
  grid-template-columns: 26px 1fr 34px;
  align-items: center;
  gap: 10px;
}
.histo-star { color: var(--muted); font-size: 0.75rem; text-align: right; }
.histo-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.histo-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d99a2b, var(--star));
}
.histo-pct { color: var(--muted); font-size: 0.72rem; }

.rate-box {
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.rate-box-label { color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.rate-box .star-btn { font-size: 21px; }

/* tagline — italic serif lead-in above the synopsis */
.story-tagline {
  margin: 2px 0 10px;
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-style: italic;
  font-size: 1.22rem;
  color: #cdd3ea;
  letter-spacing: 0.01em;
}

/* ===== reviews (design mockup) ===== */
.story-reviews {
  position: relative; z-index: 1;
  margin-top: 44px; padding-top: 26px;
  border-top: 1px solid var(--line);
}
.reviews-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 18px; }
.reviews-head .story-label { margin-bottom: 0; }
.mock-note {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(246, 196, 83, 0.35);
  color: var(--star);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.review-composer {
  display: flex; gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 22px;
}
.review-composer-body { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.review-composer .star-btn { font-size: 19px; }
.review-input { color: var(--muted); font-size: 0.94rem; opacity: 0.75; }

.review { display: flex; gap: 14px; padding: 16px 2px; }
.review + .review { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.review-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  flex: none;
}
.review-body { min-width: 0; flex: 1; }
.review-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.review-name { font-weight: 700; font-size: 0.95rem; }
.review-when { color: var(--muted); font-size: 0.8rem; }
.review-text {
  margin: 7px 0 0;
  color: #d6dae2;
  font-size: 0.97rem;
  line-height: 1.65;
  max-width: 72ch;
}

/* rating rail collapses under the info column on narrow screens */
@media (max-width: 1060px) {
  .story-hero.has-rating { grid-template-columns: 220px minmax(0, 1fr); }
  .story-hero.has-rating .rating-panel { grid-column: 1 / -1; max-width: 460px; }
}

/* stories list */
.stories-page { width: 100%; max-width: 1000px; align-self: start; text-align: left; }
.stories-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; }
.stories-head h1 { margin: 0; }
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px;
}
.story-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--text); }
.story-card-cover {
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.story-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-card:hover .story-card-cover { border-color: var(--blurple); transform: translateY(-3px); }
.story-card-title { font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.story-card-author { color: var(--muted); font-size: 0.82rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 30px; }
.pager .btn-sm { width: auto; margin-top: 0; }

/* --- chapter list on the story page --- */
.switch-row { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; color: var(--muted); font-size: 0.9rem; cursor: pointer; }
.switch {
  appearance: none; -webkit-appearance: none;
  width: 38px; height: 22px; flex: none; position: relative; cursor: pointer;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  transition: background 0.15s, border-color 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}
.switch:checked { background: var(--blurple); border-color: var(--blurple); }
.switch:checked::after { transform: translateX(16px); background: #fff; }

.chapter-rows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.chapter-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chapter-row:last-child { border-bottom: none; }
.chapter-row:hover { background: rgba(255, 255, 255, 0.02); }
.chapter-num { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 22px; }
.chapter-draft, .chapter-status.is-draft { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: #e0a53d; background: rgba(224, 165, 61, 0.14); padding: 3px 8px; border-radius: 6px; }
.chapter-link { flex: 1; min-width: 0; color: var(--text); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-link:hover { color: var(--blurple-hi); }
.chapter-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.chapter-move, .chapter-edit {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); cursor: pointer; text-decoration: none;
}
.chapter-move:hover:not(:disabled), .chapter-edit:hover { color: var(--text); background: var(--surface-2); }
.chapter-move:disabled { opacity: 0.35; cursor: default; }

/* --- chapter page (read + edit) --- */
.chapter-page { width: 100%; max-width: 760px; align-self: start; text-align: left; }
.chapter-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.chapter-topbar-right { display: flex; align-items: center; gap: 12px; }
.chapter-topbar-right .btn-sm { width: auto; margin-top: 0; }
.chapter-back { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.chapter-back:hover { color: var(--text); }
.chapter-head { margin-bottom: 22px; }
.chapter-head .chapter-status { display: inline-block; margin-bottom: 8px; }
.chapter-title { font-family: ui-serif, Georgia, "Times New Roman", serif; font-size: 2.2rem; line-height: 1.15; margin: 0; }
.chapter-status.is-pub { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: #43b581; background: rgba(67, 181, 129, 0.14); padding: 3px 8px; border-radius: 6px; }

.chapter-body { font-size: 1.08rem; line-height: 1.78; color: #d6dae2; }
.chapter-body p { margin: 0 0 1em; }
.chapter-body h2 { font-family: ui-serif, Georgia, serif; font-size: 1.5rem; color: var(--text); margin: 1.4em 0 0.5em; }
.chapter-body h3 { font-size: 1.2rem; color: var(--text); margin: 1.2em 0 0.4em; }
.chapter-body blockquote { margin: 1em 0; padding: 6px 16px; border-left: 3px solid var(--blurple); color: var(--muted); font-style: italic; }
.chapter-body ul, .chapter-body ol { margin: 0 0 1em 1.4em; }
.chapter-body li { margin: 0.3em 0; }
.chapter-body a { color: var(--blurple-hi); }
.chapter-body img { max-width: 100%; height: auto; border-radius: 10px; margin: 0.5em 0; display: block; }
.chapter-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.chapter-nav .btn-sm { width: auto; margin-top: 0; }
.chapter-nav .btn-sm:only-child { margin-left: auto; }

/* --- WYSIWYG editor --- */
.chapter-title-input {
  width: 100%; font-family: ui-serif, Georgia, serif; font-size: 2rem; font-weight: 700;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--text); margin-bottom: 16px;
}
.chapter-title-input:focus { outline: none; border-color: var(--blurple); }
/* no overflow:hidden here — it would break the sticky toolbar */
.wysiwyg { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.wysiwyg-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 8px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  border-radius: 13px 13px 0 0;
  position: sticky; top: 60px; z-index: 5;
}
.tb {
  min-width: 34px; height: 34px; padding: 0 8px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--muted); font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer;
}
.tb:hover { color: var(--text); background: var(--surface); border-color: var(--line); }
.wysiwyg-body { min-height: 360px; padding: 20px; outline: none; color: #d6dae2; font-size: 1.06rem; line-height: 1.78; }
.wysiwyg-body:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.wysiwyg-body img { max-width: 100%; height: auto; border-radius: 10px; }
.wysiwyg-body h2 { font-family: ui-serif, Georgia, serif; font-size: 1.5rem; color: var(--text); }
.wysiwyg-body blockquote { margin: 1em 0; padding-left: 14px; border-left: 3px solid var(--blurple); color: var(--muted); font-style: italic; }
.wysiwyg-body ul, .wysiwyg-body ol { margin-left: 1.4em; }

/* -------------------------- mention popup -------------------------------- */
.mention-pop {
  position: absolute;
  z-index: 100;
  min-width: 240px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.mention-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  border: none; background: none; cursor: pointer; text-align: left;
  border-bottom: 1px solid var(--line);
}
.mention-item:last-child { border-bottom: none; }
.mention-item:hover { background: var(--surface-2); }
.mention-avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; object-fit: cover; background: var(--surface-2); }
.mention-info { display: flex; flex-direction: column; min-width: 0; }
.mention-name { color: var(--text); font-weight: 600; font-size: 0.88rem; }
.mention-handle { color: var(--muted); font-size: 0.78rem; }

/* ======================= logged-out hero (front page) ====================== */
/* Full-viewport, single view — position:fixed + overflow:hidden = never scrolls. */
.hero {
  position: fixed;
  inset: 0;
  /* Cobre também a calha reservada pelo scrollbar-gutter (o hero não rola),
     pra não sobrar uma faixa do fundo na direita na tela de login. */
  right: auto;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #04050c;
}

/* --- the sky: stars, planet rim, haze, orbit line --- */
.hero-sky { position: absolute; inset: 0; pointer-events: none; }

.hero-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 28%, rgba(255,255,255,.9), transparent 100%),
    radial-gradient(1.2px 1.2px at 26% 62%, rgba(255,255,255,.6), transparent 100%),
    radial-gradient(1.8px 1.8px at 38% 18%, rgba(255,255,255,.85), transparent 100%),
    radial-gradient(1.1px 1.1px at 47% 74%, rgba(255,255,255,.55), transparent 100%),
    radial-gradient(1.5px 1.5px at 58% 38%, rgba(255,255,255,.8), transparent 100%),
    radial-gradient(1.2px 1.2px at 66% 82%, rgba(255,255,255,.5), transparent 100%),
    radial-gradient(1.9px 1.9px at 74% 22%, rgba(255,255,255,.95), transparent 100%),
    radial-gradient(1.2px 1.2px at 83% 55%, rgba(255,255,255,.6), transparent 100%),
    radial-gradient(1.5px 1.5px at 91% 34%, rgba(255,255,255,.8), transparent 100%),
    radial-gradient(1.1px 1.1px at 7% 84%, rgba(255,255,255,.5), transparent 100%),
    radial-gradient(1.4px 1.4px at 95% 78%, rgba(255,255,255,.65), transparent 100%),
    radial-gradient(1.3px 1.3px at 31% 90%, rgba(255,255,255,.5), transparent 100%);
  animation: twinkle 7s ease-in-out infinite alternate;
}
.hero-stars-2 {
  background-image:
    radial-gradient(1.1px 1.1px at 18% 46%, rgba(200,208,255,.6), transparent 100%),
    radial-gradient(1.4px 1.4px at 43% 32%, rgba(200,208,255,.7), transparent 100%),
    radial-gradient(1.1px 1.1px at 55% 60%, rgba(200,208,255,.5), transparent 100%),
    radial-gradient(1.6px 1.6px at 70% 44%, rgba(200,208,255,.75), transparent 100%),
    radial-gradient(1.1px 1.1px at 88% 14%, rgba(200,208,255,.6), transparent 100%),
    radial-gradient(1.3px 1.3px at 60% 12%, rgba(200,208,255,.6), transparent 100%),
    radial-gradient(1.2px 1.2px at 22% 12%, rgba(200,208,255,.55), transparent 100%),
    radial-gradient(1.2px 1.2px at 79% 68%, rgba(200,208,255,.5), transparent 100%);
  animation-delay: -3.5s;
}
@keyframes twinkle {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}

/* A huge sphere mostly above the viewport — only its glowing lower rim shows. */
.hero-planet {
  position: absolute;
  left: 50%;
  top: 0;
  width: 175vmax;
  height: 175vmax;
  transform: translate(-56%, -91.5%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 112%, #241028 0%, #140a1e 42%, #070510 68%);
  box-shadow:
    inset 0 -16px 44px -12px rgba(255, 148, 92, 0.85),
    0 10px 34px -8px rgba(255, 128, 70, 0.5),
    0 40px 130px -30px rgba(190, 90, 240, 0.35);
}

/* Soft blurple nebula glow behind the copy. */
.hero-haze {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 420px at 22% 62%, rgba(88, 101, 242, 0.16), transparent 65%),
    radial-gradient(560px 400px at 82% 30%, rgba(160, 107, 245, 0.12), transparent 65%);
}

.hero-orbit {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: min(28vw, 400px);
  filter: drop-shadow(0 0 6px rgba(111, 123, 247, 0.65));
}
.orbit-dot { filter: drop-shadow(0 0 8px #8f9bff); }

/* --- nav --- */
.hero-nav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 3vh, 28px) clamp(20px, 4.5vw, 56px);
}
.hero-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.hero-brand-glyph {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--blurple), #3b45c9);
  color: #fff;
  font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(88, 101, 242, 0.5);
}
.hero-signin {
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.hero-signin:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.32); }

/* --- body: copy left, visual right, vertically centered, never overflowing --- */
.hero-body {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: clamp(24px, 5vw, 80px);
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4.5vw, 56px) clamp(16px, 4vh, 44px);
}

.hero-badge { margin-bottom: clamp(10px, 2vh, 20px); }

.hero-title {
  margin: 0 0 clamp(12px, 2.2vh, 22px);
  font-size: clamp(2.1rem, 4.6vw, 4rem);
  line-height: 1.06;
  font-weight: 800;
  letter-spacing: -0.035em;
  background: linear-gradient(115deg, #ffffff 30%, #b7bfff 75%, #c9a6ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: clamp(0.98rem, 1.35vw, 1.18rem);
  line-height: 1.6;
}

.hero-cta { margin-top: clamp(18px, 3.4vh, 34px); }
.hero-btn {
  width: auto;
  margin-top: 0;
  padding: 14px 26px;
  font-size: 1.02rem;
  border-radius: 13px;
  box-shadow: 0 10px 34px rgba(88, 101, 242, 0.45);
}

.hero-note {
  margin: clamp(10px, 1.8vh, 16px) 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  opacity: 0.85;
}
.hero .error { max-width: 46ch; }

/* --- right visual: faux story card + floating tag chips --- */
.hero-visual {
  position: relative;
  height: min(58vh, 480px);
  align-self: center;
}

.hero-card {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(3.5deg);
  width: min(240px, 22vw);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 60px rgba(88, 101, 242, 0.18);
  animation: heroFloat 7s ease-in-out infinite alternate;
}
.hero-card-cover {
  aspect-ratio: 2 / 2.6;
  display: flex;
  align-items: flex-end;
  padding: 14px;
  background:
    radial-gradient(140% 90% at 80% 0%, rgba(255, 148, 92, 0.5), transparent 55%),
    linear-gradient(200deg, #46409b 0%, #232052 55%, #131129 100%);
}
.hero-card-cover span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
.hero-card-body { padding: 12px 14px 14px; }
.hero-card-meta { color: var(--muted); font-size: 0.75rem; }
.hero-card-tags { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.hero-card-tags span {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
}

.hero-chip {
  position: absolute;
  z-index: 2;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(23, 24, 28, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: heroFloat 6s ease-in-out infinite alternate;
}
.chip-1 {
  top: 5%;
  left: -4%;
  border-color: rgba(111, 123, 247, 0.65);
  color: #b7bfff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 22px rgba(88, 101, 242, 0.35);
  animation-delay: -1.2s;
}
.chip-2 { top: 26%; right: -5%; animation-delay: -3.8s; }
.chip-3 { bottom: 30%; left: -7%; animation-delay: -2.4s; }
.chip-4 {
  bottom: 7%;
  right: 2%;
  border-color: rgba(255, 148, 92, 0.55);
  color: #ffc9a8;
  animation-delay: -5s;
}

@keyframes heroFloat {
  from { translate: 0 -7px; }
  to   { translate: 0 7px; }
}

/* --- responsive: drop the visual, center the copy --- */
@media (max-width: 960px) {
  .hero-body { grid-template-columns: 1fr; text-align: center; }
  .hero-visual { display: none; }
  .hero-sub, .hero .error { margin-inline: auto; }
  .hero-orbit { opacity: 0.5; }
}
@media (max-height: 640px) {
  .hero-badge { display: none; }
  .hero-title { font-size: clamp(1.8rem, 4vw, 2.6rem); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-stars, .hero-card, .hero-chip { animation: none; }
}
