:root { color-scheme: light; font-family: "Geist", "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--background); font-size: 15px; }
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }
button, .button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
input, textarea, select { width: 100%; border: 1px solid var(--border); background: var(--surface); padding: .8rem; border-radius: 10px; color: inherit; }
textarea { resize: vertical; line-height: 1.65; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button, .button { display: inline-block; border: 0; border-radius: 10px; background: var(--button); color: var(--button-text); padding: .8rem 1.15rem; font-weight: 600; text-align: center; }
.button:hover { background: var(--button-hover); text-decoration: none; }
.secondary { background: var(--soft); color: var(--accent); }
.button.secondary:hover { background: var(--cover); }
.text-button { padding: .25rem 0; background: none; color: var(--muted); font-weight: 400; }
.site-header { display: flex; flex-direction: column; align-items: stretch; gap: 1rem; padding: 1rem max(5vw, calc((100vw - 1240px) / 2)); border-bottom: 1px solid var(--border); background: var(--surface); }
.site-banner { display: block; overflow: hidden; border-radius: 12px; background: #ffffff; }
.site-banner picture, .site-banner img { display: block; width: 100%; }
.site-banner img { height: auto; aspect-ratio: 3 / 1; }
nav, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 1.25rem; }
.site-header nav { font-size: .9rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.account-name { color: var(--muted); }
main { max-width: 1240px; padding: 2rem 2rem 5rem; margin: auto; }
h1 { font-size: clamp(1.6rem, 4vw, 2rem); letter-spacing: -.04em; font-weight: 650; line-height: 1.2; margin: .5rem 0 1rem; overflow-wrap: anywhere; }
h2 { font-weight: 600; letter-spacing: -.025em; font-size: 1.3rem; }
p { line-height: 1.7; }
.muted { color: var(--muted); font-size: .9rem; }
.page-heading { display: flex; justify-content: space-between; gap: 2rem; align-items: center; margin-bottom: 2rem; }
.search { display: flex; gap: .5rem; width: 100%; }
.catalog { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
.manga-card { color: inherit; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.manga-card h2 { font-size: 1.1rem; margin: 0 0 .4rem; line-height: 1.4; overflow-wrap: anywhere; }
.manga-card p { margin: .25rem 0; }
.cover { aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden; background: var(--cover); display: grid; place-items: center; }
.catalog .cover { aspect-ratio: 16 / 9; border-radius: 0; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { font-family: Georgia, serif; font-size: 4rem; color: var(--placeholder); }
.group-card { border: 1px solid var(--border); background: var(--soft); border-radius: 12px; padding: 1.2rem; min-height: 260px; display: flex; flex-direction: column; justify-content: space-between; overflow-wrap: anywhere; }
.group-card h2 { margin: 1rem 0; }
.pagination { justify-content: center; margin-top: 3rem; }
.empty-state { padding: 4rem 1rem; text-align: center; }
.empty-state .actions { justify-content: center; }
.narrow { max-width: 440px; margin: 4rem auto; }
.stack { display: flex; flex-direction: column; gap: 1.25rem; }
.stack label { display: flex; flex-direction: column; gap: .5rem; }
.stack button { align-self: flex-start; }
.notice { padding: .9rem 1.1rem; background: var(--notice); border-left: 3px solid var(--notice-border); overflow-wrap: anywhere; }
.notice.error { background: var(--error); border-color: var(--error-border); }
.manga-detail { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 2.5rem; margin: 1.8rem 0 2.5rem; }
.detail-cover { aspect-ratio: auto; align-self: start; }
.detail-cover img { height: auto; object-fit: contain; }
.metadata { display: grid; grid-template-columns: minmax(75px, max-content) 1fr; gap: .6rem 1rem; line-height: 1.5; }
.metadata dt { color: var(--muted); }
.metadata dd { margin: 0; overflow-wrap: anywhere; }
.description { max-width: 850px; margin-bottom: 2.5rem; }
.description p { white-space: pre-wrap; overflow-wrap: anywhere; }
.chapter-list { list-style: none; padding: 0; border-top: 1px solid var(--border); }
.chapter-list li { border-bottom: 1px solid var(--border); }
.chapter-list a { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem .3rem; color: inherit; }
.chapter-list a span:first-child { overflow-wrap: anywhere; }
.chapter-name { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; min-width: 0; }
.chapter-info { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.chapter-badge { padding: .15rem .5rem; border-radius: 5px; background: var(--notice); color: var(--text); font-size: .75rem; }
.reading-badge { background: var(--button); color: var(--button-text); }
.chapter-list a[aria-current="page"] { background: var(--soft); box-shadow: inset 3px 0 var(--accent); }
.chapter-heading { text-align: center; }
.chapter-heading h1 { font-size: 1.5rem; margin-top: 1rem; }
.reader-nav { justify-content: center; margin: 1.5rem 0; }
.reader-nav:not(.bottom) { position: sticky; top: 0; z-index: 2; background: var(--sticky-background); padding: .9rem .5rem; border-bottom: 1px solid var(--border); transition: opacity .18s ease; }
/* Giữ chỗ trong bố cục để ẩn/hiện thanh không làm ảnh hoặc vị trí đọc nhảy lên xuống. */
.reader-nav:not(.bottom).is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .reader-nav:not(.bottom) { transition: none; } }
.reading-status { font-size: .8rem; color: var(--muted); text-align: center; }
/* Thanh trang nổi trong suốt, không chiếm chiều rộng ảnh; xoay thuận chiều để đầy từ trên xuống. */
.reading-rail { position: fixed; right: 4px; top: 32vh; width: 20px; height: 36vh; z-index: 3; pointer-events: none; background: transparent; }
.reading-rail progress { position: absolute; top: 50%; left: 50%; width: 36vh; height: 4px; transform: translate(-50%, -50%) rotate(90deg); direction: ltr; border: 0; border-radius: 4px; overflow: hidden; appearance: none; background: var(--border); color: var(--muted); accent-color: var(--muted); }
.reading-rail progress::-webkit-progress-bar { background: var(--border); }
.reading-rail progress::-webkit-progress-value { background: var(--muted); }
.reading-rail progress::-moz-progress-bar { background: var(--muted); }
#reading-page { position: absolute; top: calc(100% + 8px); width: 100%; writing-mode: vertical-rl; font-size: .7rem; color: var(--muted); }
.reading-rail[data-position="bottom"] { top: auto; right: auto; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); width: min(70vw, 420px); height: 20px; display: flex; align-items: center; gap: 8px; }
.reading-rail[data-position="bottom"] progress { position: static; transform: none; width: auto; flex: 1; min-width: 0; }
.reading-rail[data-position="bottom"] #reading-page { position: static; width: auto; writing-mode: horizontal-tb; white-space: nowrap; }
.chapter-main { max-width: none; padding-inline: 0; }
.reader-pages { margin: 0; padding-inline: var(--chapter-image-gap, 4px); background: transparent; }
.reader-pages figure { margin: 0; scroll-margin-top: 15px; }
.reader-pages figure + figure { margin-top: var(--chapter-image-gap, 4px); }
.reader-pages img { width: 100%; height: auto; display: block; border: 1px solid #AAAAAA; border-radius: .5em; }
.image-error { padding: 2rem; background: var(--error); }
.continue-item { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; padding: 1.5rem 0; border-bottom: 1px solid var(--border); }
.continue-item h2 { margin: 0; overflow-wrap: anywhere; }
.continue-item form { flex-shrink: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 2rem 0; }
.stats div { border: 1px solid var(--border); border-radius: 12px; padding: 1.4rem; background: var(--surface); }
.stats dt { color: var(--muted); }
.stats dd { margin: .8rem 0 0; font-size: clamp(1.3rem, 3vw, 2.3rem); letter-spacing: -.04em; overflow-wrap: anywhere; }
.stats .loading-value { color: var(--muted); font-size: 1rem; letter-spacing: normal; }
.scan-monitor { margin-top: 1rem; }
.scan-monitor progress { width: 100%; height: 8px; accent-color: var(--accent); }
.scan-monitor p { margin: .5rem 0; overflow-wrap: anywhere; }
.scan-console { height: 150px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--soft); color: var(--text); font: .8rem/1.6 Consolas, monospace; }
.issues { padding: 0; list-style: none; }
.issues li { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: .9rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.issues code { overflow-wrap: anywhere; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin: 1rem 0 2rem; text-align: left; }
td, th { border-bottom: 1px solid var(--border); padding: 1rem; }
th { font-weight: 500; color: var(--muted); }
.form-panel { max-width: 550px; margin: 2rem 0; }
.metadata-form { max-width: 800px; }
#scan-form { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; max-width: 100%; }
#scan-form select { width: auto; min-width: 0; max-width: min(100%, 28rem); }
.checkbox { flex-direction: row !important; align-items: center; }
.checkbox input { width: auto; }
@media (max-width: 1050px) { .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); } .account-name { display: none; } }
@media (max-width: 700px) { .site-header { gap: .8rem; padding: 1rem 1.2rem; } main { padding: 1.5rem 1.2rem 3rem; } .page-heading { flex-direction: column; align-items: flex-start; gap: .8rem; } .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; } .manga-detail { grid-template-columns: minmax(0, 1fr); gap: 1rem; } .manga-detail h1 { font-size: 1.65rem; } .metadata { grid-template-columns: 1fr; gap: .3rem; } .metadata dd { margin-bottom: .6rem; } .stats { grid-template-columns: repeat(2, 1fr); } .continue-item { align-items: flex-start; } .chapter-list a { flex-direction: column; gap: .4rem; } .chapter-info { align-items: flex-start; } .narrow { margin: 1.5rem auto; } .group-card { padding: 1rem; min-height: 210px; } .group-card h2 { font-size: 1rem; } }
@media (max-width: 520px) { .catalog { grid-template-columns: minmax(0, 1fr); } .continue-item { flex-direction: column; } }

/* Màu mặc định Light; data-theme lấy từ [ui] theme trong INI. */
:root {
  --text: #171717; --background: #ffffff; --surface: #ffffff;
  --accent: #252525; --muted: #686868; --border: #e3e3e3;
  --button: #202020; --button-hover: #404040; --button-text: #ffffff;
  --soft: #f4f4f4; --cover: #eeeeee; --placeholder: #7b7b7b;
  --notice: #eef4fc; --notice-border: #6485b5;
  --error: #fff0ed; --error-border: #c36c59; --focus: #5274c7;
  --sticky-background: #fffffff5;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #ededed; --background: #171717; --surface: #202020;
  --accent: #eeeeee; --muted: #afafaf; --border: #3b3b3b;
  --button: #ededed; --button-hover: #ffffff; --button-text: #171717;
  --soft: #292929; --cover: #303030; --placeholder: #b1b1b1;
  --notice: #253044; --notice-border: #88a4ce;
  --error: #462e29; --error-border: #d99073; --focus: #e7b663;
  --sticky-background: #171717f5;
}
.language-switch { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.language-switch select { width: auto; padding: .35rem .45rem; }

/* Bố cục Astryx: tìm kiếm rộng, tab lọc và thẻ ảnh ngang trên thư viện. */
.page-heading { padding-bottom: 1.3rem; border-bottom: 1px solid var(--border); }
.catalog-search { margin-bottom: 1.6rem; padding-bottom: 1.6rem; border-bottom: 1px solid var(--border); }
.search { position: relative; align-items: center; gap: .65rem; }
.search input[type="search"] { min-width: 0; padding-left: 2.5rem; }
.search-icon { position: absolute; left: .85rem; font-size: 1.5rem; color: var(--muted); pointer-events: none; }
.search button { flex-shrink: 0; }
.catalog-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.catalog-filters { gap: .3rem; }
.catalog-filters a { padding: .65rem .85rem; border-radius: 10px; color: var(--text); }
.catalog-filters a:hover, .catalog-filters a[aria-current="true"] { background: var(--cover); text-decoration: none; }
#catalog-sort { width: auto; flex-shrink: 0; background: var(--soft); border-color: transparent; }
/* Ba dòng thông tin cố định; tên/tag dài được rút gọn, không cuộn bên trong card. */
.manga-card { display: flex; flex-direction: column; }
.catalog .cover { flex-shrink: 0; }
.catalog .group-card { overflow: hidden; }
.card-content { padding: 1rem; display: flex; flex-direction: column; gap: .4rem; min-height: 0; overflow: hidden; }
.card-content h2, .card-content p { margin: 0; flex-shrink: 0; }
.card-content h2 { line-height: 1.4; }
.card-content p { line-height: 1.5; }
.single-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card-content p { overflow-wrap: anywhere; }
.card-latest { font-size: .9rem; }
.manga-card:hover, .group-card:hover { border-color: var(--muted); box-shadow: 0 3px 12px #0000000a; text-decoration: none; }
.site-header nav > a { color: var(--text); padding-block: .35rem; }
.site-header nav > form { margin: 0; }
.narrow { padding: 2rem; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.chapter-list a:hover, .continue-item:hover { background: var(--soft); }
.chapter-list a { padding-inline: 1rem; }
.table-scroll { border: 1px solid var(--border); border-radius: 12px; }
.table-scroll table { margin: 0; }
th { background: var(--soft); }
@media (max-width: 700px) {
  .site-header nav { gap: .7rem 1rem; }
  .language-switch label { font-size: .85rem; }
  .catalog-toolbar { flex-direction: column; align-items: stretch; gap: .5rem; }
  #catalog-sort { align-self: flex-start; max-width: 100%; }
  .catalog-filters { gap: .2rem; }
  .catalog-filters a { padding: .6rem; }
  .narrow { padding: 1.4rem; }
}
