:root{
  --bg: #101119;
  --surface: #181a24;
  --surface-2: #1f212c;
  --text: #eceaf1;
  --text-dim: #9a9aa8;
  --text-faint: #6f6f7d;
  --accent: #5a8dff;
  --accent-pill: #3a6bf0;
  --danger-icon: #c9c9d4;
  --divider: #262835;
  --radius: 16px;
  /* кольори кнопки-перемикача типу бібліотеки (library.html) —
     Манґи/Манхви фіолетовий, Новели/Романи синій, Аніме зелений */
  --type-manga: #8b5cf6;
  --type-novel: #5a8dff;
  --type-anime: #34c778;
}

*{ box-sizing:border-box; }
a{ text-decoration:none; color:inherit; }
button{ font-family:inherit; }
input{ font-family:inherit; }

/* КРИТИЧНО: без цього правила `el.hidden = true` нічого не приховує для
   елементів, у яких десь нижче по каскаду є власний клас з `display: ...`
   (напр. .anime-video-status{ display:flex }) — сторінка автора завжди
   переважає стилі агента користувача незалежно від специфічності/порядку,
   тож без !important такий елемент лишається видимим і клікабельним
   НАЗАВЖДИ після першого показу, перекриваючи собою контроли <video> під
   ним. Саме це й ламало керування вбудованим плеєром на anime.html. */
[hidden]{ display:none !important; }

/* Фікс "відлипання" фіксованих панелей/меню (нижнє меню, шторки фільтрів/
   налаштувань, верхня/нижня панелі читалки тощо) від краю вікна при
   швидкому/інерційному гортанні на мобільних браузерах. position:fixed
   елементи без власного композиційного шару можуть на мить "відстати" від
   скролу — явний GPU-шар прибирає цей глюк. */
.bottomnav,
.chapters-select-bar,
.reader-topbar-chrome,
.reader-searchbar,
.reader-bottombar-chrome,
.reader-footer,
.filter-fab-wrap,
.filter-backdrop,
.filter-overlay-full,
.modal-overlay-center,
.next-chapter-fab,
.lib-type-fab-wrap{
  transform:translateZ(0);
  -webkit-transform:translateZ(0);
  will-change:transform;
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
}

html,body{
  margin:0; padding:0; height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:"Roboto","Segoe UI",system-ui,-apple-system,sans-serif;
  -webkit-font-smoothing:antialiased;
}

.app{
  max-width:480px;
  margin:0 auto;
  min-height:100vh;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  background:var(--bg);
  position:relative;
  /* Обтікання вирізу камери/заокруглень екрана в ландшафтній орієнтації —
     у портретній це майже завжди 0, але на деяких пристроях (виріз збоку)
     не завадить. Спрацьовує лише завдяки viewport-fit=cover у <head> кожної
     сторінки — без нього env() тут завжди повертає 0. */
  padding-left:env(safe-area-inset-left);
  padding-right:env(safe-area-inset-right);
}

.topbar{
  position:sticky; top:0; z-index:5;
  background:var(--bg);
  /* Android: env(safe-area-inset-top) не завжди повертає коректний розмір
     вирізу камери (баг конкретних прошивок/версій Chrome, особливо для
     центрованих punch-hole камер) — max(..., 24px) підстраховує мінімальний
     відступ навіть якщо env() поверне 0, не обрізаючи більше значення там,
     де воно рахується правильно (iOS notch тощо). */
  padding:calc(14px + max(env(safe-area-inset-top), 24px)) 16px 10px;
}

.content{
  flex:1;
  padding-bottom:84px;
  overflow-y:auto;
}

/* search bar */
.searchbar{
  display:flex; align-items:center; gap:10px;
  background:var(--surface);
  border-radius:28px;
  padding:12px 16px;
  color:var(--text-faint);
}
.searchbar input{
  border:none; outline:none; background:transparent;
  color:var(--text); font-size:15px; flex:1;
  font-family:inherit;
}
.searchbar input::placeholder{ color:var(--text-faint); }
.searchbar .sb-icon{ width:20px; height:20px; flex-shrink:0; color:var(--text-faint); }
.searchbar .sb-actions{ display:flex; gap:14px; margin-left:auto; }

/* Перемикач типу пошуку (Усі/Новели/Манґи) під пошуковим рядком у "Огляд"
   — той самий .category-tabs, що й на бібліотеці, але тут він живе всередині
   .topbar (яка сама вже має padding:14px 16px), тож власні бокові відступи
   рядка прибираємо, щоб вирівнятись із пошуковим рядком над ним. */
#search-type-tabs-row.category-tabs-row{ padding:8px 0 0; }

/* tabs (library sub-tabs, sources sub-tabs) */
.tabs{
  display:flex; gap:28px;
  padding:14px 20px 0;
  border-bottom:1px solid var(--divider);
}
.tab{
  padding-bottom:12px;
  color:var(--text-faint);
  font-size:15px; font-weight:500;
  border-bottom:2px solid transparent;
  cursor:pointer; background:none; border-top:none; border-left:none; border-right:none;
  font-family:inherit;
}
.tab.active{
  color:var(--accent);
  border-bottom-color:var(--accent);
}

/* section date label */
.section-label{
  padding:18px 20px 10px;
  color:var(--text);
  font-size:15px;
}

/* list rows (history / updates) */
.rowlist{ display:flex; flex-direction:column; }
.row{
  display:flex; align-items:center; gap:14px;
  padding:8px 20px;
}
.row .cover{
  width:64px; height:92px; border-radius:8px; flex-shrink:0;
  overflow:hidden;
}
.row .meta{ flex:1; min-width:0; }
.row .title{ font-size:16px; line-height:1.3; margin:0 0 4px; }
.row .sub{ font-size:13.5px; color:var(--text-dim); margin:0; }
.row .trailing-icon{
  width:22px; height:22px; color:var(--danger-icon); flex-shrink:0;
}
.row .chevron{ width:22px; height:22px; color:var(--text-faint); flex-shrink:0; }

