/* VietManga API - kiểu dáng cơ bản. Theme có thể ghi đè các biến --vmx-* */
:root {
  --vmx-bg: #eef0f3;
  --vmx-surface: #ffffff;
  --vmx-ink: #15171c;
  --vmx-muted: #5b6070;
  --vmx-line: #15171c;
  --vmx-shadow: #15171c;
  --vmx-accent: #2447d6;
  --vmx-accent-ink: #ffffff;
  --vmx-mark: #ffd84d;
  --vmx-radius: 6px;
}

.vmx-wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 56px; color: var(--vmx-ink); }
:where(.vmx-wrap a) { color: inherit; }
.vmx-title { font-size: clamp(1.5rem, 3.2vw, 2.1rem); line-height: 1.2; margin: 0 0 18px; }
.vmx-subtitle { font-size: 1.25rem; margin: 36px 0 14px; }

.vmx-input {
  font: inherit; color: var(--vmx-ink); background: var(--vmx-surface);
  border: 2px solid var(--vmx-line); border-radius: var(--vmx-radius); padding: 10px 12px; min-height: 44px;
}
.vmx-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  color: var(--vmx-ink); background: var(--vmx-surface);
  border: 2px solid var(--vmx-line); border-radius: var(--vmx-radius); box-shadow: 3px 3px 0 var(--vmx-shadow);
}
.vmx-btn:hover { background: var(--vmx-mark); color: #15171c; }
.vmx-btn--primary { background: var(--vmx-accent); color: var(--vmx-accent-ink); }
.vmx-btn.is-disabled { opacity: .4; box-shadow: none; pointer-events: none; }
.vmx-wrap :focus-visible, .vmx-reader :focus-visible { outline: 3px solid var(--vmx-accent); outline-offset: 2px; }

.vmx-search { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.vmx-search input[type="search"] { flex: 1 1 240px; }

.vmx-status { padding: 16px; border: 2px dashed var(--vmx-line); border-radius: var(--vmx-radius); background: var(--vmx-surface); }
.vmx-error { border-style: solid; }

/* Lưới truyện */
.vmx-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 28px 20px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.vmx-card__link { display: block; text-decoration: none; color: inherit; }
.vmx-card__cover { position: relative; display: block; aspect-ratio: 2 / 3; overflow: hidden; background: var(--vmx-surface); border: 2px solid var(--vmx-line); box-shadow: 4px 4px 0 var(--vmx-shadow); }
.vmx-card__cover img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.vmx-card__link:hover .vmx-card__cover, .vmx-card__link:focus-visible .vmx-card__cover { box-shadow: 4px 4px 0 var(--vmx-accent); }
.vmx-card__title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 12px; font-weight: 700; line-height: 1.35; }
.vmx-card__meta { display: block; margin-top: 2px; font-size: .85rem; color: var(--vmx-muted); }

.vmx-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 40px 0 8px; flex-wrap: wrap; }
.vmx-pager__now { color: var(--vmx-muted); }

/* Trang chi tiết */
.vmx-detail { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 32px; align-items: start; }
.vmx-detail__cover { position: relative; aspect-ratio: 2 / 3; overflow: hidden; background: var(--vmx-surface); border: 2px solid var(--vmx-line); box-shadow: 6px 6px 0 var(--vmx-shadow); }
.vmx-detail__cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vmx-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.vmx-facts dt { color: var(--vmx-muted); }
.vmx-facts dd { margin: 0; font-weight: 600; }
.vmx-tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; }
.vmx-tags li { padding: 3px 10px; border: 2px solid var(--vmx-line); border-radius: 999px; font-size: .9rem; background: var(--vmx-surface); }
.vmx-desc { max-width: 68ch; line-height: 1.7; }
.vmx-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }

