﻿/* ==========================================================================
   g5.css — giao diện mới TruyenSangTac (THÊM 2026-11-13)
   Ưu tiên truyện tranh, sẵn sàng đa ngôn ngữ.
   - Nạp SAU main-merged.css: phần 1 ghi đè design token để các trang cũ (truyện chữ,
     trang tác giả, thành viên) đổi tông theo; phần 2 trở đi là component mới tiền tố g5-.
   - Màu: nền "mực" tối + chữ màu giấy + 1 màu nhấn đỏ cam; vàng chỉ dùng cho nhãn nhỏ.
   - Font: Bricolage Grotesque (tiêu đề) + Be Vietnam Pro (nội dung), đều có bộ chữ tiếng Việt.
   ========================================================================== */

/* ---------- 1. Token ---------- */
:root {
    --g5-ink: #0c0c10;
    --g5-ink-2: #14141b;
    --g5-ink-3: #1c1c26;
    --g5-ink-4: #262633;
    --g5-line: #2c2c3a;
    --g5-paper: #f3efe6;
    --g5-paper-dim: #b9b4a8;
    --g5-paper-mute: #7f7b72;
    --g5-accent: #ff4d2e;
    --g5-accent-2: #ff7a59;
    --g5-accent-ink: #1a0603;
    --g5-pop: #ffd23f;
    --g5-ok: #3ddc97;
    --g5-radius: 14px;
    --g5-radius-sm: 9px;
    --g5-max: 1280px;
    --g5-font-display: 'Bricolage Grotesque', 'Be Vietnam Pro', system-ui, sans-serif;
    --g5-font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --g5-shadow: 0 18px 40px -18px rgba(0, 0, 0, .7);
    --g5-header-h: 64px;

    /* ghi đè token của main-merged.css để trang cũ đổi tông */
    --bg: var(--g5-ink);
    --bg-soft: var(--g5-ink-2);
    --bg-card: var(--g5-ink-2);
    --bg-card-2: var(--g5-ink-3);
    --border: var(--g5-line);
    --text: var(--g5-paper);
    --muted: var(--g5-paper-dim);
    --muted-2: var(--g5-paper-mute);
    --primary: var(--g5-accent);
    --primary-dark: #d93a1f;
    --radius: var(--g5-radius);
    --container: var(--g5-max);
}

body {
    font-family: var(--g5-font);
    background: var(--g5-ink);
    color: var(--g5-paper);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, .section-title, .story-title {
    font-family: var(--g5-font-display);
    letter-spacing: -.01em;
}

::selection { background: var(--g5-accent); color: #fff; }

:focus-visible { outline: 2px solid var(--g5-pop); outline-offset: 2px; }

/* nút cũ nhận màu mới */
.btn-primary { background: var(--g5-accent) !important; color: #fff !important; border-color: transparent !important; }

.g5-wrap {
    width: min(var(--g5-max), calc(100% - 32px));
    margin-inline: auto;
}

.g5-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 2. Header ---------- */
.g5-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(12, 12, 16, .88);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--g5-line);
}

.g5-header__in {
    height: var(--g5-header-h);
    display: flex;
    align-items: center;
    gap: 20px;
}

.g5-logo { display: flex; align-items: center; flex: none; }
.g5-logo img { height: 34px; width: auto; }

.g5-nav { display: flex; gap: 2px; }
.g5-nav a {
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--g5-paper-dim);
    font-weight: 600;
    font-size: 14.5px;
    white-space: nowrap;
    transition: color .15s, background .15s;
}
.g5-nav a:hover { color: var(--g5-paper); background: var(--g5-ink-3); }
.g5-nav a.active { color: var(--g5-paper); background: var(--g5-ink-4); }
.g5-nav a.g5-nav__comic { color: var(--g5-paper); }
.g5-nav a.g5-nav__comic::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--g5-accent); margin-right: 7px; vertical-align: 1px; }

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

/* ô tìm kiếm: giữ id cũ (#topSearchForm/#topSearchInput/#topSearchSuggest) cho main.js */
.g5-search { position: relative; }
.g5-search input {
    width: 260px;
    height: 40px;
    padding: 0 14px 0 38px;
    border-radius: 999px;
    border: 1px solid var(--g5-line);
    background: var(--g5-ink-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23b9b4a8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5.5'/%3E%3Cpath d='m11.2 11.2 3.3 3.3'/%3E%3C/svg%3E") no-repeat 14px 50%;
    color: var(--g5-paper);
    font-size: 14px;
    transition: border-color .15s, width .2s;
}
.g5-search input::placeholder { color: var(--g5-paper-mute); }
.g5-search input:focus { outline: none; border-color: var(--g5-accent); }
.g5-search .search-suggest-box { right: 0; left: auto; min-width: 320px; }

/* chọn ngôn ngữ: <details> không cần JS */
.g5-lang { position: relative; }
.g5-lang summary {
    list-style: none;
    cursor: pointer;
    height: 40px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    border: 1px solid var(--g5-line);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--g5-paper-dim);
}
.g5-lang summary::-webkit-details-marker { display: none; }
.g5-lang summary:hover, .g5-lang[open] summary { color: var(--g5-paper); border-color: var(--g5-paper-mute); }
.g5-lang__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    padding: 6px;
    background: var(--g5-ink-3);
    border: 1px solid var(--g5-line);
    border-radius: 12px;
    box-shadow: var(--g5-shadow);
}
.g5-lang__menu a { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 8px; font-size: 14px; color: var(--g5-paper-dim); }
.g5-lang__menu a:hover { background: var(--g5-ink-4); color: var(--g5-paper); }
.g5-lang__menu a.is-active { color: var(--g5-paper); }
.g5-lang__menu a.is-active::after { content: "✓"; color: var(--g5-accent); }
.g5-lang__menu small { color: var(--g5-paper-mute); text-transform: uppercase; }

