*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f4f0;
  --bg2: #ffffff;
  --bg3: #f0eff0;
  --bg4: #e8e7e9;
  --border: #e2e1e4;
  --border2: #d0cfd3;
  --text: #1a1820;
  --text2: #5a5865;
  --text3: #9b99a5;
  --primary: #d4420f;
  --primary-bg: #fdf0eb;
  --primary-hover: #b83a0d;
  --secondary: #d63870;
  --secondary-bg: #fdeef5;
  --accent: #d4420f;
  --accent-bg: #fdf0eb;
  --red: #d44;
  --green: #2a9d5c;
  --blue: #3b7dd8;
  --purple: #7c4dcc;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: 220px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-product-label {
  margin-top: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.logo-img {
  width: 130px;
  height: auto;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.nav-item.active svg { color: var(--primary); }
.nav-item.disabled { opacity: 0.4; pointer-events: none; }

.sidebar-nav-divider { height: 1px; background: var(--border); margin: 8px 12px; }

.nav-item-external { color: var(--text3); }
.nav-item-external:hover { color: var(--text); }
.nav-external-icon { margin-left: auto; opacity: 0.5; flex-shrink: 0; }

.badge-soon {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: var(--bg3);
  color: var(--text3);
  padding: 2px 6px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.btn-add {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s;
}

.btn-add:hover { background: var(--primary-hover); }

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  background: transparent;
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: all 0.15s;
}

.btn-logout:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }

/* ─── UPLOAD JSON MODAL ─── */
.ujson-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.ujson-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.ujson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.ujson-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.ujson-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: color 0.15s;
}
.ujson-close:hover { color: var(--text); }
.ujson-desc {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 18px;
  line-height: 1.5;
}
.ujson-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 32px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text3);
  text-align: center;
}
.ujson-drop:hover, .ujson-drop-hover { border-color: var(--primary); background: var(--primary-bg); color: var(--primary); }
.ujson-drop-text { font-size: 13px; font-weight: 600; }
.ujson-drop-sub  { font-size: 11px; }
.ujson-status {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
.ujson-status-loading { background: var(--bg3); color: var(--text2); }
.ujson-status-ok      { background: rgba(42,157,92,0.1); color: var(--green); }
.ujson-status-error   { background: rgba(212,68,68,0.1); color: var(--red); }

/* ─── LOGIN PAGE ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 48px 44px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.login-logo {
  width: 150px;
  height: auto;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 32px;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  text-align: center;
  letter-spacing: 2px;
}

.login-input:focus { border-color: var(--primary); }

.login-error {
  font-size: 12px;
  color: var(--red);
  font-weight: 500;
}

.login-btn {
  width: 100%;
  padding: 11px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s;
  margin-top: 4px;
}

.login-btn:hover { background: var(--primary-hover); }

/* ─── MAIN ─── */
.main {
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.no-sidebar .main { margin-left: 0; }

/* ─── TOP BAR ─── */
.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 5;
  gap: 12px;
}

.topbar-search {
  flex: 1;
  min-width: 180px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.back-btn:hover { background: var(--bg3); color: var(--text); }
.back-btn svg { width: 13px; height: 13px; }

.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.story-count {
  font-size: 12px;
  color: var(--text3);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}

.search-wrap svg { color: var(--text3); flex-shrink: 0; }
.search-wrap input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  width: 180px;
}
.search-wrap input::placeholder { color: var(--text3); }

.filter-wrap select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  cursor: pointer;
}

/* ─── CONTENT AREA ─── */
.content-area {
  flex: 1;
  padding: 24px 28px;
}

/* ─── STORY GRID ─── */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

/* ─── VIEW TOGGLE ─── */
.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text3);
  transition: background 0.15s, color 0.15s;
}
.view-toggle-btn:hover { background: var(--bg4); color: var(--text2); }
.view-toggle-btn.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.view-toggle-btn svg { width: 15px; height: 15px; }

/* ─── CERITA TAB ─── */
.cerita-list { display: flex; flex-direction: column; gap: 8px; }

.cerita-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
}

.cerita-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.cerita-header:hover { background: var(--bg3); }

