@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&family=Open+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #0a0a0a;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --border: #262626;
  --border-hover: #3a3a3a;
  --text: #ededed;
  --text-muted: #9a9a9a;
  --text-dim: #6a6a6a;
  --accent: #f97316;
  --accent-soft: #c2410c;
  --success: #4ade80;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 4px 14px rgba(0,0,0,.3);
  --ring: 0 0 0 2px var(--accent);

  --t: 180ms cubic-bezier(.2,.7,.3,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
  font-family: 'Open Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: 'Poppins', system-ui, sans-serif; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }

a { color: inherit; text-decoration: none; }

button, a { font-family: inherit; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ============ Header ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(10,10,10,.85);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.brand .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.header h1.title {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header .nav { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.header .stats {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: auto;
  display: flex;
  gap: 14px;
}
.header .stats b { color: var(--text); font-weight: 600; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t), border-color var(--t), color var(--t);
  white-space: nowrap;
}
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-hover); }
  .btn-primary:hover:not(:disabled) { background: #fb923c; border-color: #fb923c; }
}
.btn:active:not(:disabled) { background: var(--surface-2); transform: scale(0.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-icon { padding: 8px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a0a00; }
.btn svg { width: 16px; height: 16px; }

/* ============ Container ============ */
.container { max-width: 1280px; margin: 0 auto; padding: 28px 20px; }

/* ============ Index hero ============ */
.hero {
  padding: 36px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.hero h2 {
  font-size: clamp(24px, 4vw, 34px);
  color: var(--text);
  margin-bottom: 8px;
}
.hero p { color: var(--text-muted); font-size: 15px; max-width: 620px; }
.hero .badges { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.chip b { color: var(--text); font-weight: 600; }
.chip-accent { border-color: var(--accent-soft); color: #fdba74; background: rgba(249,115,22,.08); }

/* ============ Grid ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}
.card {
  display: block;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
  position: relative;
}
@media (hover: hover) {
  .card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }
  .card:hover .cover { transform: scale(1.03); }
}
.card:active { border-color: var(--accent); }
.card .cover-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  overflow: hidden;
}
.card .cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 400ms cubic-bezier(.2,.7,.3,1);
}
.card .badge-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
}
.card .info { padding: 12px 14px 14px; }
.card .title {
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.card .meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(0,0,0,.7);
  color: var(--text);
  backdrop-filter: blur(4px);
}
.badge-vi { background: var(--accent); color: #1a0a00; }
.badge-en { background: rgba(0,0,0,.7); color: var(--text-muted); }

/* ============ Story page ============ */
.story-head {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
  margin-bottom: 32px;
  align-items: start;
}
.story-head .cover {
  width: 200px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.story-head .info h2 {
  font-size: clamp(22px, 3vw, 30px);
  margin-bottom: 10px;
}
.story-head .info .meta {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 14px;
}
.story-head .badges { display: flex; gap: 8px; flex-wrap: wrap; }

.section-label {
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.chapter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
@media (hover: hover) { .chapter:hover { border-color: var(--accent); background: var(--surface-2); } }
.chapter:active { border-color: var(--accent); background: var(--surface-2); }
.chapter .num { color: var(--text); }
.chapter .lang {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 3px;
}
.chapter .lang.vi { background: var(--accent); color: #1a0a00; }
.chapter .lang.en { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }

/* ============ Reader ============ */
.reader { background: #000; }
.reader-page {
  display: block;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  background: #050505;
}
.reader-spacer { height: 6px; }
.reader-foot {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 32px 16px 48px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.hint {
  font-size: 12px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ============ Floating "go to top" ============ */
.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #1a0a00;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4), 0 0 0 1px rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--t), transform var(--t), background var(--t);
  z-index: 40;
}
.to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.to-top:active { transform: scale(0.92); }
@media (hover: hover) { .to-top:hover { background: #fb923c; } }
.to-top svg { width: 22px; height: 22px; }
@media (max-width: 720px) {
  .to-top { right: 14px; bottom: 14px; width: 52px; height: 52px; }
}

/* ============ Empty / states ============ */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty h2 { color: var(--text); margin-bottom: 8px; }

/* ============ Responsive ============ */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .header-inner { padding: 10px 12px; gap: 6px; }
  .header .stats { display: none; }
  .container { padding: 20px 14px; }
  .hero { padding: 24px 0 18px; margin-bottom: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .story-head { grid-template-columns: 120px 1fr; gap: 16px; }
  .story-head .cover { width: 120px; }
  .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  /* Touch target ≥ 44px */
  .btn { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .btn-icon { min-width: 44px; min-height: 44px; padding: 10px; }
  .chapter { min-height: 44px; padding: 12px; }

  /* Hide button text labels on mobile, keep icons only */
  .hide-mobile { display: none; }
  .reader-foot { padding: 24px 12px 36px; }

  /* Hide keyboard hint on touch (no physical keyboard) */
  .kbd-hint { display: none; }
}

/* Smallest phones (≤ 360px) — extra tight */
@media (max-width: 360px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .header .brand { font-size: 15px; }
  .header h1.title { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .card:hover { transform: none; }
  .card:hover .cover { transform: none; }
}
