/* ═══════════════════════════════════════════════════════
   INKWELL — Novel Reading Platform
   Aesthetic: Refined Editorial · Warm Ivory · Ink Black
═══════════════════════════════════════════════════════ */

/* ─── CSS Variables ─── */
:root {
  --bg:           #FAF9F6;
  --bg-card:      #FFFFFF;
  --bg-subtle:    #F2F0EC;
  --surface:      #EDEAE4;
  --border:       #E0DDD5;
  --text-primary: #1A1815;
  --text-secondary:#6B6760;
  --text-muted:   #A09D98;
  --accent:       #C4713A;
  --accent-soft:  #F5E8DC;
  --accent-hover: #AE6030;
  --gold:         #D4A843;
  --shadow-sm:    0 1px 3px rgba(26,24,21,.07), 0 1px 2px rgba(26,24,21,.04);
  --shadow-md:    0 4px 12px rgba(26,24,21,.10), 0 2px 4px rgba(26,24,21,.06);
  --shadow-lg:    0 16px 40px rgba(26,24,21,.14);
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', -apple-system, sans-serif;
  --transition:   0.22s cubic-bezier(.4,0,.2,1);
  --nav-h:        60px;
}

[data-theme="dark"] {
  --bg:           #111010;
  --bg-card:      #1C1B18;
  --bg-subtle:    #171614;
  --surface:      #252320;
  --border:       #2E2C28;
  --text-primary: #F0EDE6;
  --text-secondary:#9E9A93;
  --text-muted:   #5E5B54;
  --accent:       #D4824A;
  --accent-soft:  #2A1E14;
  --accent-hover: #E08A52;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.3);
  --shadow-md:    0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:    0 16px 40px rgba(0,0,0,.6);
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
/* ___ From Đăng Ký ___*/
.modal-backdrop { position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:2000;display:flex;align-items:center;justify-content:center;padding:1rem }
.modal-box { background:var(--bg-card);border-radius:var(--radius-lg);padding:2rem;width:100%;max-width:min(420px,100%);position:relative;box-shadow:var(--shadow-lg) }
.modal-close { position:absolute;top:1rem;right:1rem;font-size:1.3rem;color:var(--text-muted);background:none;border:none;cursor:pointer }
.modal-title { font-family:var(--font-display);font-size:1.4rem;font-weight:700;margin-bottom:1.5rem }
.form-field { margin-bottom:1rem }
.form-field label { display:block;font-size:.85rem;font-weight:600;margin-bottom:.35rem }
.form-field input { width:100%;padding:.6rem .85rem;border:1.5px solid var(--border);border-radius:var(--radius-sm);font-size:.9rem;font-family:inherit;background:var(--bg-card);color:var(--text-primary);transition:border-color .15s }
.form-field input:focus { outline:none;border-color:var(--accent) }
.form-error-msg { font-size:.8rem;color:#dc2626;margin-top:.25rem }
.modal-tabs { display:flex;border-bottom:1.5px solid var(--border);margin-bottom:1.5rem }
.modal-tab { padding:.6rem 1rem;font-size:.875rem;font-weight:600;color:var(--text-secondary);cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1.5px;transition:color .15s,border-color .15s }
.modal-tab.active { color:var(--accent);border-color:var(--accent) }
.user-menu { position:relative }
.user-dropdown { position:absolute;right:0;top:110%;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);min-width:180px;z-index:500;padding:.35rem }
.user-dropdown a,.user-dropdown button { display:flex;align-items:center;gap:.5rem;padding:.55rem .85rem;font-size:.875rem;color:var(--text-secondary);text-decoration:none;border:none;background:none;width:100%;cursor:pointer;border-radius:var(--radius-sm);transition:background .15s,color .15s }
.user-dropdown a:hover,.user-dropdown button:hover { background:var(--bg-subtle);color:var(--text-primary) }
.user-avatar { width:30px;height:30px;border-radius:50%;object-fit:cover;background:var(--surface);display:flex;align-items:center;justify-content:center;font-size:.85rem;flex-shrink:0 }
.toast { position:fixed;bottom:1.5rem;right:1.5rem;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-md);padding:.75rem 1.25rem;box-shadow:var(--shadow-md);font-size:.875rem;z-index:9999;animation:slideUp .25s ease;max-width:min(320px,100%) }
.toast.success { border-left:4px solid #16a34a;color:#15803d }
.toast.error   { border-left:4px solid #dc2626;color:#dc2626 }
@keyframes slideUp { from{transform:translateY(20px);opacity:0} to{transform:translateY(0);opacity:1} }
    

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}
/* .hidden{
  display:none;
} */
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { display: block; max-width: 100%; }

/* ─── Reading Progress Bar ─── */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  z-index: 1000;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
  display: none;
}
.progress-bar.visible { display: block; }

