:root {
  --ink: #1f2937;
  --paper: #f6f5f3;
  --sheet: #ffffff;
  --line: #e5e7eb;
  --accent: #1a1a1a;
  --accent-hover: #333333;
  --accent-soft: #f5f5f5;
  --muted: #6b7280;
  --success: #059669;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --radius: 12px;
  --font-ui: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
}
a { text-decoration: none; color: #374151; }
a:hover { color: var(--accent); }

.navbar {
  background: var(--sheet) !important;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}

.navbar-brand.brand {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

.brand span { color: var(--accent); }

.nav-link { color: var(--ink) !important; font-weight: 500; }
.nav-link:hover { color: var(--accent) !important; }

.btn-accent {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  padding: .55rem 1.1rem;
  transition: background .15s, transform .1s;
}

.btn-accent:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
}

.btn-outline-secondary {
  border-radius: 8px;
}

/* Text-to-Speech Player */
.tts-trigger {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .9rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  margin: .5rem 0 1rem;
  transition: all .15s;
}
.tts-trigger:hover {
  background: var(--accent-soft);
  border-color: #d1d5db;
}
.tts-trigger svg { flex-shrink: 0; }

.tts-player {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .4rem .75rem;
  margin: .5rem 0 1.25rem;
  box-shadow: var(--shadow);
  max-width: 420px;
}
.tts-btn {
  background: none;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  padding: .25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.tts-btn:hover { background: var(--accent-soft); }
.tts-close { font-size: 1.25rem; line-height: 1; padding: 0 .3rem; color: var(--muted); }
.tts-progress {
  flex: 1;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  min-width: 60px;
}
.tts-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width .3s;
}
.tts-rate {
  border: 0;
  background: var(--accent-soft);
  border-radius: 6px;
  padding: .2rem .4rem;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}
.auth {
  display: flex;
  min-height: calc(100vh - 120px);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--sheet);
  margin: 1rem auto;
  max-width: 1100px;
}

.auth-visual {
  flex: 1;
  background-size: cover;
  background-position: center;
  position: relative;
  min-height: 480px;
  display: none;
}

@media (min-width: 900px) {
  .auth-visual { display: flex; align-items: flex-end; }
}

.auth-visual figcaption {
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
  color: #fff;
  padding: 2rem 1.5rem 1.5rem;
  width: 100%;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin: 0;
}

.auth-panel {
  flex: 1;
  padding: 2.5rem 2rem;
  max-width: 480px;
  margin: 0 auto;
}

.auth-panel h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin-bottom: .5rem;
}

.auth-switch { margin-top: 1rem; color: var(--muted); }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .95rem; }

.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: .65rem .85rem;
  font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Constrain long forms */
.auth-panel form, .story-editor form, .panel form, .card-body form, .page form, form.stack {
  max-width: 720px;
}

.story-editor, .page, .panel {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.story-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 768px) {
  .story-card { grid-template-columns: 1fr; }
}

.cover-box {
  aspect-ratio: 2/3;
  background: var(--accent-soft) center/cover no-repeat;
  border-radius: 10px;
  border: 2px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  color: var(--muted);
  font-weight: 500;
}

.cover-box .pick {
  position: absolute;
  bottom: .75rem;
  left: .75rem;
  right: .75rem;
  background: rgba(255,255,255,.92);
  border-radius: 6px;
  padding: .4rem;
  text-align: center;
  font-size: .85rem;
  cursor: pointer;
}

.cover-box input[type=file] { display: none; }

.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
}

.tabs button {
  background: none;
  border: 0;
  padding: .6rem 1rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}

.tabs button.on {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.srow {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: .75rem;
  align-items: start;
  margin-bottom: 1rem;
}

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

.srow .t { font-weight: 600; padding-top: .4rem; }

.req { color: var(--danger); }

.sub, .meta { color: var(--muted); font-size: .9rem; }

/* Story cards on home/browse */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  overflow: hidden;
  background: var(--sheet);
}

.card:hover:not(.comm-post):not(.comm-side) {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

.story-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}

.story-title:hover { color: var(--accent); }

/* Hero / promo */
.hero-promo {
  background: linear-gradient(120deg, #1a1a1a 0%, #333 55%, #555 100%);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  color: #fff;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  min-height: 220px;
  display: flex;
  align-items: center;
}

.hero-promo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url('/images/promo-hero.jpg') center/cover;
  opacity: .35;
  mix-blend-mode: overlay;
}

.hero-promo > * { position: relative; z-index: 1; }

.hero-promo h1 {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  margin: 0 0 .5rem;
}

/* Admin */
.admin-side {
  background: #1c2a2a;
  min-height: 100vh;
  color: #e0e7ff;
}