.g5-btn-login {
    height: 40px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: var(--g5-paper);
    color: var(--g5-ink);
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}
.g5-btn-login:hover { background: #fff; }

.g5-burger {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--g5-line);
    background: transparent;
    color: var(--g5-paper);
    font-size: 18px;
    cursor: pointer;
}

.g5-mnav { display: none; }

/* ---------- 3. Nút, chip, tiêu đề mục ---------- */
.g5-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 22px;
    border-radius: 999px;
    border: 1px solid var(--g5-line);
    background: var(--g5-ink-3);
    color: var(--g5-paper);
    font: 700 15px/1 var(--g5-font);
    cursor: pointer;
    transition: transform .12s, background .15s, border-color .15s;
    white-space: nowrap;
}
.g5-btn:hover { border-color: var(--g5-paper-mute); }
.g5-btn:active { transform: translateY(1px); }
.g5-btn--accent { background: var(--g5-accent); border-color: var(--g5-accent); color: #fff; box-shadow: 0 10px 24px -10px rgba(255, 77, 46, .8); }
.g5-btn--accent:hover { background: var(--g5-accent-2); border-color: var(--g5-accent-2); }
.g5-btn--ghost { background: transparent; }
.g5-btn--sm { height: 36px; padding: 0 14px; font-size: 13.5px; }
.g5-btn.saved { border-color: var(--g5-accent); color: var(--g5-accent); }

.g5-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 0;
}
.g5-chips::-webkit-scrollbar { display: none; }
.g5-chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--g5-ink-2);
    border: 1px solid var(--g5-line);
    font-size: 14px;
    font-weight: 600;
    color: var(--g5-paper-dim);
    white-space: nowrap;
    transition: color .15s, border-color .15s, background .15s;
}
.g5-chip small { color: var(--g5-paper-mute); font-weight: 500; font-size: 12px; }
.g5-chip:hover { color: var(--g5-paper); border-color: var(--g5-accent); }
.g5-chip.is-active { background: var(--g5-paper); color: var(--g5-ink); border-color: var(--g5-paper); }

.g5-section { padding: 28px 0; }
.g5-section + .g5-section { padding-top: 8px; }
.g5-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.g5-head h2 {
    margin: 0;
    font-size: clamp(21px, 2.4vw, 28px);
    font-weight: 800;
    line-height: 1.1;
}
.g5-head h2 em {
    font-style: normal;
    color: var(--g5-accent);
}
.g5-head__more {
    flex: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--g5-paper-dim);
}
.g5-head__more:hover { color: var(--g5-accent); }
.g5-head__more::after { content: " →"; }

.g5-kicker {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--g5-accent);
}

/* ---------- 4. Thẻ truyện ---------- */
.g5-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 14px;
}
@media (min-width: 560px) { .g5-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 820px) { .g5-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .g5-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .g5-layout .g5-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* dải cuộn ngang */
.g5-rail {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - 14px) / 2.3);
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding-bottom: 4px;
}
.g5-rail::-webkit-scrollbar { display: none; }
.g5-rail > * { scroll-snap-align: start; }
@media (min-width: 560px) { .g5-rail { grid-auto-columns: calc((100% - 3 * 14px) / 3.4); } }
@media (min-width: 820px) { .g5-rail { grid-auto-columns: calc((100% - 4 * 14px) / 5); } }
@media (min-width: 1100px) { .g5-rail { grid-auto-columns: calc((100% - 5 * 14px) / 6); } }

.g5-railbox { position: relative; }
.g5-rail__nav {
    position: absolute;
    top: 34%;
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--g5-line);
    background: rgba(20, 20, 27, .92);
    color: var(--g5-paper);
    font-size: 18px;
    cursor: pointer;
    display: none;
}
.g5-rail__nav--prev { left: -14px; }
.g5-rail__nav--next { right: -14px; }
@media (hover: hover) and (min-width: 820px) {
    .g5-railbox:hover .g5-rail__nav { display: block; }
}

