@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700;800&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

/* ─── DESIGN TOKENS ─────────────────────────────── */
:root {
  --bg:          #0d0f1a;
  --bg-card:     #141626;
  --bg-glass:    rgba(255,255,255,0.04);
  --border:      rgba(255,255,255,0.08);
  --accent:      #7c6ef7;
  --accent-glow: rgba(124,110,247,0.35);
  --accent-2:    #e06af0;
  --text-primary:   #f0f0ff;
  --text-secondary: #8b8da8;
  --text-muted:     #555770;
  --status-pending:     #f0a500;
  --status-translating: #3b9ded;
  --status-completed:   #34d399;
  --status-failed:      #f87171;
  --radius:  14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.45);
  --transition: 0.22s cubic-bezier(.4,0,.2,1);
}

/* ─── RESET ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ─── SCROLLBAR ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 99px; }

/* ─── NAVBAR ─────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  padding: 0 1.5rem;
  height: 58px;
  background: rgba(13,15,26,0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.navbar-brand {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.2rem; font-weight: 800; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -.5px;
}
.navbar-brand svg { flex-shrink: 0; }
.navbar-search {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .4rem .4rem .4rem 1rem;
  transition: var(--transition);
  flex: 1; min-width: 0; max-width: 400px;
}
.navbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.navbar-search input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-family: inherit; font-size: .9rem;
  flex: 1; min-width: 0;
}
.navbar-search input::placeholder { color: var(--text-muted); }
.navbar-search button {
  background: var(--accent); border: none; cursor: pointer;
  border-radius: 99px; padding: .3rem .7rem;
  color: #fff; font-size: .78rem; font-weight: 600;
  transition: var(--transition); flex-shrink: 0;
}
.navbar-search button:hover { background: var(--accent-2); }
.navbar-links { display: flex; gap: 1rem; flex-shrink: 0; }
.navbar-links a {
  font-size: .9rem; font-weight: 600; color: var(--text-secondary);
  transition: var(--transition);
}
.navbar-links a:hover { color: var(--text-primary); }

/* ── Mobile navbar ─── */
@media (max-width: 640px) {
  .navbar {
    padding: 0 1rem;
    height: 52px;
    gap: .5rem;
  }
  /* Hide search on small screens — use the import button instead */
  .navbar-search { display: none; }
  .navbar-brand { font-size: 1.05rem; }
  .navbar-brand .brand-suffix { display: none; } /* hide ".VN" */
  .btn-import { font-size: .78rem; padding: .38rem .75rem; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .navbar-search { min-width: 160px; }
}

/* ─── HERO BANNER ─────────────────────────────────── */
.hero {
  text-align: center;
  padding: 5rem 2rem 4rem;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(124,110,247,0.18) 0%, transparent 70%);
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: .75rem;
}
.hero p { color: var(--text-secondary); font-size: 1.1rem; max-width: 520px; margin: 0 auto; }

/* ─── LAYOUT ─────────────────────────────────────── */
.container { max-width: 1280px; margin: 0 auto; padding: 0 2rem; }
.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 2.5rem 0 1.2rem;
}
.section-title {
  font-size: 1.25rem; font-weight: 800;
  display: flex; align-items: center; gap: .5rem;
}
.section-title::before {
  content: '';
  display: inline-block; width: 4px; height: 1em;
  background: linear-gradient(var(--accent), var(--accent-2));
  border-radius: 99px;
}
.section-count { color: var(--text-muted); font-size: .85rem; }

/* ─── STORY GRID ─────────────────────────────────── */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
  padding-bottom: 3rem;
}