/* ─── HEADER ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}
.site-header.scrolled {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: var(--nav-h);
  padding: 0 1.5rem;
  display: flex;
  justify-content:space-between;
  align-items: center;
  gap: 1.5rem;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-shrink: 0;
}
.logo-icon {
  color: var(--accent);
  font-size: 1.2rem;
  line-height: 1;
}
.logo-text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text-primary);
}

/* Nav Links */
.nav-links {
  display: flex;
  /* gap: .25rem; */
  /* margin-left: auto; */
}
.nav-link {
  padding: .4rem .8rem;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.nav-link:hover { color: var(--text-primary); background: var(--surface); }
.nav-link.active { color: var(--accent); font-weight: 600; }

/* Nav Actions */
.nav-actions {
  display: flex;
  align-items: center;
}
.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}
.icon-btn:hover { color: var(--text-primary); background: var(--surface); }

/* Theme toggle icons */
.sun-icon { display: none; }
.moon-icon { display: block; }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.hamburger:hover { background: var(--surface); }
.hamburger span {
  display: block;
  width: 18px; height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Mobile Menu */
.mobile-menu {
  display: none;
  flex-direction: column;
  padding: .5rem 1.5rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.mobile-menu.open { display: flex; }
.mobile-nav-link {
  padding: .75rem .5rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  transition: color var(--transition);
}
.mobile-nav-link:last-child { border-bottom: none; }
.mobile-nav-link:hover { color: var(--accent); }

/* ─── PAGE SYSTEM ─── */
.page { display: none; animation: fadeUp .35s ease both; }
.page.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── HERO ─── */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 1.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  min-height: 420px;
}
.hero-eyebrow {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .75rem;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin-bottom: 1.25rem;
}
.hero-title em {
  font-style: italic;
  color: var(--accent);
}
.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 400px;
  margin-bottom: 2rem;
  line-height: 1.7;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .8rem 1.8rem;
  background: var(--accent);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  border-radius: 100px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(196,113,58,.35);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(196,113,58,.4);
}
.btn-primary:active { transform: translateY(0); }

/* Hero visual stack */
.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  height: 300px;
}
.hero-stack { position: relative; width: 220px; height: 300px; }
.hero-card {
  position: absolute;
  width: 160px; height: 240px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease;
  cursor: pointer;
}
.hero-card:hover {
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
}
.hc-1 {
  background: linear-gradient(135deg, #3a1c71, #d76d77, #ffaf7b);
  transform: rotate(-8deg) translate(-30px, 10px);
  z-index: 1;
}
.hc-1:hover { transform: rotate(-8deg) translate(-30px, -12px); }
.hc-2 {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  transform: rotate(-2deg) translate(5px, 0);
  z-index: 2;
}
.hc-2:hover { transform: rotate(-2deg) translate(5px, -14px); }
.hc-3 {
  background: linear-gradient(135deg, #c94b4b, #4b134f);
  transform: rotate(6deg) translate(40px, 8px);
  z-index: 1;
}
.hc-3:hover { transform: rotate(6deg) translate(40px, -10px); }

/* ─── SECTIONS ─── */
.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -.02em;
}
.section-link {
  font-size: .825rem;
  font-weight: 500;
  color: var(--accent);
  transition: color var(--transition);
}
.section-link:hover { color: var(--accent-hover); }

/* ─── CATEGORY PILLS ─── */
.pill-scroll {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: .5rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap:wrap;
}
.pill-scroll::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0;
  padding: .45rem 1.1rem;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  font-size: .825rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  transition:
    border-color var(--transition),
    background var(--transition),
    color var(--transition),
    transform var(--transition);
  scroll-snap-align: start;
  white-space: nowrap;
}
.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ─── NOVEL GRID ─── */
.novel-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.25rem;
}

/* Novel Card */
.novel-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  will-change: transform;
  animation: fadeUp .4s ease both;
}
.novel-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-md);
}
.novel-card:active { transform: scale(.98); }

.card-cover {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.card-cover-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
  overflow: hidden;
}
.card-cover-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,.55));
}

.card-body {
  padding: .75rem;
}
.card-title {
  font-family: var(--font-display);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: .3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-desc {
  font-size: .75rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.card-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .55rem;
  border-radius: 100px;
  font-size: .7rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: .5rem;
}

/* ─── LATEST LIST ─── */
.latest-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
}
.latest-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.latest-item:last-child { border-bottom: none; }
.latest-item:hover { background: var(--bg-subtle); }