.g5-card { display: block; min-width: 0; }
.g5-card__cover {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: var(--g5-radius);
    overflow: hidden;
    background: var(--g5-ink-3);
    box-shadow: var(--g5-shadow);
}
.g5-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}
.g5-card__cover::after {
    content: "";
    position: absolute;
    inset: 55% 0 0;
    background: linear-gradient(to top, rgba(0, 0, 0, .78), transparent);
    pointer-events: none;
}
.g5-card:hover .g5-card__cover img { transform: scale(1.045); }
.g5-card__chap {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 1;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(12, 12, 16, .78);
    font-size: 12px;
    font-weight: 700;
    color: var(--g5-paper);
}
.g5-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.g5-badge--full { background: var(--g5-ok); color: #04150d; }
.g5-badge--hot { background: var(--g5-accent); color: #fff; }
.g5-badge--no {
    top: auto;
    bottom: -6px;
    left: -2px;
    padding: 0;
    background: none;
    font: 900 64px/1 var(--g5-font-display);
    color: var(--g5-paper);
    -webkit-text-stroke: 2px var(--g5-ink);
    text-shadow: 3px 3px 0 var(--g5-accent);
}
.g5-card__body { padding: 10px 2px 0; }
.g5-card__title {
    margin: 0;
    font: 700 15px/1.3 var(--g5-font);
    color: var(--g5-paper);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.g5-card:hover .g5-card__title { color: var(--g5-accent-2); }
.g5-card__meta { margin: 4px 0 0; font-size: 12.5px; color: var(--g5-paper-mute); }

.g5-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 28px;
    text-align: center;
    border: 1px dashed var(--g5-line);
    border-radius: var(--g5-radius);
    color: var(--g5-paper-mute);
}

/* ---------- 5. Hero ---------- */
.g5-hero { padding: 20px 0 8px; }
.g5-slides {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: var(--g5-ink-2);
}
.g5-slides__track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    scroll-behavior: smooth;
}
.g5-slides__track::-webkit-scrollbar { display: none; }
.g5-slide {
    position: relative;
    flex: 0 0 100%;
    scroll-snap-align: start;
    aspect-ratio: 21 / 8;
    min-height: 220px;
}
.g5-slide img { width: 100%; height: 100%; object-fit: cover; }
.g5-slide__cap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 60px 28px 24px;
    background: linear-gradient(to top, rgba(8, 8, 10, .92), transparent);
    font: 800 clamp(20px, 3vw, 34px)/1.1 var(--g5-font-display);
}
.g5-slides__dots {
    position: absolute;
    right: 20px;
    bottom: 18px;
    display: flex;
    gap: 6px;
    z-index: 2;
}
.g5-slides__dots button {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 99px;
    background: rgba(243, 239, 230, .4);
    cursor: pointer;
    transition: width .2s, background .2s;
}
.g5-slides__dots button.is-active { width: 22px; background: var(--g5-paper); }

/* spotlight: khi chưa có gallery thì hiện truyện hot nhất */
.g5-spot {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 32px;
    align-items: center;
    padding: 36px;
    border-radius: 22px;
    overflow: hidden;
    background: var(--g5-ink-2);
    isolation: isolate;
}
.g5-spot__bg {
    position: absolute;
    inset: -40px;
    z-index: -2;
    background-size: cover;
    background-position: center;
    filter: blur(40px) saturate(1.3);
    opacity: .45;
}
.g5-spot::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(rgba(12, 12, 16, .55) 1.2px, transparent 1.3px) 0 0 / 7px 7px,
        linear-gradient(90deg, rgba(12, 12, 16, .95) 30%, rgba(12, 12, 16, .35));
}
.g5-spot h1 { margin: 6px 0 12px; font-size: clamp(30px, 4.6vw, 56px); font-weight: 800; line-height: 1.02; }
.g5-spot p { margin: 0 0 22px; max-width: 58ch; color: var(--g5-paper-dim); line-height: 1.6; }
.g5-spot__cover { border-radius: 16px; overflow: hidden; aspect-ratio: 2 / 3; box-shadow: 0 30px 60px -20px #000; transform: rotate(2.5deg); border: 3px solid var(--g5-paper); }
.g5-spot__cover img { width: 100%; height: 100%; object-fit: cover; }
.g5-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- 6. Bố cục 2 cột + xếp hạng + chương mới ---------- */
.g5-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 32px;
    align-items: start;
}
.g5-aside { position: sticky; top: calc(var(--g5-header-h) + 16px); display: grid; gap: 20px; }
.g5-panel {
    padding: 20px;
    border-radius: 18px;
    background: var(--g5-ink-2);
    border: 1px solid var(--g5-line);
}
.g5-panel h2 { margin: 0 0 14px; font-size: 20px; font-weight: 800; }

.g5-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 14px;
    border-radius: 999px;
    background: var(--g5-ink);
    border: 1px solid var(--g5-line);
}
.g5-tabs button {
    flex: 1;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--g5-paper-dim);
    font: 700 13px var(--g5-font);
    cursor: pointer;
}
.g5-tabs button.is-active { background: var(--g5-paper); color: var(--g5-ink); }
.g5-tabpane { display: none; }
.g5-tabpane.is-active { display: block; }