/* library grid */
.grid{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:14px;
  padding:16px 16px 0;
}
.cardlink{ display:block; color:inherit; text-decoration:none; }
.cardcover{
  position:relative;
  aspect-ratio:2/3;
  border-radius:8px;
  overflow:hidden;
  display:flex; align-items:center; justify-content:center;
  font-size:15px; font-weight:700; color:#fff;
}
.cardcover .badge{
  position:absolute; top:6px; left:6px;
  background:rgba(0,0,0,.6);
  color:#fff; font-size:12px; font-weight:600;
  padding:2px 7px; border-radius:6px;
}
.cardtitle{
  margin-top:8px; font-size:13px; color:var(--text);
  line-height:1.3;
  display:-webkit-box; -webkit-line-clamp:2; line-clamp:2; -webkit-box-orient:vertical;
  overflow:hidden; text-overflow:ellipsis;
  max-height:2.6em; word-break:break-word; overflow-wrap:anywhere;
}
/* підпис джерела під назвою — лише в результатах крос-джерельного пошуку (Огляд) */
.cardsub{
  margin-top:2px; font-size:11.5px; color:var(--text-faint);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

/* empty state */
.empty{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; padding:80px 32px; color:var(--text-faint); gap:10px;
}
.empty svg{ width:44px; height:44px; opacity:.5; }

/* browse / sources list */
.srcrow{
  display:flex; align-items:center; gap:14px;
  padding:12px 20px;
}
.srcicon{
  width:40px; height:40px; border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:800; color:#fff; flex-shrink:0;
  overflow:hidden;
}
.srcicon img{ width:100%; height:100%; object-fit:cover; display:block; }
.srcname{ font-size:16px; flex:1; }
.srcsub{ font-size:13px; color:var(--text-dim); }
.srcaction{ color:var(--accent); font-size:14.5px; font-weight:500; }
.srcpin{ width:20px; height:20px; color:var(--text-faint); margin-left:10px; }

/* more page */
.morehero{
  display:flex; align-items:center; justify-content:center;
  padding:56px 0 20px;
  font-size:56px; font-weight:900; color:var(--text);
  letter-spacing:2px;
}
.togglerow{
  display:flex; align-items:center; gap:16px;
  padding:14px 20px;
}
.togglerow .ticon{ width:24px; height:24px; color:var(--text-dim); flex-shrink:0; }
.togglerow .tmeta{ flex:1; }
.togglerow .tlabel{ font-size:16px; margin:0 0 3px; }
.togglerow .tsub{ font-size:13px; color:var(--text-dim); margin:0; }

.switch{
  width:42px; height:24px; border-radius:14px;
  background:#3a3c4a; position:relative; flex-shrink:0;
  transition:background .15s;
}
.switch::after{
  content:""; position:absolute; top:3px; left:3px;
  width:18px; height:18px; border-radius:50%;
  background:#8d8fa0;
  transition:transform .15s;
}
.switch.on{ background:var(--accent-pill); }
.switch.on::after{ transform:translateX(18px); background:#fff; }

.linkrow{
  display:flex; align-items:center; gap:16px;
  padding:16px 20px;
}
.linkrow .ticon{ width:22px; height:22px; color:var(--text-dim); flex-shrink:0; }
.linkrow span{ font-size:16px; }
.linkrow.disabled-row{ opacity:.55; pointer-events:none; }

/* червоний закруглений лічильник (напр. непрочитані рекомендації) */
.badge-pill{
  margin-left:auto;
  background:#e5484d; color:#fff; font-size:12px; font-weight:700;
  min-width:20px; height:20px; padding:0 6px; border-radius:999px;
  display:inline-flex; align-items:center; justify-content:center;
  flex-shrink:0;
}

/* "Більше"/"Налаштування": секції згорнуті у випадаючий список за замовчуванням */
.section-label.dropdown-toggle{
  display:flex; align-items:center; justify-content:space-between;
  cursor:pointer; user-select:none;
}
.dropdown-chevron{ width:18px; height:18px; color:var(--text-dim); transition:transform .15s; flex-shrink:0; }
.dropdown-chevron.open{ transform:rotate(180deg); }
.dropdown-body{ overflow:hidden; }

/* "Налаштування" → "Резервне копіювання та відновлення": підзаголовки
   "Відновити з резервної копії"/"Створити резервну копію" всередині
   розкритого списку — трохи менші й тьмяніші за .section-label, щоб не
   плутались із заголовками самих розділів. */
.subgroup-label{
  padding:14px 20px 6px;
  color:var(--text-faint);
  font-size:12.5px; font-weight:600;
  text-transform:uppercase; letter-spacing:.4px;
}

/* Коротка примітка одразу під конкретним рядком (напр. попередження під
   кнопкою) — відступ ліворуч вирівняний під текст рядка (іконка 22px +
   gap 16px + padding-left рядка 20px = 58px), а не під іконку. */
.linkrow-hint{
  margin:-8px 20px 8px 58px;
  font-size:12.5px; color:var(--text-faint);
}

/* "Друзі" */
.friend-row{ padding:10px 20px; }
.friend-avatar{
  width:44px; height:44px; border-radius:50%; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  background:var(--surface-2); color:var(--text); font-size:14px; font-weight:700;
}
.friend-add-row{ display:flex; gap:10px; padding:0 20px; align-items:center; }
.friend-add-row .field-block-input{ flex:1; }

/* "Рекомендації" (вхідні) */
.recommend-row.recommend-read{ opacity:.5; }
.recommend-remove-btn{ margin-left:8px; }

.divider{ height:1px; background:var(--divider); margin:6px 0; }

/* ------------------------------------------------------------- */
/* novel detail page                                              */
/* ------------------------------------------------------------- */
.novel-hero{
  position:relative;
  overflow:hidden;
  /* top ідентичний .topbar (calc(14px + max(env(safe-area-inset-top), 24px)) 16px) —
     кнопка "назад" має сидіти рівно там само, де вона на browse.html та
     інших сторінках, а не заїжджати під виріз камери. Оскільки hero-bgimg
     заповнює всю коробку (inset:-10%), цей самий відступ заразом продовжує
     сам фон-обкладинку під безпечну зону зверху, а не обрізає його нею.
     Знизу — трохи більше, ніж природний відступ, аби фон обкладинки був
     вищий і помітніший (просте збільшення висоти без прив'язки до insets).
     max(env(...), 24px) — підстраховка від Android-пристроїв, де env()
     повертає 0/занижений розмір для вирізу камери (див. .topbar вище). */
  padding:calc(14px + max(env(safe-area-inset-top), 24px)) 16px 54px;
}
.hero-bgimg{
  position:absolute; inset:-10%;
  background-size:cover; background-position:center 60%;
  filter:blur(3px) brightness(.65) saturate(1.1);
  transform:scale(1.03);
  z-index:0;
}
.hero-overlay{
  position:absolute; inset:0; z-index:1;
  background:linear-gradient(180deg, rgba(16,17,25,.1) 0%, var(--bg) 94%);
}
.novel-hero-bar{
  position:relative; z-index:5;
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:20px;
}
.novel-hero-bar .iconbtn{
  color:#fff; cursor:pointer;
  background:none; border:none; padding:0;
}
.novel-hero-actions{ display:flex; align-items:center; gap:20px; }

/* Липка панель — суцільний прямокутник на всю робочу зону (без
   заокруглень/floating-картки), як звичайний .topbar. З'являється, коли
   верхня (прозора) стрілка "назад" уже проскролила поза межі екрана —
   з'яву/зникнення контролює JS (client/src/pages/novel.ts,
   IntersectionObserver за оригінальною .novel-hero-bar). Дублює ті самі дії
   (назад / рекомендувати / завантажити / меню), щоб вони лишались
   доступними й після скролу. */
.novel-sticky-bar{
  position:fixed; top:0; left:0; right:0;
  max-width:480px; margin:0 auto;
  z-index:30;
  display:flex; align-items:center; justify-content:space-between;
  padding:calc(14px + max(env(safe-area-inset-top), 24px)) 16px 10px;
  background:var(--bg);
  opacity:0; transform:translateY(-6px);
  pointer-events:none;
  transition:opacity .18s ease, transform .18s ease;
}
.novel-sticky-bar.visible{ opacity:1; transform:translateY(0); pointer-events:auto; }
.novel-sticky-bar .iconbtn{
  width:24px; height:24px; color:var(--text); cursor:pointer;
  background:none; border:none; padding:0; display:flex;
}
.novel-sticky-actions{ display:flex; align-items:center; gap:16px; }

.novel-head{
  position:relative; z-index:2;
  display:flex; gap:16px; padding:6px 16px 0;
}
.novel-head .cardcover{
  width:96px; flex-shrink:0; font-size:22px;
}
.novel-headinfo{ min-width:0; padding-top:2px; }
.novel-headinfo h1{
  font-size:20px; line-height:1.25; margin:0 0 10px; font-weight:700;
}
.novel-metaline{
  display:flex; align-items:center; gap:8px;
  font-size:14px; color:var(--text-dim);
  margin:0 0 6px;
}
.novel-metaline svg{ width:16px; height:16px; flex-shrink:0; color:var(--text-faint); }

.novel-actions{
  display:flex; justify-content:space-around;
  padding:0 16px 4px; text-align:center;
}
.novel-action{
  display:flex; flex-direction:column; align-items:center; gap:6px;
  color:var(--text-dim); font-size:13px; background:none; border:none;
  cursor:pointer; font-family:inherit;
}
.novel-action svg{ width:24px; height:24px; }
.novel-action.active{ color:var(--accent); }
.novel-action.active svg{ color:var(--accent); fill:var(--accent); }

.novel-desc{
  padding:16px 16px 0; position:relative;
}
.novel-desc p{
  margin:0; font-size:14.5px; line-height:1.5; color:var(--text);
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
  overflow:hidden;
}
.novel-desc.expanded p{ -webkit-line-clamp:unset; }
.novel-desc-toggle{
  display:flex; justify-content:center; padding-top:4px;
  color:var(--text-faint); background:none; border:none; cursor:pointer;
}
.novel-desc-toggle svg{ width:20px; height:20px; transition:transform .15s; }
.novel-desc.expanded .novel-desc-toggle svg{ transform:rotate(180deg); }

.genre-scroll{
  display:flex; gap:10px; overflow-x:auto;
  padding:16px 16px 4px;
  scrollbar-width:none;
}
.genre-scroll::-webkit-scrollbar{ display:none; }
.genrepill{
  flex-shrink:0;
  background:var(--surface-2);
  color:var(--text);
  font-size:14px;
  padding:8px 18px;
  border-radius:20px;
  white-space:nowrap;
}

/* ---------------- "Ролі озвучували", "Пов'язані твори" — нижче опису й
   жанрів. Рік/серії — окремими рядками у шапці, разом з автором/статусом
   (novel-metaline), як у novel.html. ---------------- */
.anime-section{ padding:16px 16px 0; }
.anime-section-title{ font-size:15px; font-weight:700; color:var(--text); margin-bottom:10px; }

/* "Ролі озвучували" — простий текст через кому, згрупований по командах,
   БЕЗ горизонтальної прокрутки (на відміну від жанрів). */
.voice-cast-list p{
  margin:0 0 6px; font-size:14px; line-height:1.5; color:var(--text-dim);
}
.voice-cast-list p:last-child{ margin-bottom:0; }
.voice-cast-list p b{ color:var(--text); font-weight:600; }

/* "Пов'язані твори" — випадаючий (розгортний) список замість горизонтальної
   прокрутки: кнопка-заголовок з шевроном + список рядків, у згорнутому
   стані видно рівно 2 (JS виставляє max-height по фактичній висоті). */
.anime-related-toggle{
  display:flex; align-items:center; gap:6px; width:100%;
  background:none; border:none; padding:0; margin-bottom:10px; cursor:pointer;
  font: inherit; text-align:left;
}
.anime-related-toggle svg{ width:18px; height:18px; color:var(--text-dim); transition:transform .18s; flex-shrink:0; }
.anime-related-toggle.expanded svg{ transform:rotate(180deg); }
.anime-related-toggle:disabled{ cursor:default; }
.anime-related-toggle:disabled svg{ visibility:hidden; }

.related-list{ overflow:hidden; transition:max-height .2s ease; }
.related-row{
  display:flex; align-items:center; gap:12px;
  padding:6px 0; color:inherit; text-decoration:none;
}
/* Висота обкладинки для пов'язаних творів — 100px (ширина рахується сама з aspect-ratio 2/3). */
.related-row .cardcover{ height:100px; width:auto; aspect-ratio:2/3; flex-shrink:0; }
.related-row-title{
  font-size:14px; line-height:1.35; color:var(--text);
  display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden;
}

.readbtn{
  display:block; margin:18px 16px 6px;
  background:#c7d6ff;
  color:#17296b;
  text-align:center;
  font-size:15px; font-weight:600;
  padding:14px 16px;
  border-radius:14px;
  text-decoration:none;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

.chapters-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:22px 16px 8px;
  font-size:15.5px;
}
.chapters-head svg{ width:20px; height:20px; color:var(--text-dim); }
.chapters-head-actions{ display:flex; align-items:center; gap:6px; }
.chapters-head-actions .iconbtn.active{ color:var(--accent); }
.chapters-head-actions .iconbtn.active svg{ color:var(--accent); }

.chrow{
  display:flex; align-items:center; gap:12px;
  padding:10px 16px;
  text-decoration:none; color:inherit;
  border-radius:12px;
}
.chrow.read .chtitle{ color:var(--text-dim); }
.chrow.selected{ background:rgba(90,141,255,.16); }
.chrow .chdot{
  width:7px; height:7px; border-radius:50%;
  background:var(--accent); flex-shrink:0;
  visibility:hidden;
}
.chrow .chdot.unread{ visibility:visible; }
.chrow .chmeta{ flex:1; min-width:0; }
.chrow .chtitle{
  font-size:15px; line-height:1.3; margin:0 0 4px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.chrow .chdate{ font-size:13px; color:var(--text-dim); margin:0; }
.chrow .chdl{
  width:22px; height:22px; color:var(--text-faint); flex-shrink:0;
}

/* сортування/фільтр розділів (novel.html) */
.chapters-sort-sheet{ padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.sort-rows{ display:flex; flex-direction:column; gap:10px; }

/* нижня панель дій під час вибору розділів (novel.html) */
body[data-page="novel"] .content.select-bar-open{ padding-bottom:96px; }
.chapters-select-bar{
  position:fixed; left:0; right:0; bottom:0; z-index:35;
  max-width:480px; margin:0 auto;
  display:flex; align-items:center; gap:10px;
  padding:10px 14px calc(10px + env(safe-area-inset-bottom));
  background:var(--surface); border-top:1px solid var(--divider);
}
.csb-count{ font-size:13.5px; color:var(--text-dim); flex:1; }
.csb-actions{ display:flex; align-items:center; gap:8px; }
.csb-action{
  width:42px; height:42px; border-radius:50%; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  background:var(--surface-2); color:var(--text); border:none; cursor:pointer;
  appearance:none; -webkit-appearance:none;
}
.csb-action svg{ width:20px; height:20px; }
.csb-action:active{ background:rgba(90,141,255,.24); color:var(--accent); }

/* bottom nav */
.bottomnav{
  position:fixed; bottom:0; left:0; right:0;
  max-width:480px; margin:0 auto;
  background:var(--surface);
  display:flex;
  padding:8px 6px calc(8px + env(safe-area-inset-bottom));
  border-top:1px solid var(--divider);
}
.navitem{
  flex:1;
  display:flex; flex-direction:column; align-items:center; gap:2px;
  text-decoration:none; color:var(--text-faint);
  font-size:11.5px;
  padding:6px 2px;
  border-radius:20px;
}
.navitem .icon{ width:22px; height:22px; }
.navitem.active{
  color:#fff;
}
.navitem.active .icon{
  background:var(--accent-pill);
  border-radius:14px;
  padding:3px;
  width:26px; height:26px;
  box-sizing:content-box;
}
.navitem.active span{ color:var(--accent); font-weight:500; }

/* ------------------------------------------------------------- */
/* Розширення для веб-версії (не було в оригінальному макеті)     */
/* ------------------------------------------------------------- */

.cardcover img{
  width:100%; height:100%; object-fit:cover; display:block;
  opacity:0; transition:opacity .18s ease-out;
}
.cardcover.cover-loading{ background:var(--surface-2); }
.cardcover.cover-loaded img{ opacity:1; }

/* позначка "у бібліотеці" на обкладинці в гріді джерела */
.cover-lib-overlay{
  position:absolute; inset:0;
  background:rgba(8,9,14,.5);
  pointer-events:none;
}
.cover-lib-badge{
  position:absolute; bottom:6px; right:6px;
  width:22px; height:22px; border-radius:6px;
  background:rgba(0,0,0,.55);
  display:flex; align-items:center; justify-content:center;
  color:#fff;
}
.cover-lib-badge svg{ width:13px; height:13px; }

/* toast / snackbar */
#toast{
  position:fixed; left:50%; bottom:96px; transform:translate3d(-50%, 12px, 0);
  background:#2a2c38; color:var(--text);
  padding:10px 18px; border-radius:12px; font-size:14px;
  box-shadow:0 8px 24px rgba(0,0,0,.4);
  opacity:0; pointer-events:none; transition:opacity .2s, transform .2s;
  z-index:50; max-width:80%; text-align:center;
}
#toast.show{ opacity:1; transform:translate3d(-50%, 0, 0); }

/* generic buttons used on updates/browse pages */
.btn{
  background:var(--surface-2); color:var(--text);
  border:none; border-radius:12px; padding:10px 16px;
  font-size:14px; cursor:pointer;
}
.btn:disabled{ opacity:.5; cursor:default; }
.btn-accent{ background:var(--accent-pill); color:#fff; }
.btn-danger{ background:#3a1f22; color:#e8a6ab; }

.topbar-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:0 4px 10px;
}
.topbar-title{ font-size:18px; font-weight:600; }
.detail-actions .iconbtn.active{ color:var(--accent); }
.detail-actions .iconbtn.spinning svg{ animation:spin .8s linear infinite; }
@keyframes spin{ from{ transform:rotate(0deg); } to{ transform:rotate(360deg); } }

/* "Нове": рядок з часом останньої перевірки бібліотеки */
.updates-lastcheck{
  padding:0 4px 14px;
  color:var(--text-faint);
  font-size:13.5px;
  font-style:italic;
}

/* "Нове" і "Історія": заголовок/кнопки трохи нижче, кнопки трохи далі одна
   від одної, і в кожної — трохи більша (на 5px з усіх боків) невидима зона
   кліку, без жодної зміни вигляду самої кнопки. */
#history-title-row,
#updates-title-row{
  margin-top:6px;
}
#history-title-row .detail-actions,
#updates-title-row .detail-actions{
  gap:20px;
}
#history-search-toggle, #history-clear-btn, #history-search-close,
#filter-toggle, #check-btn{
  position:relative;
}
#history-search-toggle::before, #history-clear-btn::before, #history-search-close::before,
#filter-toggle::before, #check-btn::before{
  content:"";
  position:absolute;
  inset:-5px;
}