.latest-thumb {
  width: 44px; height: 60px;
  border-radius: 6px;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.latest-info { flex: 1; min-width: 0; }
.latest-title {
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .2rem;
}
.latest-chapter {
  font-size: .775rem;
  color: var(--text-muted);
}
.latest-time {
  font-size: .75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ─── READING PAGE ─── */
.reading-topbar {
  position: sticky;
  top: var(--nav-h);
  z-index: 800;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: .6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.back-btn {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: .4rem .8rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.back-btn:hover { color: var(--text-primary); background: var(--surface); }

.reading-controls {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}
.ctrl-btn:hover { color: var(--text-primary); background: var(--surface); }
.ctrl-btn.active { color: var(--accent); background: var(--accent-soft); }

.font-controls {
  display: flex;
  align-items: center;
  gap: .2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.font-controls .ctrl-btn {
  border-radius: 0;
  width: 38px;
  font-size: .8rem;
}

/* Reading Area */
.reading-area {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.chapter-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.chapter-meta {
  font-size: .775rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .6rem;
}
.chapter-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.02em;
  margin-bottom: .75rem;
}
.chapter-info {
  font-size: .825rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
}

/* Chapter Content */

.chapter-content {
  font-size: 1.05rem;
  line-height: 1.82;
  color: var(--text-primary);
}
.chapter-content p {
  margin-bottom: 1.4em;
  animation: fadeUp .4s ease both;
}
.chapter-content p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 3.5em;
  font-weight: 700;
  float: left;
  line-height: .85;
  margin: .05em .1em 0 0;
  color: var(--accent);
}
.chapter-content .chapter-separator {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.5rem;
  letter-spacing: .5em;
  margin: 2.5rem 0;
}
.next-chapter-label {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 1.5rem 0 .5rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
/* Show.blade.php */
.story-header{
  display:grid;
  grid-template-columns:clamp(120px,25vw,180px) 1fr;
  gap:2rem;
  margin-bottom:2.5rem;
}
.hastag-show{
  display:flex;
  gap:.5rem;
  flex-wrap:wrap;
  margin-bottom:.75rem;
}
.vcrb-show{
  display:flex;
  gap:1.5rem;
  flex-wrap:wrap;
  font-size:.875rem;
  color:var(--text-muted);
  margin-bottom:1.25rem;
}
.star-rating-show{
  display:flex;
  align-items:center;
  gap:1rem;
  margin-bottom:1.25rem;
  flex-wrap:wrap;
}
#btn-bookmark{
  width:auto;
  padding:.5rem 1rem;
  gap:.35rem;
  font-size:.85rem;
  font-weight:500;
}
#btn-follow{
  width:auto;
  padding:.5rem 1rem;
  gap:.35rem;
  font-size:.85rem;
  font-weight:500;
}
.breadcrumb-show{
  font-size:.8rem;
  color:var(--text-muted);
  margin-bottom:1.5rem;
}
.title-show{
  font-family:var(--font-display);
  font-size:clamp(1.4rem,3vw,2rem);
  font-weight:700;margin-bottom:.35rem;
}
.tacgia-show{
  font-size:.9rem;
  color:var(--text-secondary);
  margin-bottom:1rem;
}
.action-buttons-show{
  display:flex;
  align-items:center;
  gap:.75rem;
  flex-wrap:wrap;
}
.button-show{
  display:flex;
}
/* show responsive */
@media(max-width: 645px)
{
  .hastag-show{
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .title-show{
    text-align:center;
  }
  .tacgia-show{
    text-align:center;
  }
  .vcrb-show{
    display:flex;
    justify-content:center;
    align-items:center;
  }
  .star-rating-show{
    display:flex;
    justify-content:center;
    align-items:center;
  }
  .action-buttons-show{
    display:flex;
    gap:.25rem;
    justify-content:center;
    align-items:center;
  }
  .story-header{
    display: flex;
    flex-direction: column;
    justify-content:center;
    align-items:center;
  }
}
/* Category Des */
.hastag-category{
  font-size:.8rem;
  color:var(--text-muted);
  margin-bottom:1rem;
}
.container-category{
  display:grid;
  grid-template-columns:220px 1fr;
  gap:2rem;
  align-items:start;
}
.sidebar-category{
  position:sticky;
  top:80px;
}
.sidebar-category-2{
  background:var(--bg-card,#fff);
  border:1px solid var(--border);
  border-radius:12px;
  padding:1.25rem;
}
.sidebar-title-category-2{
  font-size:.75rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--text-muted);
  margin-bottom:.85rem;
}
.sidebar-cate{
  display:flex;
  flex-direction:column;
  gap:.15rem;
}
.sidebar-cate a{
  padding:.45rem .75rem;
  border-radius:8px;
  font-size:.85rem;
  text-decoration:none;
}
.sidebar-cate a span{
  float:right;
  font-size:.72rem;
  opacity:.6;
}
.header-main-category{
  margin-bottom:1.25rem;
}
.header-main-category h1{
  font-size:1.5rem;
  font-weight:800;
  margin:0 0 .35rem;
}
.headersup-main-category{
  display:flex;
  gap:1rem;
  font-size:.8rem;
  color:var(--text-muted);
}
.filter-sort-category{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:1.25rem;
  flex-wrap:wrap;
  gap:.75rem;
}
.gridnovels-category{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:1.25rem;
}
/* Category novel responsive */
@media(max-width:1100px){
  .gridnovels-category{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:1.25rem;
}
}
@media(max-width:850px){
  .container-category{
    display:flex;
    flex-direction:column;
  }
  .sidebar-category{
    width:100%;
  }
  .sidebar-cate{
    display:flex;
    flex-direction:row;
    flex-wrap:wrap;
  }
  .sidebar-cate a span{
    padding-left:.5rem;
  }
}
@media(max-width:650px){
  .gridnovels-category{
  gap:.75rem;
}
}
@media(max-width:540px){
  .gridnovels-category{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:1.25rem;
}
}
@media(max-width:460px){
  .gridnovels-category{
  gap:.75rem;
}
}
@media(max-width:380px){
  .gridnovels-category{
    display:grid;
    grid-template-columns:repeat(1,1fr);
    gap:.75rem;
  }
}

/* Skeleton Loader */
.skeleton-wrap { padding: 1.5rem 0; }
.skeleton-line {
  height: 14px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: .9rem;
  position: relative;
  overflow: hidden;
}
.skeleton-line.long  { width: 100%; }
.skeleton-line.medium{ width: 80%; }
.skeleton-line.short { width: 55%; }
.skeleton-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    color-mix(in srgb, var(--bg-card) 60%, transparent) 40%,
    color-mix(in srgb, var(--bg-card) 60%, transparent) 60%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
#skeleton-loader { display: none; }
#skeleton-loader.loading { display: block; }

/* Autoscroll panel */
.autoscroll-panel {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: .6rem 1.2rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: var(--shadow-md);
  z-index: 700;
  font-size: .825rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.autoscroll-panel input[type="range"] {
  width: 100px;
  accent-color: var(--accent);
}
/* ═══════════════════════════════════════════════════════
   TRUYỆN ĐÃ HOÀN THÀNH
   Grid: 4 cột × 2 hàng = 8 truyện — Card overlay hover style
═══════════════════════════════════════════════════════ */

/* ── Grid ── */
.completed-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

/* ── Card: toàn bộ là cover, text overlay khi hover ── */
.completed-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 2/3;
  cursor: pointer;
  animation: fadeUp .4s ease both;
  text-decoration: none;
  display: block;
}

/* Cover gradient */
.completed-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .4s ease;
}
.completed-card:hover .completed-cover {
  transform: scale(1.06);
}

/* Emoji giữa card */
.completed-emoji {
  font-size: 3.5rem;
  position: relative;
  z-index: 1;
  transition: transform .3s ease, opacity .3s ease;
}
.completed-card:hover .completed-emoji {
  transform: scale(.8) translateY(-8px);
  opacity: .4;
}

/* Overlay tối phủ lên khi hover */
.completed-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.1) 0%,
    rgba(0,0,0,.5) 60%,
    rgba(0,0,0,.85) 100%
  );
  transition: opacity .3s ease;
}
.completed-card:hover .completed-cover::after {
  opacity: 1;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.3) 0%,
    rgba(0,0,0,.7) 50%,
    rgba(0,0,0,.95) 100%
  );
}