.g5-rank {
    display: grid;
    grid-template-columns: 28px 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 8px 0;
}
.g5-rank + .g5-rank { border-top: 1px solid var(--g5-line); }
.g5-rank__no { font: 900 22px/1 var(--g5-font-display); color: var(--g5-paper-mute); text-align: center; }
.g5-rank--top .g5-rank__no { color: var(--g5-accent); }
.g5-rank__cover { width: 48px; height: 66px; border-radius: 8px; object-fit: cover; background: var(--g5-ink-3); }
.g5-rank__info { min-width: 0; }
.g5-rank__info strong { display: block; font-size: 14.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g5-rank__info small { font-size: 12.5px; color: var(--g5-paper-mute); }
.g5-rank:hover strong { color: var(--g5-accent-2); }

.g5-updates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.g5-update {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--g5-line);
}
.g5-update__cover img { width: 54px; height: 72px; border-radius: 8px; object-fit: cover; background: var(--g5-ink-3); }
.g5-update__info { min-width: 0; display: grid; gap: 4px; }
.g5-update__title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g5-update__title:hover { color: var(--g5-accent-2); }
.g5-update__chap { font-size: 13.5px; color: var(--g5-paper-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g5-update__chap:hover { color: var(--g5-accent); }
.g5-update__time { font-size: 12px; color: var(--g5-paper-mute); white-space: nowrap; }

/* tiếp tục đọc */
.g5-continue { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; scrollbar-width: none; }
.g5-continue a {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px;
    border-radius: 14px;
    background: var(--g5-ink-2);
    border: 1px solid var(--g5-line);
}
.g5-continue img { width: 46px; height: 62px; border-radius: 7px; object-fit: cover; }
.g5-continue strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g5-continue small { color: var(--g5-accent-2); font-weight: 600; font-size: 12.5px; }

/* dải giới thiệu truyện chữ + mời đăng truyện */
.g5-band {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.g5-band a {
    position: relative;
    display: block;
    padding: 28px;
    min-height: 170px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--g5-ink-2);
    border: 1px solid var(--g5-line);
    isolation: isolate;
}
.g5-band a::before {
    content: "";
    position: absolute;
    right: -30px;
    bottom: -30px;
    width: 220px;
    height: 220px;
    z-index: -1;
    background: radial-gradient(var(--g5-accent) 1.6px, transparent 1.8px) 0 0 / 9px 9px;
    -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 70%);
    mask-image: radial-gradient(circle, #000 20%, transparent 70%);
    opacity: .55;
}
.g5-band a.g5-band--paper { background: var(--g5-paper); color: var(--g5-ink); border-color: var(--g5-paper); }
.g5-band a.g5-band--paper::before { background-image: radial-gradient(var(--g5-ink) 1.6px, transparent 1.8px); opacity: .25; }
.g5-band h3 { margin: 0 0 8px; font-size: 24px; font-weight: 800; }
.g5-band p { margin: 0 0 16px; max-width: 40ch; opacity: .78; line-height: 1.55; }
.g5-band span { font-weight: 800; color: var(--g5-accent); }

/* ---------- 7. Chi tiết truyện ---------- */
.g5-crumb { padding: 16px 0 0; font-size: 13.5px; color: var(--g5-paper-mute); }
.g5-crumb a:hover { color: var(--g5-paper); }
.g5-crumb span { color: var(--g5-paper-dim); }

.g5-detail {
    position: relative;
    margin-top: 14px;
    padding: 32px;
    border-radius: 24px;
    overflow: hidden;
    isolation: isolate;
    background: var(--g5-ink-2);
}
.g5-detail__bg {
    position: absolute;
    inset: -60px;
    z-index: -2;
    background-size: cover;
    background-position: center;
    filter: blur(50px) saturate(1.4);
    opacity: .5;
}
.g5-detail::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: radial-gradient(rgba(12, 12, 16, .5) 1.2px, transparent 1.3px) 0 0 / 7px 7px, linear-gradient(180deg, rgba(12, 12, 16, .55), rgba(12, 12, 16, .92));
}
.g5-detail__grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 36px; align-items: end; }
.g5-detail__cover { border-radius: 16px; overflow: hidden; aspect-ratio: 2 / 3; box-shadow: 0 30px 60px -24px #000; }
.g5-detail__cover img { width: 100%; height: 100%; object-fit: cover; }
.g5-detail h1 { margin: 10px 0 12px; font-size: clamp(28px, 4vw, 48px); font-weight: 800; line-height: 1.05; }
.g5-detail__by { margin: 0 0 16px; color: var(--g5-paper-dim); }
.g5-detail__by a { color: var(--g5-paper); font-weight: 600; }
.g5-detail__by a:hover { color: var(--g5-accent); }
.g5-stats { display: flex; flex-wrap: wrap; gap: 22px; margin: 0 0 22px; padding: 0; list-style: none; }
.g5-stats li { display: grid; }
.g5-stats strong { font: 800 22px/1.1 var(--g5-font-display); }
.g5-stats span { font-size: 12.5px; color: var(--g5-paper-mute); }
.g5-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--g5-ok); }
.g5-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.g5-status--ongoing { color: var(--g5-pop); }