.admin-side .brand { color: #fff; }
.admin-side .brand span { color: #ddd; }
.admin-side .nav-link { color: #eee !important; border-radius: 6px; }
.admin-side .nav-link:hover, .admin-side .nav-link.active { background: rgba(255,255,255,.08); color: #fff !important; }

.admin-stat {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-stat a {
  flex: 1;
  min-width: 140px;
  background: var(--sheet);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  transition: transform .15s;
}

.admin-stat a:hover { transform: translateY(-2px); }
.admin-stat strong { display: block; font-size: 1.8rem; color: var(--accent); }

/* Reader */
.reader {
  max-width: 68ch;
  margin: 0 auto;
  background: var(--sheet);
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.reader-body {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  line-height: 1.85;
  color: #111827;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.reader-body p,
.reader-body div,
.reader-body span {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.reader { overflow: hidden; }

/* Placeholder for missing covers */
.ph {
  aspect-ratio: 2/3;
  background: linear-gradient(135deg, var(--accent-soft), #fef3c7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 500;
  max-width: 220px;
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

.sw {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.sw input { margin-right: .5rem; }

.btn.quiet {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
}

.btn.quiet:hover { background: var(--accent-soft); color: var(--accent); }

.tags a {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  padding: .2rem .6rem;
  border-radius: 999px;
  margin: .15rem;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
}

.tags a:hover { background: var(--accent); color: #fff; }

/* Utilities */
.stack > * + * { margin-top: 1rem; }
.err { color: var(--danger); font-size: .875rem; }

@media (max-width: 991px) {
  .admin-side { min-height: auto; }
  .auth { flex-direction: column; }
}

.cards { display: grid; gap: 1rem; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } }
.cards article { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.cards article a { color: var(--ink); text-decoration: none; font-weight: 600; }
.cards article a:hover { color: var(--accent); }


/* Story type radios */
.types {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.types label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  background: var(--sheet);
  transition: border-color .15s, background .15s;
}
.types label:hover { border-color: var(--accent); }
.types input[type="radio"] { accent-color: var(--accent); }
.types input[type="radio"]:checked + span,
.types label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Choice lists (Nonfiction, Poetry, Fanfic formats) */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-top: .4rem;
}
.choice {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: var(--sheet);
  transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--accent); }
.choice input { margin-top: .25rem; accent-color: var(--accent); }
.choice span { display: flex; flex-direction: column; gap: .15rem; }
.choice strong { font-weight: 600; color: var(--ink); }
.choice small { color: var(--muted); font-size: .875rem; line-height: 1.4; }
.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Genre / category blocks that appear under story type */
[data-for] {
  margin-top: .5rem;
}

/* Toggle rows (Mature / Complete / Published) */
.line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--line);
}
.line:last-child { border-bottom: 0; }
.line > div { flex: 1; }
.line .t { display: block; font-weight: 600; margin-bottom: .15rem; }
.line .sub { margin: 0; }

/* Switch control */
.sw {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.sw input {
  opacity: 0;
  width: 0;
  height: 0;
}
.sw i {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: background .2s;
  cursor: pointer;
}
.sw i::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.sw input:checked + i { background: var(--accent); }
.sw input:checked + i::before { transform: translateX(20px); }

/* Copyright note */
#copyright-note {
  margin-top: .4rem;
  font-size: .875rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Ensure form sections inside story editor stay clean */
.story-editor .srow {
  padding-bottom: .5rem;
  border-bottom: 1px solid transparent;
}

/* Story editor form containment and section styling */
.story-editor form {
  max-width: none;
}
.story-card > div:last-child {
  min-width: 0;
}
.story-editor .srow {
  display: block;
  margin-bottom: 1.25rem;
  padding-bottom: 0;
  border-bottom: 0;
}
.story-editor .srow > .t,
.story-editor .srow > label.t {
  display: block;
  font-weight: 600;
  margin-bottom: .35rem;
  padding-top: 0;
}
.story-editor .form-control,
.story-editor .form-select {
  max-width: 100%;
}
/* Visual grouping for type-dependent sections */
.story-editor [data-for],
[data-for] {
  background: #f9fafb;
  border: 1px solid var(--line) !important;
  border-radius: 10px;
  padding: 1rem 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
  overflow: visible;
}
[data-for] > .t {
  font-size: 1rem;
  margin-bottom: .4rem;
}
/* Genre select rows inside blocks */
.genre-block select,
[data-for] select {
  margin-bottom: .6rem;
}
.genre-block label.t,
[data-for] label.t {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin: .4rem 0 .2rem;
}

/* Multi-content blocks (genres, fanfic) should not use the 2-column srow grid */
.srow.genre-block,
.srow[data-for="Fanfic"],
.srow[data-for="Nonfiction"],
.srow[data-for="Poetry"] {
  display: block;
  margin-bottom: 1.5rem;
}
.srow.genre-block > *,
.srow[data-for="Fanfic"] > *,
.srow[data-for="Nonfiction"] > *,
.srow[data-for="Poetry"] > * {
  margin-bottom: .5rem;
}

/* Wattpad-style story editor header */
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 0 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.editor-header-left {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.25rem;
  border: 1px solid transparent;
}
.back-link:hover { background: var(--accent-soft); border-color: var(--line); }
.editor-kicker {
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}
.editor-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}
.editor-header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.wattpad-style .story-card {
  align-items: start;
}
@media (max-width: 700px) {
  .editor-header { flex-wrap: wrap; }
  .editor-title { max-width: 200px; }
}

.chapter-media { margin: 0 0 1.5rem; }
.chapter-media iframe, .chapter-media img { display: block; max-width: 100%; border-radius: 8px; }

.media-picker { display: flex; gap: .5rem; margin: .4rem 0 .6rem; }
.media-panel { margin-top: .4rem; }
.media-wrap { display: flex; flex-direction: column; gap: .5rem; }
.media-panel .form-control { max-width: 480px; }

.reader-body p { margin: 0 0 1rem; }
.reader-body u { text-decoration: underline; }

.part-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: .75rem; }
.part-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem .25rem; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.part-row:hover { background: #fafafa; }
.part-grip { color: #9aa0a6; font-size: 1.1rem; }
.part-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.part-main strong { font-size: 1rem; color: var(--ink); }
.part-main small { color: var(--muted); }
.part-stats { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.story-list { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.story-row {
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 1rem; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.story-row:last-child { border-bottom: 0; }
.story-row:hover { background: #fafafa; }
.story-cover {
  width: 54px; height: 78px; border-radius: 4px; flex-shrink: 0;
  background: #eee center/cover no-repeat;
}
.story-main { display: flex; flex-direction: column; min-width: 0; flex: 1; text-decoration: none; color: inherit; }
.story-main:hover { color: inherit; text-decoration: none; }
.story-main strong { color: var(--ink); }
.story-main strong { font-size: 1.05rem; color: var(--ink); }
.story-main small { color: var(--muted); }

.home-hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center;
  background: linear-gradient(120deg, #f5f5f5 0%, #fff 55%, #fafafa 100%);
  border-radius: 20px; padding: 2.5rem 2rem; margin-bottom: 2rem; overflow: hidden;
}
.home-hero h1 { font-family: var(--font-serif); font-size: 2.6rem; line-height: 1.15; margin: 0 0 .75rem; }
.home-hero p { color: var(--muted); max-width: 28rem; }
.home-login { display: block; margin-top: .6rem; color: var(--muted); font-size: .9rem; }
.home-hero-art img { width: 100%; height: auto; border-radius: 16px; display: block; }
.home-decor { margin: 1.5rem 0; }
.home-decor img { width: 100%; border-radius: 16px; display: block; }
.home-block, .home-panel { margin-bottom: 2rem; }
.home-block h2, .home-panel h2, .home-genres h2 { font-size: 1.35rem; margin-bottom: .8rem; }
.cover-row { display: flex; gap: .9rem; overflow-x: auto; padding-bottom: .4rem; }
.cover-card { width: 140px; flex: 0 0 140px; text-decoration: none; color: inherit; }
.cover-card:hover { color: inherit; text-decoration: none; }
.cover-card .cover {
  display: block; width: 140px; height: 200px; border-radius: 8px;
  background: #eee center/cover no-repeat; box-shadow: var(--shadow); margin-bottom: .45rem;
}
.library-grid { flex-wrap: wrap; overflow-x: visible; }
.cover-card strong { display: block; font-size: .92rem; line-height: 1.25; }
.cover-card small { color: var(--muted); }
.home-panel { background: #f7f7f7; border-radius: 16px; padding: 1.25rem; }
.home-genres { display: flex; justify-content: space-between; gap: 1.5rem; align-items: end; margin: 1rem 0 2rem; }
.genre-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.genre-chips a {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: .45rem .8rem; text-decoration: none; color: var(--ink); font-weight: 600;
}
.genre-chips a:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 800px) {
  .home-hero { grid-template-columns: 1fr; }
  .home-hero h1 { font-size: 2rem; }
  .home-genres { flex-direction: column; align-items: start; }
}

.story-page { max-width: 760px; margin: 0 auto; }
.story-head { display: flex; gap: 1.25rem; align-items: flex-start; margin-bottom: 1.5rem; }
.story-cover-lg { flex: 0 0 160px; }
.story-cover-lg img, .story-cover-lg .ph { width: 160px; height: 240px; object-fit: cover; border-radius: 8px; display: block; box-shadow: var(--shadow); }
.story-head-copy { min-width: 0; padding-top: .15rem; }
.story-head h1 { font-family: var(--font-serif); font-size: 1.85rem; line-height: 1.15; margin: 0 0 .35rem; }
.story-head .by { color: var(--muted); margin: 0 0 .7rem; }
.story-stats { display: flex; align-items: center; gap: 1.1rem; color: var(--muted); font-size: .92rem; margin: 0 0 1rem; }
.stat { display: inline-flex; align-items: center; gap: .4rem; line-height: 1; white-space: nowrap; }
.stat b { font-weight: 600; color: var(--ink); }
.stat .ico { width: 16px; height: 16px; flex: 0 0 16px; display: block; }
.story-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.story-section { border-top: 1px solid var(--line); padding: 1.1rem 0; }
.story-section h2 { font-size: 1.05rem; margin: 0 0 .55rem; }
.part-public { list-style: none; padding: 0; margin: 0; }
.part-public a {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 44px; padding: 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.part-public .part-title { font-weight: 650; }
.part-public a:hover .part-title { color: var(--accent); }
@media (max-width: 640px) {
  .story-head { flex-direction: column; }
  .story-cover-lg, .story-cover-lg img { width: 140px; height: 210px; }
}

.ico { width: 16px; height: 16px; flex: 0 0 16px; display: block; }
.story-stats span, .part-public span { display: inline-flex; align-items: center; gap: .2rem; }

.reads { display: flex; align-items: center; gap: .25rem; color: var(--muted); font-size: .8rem; font-style: normal; margin-top: .2rem; }
.reads img, img.ico { width: 16px; height: 16px; }
.cover-stats { display: flex; gap: .7rem; margin-top: .2rem; }

.author-line { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); font-weight: 600; margin-bottom: .7rem; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #f3f4f6; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; }
.story-cta { display: flex; gap: .5rem; align-items: center; margin: .25rem 0 1.25rem; }
.start-btn { min-width: 280px; text-align: center; padding: .7rem 1.4rem; border-radius: 999px; }
.story-tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.story-tabs button, .story-tabs a { background: none; border: 0; padding: .55rem 0; font-weight: 700; color: var(--muted); cursor: pointer; text-decoration: none; }
.story-tabs button.on, .story-tabs a.on { color: var(--ink); border-bottom: 2px solid var(--accent); }
.story-meta-line { color: var(--muted); margin: 0 0 .6rem; }
.story-blurb { margin: 0 0 1rem; }
.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.tag-label { font-weight: 700; margin-right: .2rem; }
.tag-row a { background: #f3f4f6; color: var(--ink); text-decoration: none; border-radius: 999px; padding: .25rem .65rem; font-size: .85rem; }
.tag-row a:hover { background: #e5e7eb; color: var(--accent); }

.read-top { text-align: center; margin-bottom: 1.5rem; }
.read-top .author-line { justify-content: center; }
.read-story { display: block; color: var(--accent); text-decoration: none; font-size: .9rem; margin: .35rem 0 .4rem; }
.read-top h1 { font-family: var(--font-serif); font-size: 1.7rem; margin: 0; }
.reader { max-width: 680px; }
.reader-body { font-size: 1.08rem; }
.read-next { display: flex; flex-direction: column; align-items: center; gap: .6rem; margin-top: 2rem; }
.read-prev { color: var(--muted); font-size: .9rem; }

.read-layout { display: grid; grid-template-columns: 180px minmax(0, 680px); gap: 2rem; justify-content: center; align-items: start; }
.read-side { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.share-row { display: flex; flex-direction: column; gap: .35rem; }
.share-row a, .share-row button { background: none; border: 0; padding: 0; text-align: left; color: var(--muted); font-size: .85rem; cursor: pointer; }
.share-row a:hover, .share-row button:hover { color: var(--accent); }
@media (max-width: 900px) {
  .read-layout { grid-template-columns: 1fr; }
  .read-side { position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
}

.side-author { display: flex; flex-direction: column; align-items: center; gap: .4rem; text-decoration: none; color: var(--ink); font-weight: 600; text-align: center; }
.side-author .avatar { width: 56px; height: 56px; font-size: 1.2rem; }
.side-btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; text-decoration: none; color: var(--ink); font-size: .85rem; }
.side-btn:hover { border-color: var(--accent); color: var(--accent); }
.side-actions { display: flex; gap: .4rem; }
.side-actions a, .side-actions button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.side-actions img { width: 16px; height: 16px; }
.read-side { align-items: center; }

.profile-page { max-width: 860px; margin: 0 auto; }
.profile-head { text-align: center; padding: 2rem 0 1.5rem; }
.profile-avatar { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
.profile-bio { max-width: 36rem; margin: .6rem auto 1rem; }
.profile-edit { max-width: 640px; margin: 0 auto; }
.profile-banner { display: flex; justify-content: flex-end; gap: .5rem; align-items: center; background: #1a1a1a; color: #fff; border-radius: 12px 12px 0 0; padding: .8rem 1rem; }
.profile-cancel { color: #fff; text-decoration: none; margin-right: auto; }
.profile-edit-body { background: #fff; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; padding: 1.5rem; }
.avatar-edit { text-align: center; margin-bottom: 1.25rem; }
.avatar-edit label { position: relative; display: inline-block; cursor: pointer; }
.avatar-edit img { width: 128px; height: 128px; border-radius: 50%; object-fit: cover; }
.avatar-edit span { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: rgba(0,0,0,.65); color: #fff; font-size: .75rem; padding: .2rem .5rem; border-radius: 999px; }
.avatar-edit input { display: none; }
.avatar-edit small { display: block; color: var(--muted); margin-top: .4rem; }

.toast-note {
  position: fixed; top: 72px; right: 16px; z-index: 2000;
  background: #111827; color: #fff; border-radius: 10px;
  padding: .75rem 1rem; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: .92rem;
}
.toast-note.bad { background: #7f1d1d; }
.saved-note { background: #111827; color: #fff; display: inline-block; border-radius: 999px; padding: .35rem .8rem; margin-bottom: 1rem; font-size: .9rem; }

.avatar-wait {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(17,24,39,.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
}
.avatar-wait::before {
  content: "⏳"; display: block; font-size: 1.4rem; margin-bottom: 1.4rem;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.avatar-edit.busy { pointer-events: none; }

.profile-counts { display: flex; justify-content: center; gap: 1.25rem; margin: .4rem 0 .6rem; }
.profile-counts a { color: var(--muted); text-decoration: none; }
.profile-counts b { color: var(--ink); }
.profile-actions { display: flex; justify-content: center; gap: .5rem; }
.people { display: flex; flex-direction: column; gap: .4rem; margin-top: 1rem; }
.person { display: flex; align-items: center; gap: .7rem; padding: .6rem .2rem; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.person img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }

.profile-tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); margin: 1rem 0 1.25rem; }
.profile-tabs a { text-decoration: none; color: var(--muted); font-weight: 700; padding: .55rem 0; }
.profile-tabs a.on { color: var(--ink); border-bottom: 2px solid var(--accent); }
.conv-compose, .conv { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: .8rem; }
.conv-compose { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; }
.conv-compose textarea, .replies input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; }
.conv header { display: flex; align-items: center; gap: .6rem; }
.conv header img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.conv header div { flex: 1; }
.conv header a { font-weight: 700; text-decoration: none; color: var(--ink); }
.conv header time, .conv header button { color: var(--muted); font-size: .8rem; background: none; border: 0; }
.conv p { margin: .7rem 0; white-space: pre-wrap; }
.reply { display: flex; gap: .4rem; padding: .35rem 0; font-size: .92rem; }
.replies form { display: flex; gap: .4rem; margin-top: .4rem; }
.replies button { border: 0; background: none; color: var(--accent); font-weight: 700; }
.read-main { min-width: 0; }
.read-main .reader + .reader { margin-top: 1rem; }
.actas-bar { background: #111827; color: #fff; text-align: center; padding: .45rem .8rem; font-size: .9rem; }
.actas-bar a, .actas-bar button { color: #fff; background: none; border: 0; text-decoration: underline; margin-left: .4rem; }

.comments-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; margin-top: 1rem; }
.comments-card h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.comment-compose { display: flex; flex-direction: column; align-items: flex-end; gap: .45rem; margin-bottom: 1rem; }
.comment-compose textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; }
.comment { display: flex; gap: .65rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.comment > div { flex: 1; min-width: 0; }
.comment header { width: 100%; }
.comment img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.comment header { display: flex; align-items: center; gap: .45rem; }
.comment header a { font-weight: 700; color: var(--ink); text-decoration: none; }
.comment time { color: var(--muted); font-size: .78rem; }
.comment p { margin: .25rem 0 .35rem; white-space: pre-wrap; }
.comment form button { border: 0; background: none; color: var(--muted); }
.comment form button.on { color: var(--accent); }
.more { margin-left: auto; position: relative; }
.more summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 1.1rem; }
.more summary::-webkit-details-marker { display: none; }
.more button { position: absolute; right: 0; top: 1.2rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .4rem .7rem; white-space: nowrap; }
.report-modal { border: 0; border-radius: 12px; padding: 1.2rem; width: min(420px, 92vw); }
.report-modal::backdrop { background: rgba(0,0,0,.4); }
.report-modal label { display: block; padding: .45rem 0; }
.report-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .8rem; }

.reason-picks { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.reason-picks label { display: inline-flex; }
.reason-picks input { position: absolute; opacity: 0; }
.reason-picks span { border: 1px solid var(--line); border-radius: 999px; padding: .35rem .7rem; cursor: pointer; }
.reason-picks input:checked + span { border-color: var(--ink); background: #111827; color: #fff; }
.comment-letter { width: 36px; height: 36px; border-radius: 50%; background: #f3f4f6; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

.visuals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: .5rem;
}
.visual-card {
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.visual-frame {
  background: #fafafa;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .5rem;
}
.visual-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.visual-card figcaption {
  padding: .6rem .75rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.visual-type {
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.visual-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink);
}

.visual-card { cursor: pointer; }
.visual-card:hover { border-color: #d1d5db; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none; }
.lb-stage {
  max-width: min(92vw, 1100px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lb-stage img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 6px;
}
.lb-caption {
  color: #fff;
  margin-top: .75rem;
  font-size: .95rem;
  text-align: center;
}
.lb-close, .lb-prev, .lb-next {
  position: absolute;
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,.22); }
.lb-close { top: 1rem; right: 1rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }

.community-banner-wrap { position: relative; margin-bottom: 2.5rem; }
.community-banner { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; display: block; }
.community-banner-empty { background: linear-gradient(120deg, #1f2937 0%, #374151 50%, #4b5563 100%); height: 140px; border-radius: 10px; }
.community-banner-icon {
  position: absolute; left: 16px; bottom: -28px;
  width: 72px; height: 72px; border-radius: 50%;
  border: 4px solid #fff; object-fit: cover; background: #fff;
}
.community-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding-left: 96px; }
.community-sort { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.community-sort a { padding: .5rem 0; color: var(--muted); text-decoration: none; font-weight: 600; }
.community-sort a.on { color: var(--ink); border-bottom: 2px solid var(--accent); }
.community-post-card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: .9rem 1rem; text-decoration: none; color: inherit;
}
.community-post-card:hover { border-color: #d1d5db; }
.community-post-title { font-weight: 650; }
.community-post-meta { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.community-post-thumb { max-height: 140px; width: 100%; object-fit: cover; border-radius: 6px; margin-top: .6rem; }

.site-footer {
  text-align: center;
  padding: .8rem 1rem;
  color: var(--muted);
  font-size: .85rem;
  border-top: 1px solid var(--line);
  margin-top: 1.5rem;
}
.site-footer a { margin: 0 .6rem; color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* ===== Communities ===== */
.comm-page { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.comm-header { margin-bottom: 1.5rem; }
.comm-header h1 { font-family: var(--font-serif); margin: 0 0 .25rem; }

.comm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.comm-card {
  display: flex; gap: .75rem; padding: 1rem;
  background: var(--sheet); border-radius: var(--radius);
  border: 1px solid var(--line); text-decoration: none; color: inherit;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.comm-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.comm-card-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0; overflow: hidden;
}
.comm-card-icon img { width: 100%; height: 100%; object-fit: cover; }
.comm-card-body { display: flex; flex-direction: column; gap: .25rem; }
.comm-card-body strong { font-size: 1rem; color: var(--ink); }
.comm-card-body .sub { font-size: .85rem; }

.comm-banner { height: 140px; background-size: cover; background-position: center; border-radius: var(--radius); margin-bottom: 1rem; }

.comm-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; }
@media (max-width: 800px) { .comm-layout { grid-template-columns: 1fr; } .comm-sidebar { order: -1; } }

.comm-tabs {
  display: flex; gap: .5rem; align-items: center;
  margin-bottom: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .5rem;
}
.comm-tabs a { padding: .5rem 1rem; text-decoration: none; color: var(--muted); border-radius: 6px; font-weight: 600; }
.comm-tabs a.active { color: var(--ink); border-bottom: 2px solid var(--accent); }
.comm-tabs .comm-new { margin-left: auto; background: var(--accent); color: #fff; border-radius: 8px; }
.comm-tabs .comm-new:hover { background: var(--accent-hover); color: #fff; }

.comm-feed { display: flex; flex-direction: column; gap: .75rem; }
.post-card {
  background: var(--sheet); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.post-card h2 { margin: .5rem 0; font-size: 1.1rem; font-family: var(--font-serif); }
.post-card h2 a { color: var(--ink); text-decoration: none; }
.post-card h2 a:hover { color: var(--accent); }
.post-card h1 { margin: .5rem 0 1rem; font-size: 1.4rem; font-family: var(--font-serif); color: var(--ink); }
.post-meta { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.post-meta .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #f3f4f6; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 600;
}
.post-meta .avatar.sm { width: 24px; height: 24px; font-size: .7rem; }
.post-meta .author { font-weight: 500; color: var(--ink); }
.post-meta .badge { background: var(--accent-soft); padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; }
.post-meta .badge.nsfw { background: #fee2e2; color: var(--danger); }
.post-meta .badge.spoiler { background: #fef3c7; color: #92400e; }
.post-preview { color: #555; font-size: .95rem; margin: .5rem 0; line-height: 1.5; }
.post-body { line-height: 1.6; margin: 1rem 0; font-family: var(--font-serif); }
.post-link { display: block; color: #2563eb; margin: .5rem 0; word-break: break-all; }
.post-actions { display: flex; align-items: center; gap: 1rem; margin-top: .75rem; font-size: .9rem; color: var(--muted); }
.vote-form { display: flex; align-items: center; gap: .25rem; }
.vote-btn {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  padding: .25rem .5rem; cursor: pointer; color: var(--ink);
}
.vote-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.score { min-width: 1.5rem; text-align: center; font-weight: 600; }

.comm-sidebar { display: flex; flex-direction: column; gap: 1rem; }
.side-card {
  background: var(--sheet); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
}
.side-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.side-icon { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.side-card p { font-size: .9rem; color: #555; margin: .5rem 0; }
.side-card .btn { display: block; text-align: center; margin-top: .75rem; }
.rules { list-style: none; padding: 0; margin: .5rem 0 0; }
.rules li { padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .85rem; }
.rules li:last-child { border: none; }

.replies-section { margin-top: 1.5rem; }
.replies-section h2 { font-size: 1.1rem; margin-bottom: 1rem; font-family: var(--font-serif); }
.reply-form { margin-bottom: 1.5rem; }
.reply-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: .75rem; resize: vertical; font-family: inherit;
}
.reply-form textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.reply-form button { margin-top: .5rem; }
.replies-list { display: flex; flex-direction: column; gap: .75rem; }
.reply-card { background: #fafafa; border-radius: 8px; padding: .75rem 1rem; }
.reply-body { margin: .5rem 0; line-height: 1.5; }

.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.pager a { color: var(--ink); text-decoration: none; font-weight: 600; }
.pager a:hover { color: var(--accent); }

.post-nav { margin-bottom: 1rem; }
.post-nav a { color: var(--muted); text-decoration: none; }
.post-nav a:hover { color: var(--accent); }

.btn-outline {
  background: var(--sheet); border: 1px solid var(--line);
  color: var(--ink); padding: .5rem 1rem; border-radius: 8px;
  text-decoration: none; display: inline-block;
}
.btn-outline:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ===== Board Layout ===== */
.board-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; max-width: 1100px; margin: 0 auto; padding: 1rem; }
.board-main { min-width: 0; }
.board-sidebar { display: flex; flex-direction: column; gap: 1rem; }
.board-tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.board-tabs a { padding: .75rem 0; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.board-tabs a.active, .board-tabs a:hover { color: var(--ink); border-bottom-color: var(--accent); }
.board-feed { display: flex; flex-direction: column; gap: .75rem; }
.board-card { background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.25rem; }
.board-card-meta { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.board-avatar, .board-avatar-letter { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.board-avatar-letter { display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 700; font-size: .8rem; }
.board-avatar-letter.sm { width: 22px; height: 22px; font-size: .7rem; }
.board-card h2 { font-size: 1.15rem; margin: 0 0 .5rem; line-height: 1.3; }
.board-card h2 a { color: var(--ink); text-decoration: none; }
.board-card h2 a:hover { color: var(--accent); }
.board-preview { color: var(--muted); font-size: .95rem; line-height: 1.5; margin: 0; }
.board-actions { display: flex; gap: .75rem; margin-top: .75rem; }
.board-vote, .board-comments { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: .35rem .75rem; font-size: .85rem; }
.board-banner { height: 120px; background-size: cover; background-position: center; border-radius: 12px; margin-bottom: 1rem; position: relative; }
.board-banner-icon { position: absolute; bottom: -20px; left: 1.5rem; width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--sheet); }
.board-list { list-style: none; padding: 0; margin: .75rem 0 0; }
.board-list li { margin-bottom: .5rem; }
.board-list a { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none; }
.board-list a:hover { color: var(--accent); }
.board-icon-sm, .board-icon-letter { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.board-icon-letter { display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 700; }
.board-back { color: var(--muted); text-decoration: none; margin-right: .25rem; }
.board-back:hover { color: var(--accent); }
.board-back-link { color: var(--accent); text-decoration: none; display: block; margin-top: .75rem; }
.board-body { line-height: 1.7; margin: 1rem 0; }
.board-post h1 { font-size: 1.4rem; margin: .5rem 0 1rem; }
.board-comments { margin-top: 1.5rem; }
.board-comments h2 { font-size: 1.1rem; margin-bottom: 1rem; }
@media (max-width: 768px) { .board-layout { grid-template-columns: 1fr; } .board-sidebar { order: -1; } }


/* ===== Communities ===== */
.comm-layout {
  display: grid;
  grid-template-columns: 200px 1fr 280px;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}
.comm-sticky { position: sticky; top: 5rem; }
.comm-promo { width: 100%; border-radius: var(--radius); object-fit: cover; }

.comm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--line);
}
.comm-tabs { display: flex; gap: 1.25rem; }
.comm-tabs a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: .9rem;
  padding-bottom: .25rem;
}
.comm-tabs a.active { color: var(--ink); border-bottom: 2px solid var(--ink); }
.comm-create-btn {
  background: var(--accent);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
}
.comm-create-btn:hover { background: var(--accent-hover); color: #fff; }

.comm-post {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  transition: background .12s ease, border-color .12s ease;
}
.comm-post:hover { background: var(--paper); border-color: #d1d5db; }
.comm-post-hit { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.comm-post > *:not(.comm-post-hit) { position: relative; z-index: 2; pointer-events: none; }
.comm-post a, .comm-post button { pointer-events: auto; }

.comm-post-meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: .5rem;
}
.comm-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 600;
}
.comm-author { font-weight: 500; color: var(--ink); }
.comm-board { color: var(--muted); text-decoration: none; }
.comm-board:hover { text-decoration: underline; }
.comm-dot { color: #d1d5db; }
.comm-badge { background: var(--paper); padding: .1rem .4rem; border-radius: 4px; font-size: .7rem; }

.comm-post-title {
  margin: 0 0 .4rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.comm-post-preview { color: var(--muted); font-size: .9rem; line-height: 1.5; margin: 0; }
.comm-post-image img { max-width: 100%; max-height: 180px; border-radius: 8px; margin-top: .5rem; object-fit: cover; }

.comm-post-actions { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; }
.comm-vote {
  display: flex;
  align-items: center;
  gap: .15rem;
  background: var(--paper);
  border-radius: 999px;
  padding: .25rem .4rem;
}
.comm-vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: .25rem;
  border-radius: 50%;
  color: var(--muted);
  display: flex;
}
.comm-vote-btn:hover { color: var(--accent); background: var(--sheet); }
.comm-vote-count { font-weight: 600; font-size: .8rem; min-width: 1rem; text-align: center; }
.comm-comment-btn {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .6rem;
  background: var(--paper);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: .8rem;
}
.comm-comment-btn:hover { background: var(--line); }

.comm-side {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.comm-side-title { margin: 0 0 .25rem; font-size: 1rem; font-weight: 600; color: var(--ink); }
.comm-side-slug { color: var(--muted); font-size: .8rem; margin: 0 0 .5rem; }
.comm-side-desc { color: var(--muted); font-size: .85rem; line-height: 1.5; margin: 0 0 .5rem; }
.comm-side-meta { color: var(--muted); font-size: .75rem; margin: 0 0 .75rem; }
.comm-side-actions { display: flex; gap: .5rem; }
.comm-btn {
  padding: .5rem .75rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  flex: 1;
  text-align: center;
}
.comm-btn-primary { background: var(--accent); color: #fff; }
.comm-btn-primary:hover { background: var(--accent-hover); color: #fff; }
.comm-btn-outline { background: var(--sheet); color: var(--ink); border: 1px solid var(--line); }
.comm-btn-outline:hover { background: var(--paper); }
.comm-rules { white-space: pre-wrap; font-size: .8rem; color: var(--muted); line-height: 1.6; }

.comm-list { list-style: none; padding: 0; margin: 0; }
.comm-list li { margin-bottom: .5rem; }
.comm-list a { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none; font-size: .85rem; }
.comm-list a:hover { color: var(--accent); }
.comm-list-icon { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.comm-list-letter {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 600;
}

.comm-empty { text-align: center; padding: 2.5rem; color: var(--muted); }
.comm-pager { display: flex; gap: .75rem; justify-content: center; padding: 1rem 0; }
.comm-pager a { color: var(--ink); text-decoration: none; font-weight: 500; }
.comm-pager a:hover { color: var(--accent); }

@media (max-width: 992px) {
  .comm-layout { grid-template-columns: 1fr 260px; }
  .comm-left { display: none; }
}
@media (max-width: 768px) {
  .comm-layout { grid-template-columns: 1fr; }
  .comm-right { display: none; }
}

.comm-post, .comm-side, .post-card { transform: none !important; }
.comm-post:hover, .comm-side:hover, .post-card:hover { transform: none !important; }


.comm-reply-form, .comm-edit-form { display: none; margin-top: .5rem; }
.comm-reply-form.show, .comm-edit-form.show { display: block; }
.comm-reply-form textarea, .comm-edit-form textarea { width: 100%; padding: .5rem; border: 1px solid var(--line); border-radius: 6px; margin-bottom: .5rem; font-family: inherit; }
.comm-comment { margin-bottom: 1rem; }
.comm-comment-meta { display: flex; align-items: center; gap: .4rem; font-size: .8rem; margin-bottom: .25rem; }
.comm-comment-body { font-size: .9rem; line-height: 1.5; margin-bottom: .5rem; }
.comm-comment-actions { display: flex; align-items: center; gap: .75rem; font-size: .75rem; }
.comm-comment-actions button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; }
.comm-comment-actions button:hover { color: var(--ink); }


.comm-comment { margin-bottom: 1rem; }
.comm-replies { margin-top: .75rem; margin-left: 1rem; padding-left: .75rem; border-left: 2px solid var(--line); }