/* Badge hoàn thành — luôn hiện góc trên phải */
.completed-badge {
  position: absolute;
  top: .65rem;
  right: .65rem;
  z-index: 10;
  background: #AE6030;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 100px;
  letter-spacing: .03em;
  white-space: nowrap;
}

/* Body text — ẩn dưới, trượt lên khi hover */
.completed-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 1rem .85rem .85rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  transform: translateY(40%);
  opacity: 0;
  transition: transform .35s ease, opacity .3s ease;
}
.completed-card:hover .completed-body {
  transform: translateY(0);
  opacity: 1;
}

/* Category tag trong body */
.completed-body > .completed-badge {
  position: static;
  top: unset;
  right: unset;
  align-self: flex-start;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
}

.completed-title {
  font-family: var(--font-display);
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.completed-meta {
  display: flex;
  gap: .6rem;
  font-size: .72rem;
  color: rgba(255,255,255,.7);
}

/* Empty state */
.completed-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: .875rem;
}

/* Stagger animation */
.completed-card:nth-child(1) { animation-delay: .04s; }
.completed-card:nth-child(2) { animation-delay: .08s; }
.completed-card:nth-child(3) { animation-delay: .12s; }
.completed-card:nth-child(4) { animation-delay: .16s; }
.completed-card:nth-child(5) { animation-delay: .20s; }
.completed-card:nth-child(6) { animation-delay: .24s; }
.completed-card:nth-child(7) { animation-delay: .28s; }
.completed-card:nth-child(8) { animation-delay: .32s; }