.g5-desc { color: var(--g5-paper-dim); line-height: 1.75; }
.g5-desc.is-clamped { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.g5-more { margin-top: 8px; padding: 0; border: 0; background: none; color: var(--g5-accent); font: 700 14px var(--g5-font); cursor: pointer; }

/* danh sách chương: giữ id #chapterList / #chapterSearch / #chapterSort cho main.js */
.g5-chapbar { display: flex; gap: 10px; margin-bottom: 14px; }
.g5-chapbar input, .g5-chapbar select {
    height: 42px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--g5-line);
    background: var(--g5-ink);
    color: var(--g5-paper);
    font: 14px var(--g5-font);
}
.g5-chapbar input { flex: 1; min-width: 0; }
.g5-chapters .chapter-list,
.g5-chapters #chapterList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    max-height: 640px;
    overflow-y: auto;
    padding-right: 4px;
}
.g5-chapters .chapter-item,
.g5-chapters #chapterList > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--g5-ink);
    border: 1px solid var(--g5-line);
    transition: border-color .15s;
}
.g5-chapters #chapterList > a:hover { border-color: var(--g5-accent); }

.g5-tags { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 8. Trang đọc truyện tranh ---------- */
body.g5-reading .g5-header { transition: transform .25s ease; }
body.g5-reading.g5-hide-ui .g5-header { transform: translateY(-100%); }
.g5-progress { position: fixed; left: 0; top: 0; z-index: 300; height: 3px; width: 0; background: var(--g5-accent); }

.g5-readhead { padding: 22px 0 18px; text-align: center; }
.g5-readhead a.g5-readhead__story { font-size: 14px; font-weight: 700; color: var(--g5-accent); }
.g5-readhead h1 { margin: 6px 0 6px; font-size: clamp(22px, 3vw, 32px); font-weight: 800; }
.g5-readhead p { margin: 0 0 16px; font-size: 13.5px; color: var(--g5-paper-mute); }
.g5-readhead .g5-actions { justify-content: center; }

.g5-pages { max-width: 860px; margin: 0 auto; background: #000; }
.g5-pages img { display: block; width: 100%; height: auto; margin: 0 auto; }
.g5-pages br { display: none; }
.g5-pages p { margin: 0; }
body.g5-wide .g5-pages { max-width: 1100px; }

.g5-readnav {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 250;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(20, 20, 27, .94);
    border: 1px solid var(--g5-line);
    box-shadow: var(--g5-shadow);
    transition: transform .25s ease, opacity .25s;
}
body.g5-hide-ui .g5-readnav { transform: translate(-50%, 140%); opacity: 0; }
.g5-readnav a, .g5-readnav button {
    height: 42px;
    min-width: 42px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--g5-paper);
    font: 700 14px var(--g5-font);
    cursor: pointer;
    white-space: nowrap;
}
.g5-readnav a:hover, .g5-readnav button:hover { background: var(--g5-ink-4); }
.g5-readnav .g5-readnav__next { background: var(--g5-accent); }
.g5-readnav .g5-readnav__next:hover { background: var(--g5-accent-2); }

.g5-readend { max-width: 860px; margin: 0 auto; padding: 36px 16px 120px; text-align: center; }
.g5-readend h2 { margin: 0 0 16px; font-size: 22px; }
.g5-readend .g5-actions { justify-content: center; margin-bottom: 40px; }
.g5-readend .wrap-comment, .g5-readend section { text-align: left; }

/* khóa chương VIP */
.g5-lock {
    max-width: 560px;
    margin: 24px auto;
    padding: 32px;
    border-radius: 22px;
    background: var(--g5-ink-2);
    border: 1px solid var(--g5-line);
    text-align: center;
}
.g5-lock__icon { width: 56px; height: 56px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; background: var(--g5-accent); font-size: 24px; }
.g5-lock h2 { margin: 0 0 8px; font-size: 24px; }
.g5-lock p { margin: 0 0 20px; color: var(--g5-paper-dim); line-height: 1.6; }
.g5-lock dl { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 0 0 20px; padding: 16px; border-radius: 14px; background: var(--g5-ink); text-align: left; }
.g5-lock dt { color: var(--g5-paper-mute); }
.g5-lock dd { margin: 0; font-weight: 700; text-align: right; }
.g5-lock dd.coin { color: var(--g5-pop); }
.g5-lock .g5-actions { justify-content: center; }
.g5-lock label { display: flex; gap: 10px; margin-top: 18px; text-align: left; font-size: 13.5px; color: var(--g5-paper-dim); }
.g5-preview { max-height: 70vh; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }

/* ---------- 9. Footer ---------- */
.g5-footer { margin-top: 56px; border-top: 1px solid var(--g5-line); background: var(--g5-ink-2); }
.g5-footer__in { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; padding: 44px 0 28px; }
.g5-footer h3 { margin: 12px 0 8px; font-size: 20px; }
.g5-footer h4 { margin: 0 0 12px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--g5-paper-mute); }
.g5-footer p { margin: 0; max-width: 40ch; color: var(--g5-paper-dim); line-height: 1.6; font-size: 14px; }
.g5-footer a { display: block; padding: 4px 0; color: var(--g5-paper-dim); font-size: 14px; }
.g5-footer a:hover { color: var(--g5-paper); }
.g5-footer__bottom { padding: 18px 0 28px; border-top: 1px solid var(--g5-line); font-size: 13px; color: var(--g5-paper-mute); }