/* "Нове": непрочитаний розділ — яскравий текст із крапкою-маркером,
   прочитаний — сірий (лише в межах цієї сторінки, не займає .row деінде) */
.update-row .sub{ color:var(--text); }
.update-row.update-read .title{ color:var(--text-dim); }
.update-row.update-read .sub{ color:var(--text-faint); }
.update-dot{
  display:inline-block; width:6px; height:6px; border-radius:50%;
  background:var(--text); margin-right:7px; flex-shrink:0; vertical-align:middle;
}

/* browse: source detail header with back button */
.detail-header{
  display:flex; align-items:center; gap:12px;
  padding:0 4px 6px;
}
.detail-header .iconbtn{
  width:22px; height:22px; color:var(--text); flex-shrink:0;
}
.detail-header h2{ font-size:17px; margin:0; font-weight:600; }
.detail-actions{ margin-left:auto; display:flex; gap:14px; }

.empty{ min-height:200px; }
.empty svg{ width:44px; height:44px; opacity:.5; }

/* ------------------------------------------------------------- */
/* reader (chapter text) page                                     */
/* ------------------------------------------------------------- */
body[data-page="reader"] .app{ max-width:720px; }

.reader-footer{
  position:fixed; left:0; right:0; bottom:0; z-index:15;
  max-width:720px; margin:0 auto;
  background:none; border:none;
  padding:10px 20px calc(10px + env(safe-area-inset-bottom));
  display:flex; align-items:center; justify-content:center;
  pointer-events:none;
}
.reader-progress-track{ display:none; }
.reader-progress-fill{ display:none; }
.reader-progress-pct{
  font-size:13px; color:var(--text-faint); text-align:center;
}