/* Responsive */
@media (max-width: 1066px) {
  .nav-links{
    justify-content:space-beteen;
    align-items: center;
  }
  .nav-links a{
    font-size: 14px;
    padding:0.5rem;
  }
}
@media (max-width: 1066px) {
  .nav-links{
    display:flex;
    justify-content:space-beteen;
    align-items: center;
  }
  .nav-links a{
    font-size: 13px;
    padding:0.5rem;
  }
}
@media (max-width: 1010px) {
  .nav-actions{
    transform:scale(0.9);
    transform-origin:center;
  }
  .nav-links{
    text-align:center;
  }
  .logo{
    transform:scale(0.9);
    transform-origin:center;
  }
}
@media (max-width: 970px) {
  #mobile-user-section{
    display:none;
  }
  .nav-inner{
    display:flex;
    justify-content:space-between;
  }
  .nav-links{
    display:none;
  }
  .hamburger { display: flex; }
  .profile-user{
    display:flex;
    flex-direction:column;
  }
}
@media (max-width: 900px) {
  .completed-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .completed-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
  }
  .completed-body {
    transform: translateY(0);
    opacity: 1;
  }
  .completed-emoji { opacity: .5; }
}
@media (max-width: 450px){
  .logo{
    transform:scale(0.8);
    transform-origin: center;
  }
  .nav-actions{
    transform:scale(0.9);
    transform-origin: center;
    
  }
  #login-btn{
    padding:0;
  }
}
@media (max-width: 380px){
  .nav-inner{
    padding:0;
  }
}
/* ─── BOOKMARKS PANEL ─── */
/* [hidden] fix: explicit display:flex overrides the hidden attribute in some browsers */
/* .bookmarks-panel[hidden], */
.panel-overlay[hidden],
.autoscroll-panel[hidden] { display: none !important; }

.bookmarks-panel {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: 340px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 950;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn .28s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.panel-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}
.close-panel {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}
.close-panel:hover { color: var(--text-primary); background: var(--surface); }

.bookmarks-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.empty-state {
  font-size: .875rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem;
  line-height: 1.6;
}
.bookmark-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.bookmark-item:hover { background: var(--surface); border-color: var(--accent); }
.bookmark-icon { font-size: 1.5rem; flex-shrink: 0; }
.bookmark-text { flex: 1; min-width: 0; }
.bookmark-novel {
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: .15rem;
}
.bookmark-chapter { font-size: .75rem; color: var(--text-muted); }
.bookmark-remove {
  color: var(--text-muted);
  font-size: .85rem;
  padding: .25rem .5rem;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}
.bookmark-remove:hover { color: #e05555; background: #fef2f2; }

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 940;
  animation: fadeOverlay .25s ease;
}
@keyframes fadeOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── INTERSECTION OBSERVER FADE ─── */
.fade-in-element {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .5s ease, transform .5s ease;
}
.fade-in-element.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 2.5rem 1.5rem 1.5rem;
    min-height: auto;
  }
  .hero-subtitle { margin: 0 auto 2rem; }
  .hero-visual { display: none; }
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .novel-grid { grid-template-columns: repeat(3, 1fr); }
  .bookmarks-panel { width: min(360px, 100vw); right: 0; }

  /* Mobile menu visible */
  .mobile-menu { display: none; flex-direction: column; }
  .mobile-menu.open { display: flex; }
}

@media (max-width: 600px) {
  .section { padding: 1.75rem 1rem; }
  .reading-area { padding: 2rem 1rem 4rem; }
  .novel-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .reading-topbar {
    padding: .5rem 1rem;
    flex-wrap: wrap;
    gap: .5rem;
  }
  .chapter-content { font-size: 1rem; }

  /* Section header stack */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
  }

  /* Floating comments smaller */
  .floating-comments { display: none; }

  /* Story overlay full screen */
  .story-overlay { padding: 0; align-items: flex-end; }
  .story-card { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; overflow-y: auto; }
  .story-card-header { padding: 1.25rem 1.25rem 1rem; gap: 1rem; }
  .story-cover { width: clamp(80px, 25vw, 110px); height: auto; }
  .story-card-title { font-size: 1.1rem; }
  .story-desc { padding: 0 1.25rem 1rem; }
  .story-chapters { padding: .75rem 1.25rem 1.5rem; }
}

/* ─── STAGGER ANIMATION DELAYS ─── */
.novel-card:nth-child(1) { animation-delay: .04s; }
.novel-card:nth-child(2) { animation-delay: .08s; }
.novel-card:nth-child(3) { animation-delay: .12s; }
.novel-card:nth-child(4) { animation-delay: .16s; }
.novel-card:nth-child(5) { animation-delay: .20s; }
.novel-card:nth-child(6) { animation-delay: .24s; }
.novel-card:nth-child(7) { animation-delay: .28s; }
.novel-card:nth-child(8) { animation-delay: .32s; }
/* ═══════════════════════════════════════════
   CHAPTER PAGE — Paper, Lamp, Dialogue
   ═══════════════════════════════════════════ */