/* ---------- 10. Responsive ---------- */
@media (max-width: 1100px) {
    .g5-search input { width: 200px; }
    .g5-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
}

@media (max-width: 900px) {
    .g5-nav, .g5-search { display: none; }
    .g5-burger { display: block; }
    .g5-mnav.is-open {
        display: grid;
        gap: 4px;
        padding: 12px 0 16px;
    }
    .g5-mnav a { padding: 12px 14px; border-radius: 10px; font-weight: 600; background: var(--g5-ink-2); }
    .g5-mnav .g5-search { display: block; margin-bottom: 6px; }
    .g5-mnav .g5-search input { width: 100%; }
    .g5-layout { grid-template-columns: minmax(0, 1fr); }
    .g5-aside { position: static; }
    .g5-updates { grid-template-columns: minmax(0, 1fr); }
    .g5-footer__in { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    :root { --g5-header-h: 56px; }
    .g5-wrap { width: calc(100% - 24px); }
    .g5-logo img { height: 28px; }
    .g5-header__in { gap: 10px; }
    .g5-lang summary { padding: 0 10px; }
    .g5-btn-login { padding: 0 14px; }
    .g5-hero { padding-top: 12px; }
    .g5-slides { border-radius: 14px; }
    .g5-slide { aspect-ratio: 16 / 9; min-height: 0; }
    .g5-slide__cap { padding: 40px 16px 14px; font-size: 18px; }
    .g5-spot { grid-template-columns: minmax(0, 1fr) 110px; gap: 16px; padding: 20px; border-radius: 16px; }
    .g5-spot h1 { font-size: 26px; }
    .g5-spot p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; margin-bottom: 16px; }
    .g5-spot .g5-btn { height: 40px; padding: 0 16px; font-size: 14px; }
    .g5-section { padding: 20px 0; }
    .g5-grid { gap: 16px 12px; }
    .g5-card__title { font-size: 14px; }
    .g5-badge--no { font-size: 48px; }
    .g5-band { grid-template-columns: minmax(0, 1fr); }
    .g5-detail { padding: 18px; border-radius: 18px; }
    .g5-detail__grid { grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: start; }
    .g5-detail h1 { font-size: 24px; margin-top: 4px; }
    .g5-detail .g5-actions { grid-column: 1 / -1; }
    .g5-detail .g5-actions .g5-btn { flex: 1; }
    .g5-stats { gap: 16px; }
    .g5-stats strong { font-size: 18px; }
    .g5-readnav a span, .g5-readnav button span { display: none; }
    .g5-footer__in { grid-template-columns: 1fr; gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- 10. Bổ sung 2026-11-13: chi tiết + đọc truyện tranh ---------- */
.g5-stack { display: grid; gap: 20px; min-width: 0; }
.g5-detail__info { min-width: 0; }
.g5-detail__info .g5-status { margin-bottom: 4px; }
.g5-chips--wrap { flex-wrap: wrap; overflow: visible; margin-top: 16px; }
.g5-head__note { font-size: 13px; color: var(--g5-paper-mute); font-weight: 600; }
.g5-panel .g5-head { margin-bottom: 12px; }
.g5-panel .g5-head h2 { margin: 0; font-size: 20px; }
.g5-panel h2 small { font-size: 14px; color: var(--g5-paper-mute); font-weight: 600; }

.g5-chapbar { flex-wrap: wrap; }
.g5-chaplist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px;
    max-height: 620px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
}
.g5-chaplist .g5-empty { grid-column: 1 / -1; }
.g5-chap {
    position: relative;
    display: grid;
    gap: 3px;
    padding: 11px 14px;
    border-radius: 12px;
    background: var(--g5-ink);
    border: 1px solid var(--g5-line);
    transition: border-color .15s, background .15s;
}
.g5-chap:hover { border-color: var(--g5-accent); background: var(--g5-ink-3); }
.g5-chap:visited .g5-chap__t { color: var(--g5-paper-mute); }
.g5-chap__t { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 54px; }
.g5-chap small { font-size: 12px; color: var(--g5-paper-mute); }
.g5-chap__vip {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--g5-pop);
    color: var(--g5-ink);
    font-size: 11px;
    font-weight: 800;
}