.cerita-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  min-width: 24px;
  font-variant-numeric: tabular-nums;
}

.cerita-judul {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.cerita-arrow {
  width: 16px;
  height: 16px;
  color: var(--text3);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.cerita-konten {
  display: none;
  padding: 16px 16px 16px 52px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text2);
  border-top: 1px solid var(--border);
}
.cerita-konten p { margin-bottom: 12px; }
.cerita-konten p:last-child { margin-bottom: 0; }

.cerita-item.open .cerita-arrow { transform: rotate(180deg); }
.cerita-item.open .cerita-konten { display: block; }

.card-completeness {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card-completeness-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.completeness-score {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
}
.completeness-bar-track {
  height: 4px;
  background: var(--bg4);
  border-radius: 99px;
  overflow: hidden;
}
.completeness-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}
.completeness-bar-fill.level-1 { background: #ccc; }
.completeness-bar-fill.level-2 { background: #f59e0b; }
.completeness-bar-fill.level-3 { background: #eab308; }
.completeness-bar-fill.level-4 { background: #3b82f6; }
.completeness-bar-fill.level-5 { background: #8b5cf6; }
.completeness-bar-fill.level-6 { background: #22c55e; }

.card-footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.completeness-badge {
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.completeness-badge.level-1 { background: #f0f0f0; color: #888; border-color: #ddd; }
.completeness-badge.level-2 { background: #fef3e2; color: #b45309; border-color: #fcd89a; }
.completeness-badge.level-3 { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.completeness-badge.level-4 { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.completeness-badge.level-5 { background: #f3e8ff; color: #7c3aed; border-color: #ddd6fe; }
.completeness-badge.level-6 { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }

.btn-approve {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #16a34a;
  background: #f0fdf4;
  color: #15803d;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-approve:hover { background: #dcfce7; transform: translateY(-1px); }

.btn-approved {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #bbf7d0;
  background: #dcfce7;
  color: #15803d;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
  opacity: 0.8;
}

.source-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  margin-left: auto;
}

.fiction-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #e8f4fd;
  color: #2d6fa8;
  border: 1px solid #b8d9f0;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── LIST VIEW ─── */
.story-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.story-list-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.story-list-row:hover { border-color: var(--border2); box-shadow: var(--shadow); }
.list-row-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  min-width: 28px;
  font-variant-numeric: tabular-nums;
}
.list-row-body { flex: 1; min-width: 0; }
.list-row-top {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 4px;
}
.list-row-badges {
  display: flex;
  align-items: center;
  gap: 4px;
}
.list-row-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row-tagline {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.list-row-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--text3);
}
.list-row-completeness {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.list-score-pill {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  padding: 8px 14px;
  border-radius: 99px;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.list-score-pill.level-1 { background: #f0f0f0; color: #888; }
.list-score-pill.level-2 { background: #fef3e2; color: #b45309; }
.list-score-pill.level-3 { background: #fef9c3; color: #854d0e; }
.list-score-pill.level-4 { background: #e0f2fe; color: #0369a1; }
.list-score-pill.level-5 { background: #f3e8ff; color: #7c3aed; }
.list-score-pill.level-6 { background: #dcfce7; color: #15803d; }

.list-score-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  white-space: nowrap;
  text-align: center;
}

.list-row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.story-list-row:hover .list-row-actions { opacity: 1; }

/* ─── CARD THUMBNAIL ─── */
.card-thumb {
  width: calc(100% + 40px);
  margin: -20px -20px 16px -20px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  display: block;
}

.card-thumb-placeholder {
  width: calc(100% + 40px);
  margin: -20px -20px 16px -20px;
  height: 160px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.card-thumb-placeholder svg {
  width: 32px;
  height: 32px;
  color: var(--border2);
}

/* ─── DETAIL HERO ─── */
.detail-hero {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 28px;
  display: block;
}

.story-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.story-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--accent));
}

.story-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-num {
  font-size: 10px;
  color: var(--text3);
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.genre-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 4px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.card-tagline {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.6;
  font-style: italic;
}

.card-synopsis {
  font-size: 12.5px;
  color: var(--text3);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text3);
}

.meta-item svg { width: 12px; height: 12px; }

.card-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.char-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.card-actions { display: flex; gap: 6px; }

.btn-icon {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-icon:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.btn-icon svg { width: 12px; height: 12px; }

.pdf-link {
  font-size: 11px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── PAGE: DETAIL ─── */
.detail-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 28px 48px;
}

.detail-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.detail-title {
  font-family: 'Playfair Display', serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 8px;
}

.detail-tagline {
  font-size: 15px;
  color: var(--text2);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 20px;
}

.detail-meta-row {
  display: flex;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.detail-meta-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text2);
}

.detail-meta-item svg { width: 15px; height: 15px; color: var(--primary); flex-shrink: 0; }

.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.8px;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 10px;
  margin-top: 28px;
}

.synopsis-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text2);
}

.chars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.char-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.char-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 3px;
}

.char-role { font-size: 11.5px; color: var(--text3); }

.char-flag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 5px;
}

.flag-killer { background: #fff0f0; color: var(--red); border: 1px solid #f8c0c0; }
.flag-victim { background: #eef4ff; color: var(--blue); border: 1px solid #c0d4f8; }
.flag-optional { background: var(--bg4); color: var(--text3); border: 1px solid var(--border); }
.flag-cult { background: #f3eeff; color: var(--purple); border: 1px solid #d4c0f8; }

.mechanics-box {
  background: var(--primary-bg);
  border: 1px solid #f0c0a0;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text2);
  line-height: 1.65;
}

.content-warning {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--red);
  background: #fff0f0;
  border: 1px solid #f8c0c0;
  padding: 5px 12px;
  border-radius: 20px;
  margin-top: 20px;
}

.detail-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  padding: 10px 18px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.detail-pdf-btn:hover { border-color: var(--text); color: var(--text); background: var(--bg4); }

/* ─── PAGE: FORM ─── */
.form-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 28px 48px;
}

.form-page-title {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.form-section {
  margin-bottom: 28px;
}

.form-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-row label, .form-label-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}

.form-row input,
.form-row textarea,
.form-row select {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: 'Inter', sans-serif;
  width: 100%;
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212,66,15,0.1);
}

.form-row textarea { resize: vertical; }
.form-row input::placeholder, .form-row textarea::placeholder { color: var(--text3); }

.form-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.char-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.char-field-row input {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
  font-family: 'Inter', sans-serif;
}

.char-field-row input:focus { border-color: var(--primary); }

.btn-remove-char {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  border-radius: 5px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-remove-char:hover { border-color: var(--red); color: var(--red); background: #fff0f0; }

.btn-sm {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sm:hover { border-color: var(--primary); color: var(--primary); }

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.btn-secondary {
  padding: 10px 20px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover { border-color: var(--text2); color: var(--text); }

.btn-primary {
  padding: 10px 22px;
  background: var(--primary);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-danger {
  padding: 10px 20px;
  background: none;
  border: 1px solid #f8c0c0;
  color: var(--red);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: auto;
}

.btn-danger:hover { background: #fff0f0; }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
  grid-column: 1/-1;
}

.empty-state h3 { font-size: 16px; color: var(--text2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ─── DIVIDER ─── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ─── DETAIL PAGE SECTIONS ─── */

/* Tabs */
.detail-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
  position: sticky;
  top: 57px;
  background: var(--bg);
  z-index: 4;
  padding-top: 4px;
}

.detail-tab {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
}

.detail-tab:hover { color: var(--text2); }
.detail-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Prolog */
.prolog-text {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text2);
  max-width: 680px;
}

.prolog-text p + p { margin-top: 18px; }

/* Timeline */
.timeline-list {
  position: relative;
  padding-left: 0;
  list-style: none;
  max-width: 640px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 16px;
  padding-bottom: 24px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 72px;
  top: 28px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item:last-child::before { display: none; }

.timeline-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  padding-top: 4px;
  text-align: right;
}

.timeline-dot {
  position: absolute;
  left: calc(72px + 16px - 5px);
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--primary);
}

.timeline-event {
  padding-left: 24px;
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  padding-top: 2px;
}

/* Character Cards */
.char-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.char-detail-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.char-detail-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.char-detail-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}

.char-detail-role {
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 2px;
}

.char-detail-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.char-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 3px;
}

.char-field-text {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.55;
}

.char-secret-box {
  background: var(--primary-bg);
  border: 1px solid #f0c0a0;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 4px;
}

.char-secret-box .char-field-label { color: var(--primary); }
.char-secret-box .char-field-text { color: var(--text); }

/* Clue Cards */
.clue-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.clue-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clue-num {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text3);
}

.clue-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.clue-location {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text3);
  background: var(--bg3);
  border-radius: 4px;
  padding: 3px 8px;
  width: fit-content;
}

.clue-desc {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.6;
}

/* Epilog */
.epilog-block {
  max-width: 680px;
}

.epilog-verdict {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.epilog-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.epilog-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
}

.epilog-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.epilog-recon {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 16px;
}

.epilog-twist {
  background: var(--secondary-bg);
  border: 1px solid rgba(214,56,112,0.2);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 10px;
}

.epilog-twist-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--secondary);
  margin-bottom: 6px;
}

/* Section panel loading */
.section-loading {
  padding: 40px 0;
  color: var(--text3);
  font-size: 13px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── TOPBAR EDIT BTN ─── */
.btn-edit-page {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--primary);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}

.btn-edit-page:hover { background: var(--primary-hover); }
.btn-edit-page svg { width: 13px; height: 13px; }

/* ─── MOBILE ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar → hidden, replaced by bottom bar */
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 20;
    padding: 0;
  }

  .sidebar-header { display: none; }

  .sidebar-nav {
    flex: 1;
    flex-direction: row;
    padding: 0;
    gap: 0;
  }

  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 10px 8px;
    border-radius: 0;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
  }

  .nav-item svg { width: 18px; height: 18px; }
  .badge-soon { display: none; }

  .sidebar-footer {
    border-top: none;
    border-left: 1px solid var(--border);
    padding: 0;
    display: flex;
    align-items: stretch;
  }

  .btn-add {
    border-radius: 0;
    padding: 10px 16px;
    flex-direction: column;
    gap: 3px;
    font-size: 10px;
    height: 100%;
    min-width: 72px;
  }

  /* Main — full width, padding bottom for bottom bar */
  .main {
    margin-left: 0;
    padding-bottom: 64px;
  }

  /* Topbar */
  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
    position: sticky;
  }

  .topbar-left {
    flex: 1;
    min-width: 0;
    gap: 6px;
  }

  .page-title {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-right {
    gap: 6px;
    margin-left: auto;
  }

  .topbar-search {
    flex: 1 0 100%;
    order: 3;
  }

  .filter-wrap select {
    font-size: 12px;
    padding: 6px 8px;
  }

  .back-btn {
    font-size: 11px;
    padding: 5px 8px;
    flex-shrink: 0;
  }

  .btn-edit-page {
    font-size: 11px;
    padding: 6px 10px;
  }

  /* Content */
  .content-area {
    padding: 16px;
  }

  /* Story grid → single column */
  .story-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Card thumbnail slightly shorter */
  .card-thumb,
  .card-thumb-placeholder {
    height: 130px;
  }

  /* Detail page */
  .detail-page {
    padding: 16px 0 32px;
  }

  .detail-hero {
    height: 200px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
  }

  .detail-title { font-size: 26px; }
  .detail-tagline { font-size: 13px; }

  .detail-meta-row {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
  }

  /* Tabs — scrollable horizontal */
  .detail-tabs {
    top: 53px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    margin: 0 -16px;
    padding: 0 16px;
  }

  .detail-tabs::-webkit-scrollbar { display: none; }

  .detail-tab {
    padding: 9px 14px;
    font-size: 12px;
    white-space: nowrap;
  }

  .tab-panel.active {
    padding-top: 20px;
  }

  /* Character cards → single column */
  .char-cards-grid {
    grid-template-columns: 1fr;
  }

  /* Clue cards → single column */
  .clue-cards-grid {
    grid-template-columns: 1fr;
  }

  /* Timeline */
  .timeline-item {
    grid-template-columns: 54px 1fr;
    gap: 12px;
  }

  .timeline-item::before { left: 54px; }
  .timeline-dot { left: calc(54px + 12px - 5px); }

  /* Form */
  .form-page {
    padding: 20px 0 48px;
  }

  .form-3col {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .chars-grid {
    grid-template-columns: 1fr;
  }

  .char-field-row {
    grid-template-columns: 1fr auto;
    gap: 6px;
  }

  .char-field-row input:first-child { grid-column: 1; }
  .char-field-row input:nth-child(2) { grid-column: 1; }
  .char-field-row { grid-template-columns: 1fr 1fr auto; flex-wrap: wrap; }

  .search-wrap input { width: 100%; }
}

/* ─── NAV SUB-LABEL ─────────────────────────────────────────────────────── */
.nav-sub {
  display: block;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.55;
  margin-top: 1px;
  letter-spacing: 0.2px;
}

/* ─── LANDING PAGE ───────────────────────────────────────────────────────── */
.landing-page {
  padding: 0 0 60px;
}

.landing-hero {
  padding: 48px 40px 40px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg) 60%, rgba(212,66,15,0.04) 100%);
}
.landing-hero-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--primary);
  margin-bottom: 12px;
}
.landing-hero-title {
  font-family: 'Playfair Display', serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 10px;
}
.landing-hero-title em { color: var(--primary); font-style: italic; }
.landing-hero-sub {
  font-size: 15px;
  color: var(--text2);
  margin-bottom: 28px;
  line-height: 1.6;
}
.landing-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.stat-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
}
.stat-chip strong {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-chip span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.landing-section {
  padding: 36px 40px 0;
}

/* Landing search bar */
.landing-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.landing-search-icon {
  position: absolute;
  left: 14px;
  color: var(--text3);
  pointer-events: none;
}

.landing-search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.landing-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212,66,15,0.08);
}

.landing-search-results {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.landing-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.landing-search-item:last-child { border-bottom: none; }
.landing-search-item:hover { background: var(--bg3); }

.landing-search-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.landing-search-item-tagline {
  font-size: 12px;
  color: var(--text3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.landing-search-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--text3);
  text-align: center;
}
.landing-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 16px;
}
.landing-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.landing-see-all {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
}
.landing-see-all:hover { text-decoration: underline; }

/* Category cards */
.landing-cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.landing-cat-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  overflow: hidden;
}
.landing-cat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.landing-cat-ttrpg::before      { background: var(--primary); }
.landing-cat-horror::before     { background: #7c3aed; }
.landing-cat-webseries::before  { background: #1076a9; }
.landing-cat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
.landing-cat-ttrpg:hover     { border-color: var(--primary); }
.landing-cat-horror:hover    { border-color: #7c3aed; }
.landing-cat-webseries:hover { border-color: #1076a9; }
.landing-cat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.landing-cat-ttrpg .landing-cat-icon     { background: rgba(212,66,15,0.1);  color: var(--primary); }
.landing-cat-horror .landing-cat-icon    { background: rgba(124,58,237,0.1); color: #7c3aed; }
.landing-cat-webseries .landing-cat-icon { background: rgba(16,118,169,0.1); color: #1076a9; }
.landing-cat-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.landing-cat-sub {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 12px;
  font-weight: 500;
}
.landing-cat-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
}
.landing-cat-arrow {
  position: absolute;
  bottom: 18px; right: 18px;
  color: var(--text3);
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
}
.landing-cat-card:hover .landing-cat-arrow { opacity: 1; transform: translateX(3px); }
.landing-cat-ttrpg:hover .landing-cat-arrow     { color: var(--primary); }
.landing-cat-horror:hover .landing-cat-arrow    { color: #7c3aed; }
.landing-cat-webseries:hover .landing-cat-arrow { color: #1076a9; }

/* Genre pills */
.landing-genre-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.landing-genre-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  letter-spacing: 0.2px;
}
.landing-genre-pill:hover { opacity: 0.8; transform: translateY(-1px); }
.genre-pill-count {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.7;
}

/* Recent stories */
.landing-recent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.landing-recent-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border-top: 3px solid var(--card-accent, var(--primary));
}
.landing-recent-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(0,0,0,0.1); }
.landing-recent-thumb {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
}
.landing-recent-thumb-empty { background: var(--bg3); }
.landing-recent-body { padding: 14px 16px 16px; }
.landing-recent-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 8px 0 5px;
  line-height: 1.3;
}
.landing-recent-tagline {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tags on landing category cards */
.landing-cat-tags { margin-bottom: 4px; }
.landing-cat-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.ttrpg-tag {
  background: rgba(212,66,15,0.1);
  color: var(--primary);
  border: 1px solid rgba(212,66,15,0.2);
}

/* SRPG tag on cards */
.srpg-tag-small {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(212,66,15,0.08);
  color: var(--primary);
  border: 1px solid rgba(212,66,15,0.18);
  letter-spacing: 0.2px;
}
.landing-recent-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}
.card-srpg-tag {
  margin: 4px 0 0;
}

@media (max-width: 900px) {
  .landing-hero { padding: 32px 20px 28px; }
  .landing-section { padding: 28px 20px 0; }
  .landing-cat-grid { grid-template-columns: 1fr 1fr; }
  .landing-recent-grid { grid-template-columns: 1fr 1fr; }
  .landing-hero-title { font-size: 26px; }
}
@media (max-width: 600px) {
  .landing-recent-grid { grid-template-columns: 1fr; }
}

/* ─── CHATBOT ────────────────────────────────────────────────────────────── */

.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: #d4420f;
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(212,66,15,0.4);
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
.chat-fab:hover { background: #b83608; transform: translateY(-2px); box-shadow: 0 6px 24px rgba(212,66,15,0.5); }
.chat-fab-active { background: #9e2d07; }

.chat-panel {
  position: fixed;
  bottom: 84px;
  right: 28px;
  z-index: 99;
  width: 520px;
  max-height: 640px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.2s, transform 0.2s;
  overflow: hidden;
}
.chat-panel.chat-open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #d4420f;
  color: #fff;
  flex-shrink: 0;
}
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-title { font-size: 14px; font-weight: 700; }
.chat-subtitle { font-size: 11px; opacity: 0.75; margin-top: 1px; }
.chat-header-actions { display: flex; gap: 4px; }
.chat-icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 6px;
  color: #fff;
  padding: 5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.chat-icon-btn:hover { background: rgba(255,255,255,0.3); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.chat-msg { display: flex; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-bot  { justify-content: flex-start; }

.chat-bubble {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.chat-msg-user .chat-bubble {
  background: #d4420f;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-bot .chat-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-bubble code {
  background: rgba(0,0,0,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}
.chat-msg-user .chat-bubble code { background: rgba(255,255,255,0.2); }

.chat-thinking { opacity: 0.7; }

/* Status indicator */
.chat-status { display: flex; align-items: center; gap: 8px; }
.chat-status-text { font-size: 12px; color: var(--text3); }
/* Typing dots */
.chat-dots { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.chat-dots span {
  width: 7px; height: 7px;
  background: var(--text3);
  border-radius: 50%;
  animation: chatDot 1.2s infinite ease-in-out;
}
.chat-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.15s;
}
.chat-input:focus { border-color: #d4420f; }
.chat-input::placeholder { color: var(--text3); }
.chat-input:disabled { opacity: 0.5; }

.chat-send-btn {
  width: 38px; height: 38px;
  background: #d4420f;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-send-btn:hover { background: #b83608; }
.chat-send-btn:disabled { background: var(--bg4); color: var(--text3); cursor: not-allowed; }

.chat-footer-note {
  padding: 6px 14px 10px;
  font-size: 10px;
  color: var(--text3);
  text-align: center;
  flex-shrink: 0;
}

/* Mobile */
@media (max-width: 768px) {
  .chat-fab {
    bottom: 72px;
    right: 16px;
    padding: 10px 14px;
    font-size: 12px;
  }
  .chat-panel {
    bottom: 130px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 65vh;
    border-radius: 14px;
  }
}