/* Nền giấy cream */
:root {
  --paper-bg:     #faf6f0;
  --paper-shadow: 0 2px 24px rgba(120,90,40,.08), 0 1px 4px rgba(120,90,40,.06);
  --paper-border: rgba(180,150,100,.15);
}
[data-theme="dark"] {
  --paper-bg:     #1e1a14;
  --paper-shadow: 0 2px 24px rgba(0,0,0,.35);
  --paper-border: rgba(255,255,255,.06);
}
body:has(.reading-area) { background: #f0ebe3; }
[data-theme="dark"] body:has(.reading-area) { background: #111008; }

.reading-area {
  max-width: 720px;
  margin: 2rem auto;
  padding: 3rem 3.5rem;
  background: var(--paper-bg);
  border-radius: 4px;
  border: 1px solid var(--paper-border);
  box-shadow: var(--paper-shadow);
  position: relative;
}
.reading-area::before {
  content: '';
  position: absolute;
  top: 0; left: 3.5rem; right: 3.5rem;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .35;
  border-radius: 0 0 2px 2px;
}

/* Drop cap chữ đầu chương */
.chapter-content p:first-child { text-indent: 0; }
.chapter-content p:first-child::first-letter {
  font-size: 3.2rem;
  font-weight: 700;
  float: left;
  line-height: .85;
  margin: .05em .12em 0 0;
  color: var(--accent);
  font-family: Georgia, serif;
}

/* Text indent các đoạn */
.chapter-content p { text-indent: 1.5em; margin-bottom: .9em; }

/* HTML content từ editor — chuẩn hóa font */
.chapter-content p,
.chapter-content li,
.chapter-content blockquote {
  font-family: inherit !important;
  font-size: inherit !important;
  color: inherit !important;
  background: transparent !important;
  line-height: inherit !important;
}
/* Xóa margin/padding thừa của editor */
.chapter-content p:empty { display: none; }
.chapter-content br + br { display: none; }

/* Câu thoại highlight */
.chapter-content .dialogue {
  font-weight: 600;
  color: var(--accent);
}
.chapter-content p.dialogue-para {
  text-indent: 0;
  /* border-left: 2.5px solid var(--accent);
  padding-left: .85rem;
  margin-left: -.85rem; */
}

/* Hiệu ứng đèn bàn — overlay nằm TRONG tờ giấy */
.lamp-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  border-radius: 4px;
  /* Gradient tối trên và dưới, giữa trong suốt */
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.92) 0%,
    rgba(0,0,0,.75) 8%,
    rgba(0,0,0,.3)  18%,
    transparent     28%,
    transparent     72%,
    rgba(0,0,0,.3)  82%,
    rgba(0,0,0,.75) 92%,
    rgba(0,0,0,.92) 100%
  );
  transition: opacity .4s ease;
  opacity: 0;
}
.lamp-mode .lamp-overlay {
  display: block;
  opacity: 1;
}

/* Giấy cần position relative để overlay absolute hoạt động */
.lamp-mode .reading-area {
  position: relative;
}

/* Nền page tối hơn khi lamp mode dark */
[data-theme="dark"] .lamp-mode body,
.lamp-mode body {
  background: #0a0806 !important;
}

#lamp-btn { display: none; }
[data-theme="dark"] #lamp-btn { display: flex !important; }
#lamp-btn.active { color: #f59e0b; background: rgba(245,158,11,.12); }

/* Mobile chapter */
@media (max-width: 600px) {
  .reading-area { padding: 1.75rem 1.25rem; margin: 0; border-radius: 0; box-shadow: none; }
  .reading-area::before { left: 1.25rem; right: 1.25rem; }
}
/* ═══════════════════════════════
   FOOTER
═══════════════════════════════ */
.site-footer {
  background: #1A1815;
  color: rgba(255,255,255,.7);
  margin-top: 4rem;
  border-top: 3px solid var(--accent);
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem 2rem;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: 1rem;
}
.footer-logo-icon {
  color: var(--accent);
  font-size: 1.15rem;
}
.footer-logo-text {
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}
.footer-about {
  font-size: .85rem;
  line-height: 1.75;
  color: rgba(255,255,255,.45);
  margin-bottom: 1.25rem;
  max-width: 300px;
}
.footer-socials {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.footer-social-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.footer-social-btn:hover {
  background: var(--accent);
  color: #fff;
}
.footer-col-title {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  margin-bottom: .9rem;
}
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.footer-links a {
  color: rgba(255,255,255,.5);
  text-decoration: none;
  font-size: .875rem;
  transition: color var(--transition);
}
.footer-links a:hover {
  color: var(--accent);
}
.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 2rem;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  font-size: .78rem;
  color: rgba(255,255,255,.25);
}