.g5-rank--plain { grid-template-columns: 48px minmax(0, 1fr); }

.g5-comments { overflow: hidden; }

/* trang đọc: nút nổi + drawer mục lục (giữ class cũ của main.js) */
.g5-readnav .g5-readnav__ico { min-width: 44px; justify-content: center; }
body.g5-reading .chapter-drawer { background: var(--g5-ink-2); color: var(--g5-paper); border-left: 1px solid var(--g5-line); }
body.g5-reading .drawer-chapter { color: var(--g5-paper-dim); }
body.g5-reading .drawer-chapter.current { color: var(--g5-accent); font-weight: 800; }
body.g5-reading .drawer-search input { background: var(--g5-ink); color: var(--g5-paper); border: 1px solid var(--g5-line); }
.g5-readhead__meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; }
.g5-readcomments { max-width: 860px; margin: 0 auto; }

@media (max-width: 900px) {
    .g5-chaplist { grid-template-columns: 1fr; max-height: 520px; }
}

/* SỬA 2026-11-13: mobile - khối thông tin trải ra lưới để hàng nút chiếm hết chiều ngang (tránh tràn chữ) */
@media (max-width: 640px) {
    .g5-detail__info { display: contents; }
    .g5-detail__cover { grid-row: 1 / span 4; align-self: start; }
    .g5-detail__info > * { grid-column: 2; }
    .g5-detail__info > .g5-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .g5-detail__info > .g5-actions .g5-btn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .g5-detail__info > .g5-actions > :not(#saveStoryBtn):not(#shareBtn) { grid-column: 1 / -1; }
}
/* =====================================================================
   THÊM 2026-11-13: trang Danh sách truyện + Bảng xếp hạng
   ===================================================================== */
.g5-pagehead {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 18px 0 22px;
}
.g5-pagehead h1 { margin: 0; font: 800 clamp(26px, 3.6vw, 40px)/1.1 var(--g5-font-display); }

/* nhóm nút chọn 1 (tab dạng viên thuốc) */
.g5-seg {
    display: inline-flex;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 4px;
    padding: 4px;
    background: var(--g5-ink-2);
    border: 1px solid var(--g5-line);
    border-radius: 999px;
}
.g5-seg::-webkit-scrollbar { display: none; }
.g5-seg a {
    flex: none;
    padding: 8px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14.5px;
    color: var(--g5-paper-dim);
    white-space: nowrap;
}
.g5-seg a:hover { color: var(--g5-paper); }
.g5-seg a.is-active { background: var(--g5-paper); color: var(--g5-ink); }
.g5-seg--sm a { padding: 6px 14px; font-size: 13.5px; }

/* bố cục danh sách: cột lọc + kết quả */
.g5-listing { display: grid; gap: 22px; align-items: start; margin-bottom: 48px; }
@media (min-width: 960px) {
    .g5-listing { grid-template-columns: 280px minmax(0, 1fr); }
    .g5-filter { position: sticky; top: calc(var(--g5-header-h) + 16px); max-height: calc(100vh - var(--g5-header-h) - 32px); overflow-y: auto; }
    .g5-listing .g5-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1180px) { .g5-listing .g5-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.g5-filter { display: grid; gap: 0; }
.g5-filter > summary {
    list-style: none;
    cursor: pointer;
    font: 800 18px/1.2 var(--g5-font-display);
    display: flex;
    align-items: center;
    gap: 8px;
}
.g5-filter > summary::-webkit-details-marker { display: none; }
.g5-filter > summary::after { content: "▾"; margin-left: auto; color: var(--g5-paper-mute); transition: transform .2s; }
.g5-filter[open] > summary { margin-bottom: 16px; }
.g5-filter[open] > summary::after { transform: rotate(180deg); }
.g5-filter > summary b {
    min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
    background: var(--g5-accent); color: #fff; font: 800 12px/22px var(--g5-font); text-align: center;
}
.g5-field { display: grid; gap: 8px; margin-bottom: 18px; }
.g5-field > span { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--g5-paper-mute); }
.g5-field input[type=search],
.g5-field select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    background: var(--g5-ink-3);
    border: 1px solid var(--g5-line);
    border-radius: var(--g5-radius-sm);
    color: var(--g5-paper);
    font: 500 14.5px var(--g5-font);
}
.g5-field input:focus, .g5-field select:focus { outline: none; border-color: var(--g5-accent); }
.g5-chips--pick { margin-top: 0; gap: 6px; max-height: 236px; overflow-y: auto; padding-right: 4px; }
.g5-chips--pick .g5-chip { position: relative; cursor: pointer; padding: 6px 12px; font-size: 13px; }
.g5-chips--pick .g5-chip input { position: absolute; opacity: 0; pointer-events: none; }
.g5-chips--pick .g5-chip:has(input:checked) { background: var(--g5-paper); color: var(--g5-ink); border-color: var(--g5-paper); }
.g5-chips--pick .g5-chip:has(input:focus-visible) { outline: 2px solid var(--g5-accent); outline-offset: 2px; }
.g5-filter__actions { display: flex; gap: 10px; }
.g5-filter__actions .g5-btn { flex: 1; justify-content: center; }