.reader-topbar{
  display:flex; align-items:center; gap:12px;
}
.reader-topbar .iconbtn{
  width:24px; height:24px; color:var(--text); flex-shrink:0;
}
.reader-title{
  font-size:15px; color:var(--text-dim);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.reader-fonts{
  margin-left:auto; display:flex; gap:6px;
}
.reader-fonts button{
  background:var(--surface-2); color:var(--text);
  border:none; border-radius:8px; width:30px; height:30px;
  cursor:pointer; font-size:15px;
}

.reader-text{
  /* +env(safe-area-inset-top) — щоб перший рядок тексту не опинявся під
     вирізом камери (notch/punch-hole): верхня панель у режимі читання
     схована за замовчуванням (.reader-topbar-chrome — position:fixed, не
     виштовхує вміст вниз), тож текст скролиться аж до самого верху екрана.
     На мангу/манхву це НЕ впливає — нижче .reader-text.manga-mode явно
     обнуляє padding (зображення мають йти впритул, без "дірки" зверху). */
  padding:max(29px, env(safe-area-inset-top)) 20px 8px;
  font-size:17px; line-height:1.8; color:var(--text);
}
.reader-text p{ margin:0 0 1.1em; }
/* Плейсхолдер-завантаження для зображень у контенті розділу: сірий
   прямокутник, що плавно (але швидко) змінюється на зображення після
   довантаження. Це прибирає "стрибки" висоти сторінки, через які раніше
   збивалось відновлення позиції читання й прогрес міг помилково стати 100%. */
.reader-text img{
  max-width:100%; width:auto; height:auto; border-radius:8px; display:block; margin:12px auto;
  background:var(--surface-2);
  opacity:0; transition:opacity .18s ease-out;
}
.reader-text img:not(.content-img-loaded){ min-height:200px; width:100%; }
.reader-text img.content-img-loaded{ opacity:1; width:auto; height:auto; }

.reader-nav{
  display:flex; gap:12px; padding:16px 20px 4px;
}
.reader-nav button{
  flex:1; padding:14px; border-radius:14px; border:none;
  background:var(--surface-2); color:var(--text); font-size:14.5px; cursor:pointer;
}
.reader-nav button:disabled{ opacity:.35; cursor:default; }

/* library search-only header (no tabs, simplified vs mockup) */
.grid.hidden, .rowlist.hidden{ display:none; }

/* generic icon button fallback (used outside novel-hero/detail-header contexts) */
.iconbtn{
  display:inline-flex; align-items:center; justify-content:center;
  width:24px; height:24px; color:var(--text); cursor:pointer;
  background:none; border:none; padding:0; text-decoration:none;
}
.iconbtn svg{ width:100%; height:100%; }

/* ------------------------------------------------------------- */
/* browse: detail header (як на скріншоті)                        */
/* ------------------------------------------------------------- */
.detail-topbar{
  display:flex; align-items:center; gap:10px;
}
.detail-searchbar{ flex:1; }
.detail-searchbar .iconbtn{ flex-shrink:0; }
.globe-btn{
  width:38px; height:38px; border-radius:50%;
  background:var(--surface-2); color:var(--text-dim);
  flex-shrink:0;
}
.globe-btn svg{ width:20px; height:20px; }

/* ------------------------------------------------------------- */
/* панель фільтрів — прихована за замовчуванням, відкривається    */
/* плавним виїздом знизу по кліку на плаваючу кнопку "Фільтр"      */
/* ------------------------------------------------------------- */
.filter-fab-wrap{
  position:fixed; inset:0; z-index:25;
  max-width:480px; margin:0 auto;
  pointer-events:none;
}
.filter-fab{
  position:absolute; right:20px; bottom:24px;
  pointer-events:auto;
  display:flex; align-items:center; gap:8px;
  appearance:none; -webkit-appearance:none;
  background:#c7d6ff; color:#17296b;
  border:none; border-radius:999px; padding:12px 18px;
  font-size:14.5px; font-weight:600; cursor:pointer;
  box-shadow:0 8px 24px rgba(0,0,0,.35);
  transition:opacity .2s, transform .2s;
}
.filter-fab svg{ width:18px; height:18px; }
.filter-fab.hidden{ opacity:0; transform:scale(.85); pointer-events:none; }

/* ------------------------------------------------------------- */
/* library.html — перемикач "власної" бібліотеки за типом контенту */
/* напівпрозора кнопка-пігулка внизу по центру + випадаюче меню    */
/* ------------------------------------------------------------- */
body[data-page="library"] .content{ padding-bottom:132px; }

.lib-type-fab-wrap{
  position:fixed; inset:0; z-index:26;
  max-width:480px; margin:0 auto;
  pointer-events:none;
}
.lib-type-switcher{
  position:absolute; left:50%; bottom:calc(83px + env(safe-area-inset-bottom));
  transform:translateX(-50%);
  pointer-events:auto;
}
.lib-type-pill{
  display:flex; align-items:center; gap:8px;
  appearance:none; -webkit-appearance:none;
  border:1px solid rgba(255,255,255,.16);
  border-radius:999px; padding:11px 18px;
  font-size:14px; font-weight:600; color:#fff;
  cursor:pointer; white-space:nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:0 8px 24px rgba(0,0,0,.35);
  transition:background-color .15s ease, border-color .15s ease;
}
.lib-type-pill .lib-type-caret{ width:16px; height:16px; flex-shrink:0; }
/* кожен тип — власний напівпрозорий колір (rgba з альфою ~.55, тому і крізь
   кнопку видно контент бібліотеки під нею — це і є "напівпрозора") */
.lib-type-pill.type-manga{ background:rgba(139,92,246,.55); border-color:rgba(139,92,246,.75); }
.lib-type-pill.type-novel{ background:rgba(90,141,255,.55); border-color:rgba(90,141,255,.75); }
.lib-type-pill.type-anime{ background:rgba(52,199,120,.55); border-color:rgba(52,199,120,.75); }
.lib-type-pill:active{ filter:brightness(1.08); }

.lib-type-dropdown{
  position:absolute; left:50%; bottom:calc(100% + 10px); transform:translateX(-50%);
  z-index:27;
  background:#2a2c38; border-radius:14px; padding:6px; min-width:200px;
  box-shadow:0 10px 30px rgba(0,0,0,.4);
  display:flex; flex-direction:column; gap:2px;
}
.lib-type-option{
  display:flex; align-items:center; gap:8px;
  background:none; border:none; color:var(--text);
  font-size:14.5px; text-align:left; padding:11px 12px; border-radius:10px;
  cursor:pointer;
}
.lib-type-option::before{
  content:''; width:9px; height:9px; border-radius:50%; flex-shrink:0;
  background:var(--text-faint);
}
.lib-type-option[data-type="manga"]::before{ background:var(--type-manga); }
.lib-type-option[data-type="novel"]::before{ background:var(--type-novel); }
.lib-type-option[data-type="anime"]::before{ background:var(--type-anime); }
.lib-type-option:active{ background:rgba(255,255,255,.08); }
.lib-type-option.active{ background:rgba(255,255,255,.1); color:#fff; font-weight:600; }

.filter-backdrop{
  position:fixed; inset:0; z-index:19;
  background:rgba(0,0,0,.45);
  opacity:0; pointer-events:none;
  transition:opacity .25s ease;
}
.filter-backdrop.open{ opacity:1; pointer-events:auto; }

.filter-panel{
  position:fixed; left:0; right:0; bottom:0; z-index:20;
  margin:0 auto; width:100%; max-width:520px;
  background:var(--surface);
  border-radius:20px 20px 0 0;
  box-shadow:0 -8px 28px rgba(0,0,0,.4);
  padding:14px 18px calc(18px + env(safe-area-inset-bottom));
  max-height:60vh; overflow-y:auto;
  transform:translate3d(0,105%,0);
  transition:transform .28s cubic-bezier(.32,.72,0,1);
}
.filter-panel.open{ transform:translate3d(0,0,0); }
.filter-panel-head{
  display:flex; align-items:center; justify-content:space-between;
  padding-bottom:10px; margin-bottom:12px;
  border-bottom:1px solid var(--divider);
}
.filter-reset-link{
  appearance:none; -webkit-appearance:none;
  background:none; border:none; color:var(--accent);
  font-size:15px; font-weight:600; cursor:pointer; padding:8px 4px;
}
.filter-apply-pill{
  appearance:none; -webkit-appearance:none;
  background:#c7d6ff; color:#17296b;
  border:none; border-radius:999px; padding:10px 22px;
  font-size:15px; font-weight:700; cursor:pointer;
}

.filter-body{ display:flex; flex-direction:column; gap:20px; }
.filter-row{ display:flex; flex-direction:column; gap:8px; }

/* outlined-поле (Жанр і подібні Picker/Text фільтри) */
.field-outline{
  position:relative; border:1.5px solid var(--accent);
  border-radius:10px; padding:14px 12px 12px; margin-top:6px;
}
.field-label{
  position:absolute; top:-9px; left:10px;
  background:var(--surface); padding:0 6px;
  font-size:12px; color:var(--accent);
}
.field-select, .field-text{
  width:100%; background:transparent; border:none; outline:none;
  color:var(--text); font-size:16px; appearance:none;
  -webkit-appearance:none;
}
.field-select{ cursor:pointer; }

/* двосторонній повзунок (FilterTypes.Range — рейтинг/рік у фільтрах) */
.field-range{ padding-top:12px; }
.range-values{
  text-align:right; margin-bottom:12px; font-size:14px; color:var(--text-dim);
  font-variant-numeric:tabular-nums;
}
.range-values .rv-min, .range-values .rv-max{ color:var(--text); font-weight:600; }
.dual-range{ position:relative; height:22px; }
.dual-range-track{
  position:absolute; left:0; right:0; top:50%; height:4px; margin-top:-2px;
  border-radius:999px; background:var(--surface-2);
}
.dual-range-fill{ position:absolute; top:0; bottom:0; background:var(--accent); border-radius:999px; }
.dual-range-input{
  position:absolute; left:0; right:0; top:0; width:100%; height:22px; margin:0;
  background:none; pointer-events:none; -webkit-appearance:none; appearance:none;
}
.dual-range-input::-webkit-slider-runnable-track{ background:transparent; height:22px; }
.dual-range-input::-moz-range-track{ background:transparent; height:22px; border:none; }
.dual-range-input::-webkit-slider-thumb{
  -webkit-appearance:none; pointer-events:auto; cursor:pointer;
  width:18px; height:18px; margin-top:2px; border-radius:50%;
  background:var(--accent); border:2px solid var(--bg);
  box-shadow:0 1px 3px rgba(0,0,0,.4);
}
.dual-range-input::-moz-range-thumb{
  pointer-events:auto; cursor:pointer; width:18px; height:18px; border-radius:50%;
  background:var(--accent); border:2px solid var(--bg); box-shadow:0 1px 3px rgba(0,0,0,.4);
}

/* тумблер-перемикач (Новинки / Довгочити / Завершене) */
/* Навмисно НЕ .switch — цей клас уже зайнятий іншим (::after-based) */
/* тумблером у решті інтерфейсу; однакова назва спричиняла подвоєння. */
.switchrow{
  display:flex; align-items:center; justify-content:space-between;
  font-size:15px; color:var(--text); padding:2px 0;
}
.toggle{ position:relative; display:inline-block; width:46px; height:26px; flex-shrink:0; }
.toggle input{
  position:absolute; inset:0; opacity:0; margin:0; cursor:pointer; z-index:1;
  appearance:none; -webkit-appearance:none;
}
.toggle-track{
  position:absolute; inset:0; background:var(--surface-2);
  border:1.5px solid var(--text-faint); border-radius:999px;
  transition:background .15s, border-color .15s;
  pointer-events:none;
}
.toggle-thumb{
  position:absolute; top:2px; left:2px; width:19px; height:19px;
  border-radius:50%; background:#c7c7d1;
  transition:transform .15s, background .15s;
}
.toggle input:checked + .toggle-track{ background:rgba(90,141,255,.35); border-color:var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb{ transform:translateX(20px); background:var(--accent); }

.filter-checkgroup{ display:flex; flex-wrap:wrap; gap:10px; }
.filter-checkbox{
  display:flex; align-items:center; gap:6px; font-size:13.5px;
  background:var(--surface-2); padding:6px 10px; border-radius:999px;
}
.filter-checkbox input{ accent-color:var(--accent); }

/* ------------------------------------------------------------- */
/* міграція твору на інше джерело (novel.html)                    */
/* ------------------------------------------------------------- */
.filter-overlay-full{
  position:fixed; inset:0; z-index:40;
  background:rgba(0,0,0,.6);
  display:flex; align-items:flex-end; justify-content:center;
}
/* #picker-overlay (вибір жанрів/типів тощо) може відкриватись ПОВЕРХ
   #settings-overlay (модалка налаштувань джерела) — обидва мають клас
   .filter-overlay-full, тож без явного z-index вони конфліктували і
   #picker-overlay опинявся позаду. */
#picker-overlay{ z-index:60; }
/* Список у пікері (жанри/тематика/команда) може бути дуже довгим (сотні
   пунктів) — раніше весь .migrate-sheet скролився ЯК ОДНЕ ціле, тож кнопка
   "Застосувати" опинялась далеко внизу під довгим списком і практично не
   діставалась без прокрутки через весь перелік. Тепер заголовок і кнопка
   "Застосувати" закріплені (завжди видні), а прокручується лише сам
   список — саме для #picker-overlay, щоб не чіпати інші панелі
   (.migrate-sheet використовується й деінде, без довгих списків). */
#picker-overlay .migrate-sheet{ display:flex; flex-direction:column; overflow:hidden; }
#picker-overlay .filter-panel-head{ flex-shrink:0; }
#picker-overlay #picker-list{ overflow-y:auto; flex:1 1 auto; min-height:0; }
#picker-overlay #picker-actions{ flex-shrink:0; }
.migrate-sheet{
  width:100%; max-width:520px;
  background:var(--surface); border-radius:20px 20px 0 0;
  padding:14px 18px calc(18px + env(safe-area-inset-bottom));
  max-height:78vh; overflow-y:auto;
}
.migrate-plugins{ display:flex; flex-direction:column; gap:2px; }
.migrate-plugin-row{
  display:flex; align-items:center; gap:12px;
  padding:12px 4px; cursor:pointer; border-radius:12px;
}
.migrate-plugin-row:active{ background:var(--surface-2); }
.migrate-results{ display:flex; flex-direction:column; gap:2px; max-height:40vh; overflow-y:auto; }
.migrate-result-row{
  display:flex; align-items:center; gap:12px;
  padding:10px 4px; cursor:pointer; border-radius:12px;
}
.migrate-result-row:active{ background:var(--surface-2); }
.migrate-result-row .cardcover{ width:44px; height:66px; font-size:12px; flex-shrink:0; }
.migrate-back-link{
  background:none; border:none; color:var(--accent);
  font-size:14px; cursor:pointer; padding:6px 4px; margin-bottom:6px;
}

/* бейдж типу контенту (Novel/Manga) під шапкою джерела */

/* власне меню вибору (заміна нативного select) */
.field-outline-btn{
  width:100%; text-align:left; background:transparent; border:none;
  color:var(--text); font-size:16px; cursor:pointer;
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:0; font-family:inherit;
}
.field-outline-btn .chev{ width:18px; height:18px; color:var(--text-faint); flex-shrink:0; }

.picker-option{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.picker-option.selected{ color:var(--accent); }
.picker-option .check{ width:18px; height:18px; color:var(--accent); flex-shrink:0; }
.picker-option.excluded{ color:#e8848a; }
.picker-option.excluded .check.cross{ color:#e8848a; }

/* міні-прогрес-бар прочитаного розділу в історії */
.history-progress{
  display:flex; align-items:center; gap:8px; margin-top:4px;
}
.history-progress-track{
  flex:1; height:4px; border-radius:999px;
  background:var(--surface-2); overflow:hidden; display:block;
}
.history-progress-fill{
  display:block; height:100%; background:var(--accent); border-radius:999px;
}
.history-progress-pct{
  font-size:11.5px; color:var(--text-faint); white-space:nowrap; flex-shrink:0;
}

/* кнопка-шестерня "Налаштування джерела" в списку джерел */
.srcgear{
  width:34px; height:34px; border-radius:50%; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  background:var(--surface-2); color:var(--text-dim);
  border:none; cursor:pointer; appearance:none; -webkit-appearance:none;
}
.srcgear svg{ width:18px; height:18px; }

/* ================================================================= */
/* Читалка розділів — повний редизайн (chrome-toggle, слайдер, налаштування) */
/* ================================================================= */

body[data-page="reader"] .app{ max-width:720px; position:relative; }
body[data-page="reader"] .content{ padding:0 20px 90px; }
/* мангу-режим: без бічних відступів, щоб зображення йшли на всю ширину */
body[data-page="reader"] .content.manga-content{ padding-left:0; padding-right:0; }
.reader-app{ min-height:100vh; min-height:100dvh; }

/* верхня панель (chrome), прихована за замовчуванням */
.reader-topbar-chrome{
  position:fixed; top:0; left:0; right:0; z-index:30;
  max-width:720px; margin:0 auto;
  display:flex; align-items:center; gap:10px;
  padding:calc(14px + max(env(safe-area-inset-top), 24px)) 16px 14px; background:rgba(16,17,25,.94);
  backdrop-filter:blur(6px);
  border-bottom:1px solid var(--divider);
}
.reader-title-block{ flex:1; min-width:0; }
.reader-title-block .reader-title{
  font-size:14.5px; color:var(--text); font-weight:600;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.reader-title-block .reader-subtitle{
  font-size:12px; color:var(--text-dim);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.reader-top-actions{ display:flex; align-items:center; gap:16px; flex-shrink:0; }
.reader-menu-wrap{ position:relative; }
.reader-more-menu{
  position:absolute; top:calc(100% + 8px); right:0; z-index:31;
  background:var(--surface); border-radius:12px; overflow:hidden;
  box-shadow:0 10px 28px rgba(0,0,0,.45); min-width:190px;
}
.reader-more-menu button{
  display:block; width:100%; text-align:left; padding:12px 16px;
  background:none; border:none; color:var(--text); font-size:14px;
  cursor:pointer; appearance:none; -webkit-appearance:none;
}
.reader-more-menu button:active{ background:var(--surface-2); }

/* панель пошуку в тексті — так само, як .reader-topbar-chrome, фон панелі
   має йти під виріз камери, а не обрізатись безпечною зоною зверху. */
.reader-searchbar{
  position:fixed; top:0; left:0; right:0; z-index:30;
  max-width:720px; margin:0 auto;
  display:flex; align-items:center; gap:8px;
  padding:calc(10px + max(env(safe-area-inset-top), 24px)) 12px 10px; background:var(--surface);
  border-bottom:1px solid var(--divider);
}
.reader-searchbar input{
  flex:1; background:var(--surface-2); border:none; border-radius:10px;
  padding:10px 12px; color:var(--text); font-size:14.5px;
}
.search-count{ font-size:12.5px; color:var(--text-dim); white-space:nowrap; }
.reader-text mark{ background:rgba(90,141,255,.4); color:inherit; border-radius:3px; }
.reader-text mark.current-match{ background:var(--accent); color:#0a0f1a; }

/* нижня панель дій (chrome), прихована за замовчуванням */
.reader-bottombar-chrome{
  position:fixed; left:0; right:0; z-index:30;
  bottom:0; /* поверх постійної смужки прогресу (z-index вище за .reader-footer) */
  max-width:720px; margin:0 auto;
  display:flex; align-items:center; justify-content:space-around;
  padding:10px 12px calc(10px + env(safe-area-inset-bottom));
  background:rgba(16,17,25,.94);
  backdrop-filter:blur(6px);
  border-top:1px solid var(--divider);
}
.reader-bb-btn{
  width:40px; height:40px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background:none; border:none; color:var(--text); cursor:pointer;
  appearance:none; -webkit-appearance:none;
}
.reader-bb-btn svg{ width:22px; height:22px; }
.reader-bb-btn:active{ background:var(--surface-2); }
.reader-bb-btn:disabled{ color:var(--text-faint); opacity:.45; pointer-events:none; }

/* вертикальний повзунок розділу (справа) — притиснутий до краю робочої зони
   читалки (макс. ширина 720px, як і верхня/нижня панелі), а не до самого
   краю вікна браузера на широких екранах. */
.v-slider{
  position:fixed; right:max(6px, calc((100vw - 720px) / 2 + 10px)); top:50%; transform:translate3d(0,-50%,0); z-index:29;
  display:flex; flex-direction:column; align-items:center; gap:6px;
  padding:10px 6px; background:rgba(24,26,36,.75); border-radius:999px;
  backdrop-filter:blur(4px);
}
.v-slider-label{ font-size:11px; color:var(--text-dim); }
.v-slider-track{
  position:relative; width:4px; height:220px; border-radius:999px;
  background:var(--surface-2); touch-action:none;
}
.v-slider-fill{
  position:absolute; left:0; right:0; top:0; border-radius:999px;
  background:var(--accent); opacity:.5;
}
.v-slider-thumb{
  position:absolute; left:50%; width:16px; height:16px; border-radius:50%;
  background:var(--accent); transform:translate(-50%, -50%);
  box-shadow:0 2px 6px rgba(0,0,0,.4);
}

/* кругла кнопка "Наступний розділ", з'являється в кінці сторінки */
.next-chapter-fab{
  position:fixed; z-index:28;
  right:max(20px, calc((100vw - 720px) / 2 + 20px));
  bottom:calc(56px + env(safe-area-inset-bottom));
  width:52px; height:52px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background:var(--accent); color:#0a0f1a; border:none; cursor:pointer;
  appearance:none; -webkit-appearance:none;
  box-shadow:0 6px 18px rgba(0,0,0,.4);
  animation:next-chapter-fab-in .18s ease-out;
}
.next-chapter-fab svg{ width:24px; height:24px; }
.next-chapter-fab:active{ transform:scale(.94); }
@keyframes next-chapter-fab-in{
  from{ opacity:0; transform:translateY(8px); }
  to{ opacity:1; transform:translateY(0); }
}

/* прогрес поточного (недочитаного) розділу біля дати — в списку розділів і в панелі "Глави" */
.chrow .chdate .ch-progress, .ci-date .ch-progress{
  color:var(--accent); font-weight:600;
}

/* мангу-режим: сторінка за раз */
.manga-paged{
  position:fixed; inset:0; z-index:5; background:#000;
  display:flex; align-items:center; justify-content:center;
}
.manga-paged img{
  max-width:100%; max-height:100%; object-fit:contain;
  background:var(--surface-2); border-radius:4px;
  opacity:0; transition:opacity .18s ease-out;
}
.manga-paged img:not(.content-img-loaded){ width:min(92vw, 480px); height:78vh; }
.manga-paged img.content-img-loaded{ opacity:1; width:auto; height:auto; }

/* безперервний (webtoon) режим — просто зображення одне під одним */
.reader-text.manga-mode{ padding:0; }
.reader-text.manga-mode img{ margin:0 auto; display:block; max-width:100%; border-radius:0; }
.reader-text.manga-mode img:not(.content-img-loaded){ min-height:60vh; }
.chapter-boundary-marker{ height:1px; }

/* "Назад до Бібліотеки" — пігулка в кінці останнього розділу (манхва: під
   останнім зображенням з відступом 6px; новела: після всього тексту).
   Колір повторює кнопку-перемикач типу контенту в Бібліотеці. */
.reader-end-library-wrap{
  display:flex; justify-content:center;
  padding:0 16px calc(28px + env(safe-area-inset-bottom));
}
.reader-end-library-wrap.reader-end-library-manga{ margin-top:6px; padding-top:0; padding-bottom:calc(15px + env(safe-area-inset-bottom)); }
.reader-end-library-wrap.reader-end-library-novel{ margin-top:8px; }
.reader-end-library-btn{
  display:flex; align-items:center; gap:8px;
  appearance:none; -webkit-appearance:none;
  border:1px solid rgba(255,255,255,.16);
  border-radius:999px; padding:12px 22px;
  font-size:14.5px; font-weight:600; color:#fff;
  cursor:pointer; white-space:nowrap; text-decoration:none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:0 8px 24px rgba(0,0,0,.35);
  transition:filter .15s ease;
}
.reader-end-library-btn svg{ width:18px; height:18px; flex-shrink:0; }
.reader-end-library-btn:active{ filter:brightness(1.08); }
/* ті самі кольори, що й .lib-type-pill.type-manga / .type-novel у Бібліотеці */
.reader-end-library-btn.type-manga{ background:rgba(139,92,246,.55); border-color:rgba(139,92,246,.75); }
.reader-end-library-btn.type-novel{ background:rgba(90,141,255,.55); border-color:rgba(90,141,255,.75); }

/* панель "Глави" */
.chapters-sheet{ max-height:80vh; }
.chapters-list-panel{ display:flex; flex-direction:column; max-height:50vh; overflow-y:auto; }
.chapter-item-row{
  padding:12px 6px; border-radius:10px; cursor:pointer;
}
.chapter-item-row.current{ background:rgba(90,141,255,.18); }
.chapter-item-row .ci-name{ font-size:14.5px; color:var(--text); }
.chapter-item-row .ci-date{ font-size:12px; color:var(--text-dim); margin-top:2px; }

/* панель налаштувань читання */
.reader-settings-sheet{ max-height:82vh; }
.settings-tabs{
  display:flex; gap:22px; border-bottom:1px solid var(--divider);
  margin-bottom:16px; padding-bottom:8px;
}
.settings-tab{
  background:none; border:none; color:var(--text-dim); font-size:14.5px;
  cursor:pointer; padding:4px 0; appearance:none; -webkit-appearance:none;
}
.settings-tab.active{ color:var(--accent); font-weight:600; }
.settings-tab-panel{ display:flex; flex-direction:column; gap:22px; }

.setting-row{ display:flex; flex-direction:column; gap:10px; }
.setting-row-head{ display:flex; align-items:center; justify-content:space-between; font-size:14px; color:var(--text); }
.setting-row-head .val{ color:var(--text-dim); font-size:13px; }

.epub-export-sheet{ padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.epub-export-body{ display:flex; flex-direction:column; gap:20px; }

.epub-filename-field{
  display:flex; align-items:center; gap:8px;
  border:1.5px solid var(--accent); border-radius:10px; padding:11px 12px;
}
.epub-filename-field input{
  flex:1; min-width:0; background:transparent; border:none; outline:none;
  color:var(--text); font-size:15px; font-family:inherit;
}
.epub-ext{ color:var(--text-faint); font-size:15px; flex-shrink:0; }

.epub-range-row{ display:flex; gap:12px; margin-top:-8px; }
.epub-range-field{ flex:1; display:flex; flex-direction:column; gap:6px; }
.epub-range-field label{ font-size:12.5px; color:var(--text-dim); }
.epub-range-field input{
  background:var(--surface-2); border:1.5px solid transparent; border-radius:10px;
  padding:10px 12px; color:var(--text); font-size:15px; font-family:inherit;
  outline:none; width:100%;
}
.epub-range-field input:focus{ border-color:var(--accent); }

.epub-export-actions{ display:flex; gap:10px; margin-top:4px; }
.epub-export-actions .btn{ flex:1; padding:13px 16px; font-size:15px; font-weight:600; text-align:center; }

.epub-custom-css-textarea{
  width:100%; margin-top:-8px; background:var(--surface-2); border:1.5px solid transparent;
  border-radius:10px; padding:10px 12px; color:var(--text); font-size:13.5px;
  font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,monospace;
  outline:none; resize:vertical;
}
.epub-custom-css-textarea:focus{ border-color:var(--accent); }

.setting-slider{
  -webkit-appearance:none; appearance:none; width:100%; height:4px;
  border-radius:999px; background:var(--surface-2); outline:none;
}
.setting-slider::-webkit-slider-thumb{
  -webkit-appearance:none; width:18px; height:18px; border-radius:50%;
  background:var(--accent); cursor:pointer;
}
.setting-slider::-moz-range-thumb{
  width:18px; height:18px; border-radius:50%; background:var(--accent);
  cursor:pointer; border:none;
}

.color-swatches{ display:flex; gap:12px; }
.color-swatch{
  width:38px; height:38px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; cursor:pointer; border:2px solid transparent;
}
.color-swatch.active{ border-color:var(--accent); }

.segmented{ display:flex; background:var(--surface-2); border-radius:12px; padding:3px; gap:2px; }
.segmented button{
  flex:1; background:none; border:none; color:var(--text-dim); padding:10px 0;
  border-radius:9px; cursor:pointer; appearance:none; -webkit-appearance:none;
  display:flex; align-items:center; justify-content:center;
}
.segmented button.active{ background:var(--surface); color:var(--text); }
.segmented button svg{ width:18px; height:18px; }

.font-pills{ display:flex; gap:10px; flex-wrap:wrap; }
.font-pill{
  background:var(--surface-2); color:var(--text); padding:9px 16px;
  border-radius:10px; border:none; cursor:pointer; font-size:14px;
  appearance:none; -webkit-appearance:none;
}
.font-pill.active{ background:rgba(90,141,255,.22); color:var(--accent); font-weight:600; }

/* панель "Редагувати" (заміна тексту/назв, redact) */
.redact-sheet{ max-height:84vh; }
.redact-hint{ font-size:13px; color:var(--text-dim); line-height:1.5; margin:0 0 16px; }
.redact-body{ display:flex; flex-direction:column; gap:20px; }
.redact-section-title{
  font-size:12.5px; color:var(--text-dim); font-weight:600;
  text-transform:uppercase; letter-spacing:.03em; margin-bottom:8px;
}
.redact-list{ display:flex; flex-direction:column; gap:6px; }
.redact-empty{ font-size:13px; color:var(--text-faint); padding:6px 2px; }
.redact-item-row{
  display:flex; align-items:center; gap:10px;
  background:var(--surface-2); border-radius:10px; padding:10px 12px;
}
.redact-item-text{
  flex:1; min-width:0; font-size:14px; color:var(--text);
  display:flex; align-items:center; gap:6px; flex-wrap:wrap; overflow-wrap:anywhere;
}
.redact-item-text .ri-arrow{ width:14px; height:14px; color:var(--text-faint); flex-shrink:0; }
.redact-item-text .ri-to{ color:var(--accent); font-weight:600; }
.redact-item-text .ri-to em{ color:var(--text-faint); font-style:normal; }
.redact-item-del{
  width:28px; height:28px; border-radius:50%; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  background:none; border:none; color:var(--text-faint); cursor:pointer;
  appearance:none; -webkit-appearance:none;
}
.redact-item-del svg{ width:16px; height:16px; }
.redact-item-del:active{ background:rgba(232,132,138,.15); color:#e8848a; }

.redact-add-row{ display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.redact-input{
  flex:1; min-width:0; background:var(--surface-2); border:1.5px solid transparent;
  border-radius:10px; padding:10px 12px; color:var(--text); font-size:14.5px;
  font-family:inherit; outline:none;
}
.redact-input:focus{ border-color:var(--accent); }
.redact-arrow{ width:16px; height:16px; color:var(--text-faint); flex-shrink:0; }
.redact-add-btn{ width:100%; padding:12px 16px; font-size:15px; font-weight:600; text-align:center; margin-top:2px; }

.reading-mode-row{
  display:flex; align-items:center; justify-content:space-between;
  background:var(--surface-2); border-radius:14px; padding:14px 16px; cursor:pointer;
}
.reading-mode-row.active{ background:rgba(90,141,255,.16); }
.reading-mode-row .rm-title{ font-size:14.5px; color:var(--text); font-weight:600; }
.reading-mode-row .rm-sub{ font-size:12.5px; color:var(--text-dim); margin-top:2px; }

/* ============================================================= */
/* Бібліотека: горизонтальні таби категорій, картки з підписом    */
/* поверх обкладинки, режим вибору творів, керування категоріями. */
/* ============================================================= */

.category-tabs-row{ display:flex; align-items:center; gap:2px; padding:2px 10px 12px 16px; }
.category-tabs{
  display:flex; gap:20px; overflow-x:auto; flex:1; min-width:0;
  scrollbar-width:none;
}
.category-tabs::-webkit-scrollbar{ display:none; }
.category-tab{
  flex-shrink:0; white-space:nowrap; position:relative;
  background:none; border:none; color:var(--text-dim);
  padding:8px 1px 10px; font-size:14.5px; font-weight:600; cursor:pointer;
}
.category-tab.active{ color:var(--text); }
.category-tab.active::after{
  content:""; position:absolute; left:0; right:0; bottom:0; height:2px;
  background:var(--accent); border-radius:2px;
}
.category-tabs-edit-btn{
  flex-shrink:0; width:30px; height:30px; border-radius:50%; margin-bottom:8px;
  display:flex; align-items:center; justify-content:center;
  background:none; border:none; color:var(--text-faint); cursor:pointer;
}
.category-tabs-edit-btn svg{ width:16px; height:16px; }

/* ---------------- сторінка аніме (anime.html) — покроковий вибір ---------------- */
/* Верхній відступ такий самий, як у .anime-section (16px) — щоб проміжок
   перед "Оберіть переклад" збігався з проміжком перед "Пов'язані твори". */
.anime-step{ padding:16px 16px 8px; }
.anime-step-title{
  display:flex; align-items:center; gap:10px;
  font-size:15px; font-weight:700; color:var(--text);
  margin-bottom:10px;
}
/* Відступ від краю до стрілки "назад" має збігатися з відступом опису
   (.novel-desc має padding-left:16px) — без додаткового горизонтального
   негативного margin, лише вертикальний (для компактності клікабельної зони). */
.anime-step-back{ margin:-6px 0; }
.anime-step-count{
  margin-left:auto; font-size:13px; font-weight:600; color:var(--text-dim);
}
/* Крок 4 (плеєр+список серій) НЕ успадковує горизонтальний padding від
   .anime-step — плеєр сам керує своїми (5px) відступами, а chapters-head/
   .chrow нижче вже мають власний 16px padding, тож нічого не "з'їдається". */
.anime-step--player{ padding-left:0; padding-right:0; }
.anime-player-wrap{ padding:0 5px 4px; }
.anime-player-wrap iframe{ display:block; }
.anime-player-hint{
  margin:0 5px; padding:32px 16px; text-align:center;
  color:var(--text-dim); font-size:14px;
  background:var(--surface-2); border-radius:8px;
}

/* ---- вбудований відеоплеєр (extract з чужого хостингу -> звичайний
   <video>/hls.js, з фолбеком на <iframe>, якщо екстрактора немає) ---- */
.anime-video{ position:relative; width:100%; }
.anime-video-frame{
  position:relative; width:100%; aspect-ratio:16/9;
  background:#000; border-radius:8px; overflow:hidden;
}
.anime-video-frame video,
.anime-video-frame iframe{
  position:absolute; inset:0; width:100%; height:100%; border:0; display:block;
}
.anime-video-frame video{
  /* контроли самого <video> мають лишатись клікабельними — .anime-video-status
     має власний z-index і ховається через [hidden] (див. правило нижче),
     інакше він назавжди перекриває controls і плеєром неможливо керувати. */
  z-index:1;
}
.anime-video-status{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  text-align:center; padding:16px; font-size:13.5px; color:var(--text-dim);
  background:rgba(0,0,0,.55); z-index:2; pointer-events:none;
}
.anime-video-status.error{ color:#ff8fa3; }
/* Оверлей "Продовжити з X:XX" / "Почати з початку" — показується ЗАМІСТЬ
   автозапуску відео, поки серія має збережену позицію з минулого разу.
   Напівпрозорий фон поверх усього кадру, дві кнопки по центру. */
.anime-video-resume-overlay{
  position:absolute; inset:0; z-index:3;
  display:flex; align-items:center; justify-content:center;
  background:rgba(10,12,18,.72);
}
.anime-video-resume-box{
  display:flex; flex-direction:column; gap:10px;
  padding:0 24px; width:100%; max-width:280px;
}
.anime-video-resume-btn{
  padding:12px 20px; border-radius:12px; border:1px solid var(--divider);
  background:var(--surface-2); color:var(--text);
  font-size:14.5px; font-weight:600; cursor:pointer;
}
.anime-video-resume-btn.primary{
  background:var(--accent); color:#0a0f1a; border-color:var(--accent);
}
.anime-video-players{
  display:flex; gap:8px; overflow-x:auto; padding:10px 5px 2px;
  scrollbar-width:none;
}
.anime-video-players::-webkit-scrollbar{ display:none; }
.anime-video-player-btn{
  flex-shrink:0; white-space:nowrap; cursor:pointer;
  display:inline-flex; align-items:center; gap:6px;
  background:var(--surface-2); color:var(--text-dim);
  border:1px solid transparent;
  font-size:13px; font-weight:600;
  padding:7px 14px; border-radius:20px;
}
.anime-video-player-btn.active{ background:var(--accent); color:#0a0f1a; border-color:var(--accent); }
.anime-video-player-btn .badge{
  font-size:10.5px; font-weight:700; padding:1px 6px; border-radius:999px;
  background:rgba(255,255,255,.18);
}
.anime-video-player-btn:not(.active) .badge{ background:var(--border,var(--divider)); color:var(--text-faint); }
.anime-video-quality-bar{
  display:flex; gap:6px; padding:8px 5px 0; flex-wrap:wrap;
}
.anime-video-quality-bar button{
  padding:5px 12px; font-size:12px; font-weight:600; border-radius:999px;
  background:var(--surface-2); color:var(--text-dim); border:1px solid transparent; cursor:pointer;
}
.anime-video-quality-bar button.active{ background:var(--accent); color:#0a0f1a; border-color:var(--accent); }

/* ---------------- список серій — горизонтальна прокрутка пігулками (як
   жанри на .genre-scroll), замість вертикального списку рядків. ---------------- */
.episodes-scroll{
  display:flex; gap:10px; overflow-x:auto;
  padding:14px 16px 8px;
  scrollbar-width:none;
  -webkit-user-select:none; user-select:none;
}
.episodes-scroll::-webkit-scrollbar{ display:none; }
.episode-chip{
  flex-shrink:0; display:flex; align-items:center; gap:8px;
  background:var(--surface-2); color:var(--text);
  font-size:14px; font-weight:600;
  padding:9px 14px; border-radius:20px;
  white-space:nowrap; cursor:pointer;
  border:1px solid transparent;
  -webkit-tap-highlight-color:transparent;
}
.episode-chip.active{ border-color:var(--accent); }
/* Значок Lucide "eye" на тому ж фоні, що й текст пігулки (не окремий
   елемент/бейдж) — білий, якщо серію переглянуто, сірий, якщо ще ні. */
.episode-chip-eye{ width:17px; height:17px; flex-shrink:0; color:var(--text-faint); }
.episode-chip.watched .episode-chip-eye{ color:#fff; }
.episode-chip.watched{ color:var(--text-dim); }


/* перемикач "Озвучення/Субтитри" (та команд) на сторінці твору для
   contentType==='anime' — рядок пігулок-кнопок, як genrepill, але клікабельний
   і з активним станом; з'являється лише коли SourceNovel.groups.length > 1. */
.group-picker{
  display:flex; gap:8px; overflow-x:auto; padding:2px 16px 14px;
  scrollbar-width:none;
}
.group-picker::-webkit-scrollbar{ display:none; }
.group-pill{
  flex-shrink:0; white-space:nowrap; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:2px;
  background:var(--surface-2); color:var(--text-dim);
  border:1px solid transparent;
  font-size:14px; font-weight:600;
  padding:8px 16px; border-radius:20px;
}
.group-pill.active{ background:var(--accent); color:#0a0f1a; border-color:var(--accent); }
.group-pill-title{ font-size:14px; font-weight:600; }
/* "Рекомендований" плеєр (типове джерело серій цього перекладу) на кроці
   "Оберіть плеєр" — легкий натяк, не плутати з .active (реально обраним). */
.group-pill.recommended{ border-color:var(--accent); }
.group-pill-count{
  font-size:11px; font-weight:600; color:var(--text-faint);
}
.group-pill.recommended .group-pill-count{ color:var(--accent); }

/* випадаюче меню трьох крапок (замінює повноекранну шторку) */
.menu-anchor{ position:relative; }
.dropdown-menu{
  position:absolute; top:calc(100% + 6px); right:0; z-index:20;
  background:#2a2c38; border-radius:14px;
  padding:6px; min-width:220px;
  box-shadow:0 10px 30px rgba(0,0,0,.4);
  display:flex; flex-direction:column;
}
.dropdown-item{
  background:none; border:none; color:var(--text);
  font-size:14.5px; text-align:left; padding:12px 12px; border-radius:10px;
  cursor:pointer;
}
.dropdown-item:active{ background:rgba(255,255,255,.08); }
.dropdown-item-danger{ color:#e8707a; }

/* той самий дропдаун, але розкривається ВГОРУ від кнопки — для кнопок у
   нижніх фіксованих панелях (напр. "Ще" у панелі дій вибору бібліотеки),
   де звичайне розкриття вниз виїжджало б за межі екрана */
.dropdown-menu-up{ top:auto; bottom:calc(100% + 6px); z-index:40; }

/* картка твору: назва в 2 рядки поверх обкладинки (з градієнтним
   затемненням для читабельності), обрізається "..." якщо не влазить */
.lib-card{ position:relative; }
.lib-card-scrim{
  position:absolute; left:0; right:0; bottom:0; height:64%;
  background:linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,0));
  pointer-events:none;
}
.lib-card-title{
  position:absolute; left:0; right:0; bottom:0;
  padding:6px 8px 8px;
  font-size:12.5px; line-height:1.32; font-weight:600; color:#fff;
  display:-webkit-box; -webkit-line-clamp:2; line-clamp:2; -webkit-box-orient:vertical;
  overflow:hidden; text-overflow:ellipsis;
  max-height:calc(2.64em + 14px); word-break:break-word; overflow-wrap:anywhere;
  text-shadow:0 1px 3px rgba(0,0,0,.5);
}
.lib-card .cardcover{ position:relative; }
/* обведення вибору малюємо ОКРЕМИМ шаром поверх обкладинки: box-shadow тут
   не годиться — inset-тінь малюється ПІД дочірніми елементами (тобто під
   самим зображенням обкладинки) і фізично не видна на картках із фото. */
.lib-card-selring{
  position:absolute; inset:0; border-radius:inherit;
  border:3px solid transparent; box-sizing:border-box;
  pointer-events:none; transition:border-color .1s ease;
}
.lib-card.selected .lib-card-selring{ border-color:var(--accent); }

/* режим вибору творів — верхня панель */
.lib-select-label{ flex:1; font-size:15.5px; font-weight:600; }

/* керування категоріями */
.category-manage-list{ display:flex; flex-direction:column; gap:2px; max-height:52vh; overflow-y:auto; }
.category-manage-row{
  display:flex; align-items:center; gap:10px; padding:9px 4px;
  background:var(--surface); border-radius:10px;
}
.category-manage-row.dragging{ opacity:.4; }
.category-drag-handle{
  width:22px; height:22px; flex-shrink:0; color:var(--text-faint);
  cursor:grab; touch-action:none; display:flex; align-items:center; justify-content:center;
}
.category-drag-handle svg{ width:18px; height:18px; }
.category-manage-name{ flex:1; font-size:15px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.category-manage-row .iconbtn{ width:20px; height:20px; flex-shrink:0; }
.category-manage-row .icon-danger{ color:var(--danger-icon); }
.category-manage-footer{ display:flex; justify-content:flex-end; padding-top:14px; }
.add-category-btn{
  background:var(--accent-pill); color:#fff; border:none; border-radius:12px;
  padding:12px 20px; font-size:14px; font-weight:600; cursor:pointer;
}
.category-manage-empty{ padding:22px 4px; color:var(--text-faint); font-size:14px; text-align:center; }

/* модалка "Рекомендувати" на сторінці твору — список друзів */
.recommend-modal-list{ display:flex; flex-direction:column; gap:2px; max-height:52vh; overflow-y:auto; }
.recommend-modal-row{
  display:flex; align-items:center; gap:12px; padding:9px 4px;
}
.recommend-modal-row .friend-avatar{ width:36px; height:36px; font-size:12px; }
.recommend-modal-row .recommend-username{ flex:1; font-size:15px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.recommend-modal-row button{
  flex-shrink:0; padding:8px 14px; font-size:13px; border-radius:10px;
  border:none; cursor:pointer; font-family:inherit; font-weight:600;
}
.recommend-modal-row button.btn-accent{ background:var(--accent-pill); color:#fff; }
.recommend-modal-row button.btn-sent{ background:var(--surface-2); color:var(--text-faint); cursor:default; }
.recommend-modal-empty{ padding:22px 4px; color:var(--text-faint); font-size:14px; text-align:center; }

/* центрована модалка (додати/редагувати категорію) */
.modal-overlay-center{
  position:fixed; inset:0; z-index:45;
  background:rgba(0,0,0,.6);
  display:flex; align-items:center; justify-content:center;
  padding:20px;
}
.center-modal{
  width:100%; max-width:360px;
  background:var(--surface); border-radius:20px;
  padding:20px;
}
.field-block{ display:flex; flex-direction:column; gap:6px; }
.field-block-label{ font-size:12.5px; color:var(--text-dim); }
.required-mark{ color:#e8707a; }
.field-block-input{
  background:var(--surface-2); border:1.5px solid transparent; border-radius:10px;
  padding:11px 12px; color:var(--text); font-size:15px; font-family:inherit;
  outline:none; width:100%;
}
.field-block-input:focus{ border-color:var(--accent); }
.category-edit-switchrow{ margin-top:18px; }
.modal-actions{ display:flex; gap:10px; margin-top:20px; }
.modal-actions .btn{ flex:1; padding:12px 16px; font-size:15px; font-weight:600; text-align:center; }
.modal-actions .btn:disabled{ opacity:.45; pointer-events:none; }

/* власна (не браузерна) заміна confirm()/alert() — використовується
   confirmDialog() та подібними модалками у стилі застосунку */
.modal-title{ margin:0 0 10px; font-size:16px; font-weight:600; color:var(--text); }
.modal-details{ margin:0 0 14px; font-size:13.5px; line-height:1.5; color:var(--text-dim); }
.modal-message{ margin:0; font-size:14.5px; line-height:1.5; color:var(--text); }

/* призначення категорій обраним творам — список чекбоксів */
.assign-cat-row{ display:flex; align-items:center; gap:12px; padding:11px 4px; cursor:pointer; }
.assign-cat-row input[type="checkbox"],
.assign-cat-row input[type="radio"]{ width:19px; height:19px; accent-color:var(--accent); flex-shrink:0; }
.assign-cat-row span{ font-size:15px; }
.assign-categories-apply{ width:100%; margin-top:14px; padding:13px 16px; font-size:15px; font-weight:600; }

/* нижня панель дій вибору бібліотеки — суцільний прямокутник, підняний
   трохи вище нижнього краю, без заокруглень і без тіні */
.lib-select-bar{
  bottom:calc(14px + env(safe-area-inset-bottom));
  border-radius:0;
  box-shadow:none;
  justify-content:space-evenly;
}

/* Плейсхолдер поки довантажується список розділів (сторінка твору з кешу бібліотеки) */
.chapters-loading{
  padding:24px 4px; text-align:center;
  color:var(--text-faint); font-size:14px;
}

/* Сторінка "Більше": форма входу для неавторизованих */
.login-hint{ color:var(--text-dim); font-size:13.5px; line-height:1.4; margin:0 0 18px; }
.login-field-gap{ margin-top:14px; }
.login-error{ color:#e8707a; font-size:13.5px; margin:10px 0 0; }
.login-submit-btn{ width:100%; margin-top:18px; padding:12px 16px; font-size:15px; font-weight:600; }
.linkrow-danger .ticon,
.linkrow-danger span{ color:#e8a6ab; }

/* Сторінка "Більше": імпорт бекапу Kotatsu */
.import-panel{ margin:10px 4px 0; }
.import-panel-desc{ margin:0 0 12px; font-size:13px; line-height:1.45; color:var(--text-dim); text-align:center; }
.import-quick-toggle{
  display:flex; align-items:flex-start; gap:10px;
  margin:0 0 12px; padding:12px 14px; border-radius:14px;
  background:var(--surface-2); font-size:12.5px; line-height:1.4; color:var(--text-dim);
  cursor:pointer;
}
.import-quick-toggle input{ flex-shrink:0; margin-top:2px; width:18px; height:18px; accent-color:var(--accent); }
.import-dropzone{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:10px; padding:32px 20px; border-radius:16px; text-align:center;
  border:1.5px dashed var(--divider); background:var(--surface-2);
  cursor:pointer; transition:border-color .15s, background-color .15s;
}
.import-dropzone:hover, .import-dropzone:focus-visible{ border-color:var(--accent); outline:none; }
.import-dropzone.dragover{ border-color:var(--accent); background:rgba(90,141,255,.12); }
.import-dropzone-icon{ width:34px; height:34px; color:var(--text-dim); }
.import-dropzone:hover .import-dropzone-icon, .import-dropzone.dragover .import-dropzone-icon{ color:var(--accent); }
.import-dropzone-text{ margin:0; font-size:13.5px; line-height:1.45; color:var(--text-dim); }
.import-progress{
  display:flex; flex-direction:column; gap:10px;
  margin:0; padding:16px 14px; border-radius:16px;
  background:var(--surface-2); color:var(--text-dim); font-size:13.5px; line-height:1.45;
}
.import-progress-top{ display:flex; align-items:center; gap:12px; }
.import-progress-text{ flex:1; }
.import-progress-count{
  flex-shrink:0; color:var(--text); font-weight:600; font-size:13px;
  font-variant-numeric:tabular-nums; white-space:nowrap;
}
.import-progress-bar-track{
  height:6px; border-radius:999px; background:var(--divider); overflow:hidden;
}
.import-progress-bar-fill{
  height:100%; width:0%; border-radius:999px; background:var(--accent);
  transition:width .25s ease;
}
.import-spinner{
  width:20px; height:20px; flex-shrink:0; border-radius:50%;
  border:2.5px solid var(--divider); border-top-color:var(--accent);
  animation:import-spin .8s linear infinite;
}
@keyframes import-spin{ to{ transform:rotate(360deg); } }
.import-result{ margin:12px 0 0; padding:12px 14px; border-radius:12px; background:var(--surface-2); font-size:13.5px; }
.import-result-summary{ color:var(--text); font-weight:600; margin:0 0 8px; }
.import-result-errors{ max-height:200px; overflow-y:auto; }
.import-result-error-row{ color:#e8a6ab; padding:3px 0; border-top:1px solid var(--divider); }
.import-result-error-row:first-child{ border-top:none; }