.vmx-chapters { list-style: none; margin: 0; padding: 0; max-height: 560px; overflow: auto; background: var(--vmx-surface); border: 2px solid var(--vmx-line); }
.vmx-chapters li + li { border-top: 1px solid color-mix(in srgb, var(--vmx-line) 25%, transparent); }
.vmx-chapters a { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; text-decoration: none; }
.vmx-chapters a:hover { background: var(--vmx-mark); color: #15171c; }
.vmx-chapters__meta { color: var(--vmx-muted); font-size: .9rem; text-align: right; }
.vmx-chapters a:hover .vmx-chapters__meta { color: #15171c; }

.vmx-credit { margin-top: 40px; font-size: .88rem; color: var(--vmx-muted); max-width: 70ch; }
.vmx-credit a { text-decoration: underline; }

/* Trình đọc: luôn nền tối để dễ nhìn ảnh */
.vmx-reader {
  --vmx-surface: #1a1c24; --vmx-ink: #e8eaf0; --vmx-line: #4b5166; --vmx-shadow: #000; --vmx-muted: #9aa1b2; --vmx-accent: #7d96ff; --vmx-accent-ink: #0d0e12;
  background: #0d0e12; color: var(--vmx-ink); min-height: 70vh;
}
.vmx-reader .vmx-wrap { color: var(--vmx-ink); }
.vmx-bar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; background: #14161d; border-bottom: 2px solid var(--vmx-line); }
.vmx-bar__title { display: flex; flex-direction: column; flex: 1 1 180px; min-width: 0; line-height: 1.3; }
.vmx-bar__title strong, .vmx-bar__title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vmx-bar__title span { color: var(--vmx-muted); font-size: .9rem; }
.vmx-bar select { max-width: 220px; }
.vmx-saver { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--vmx-muted); }
.vmx-pages { max-width: 860px; margin: 0 auto; }
.vmx-pages .vmx-status { margin: 24px 16px; }
.vmx-page { display: block; width: 100%; height: auto; min-height: 360px; background: #1a1c24; }
.vmx-page.is-loaded { min-height: 0; }
.vmx-bottom { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding: 28px 16px 8px; }

@media (max-width: 720px) {
  .vmx-detail { grid-template-columns: 1fr; }
  .vmx-detail__cover { max-width: 220px; }
  .vmx-bar select { max-width: 100%; flex: 1 1 100%; }
}

/* ===== v1.1: thể loại, tiếp tục đọc, trình đọc nâng cấp ===== */
.vmx-wrap [hidden], .vmx-reader [hidden] { display: none !important; }

/* Ảnh bìa: chữ cái làm nền giữ chỗ, ảnh lỗi thì ẩn đi để lộ chữ cái */
.vmx-card__fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 3rem; font-weight: 800; color: var(--vmx-muted); background: color-mix(in srgb, var(--vmx-line) 8%, var(--vmx-surface)); }
.vmx-cover-img.is-broken { display: none; }

/* Thể loại */
.vmx-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; margin: 0 0 4px; list-style: none; scrollbar-width: thin; }
.vmx-chips--wrap { flex-wrap: wrap; overflow: visible; padding-bottom: 4px; }
.vmx-chip { display: inline-flex; align-items: center; white-space: nowrap; min-height: 36px; padding: 4px 14px; font-size: .92rem; font-weight: 600; text-decoration: none; color: var(--vmx-ink); background: var(--vmx-surface); border: 2px solid var(--vmx-line); border-radius: 999px; }
.vmx-chip:hover { background: var(--vmx-mark); color: #15171c; }
.vmx-chip.is-on { background: var(--vmx-accent); color: var(--vmx-accent-ink); }
.vmx-morelink { margin: 0 0 24px; font-size: .92rem; }
.vmx-morelink a { text-decoration: underline; }

/* Tiếp tục đọc */
.vmx-continue { margin-bottom: 40px; }
.vmx-continue__head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 16px; }
.vmx-continue h2 { margin: 0; font-size: 1.3rem; }
.vmx-linkbtn { padding: 4px 0; font: inherit; font-size: .9rem; color: var(--vmx-muted); background: none; border: 0; text-decoration: underline; cursor: pointer; }

/* Danh sách chương */
.vmx-chhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-top: 36px; }
.vmx-chhead .vmx-subtitle { margin: 0; }
.vmx-chtools { display: flex; flex-wrap: wrap; gap: 10px; }
.vmx-chhead + .vmx-chapters { margin-top: 14px; }
.vmx-chapters li.is-read .vmx-chapters__name { color: var(--vmx-muted); }
.vmx-chapters li.is-read .vmx-chapters__name::after { content: "Đã đọc"; margin-left: 10px; padding: 1px 8px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; border-radius: 999px; }

/* Trình đọc */
.admin-bar .vmx-bar { top: 32px; }
@media (max-width: 782px) { .admin-bar .vmx-bar { top: 46px; } }
.vmx-bar { display: block; padding: 0; gap: 0; transition: transform .2s ease; }
.vmx-bar.is-hidden { transform: translateY(-100%); }
@media (prefers-reduced-motion: reduce) { .vmx-bar { transition: none; } }
.vmx-bar__row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; }
.vmx-settings { display: flex; flex-wrap: wrap; gap: 16px 32px; padding: 14px 16px 18px; border-top: 1px solid var(--vmx-line); }
.vmx-field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; font-size: .92rem; }
.vmx-field legend { padding: 0; margin-bottom: 6px; color: var(--vmx-muted); }
fieldset.vmx-field label { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; min-height: 32px; }
.vmx-saver { flex-direction: row; align-items: center; color: var(--vmx-ink); }
.vmx-progress { position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 30; pointer-events: none; }
.vmx-progress span { display: block; width: 0; height: 100%; background: var(--vmx-accent); }
.is-w-sm .vmx-pages { max-width: 640px; }
.is-w-md .vmx-pages { max-width: 860px; }
.is-w-lg .vmx-pages { max-width: 1120px; }
.is-mode-page .vmx-pages { cursor: pointer; }
.is-mode-page .vmx-page { min-height: 60vh; }
.vmx-pagebar { position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: center; align-items: center; gap: 16px; padding: 18px 16px 14px; background: linear-gradient(to bottom, transparent, #0d0e12 45%); }
.vmx-end { padding: 40px 16px 8px; text-align: center; }
.vmx-end__t { margin: 0 0 18px; font-size: 1.3rem; font-weight: 800; }
.vmx-end__n { margin: 18px 0 0; color: var(--vmx-muted); }

.vmx-desc__note { margin: 6px 0 0; font-size: .85rem; color: var(--vmx-muted); }

/* ===== v1.3: thẻ truyện có chương mới ===== */
a.vmx-card__title { text-decoration: none; color: inherit; }
a.vmx-card__title:hover { color: var(--vmx-accent); text-decoration: underline; }
.vmx-card__badge { position: absolute; left: 0; bottom: 0; padding: 3px 8px; font-size: .78rem; font-weight: 700; color: #fff; background: rgba(15, 17, 22, .86); border-top-right-radius: 4px; }
.vmx-card__chs { list-style: none; margin: 4px 0 0; padding: 0; font-size: .85rem; }
.vmx-card__chs li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.vmx-card__chs a { text-decoration: none; color: var(--vmx-ink); font-weight: 600; }
.vmx-card__chs a:hover { color: var(--vmx-accent); text-decoration: underline; }
.vmx-card__chs time { color: var(--vmx-muted); white-space: nowrap; font-size: .78rem; }