.g5-results__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 18px; }
.g5-results__head > strong { font-size: 15px; color: var(--g5-paper-dim); }
.g5-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.g5-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px 5px 12px; border-radius: 999px;
    background: rgba(255, 77, 46, .12); border: 1px solid rgba(255, 77, 46, .35);
    color: var(--g5-accent-2); font-size: 13px; font-weight: 600;
}
.g5-pill i { font-style: normal; font-size: 15px; line-height: 1; opacity: .7; }
.g5-pill:hover { background: rgba(255, 77, 46, .22); }
.g5-pill:hover i { opacity: 1; }

/* phân trang */
.g5-pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 32px 0 8px; }
.g5-pager a, .g5-pager span {
    min-width: 40px; height: 40px; padding: 0 12px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--g5-radius-sm); border: 1px solid var(--g5-line);
    background: var(--g5-ink-2); font-weight: 700; font-size: 14px; color: var(--g5-paper-dim);
}
.g5-pager a:hover { border-color: var(--g5-accent); color: var(--g5-paper); }
.g5-pager .is-active { background: var(--g5-accent); border-color: var(--g5-accent); color: #fff; }
.g5-pager .g5-pager__gap { border-color: transparent; background: none; min-width: 24px; padding: 0; }

/* bảng xếp hạng */
.g5-rankbar {
    display: grid; gap: 12px;
    padding: 16px; margin-bottom: 20px;
    background: var(--g5-ink-2); border: 1px solid var(--g5-line); border-radius: var(--g5-radius);
}
.g5-rankbar__row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.g5-rankbar__row > span { flex: none; width: 110px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--g5-paper-mute); }
.g5-rankbar .g5-chips { margin: 0; }

.g5-board { list-style: none; margin: 0 0 48px; padding: 0; display: grid; gap: 10px; }
.g5-board__row {
    display: grid;
    grid-template-columns: 56px 72px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 12px 18px 12px 8px;
    background: var(--g5-ink-2);
    border: 1px solid var(--g5-line);
    border-radius: var(--g5-radius);
    transition: border-color .2s, transform .2s;
}
.g5-board__row:hover { border-color: var(--g5-paper-mute); transform: translateY(-1px); }
.g5-board__no { font: 900 30px/1 var(--g5-font-display); color: var(--g5-paper-mute); text-align: center; }
.g5-board__cover img { display: block; width: 72px; height: 100px; border-radius: 8px; object-fit: cover; background: var(--g5-ink-3); }
.g5-board__info { min-width: 0; display: grid; gap: 4px; }
.g5-board__name {
    font: 700 17px/1.3 var(--g5-font);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.g5-board__name:hover { color: var(--g5-accent-2); }
.g5-board__genres, .g5-board__meta { margin: 0; font-size: 13px; color: var(--g5-paper-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g5-board__meta { color: var(--g5-paper-mute); }
.g5-board__meta i { font-style: normal; margin: 0 6px; opacity: .6; }
.g5-board__row--top { background: linear-gradient(90deg, rgba(255, 77, 46, .14), var(--g5-ink-2) 55%); border-color: rgba(255, 77, 46, .35); }
.g5-board__row--top .g5-board__no { color: var(--g5-accent); font-size: 38px; }
.g5-board__row--1 { background: linear-gradient(90deg, rgba(255, 210, 63, .16), var(--g5-ink-2) 55%); border-color: rgba(255, 210, 63, .45); }
.g5-board__row--1 .g5-board__no { color: var(--g5-pop); }
.g5-board__row--top .g5-board__cover img { width: 84px; height: 116px; }
.g5-board__row--top { grid-template-columns: 56px 84px minmax(0, 1fr) auto; }

@media (max-width: 640px) {
    .g5-pagehead { margin: 12px 0 16px; }
    .g5-pagehead .g5-seg { width: 100%; }
    .g5-pagehead .g5-seg a { flex: 1; text-align: center; }
    .g5-rankbar { padding: 12px; }
    .g5-rankbar__row { flex-direction: column; align-items: stretch; gap: 6px; }
    .g5-rankbar__row > span { width: auto; }
    .g5-board__row, .g5-board__row--top { grid-template-columns: 34px 60px minmax(0, 1fr); gap: 12px; padding: 10px 12px 10px 4px; }
    .g5-board__no { font-size: 22px; }
    .g5-board__row--top .g5-board__no { font-size: 28px; }
    .g5-board__cover img, .g5-board__row--top .g5-board__cover img { width: 60px; height: 84px; }
    .g5-board__name { font-size: 15px; }
    .g5-board__read { display: none; }
}