/* Footer responsive */
@media (max-width: 768px) {
  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
  .footer-col:first-child {
    grid-column: 1 / -1;
  }

  /* Novel grid 3→2 cols */
  .novel-grid { grid-template-columns: repeat(2, 1fr); }

  /* Story card full width */
  .story-card { max-width: 100%; margin: 0 .5rem; }

  /* Bookmarks panel full width */
  .bookmarks-panel { width: 100%; max-width: 100%; }

  /* User dropdown safe positioning */
  .user-dropdown { right: 0; min-width: 160px; }

  /* Modal safer on tablet */
  .modal-box { max-width: min(420px, calc(100vw - 2rem)); }
}
@media (max-width: 480px) {
  .footer-inner {
    grid-template-columns: 1fr;
    padding: 2rem 1.25rem 1.5rem;
  }
  .footer-bottom {
    padding: 1rem 1.25rem;
    flex-direction: column;
    text-align: center;
  }

  /* Novel grid → 2 cols on very small screens */
  .novel-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }

  /* Novel card compact */
  .novel-card-title { font-size: .8rem; }
  .novel-card-meta { font-size: .7rem; }

  /* Action buttons stack */
  .story-actions { flex-direction: column; }
  .story-actions a, .story-actions button { width: 100%; justify-content: center; }

  /* Tabs scroll on mobile */
  .tabs-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }

  /* Font controls on mobile */
  .font-controls { display: flex; gap: .2rem; }
  .ctrl-btn { min-width: 32px; min-height: 32px; }

  /* Reading topbar stack */
  .reading-controls { gap: .2rem; }

  /* Chapter nav buttons */
  .chapter-nav a { font-size: .8rem; padding: .5rem .75rem; }

  /* Toast full width on mobile */
  #toast-container .toast {
    left: .75rem;
    right: .75rem;
    max-width: none;
  }
}
/* ═══════════════════════════════════════════════
   QUẢNG CÁO — Ad Zones
   Zone rỗng = display:none → layout không vỡ
═══════════════════════════════════════════════ */

.ad-zone { display: block; }
.ad-zone:empty { display: none !important; }
.ad-zone:empty::before { display: none !important; }

.ad-slot {
  display: block;
  text-align: center;
  overflow: hidden;
  line-height: 0; /* tránh gap dưới ảnh */
}
.ad-slot img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  line-height: 0;
}
.ad-slot a { display: block; line-height: 0; }

/* Label "Quảng cáo" */
.ad-zone:not(:empty)::before {
  content: 'Quảng cáo';
  display: block;
  font-size: .62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  text-align: center;
  margin-bottom: .3rem;
  opacity: .5;
  line-height: 1;
}

/* ── Header ── */
.ad-zone--header {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: .5rem 0 .75rem;
}
.ad-zone--header .ad-slot {
  max-width: 728px;
  margin: 0 auto;
}