.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}
.story-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  box-shadow: 0 12px 40px rgba(124,110,247,0.25);
}
.story-card__cover {
  aspect-ratio: 2/3;
  object-fit: cover; width: 100%;
  background: var(--bg-glass);
}
.story-card__cover-placeholder {
  aspect-ratio: 2/3; width: 100%;
  background: linear-gradient(135deg, #1e1f36, #2a1f4a);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
}
.story-card__body { padding: .75rem; }
.story-card__title {
  font-size: .88rem; font-weight: 700;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.4; margin-bottom: .3rem;
}
.story-card__author { font-size: .75rem; color: var(--text-muted); }
.story-card__badge {
  position: absolute; top: .5rem; right: .5rem;
  background: var(--accent); color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: .15rem .4rem; border-radius: 4px;
}

/* ─── EMPTY STATE ────────────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center; padding: 5rem 2rem;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 4rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-size: 1.2rem; color: var(--text-secondary); margin-bottom: .5rem; }

/* ─── PAGINATION ─────────────────────────────────── */
.pagination {
  display: flex; justify-content: center; gap: .5rem;
  padding: 2rem 0 3rem;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .9rem;
  border: 1px solid var(--border);
  transition: var(--transition);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.pagination .dots { border: none; color: var(--text-muted); }

/* ─── STORY DETAIL PAGE ──────────────────────────── */
.story-detail { display: grid; grid-template-columns: 220px 1fr; gap: 2.5rem; padding: 2.5rem 0 4rem; }
@media (max-width: 700px) { .story-detail { grid-template-columns: 1fr; } }

.story-cover-wrap img, .story-cover-wrap .cover-placeholder {
  width: 100%; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.story-cover-wrap .cover-placeholder {
  aspect-ratio: 2/3;
  background: linear-gradient(135deg, #1e1f36, #2a1f4a);
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem;
}
.story-info__title { font-size: 1.6rem; font-weight: 800; line-height: 1.3; margin-bottom: .4rem; }
.story-info__author { color: var(--text-secondary); font-size: .95rem; margin-bottom: 1rem; }
.story-info__desc {
  color: var(--text-secondary); font-size: .9rem; line-height: 1.75;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 1.25rem;
}
.story-info__tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.5rem; }
.tag {
  font-size: .75rem; padding: .2rem .65rem;
  border-radius: 99px; border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-primary {
  display: inline-flex; align-items: center; gap: .5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; cursor: pointer;
  font-family: inherit; font-size: .95rem; font-weight: 700;
  padding: .7rem 1.5rem; border-radius: 99px;
  transition: var(--transition); text-decoration: none;
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--bg-glass); color: var(--text-secondary);
  border: 1px solid var(--border); cursor: pointer;
  font-family: inherit; font-size: .9rem; font-weight: 600;
  padding: .6rem 1.25rem; border-radius: 99px;
  transition: var(--transition); text-decoration: none;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Chapter list */
.chapter-list-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
  font-size: .85rem; color: var(--text-muted);
}
.chapter-list { display: flex; flex-direction: column; gap: .35rem; }
.chapter-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: var(--transition); cursor: pointer;
}
.chapter-item:hover { border-color: var(--accent); background: var(--bg-glass); }
.chapter-item__num { color: var(--text-muted); font-size: .8rem; min-width: 42px; }
.chapter-item__title { font-size: .9rem; font-weight: 600; flex: 1; }
.chapter-item__status { font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 4px; }
.status--pending     { color: var(--status-pending);     background: rgba(240,165,0,.12); }
.status--translating { color: var(--status-translating); background: rgba(59,157,237,.12); }
.status--completed   { color: var(--status-completed);   background: rgba(52,211,153,.12); }
.status--failed      { color: var(--status-failed);      background: rgba(248,113,113,.12); }

/* Chapter page tabs */
.ch-page-tabs {
  display: flex; flex-wrap: wrap; gap: .4rem;
  margin-bottom: 1rem;
}
.ch-page-tab {
  font-size: .78rem; font-weight: 700;
  padding: .3rem .7rem; border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
}
.ch-page-tab:hover { border-color: var(--accent); color: var(--accent); }
.ch-page-tab.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}

/* ─── READER PAGE ────────────────────────────────── */
.reader-nav {
  position: sticky; top: 64px; z-index: 90;
  background: rgba(13,15,26,0.9); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: .65rem 2rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.reader-nav__title { font-size: .85rem; color: var(--text-secondary); truncate: ellipsis; flex:1; overflow: hidden; white-space: nowrap; }
.reader-nav__controls { display: flex; gap: .5rem; flex-shrink: 0; }

.reader-body { max-width: 780px; margin: 0 auto; padding: 3rem 2rem 5rem; }
.reader-chapter-title {
  font-size: 1.5rem; font-weight: 800;
  margin-bottom: 2.5rem; line-height: 1.35;
}
.reader-progress {
  font-size: .8rem; color: var(--text-muted); margin-bottom: 2rem;
  display: flex; align-items: center; gap: .75rem;
}
.reader-progress__bar {
  flex: 1; height: 3px; background: var(--border); border-radius: 99px; overflow: hidden;
}
.reader-progress__fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }

.reader-content {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.1rem; line-height: 2;
  color: #d8d8ef;
}
.reader-content p { margin-bottom: 1.35em; }

.reader-pending {
  text-align: center; padding: 4rem 2rem;
  color: var(--text-muted);
}
.reader-pending .spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.reader-footer {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 2.5rem 0 0;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ─── TOAST ──────────────────────────────────────── */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .75rem 1.25rem;
  font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
}
@keyframes slideIn { from { transform: translateX(100px); opacity:0; } to { transform:none; opacity:1; } }

/* ─── FOOTER ─────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  text-align: center; padding: 2rem;
  color: var(--text-muted); font-size: .85rem;
}
footer span { color: var(--accent); }

/* ─── IMPORT BUTTON (NAVBAR) ─────────────────────── */
.btn-import {
  display: inline-flex; align-items: center; gap: .4rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; cursor: pointer;
  font-family: inherit; font-size: .85rem; font-weight: 700;
  padding: .45rem 1rem; border-radius: 99px;
  transition: var(--transition); white-space: nowrap;
}
.btn-import:hover { opacity: .85; transform: translateY(-1px); }

/* ─── MODAL ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #1a1c2e;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  width: 100%; max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.open .modal { transform: none; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-title { font-size: 1.15rem; font-weight: 800; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem;
  padding: .2rem .5rem; border-radius: 6px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-glass); }
.modal-desc { color: var(--text-secondary); font-size: .9rem; margin-bottom: 1.25rem; line-height: 1.6; }
.modal-input-wrap { margin-bottom: 1rem; }
.modal-input {
  width: 100%;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  color: var(--text-primary);
  font-family: 'Nunito', monospace;
  font-size: .9rem;
  outline: none;
  transition: var(--transition);
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.modal-input::placeholder { color: var(--text-muted); }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Import status feedback */
.import-status {
  font-size: .875rem; padding: .65rem 1rem;
  border-radius: var(--radius-sm); line-height: 1.5;
}
.import-status.importing { background: rgba(59,157,237,.12); color: #3b9ded; }
.import-status.success   { background: rgba(52,211,153,.12); color: #34d399; }
.import-status.error     { background: rgba(248,113,113,.12); color: #f87171; }