/* ── Home mid — span toàn bộ grid ── */
.ad-zone--home_mid {
  grid-column: 1 / -1; /* span full width trong novel-grid */
  padding: .5rem 0;
  margin: .25rem 0;
}
.ad-zone--home_mid .ad-slot {
  max-width: 728px;
  margin: 0 auto;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ad-zone--home_mid:not(:empty)::before {
  grid-column: 1 / -1;
}

/* ── Before / After chapters ── */
.ad-zone--before_chapters,
.ad-zone--after_chapters {
  margin: 1rem 0;
}
.ad-zone--before_chapters .ad-slot,
.ad-zone--after_chapters .ad-slot {
  max-width: 728px;
  margin: 0 auto;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* ── Chapter top ── */
.ad-zone--chapter_top {
  max-width: 760px;
  margin: 1rem auto 1.5rem;
  padding: 0 1.5rem;
}
.ad-zone--chapter_top .ad-slot {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* ── Chapter mid — giữa nội dung ── */
.ad-zone--chapter_mid {
  margin: 1.5rem auto;
  clear: both;
  text-indent: 0 !important; /* override chapter text-indent */
}
.ad-zone--chapter_mid .ad-slot {
  max-width: 336px;
  margin: 0 auto;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* ── Chapter sidebar ── */
.chapter-reading-wrap {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 1rem;
}
.chapter-reading-wrap > div:first-child {
  flex: 1;
  min-width: 0; /* quan trọng: ngăn overflow */
}
.ad-zone--chapter_sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
  width: 300px;
  flex-shrink: 0;
}
.ad-zone--chapter_sidebar .ad-slot {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 300px;
}

/* ── Footer top ── */
.ad-zone--footer_top {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
}
.ad-zone--footer_top .ad-slot {
  max-width: 970px;
  margin: 0 auto;
}

/* ── AdSense ── */
.ad-adsense ins { display: block !important; }
.ad-affiliate { text-align: center; }

/* ── Sidebar ẩn trên mobile ── */
@media (max-width: 900px) {
  .chapter-reading-wrap {
    display: block;
    padding: 0;
  }
  .ad-zone--chapter_sidebar { display: none !important; }
}

/* ── Các zone thu nhỏ trên mobile ── */
@media (max-width: 600px) {
  .ad-zone--header .ad-slot,
  .ad-zone--chapter_top .ad-slot,
  .ad-zone--before_chapters .ad-slot,
  .ad-zone--after_chapters .ad-slot,
  .ad-zone--footer_top .ad-slot { max-width: 320px; }
}
/* ── Section save buttons spacing ── */
.section-save-btn {
  margin-bottom: 2rem;
}
/* ── Tabs responsive ── */
.user-tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap:wrap;
}
.user-tabs::-webkit-scrollbar { display: none; }
.user-tabs a {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Safe container padding ── */
.container, [style*="max-width:1100px"], [style*="max-width: 1100px"] {
  padding-left: clamp(.75rem, 4vw, 1.5rem);
  padding-right: clamp(.75rem, 4vw, 1.5rem);
}

/* ── Prevent horizontal scroll ── */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ── Images responsive by default ── */
img { max-width: 100%; height: auto; }
/* ═══════════════════════════════════════════════
   NOTIFICATION BADGE — nav bell
═══════════════════════════════════════════════ */
#notif-btn {
  position: relative;
}
#notif-badge {
  pointer-events: none;
  transform: scale(1);
  animation: badge-pop .25s cubic-bezier(.4,0,.2,1);
}
@keyframes badge-pop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ═══════════════════════════════════════════════
   SEARCH PAGE — /search
═══════════════════════════════════════════════ */
#search-bar-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#search-results-grid a {
  /* Đã dùng inline style — override khi cần */
}

@media (max-width: 600px) {
  #search-results-grid a {
    gap: .65rem;
  }
  #search-results-grid a > div:first-child {
    width: 40px;
    height: 54px;
  }
}
/* ═══════════════════════════════════════════════
   MOBILE USER AREA
   ẩn #user-area khỏi nav trên mobile (≤970px)
   user section chuyển vào mobile-menu thay thế
═══════════════════════════════════════════════ */
.user-area-desktop { display: flex; align-items: center; }

@media (max-width: 550px) {
  /* Ẩn user-area khỏi nav — đã có trong mobile menu */
  #mobile-user-section{
    display:flex;
  }
  .user-area-desktop { display: none !important; }
  .user-login-mobie{
    display:flex;
    align-items:center;
    gap:.75rem;
    padding:.6rem 1.25rem .4rem;
  }
  .icon-user-mobie{
    padding: 0 0.8rem;
    display:flex;
    flex-direction:column;
  }
  .icon-user-mobie .mobile-nav-link{
    padding:1rem 1rem 1rem 0.4rem;
  }
  .mobile-nav-link:last-child { border-bottom: 1px solid var(--border); }
}

/* Nút logout mobile — hover style */
#mobile-logout-btn:hover {
  background: var(--bg-subtle) !important;
  color: var(--accent) !important;
}
/* ═══════════════════════════════════════════════
   AI CHATBOX
═══════════════════════════════════════════════ */

/* Message rows */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: .4rem;
  animation: chatFadeIn .2s ease;
}
.chat-msg--user { flex-direction: row-reverse; }
.chat-msg--bot  { flex-direction: row; }

@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bubbles */
.chat-bubble {
  max-width: 82%;
  padding: .55rem .85rem;
  border-radius: 16px;
  font-size: .85rem;
  line-height: 1.55;
  word-break: break-word;
}
.chat-bubble--user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble--bot {
  background: var(--surface);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.chat-bubble strong { font-weight: 700; }
.chat-bubble ul { margin: .3rem 0 0 1rem; padding: 0; }
.chat-bubble li { margin-bottom: .15rem; }

/* Typing indicator */
.chat-bubble--typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: .65rem 1rem;
  min-width: 52px;
}
.chat-bubble--typing span {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s ease infinite;
  display: inline-block;
}
.chat-bubble--typing span:nth-child(2) { animation-delay: .2s; }
.chat-bubble--typing span:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* Chat input focus */
#chat-input:focus {
  border-color: var(--accent);
  outline: none;
}

/* Chat send button hover */
#chat-send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* Suggestion buttons hover */
.chat-suggestion-btn:hover {
  background: var(--accent-soft) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* Mobile: chatbox nhỏ hơn */
@media (max-width: 480px) {
  #ai-chatbox {
    bottom: 1rem;
    right: 1rem;
  }
  #chat-window {
    width: calc(100vw - 2rem) !important;
    height: 420px !important;
  }
}