/* ============ Luminous — тёмная тёплая тема (по референсу) ============ */
:root {
  --bg: #100a07;
  --bg-soft: #161009;
  --card: #1c1510;
  --card-2: #241b13;
  --border: #2f251b;
  --border-soft: #271e16;
  --text: #f3eae1;
  --muted: #a4948a;
  --muted-2: #7d6f66;
  --accent: #e0772e;
  --accent-deep: #c2601f;
  --accent-soft: rgba(224, 119, 46, .14);
  --green: #57b96b;
  --green-soft: rgba(87, 185, 107, .14);
  --radius: 14px;
  --radius-s: 10px;
  --tabbar-h: 62px;
  --maxw: 760px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 500px at 50% -200px, #2a1a0e 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
img { display: block; }
.hidden { display: none !important; }

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 14px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
#app.reader-mode { max-width: none; padding: 0; }

/* ---------- Загрузка ---------- */
.boot-spinner { display: flex; justify-content: center; padding-top: 40vh; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Шапка-бренд ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 2px 14px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #3a2415, #1c1108);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 800; font-size: 17px;
}
.brand .eyebrow { font-size: 10px; letter-spacing: .18em; color: var(--muted-2); text-transform: uppercase; }
.brand .name { font-weight: 800; font-size: 16px; margin-top: 1px; }

/* ---------- Карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card .eyebrow {
  font-size: 11px; font-weight: 800; letter-spacing: .14em;
  color: var(--accent); text-transform: uppercase; margin-bottom: 6px;
}
.card h2 { margin: 0 0 8px; font-size: 21px; line-height: 1.2; }
.card p.desc { margin: 0; color: var(--muted); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 11px 18px;
  font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 2px 10px rgba(224,119,46,.25);
}
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--border); box-shadow: none;
}
.btn.small { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .04em;
  padding: 5px 11px; border-radius: 999px;
}
.pill.premium { background: linear-gradient(180deg, var(--accent), var(--accent-deep)); color: #fff; }
.pill.free { background: var(--green-soft); color: var(--green); border: 1px solid rgba(87,185,107,.3); }
.pill.dark { background: var(--card-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Чипы статистики ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip {
  font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--border); color: var(--muted);
}
.chip.green { color: var(--green); border-color: rgba(87,185,107,.35); background: var(--green-soft); }
.chip.orange { color: var(--accent); border-color: rgba(224,119,46,.35); background: var(--accent-soft); }

/* ---------- Хранилище (шапка библиотеки) ---------- */
.vault-card { display: flex; align-items: center; gap: 12px; }
.vault-card .info { flex: 1; min-width: 0; }
.vault-card .label { font-size: 10px; letter-spacing: .16em; color: var(--muted-2); text-transform: uppercase; }
.vault-card .vname { font-weight: 800; font-size: 16px; }
.vault-card .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Список тайтлов ---------- */
.title-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 11px; margin-bottom: 10px;
}
.title-card .cover {
  width: 58px; height: 78px; border-radius: 9px; flex: none;
  object-fit: cover; background: var(--card-2); border: 1px solid var(--border-soft);
}
.title-card .cover.placeholder { display:flex; align-items:center; justify-content:center; color: var(--muted-2); font-size: 20px; }
.title-card .body { flex: 1; min-width: 0; }
.title-card .tname { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-card .tdesc {
  color: var(--muted); font-size: 12.5px; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.title-card .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 12px; color: var(--muted-2); font-weight: 600; }
.title-card .meta .free { color: var(--green); }
.title-card .meta .prem { color: var(--accent); }
.title-card .chev { color: var(--muted-2); flex: none; }
.eye { display: inline-flex; align-items: center; gap: 4px; }
.eye svg { width: 14px; height: 14px; }

/* ---------- Страница тайтла ---------- */
.back-row { display: flex; align-items: center; gap: 8px; padding: 2px 0 12px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.active { background: linear-gradient(180deg, var(--accent), var(--accent-deep)); border-color: transparent; color: #fff; }

.title-hero { display: flex; gap: 14px; margin-bottom: 4px; }
.title-hero .cover {
  width: 104px; height: 146px; border-radius: 12px; object-fit: cover; flex: none;
  background: var(--card-2); border: 1px solid var(--border-soft);
}
.title-hero .right { flex: 1; min-width: 0; }
.title-hero .eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--accent); margin-bottom: 4px; }
.title-hero h1 { margin: 0; font-size: 25px; line-height: 1.15; font-weight: 800; }
.title-desc { color: var(--muted); font-size: 13.5px; margin-top: 8px; }
.title-desc.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.expand-link { color: var(--accent); font-size: 13px; font-weight: 700; background: none; border: none; padding: 4px 0; }
.genres { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.genres .g { font-size: 11px; color: var(--muted); background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; }

.continue-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 13px; margin: 12px 0; width: 100%; text-align: left;
}
.continue-card .ic {
  width: 42px; height: 42px; border-radius: 11px; flex: none;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.continue-card .t { font-weight: 800; color: var(--accent); font-size: 15px; }
.continue-card .s { color: var(--muted); font-size: 12.5px; margin-top: 1px; }

.list-tools { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.sort-group { display: flex; gap: 6px; }

/* ---------- Строки глав ---------- */
.chapter-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 11px 13px; margin-bottom: 9px; color: var(--text);
}
.chapter-row .num {
  width: 46px; height: 46px; border-radius: 11px; flex: none;
  background: var(--card-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.chapter-row .body { flex: 1; min-width: 0; }
.chapter-row .cname { font-weight: 700; font-size: 14.5px; }
.chapter-row .csub { color: var(--muted-2); font-size: 12px; margin-top: 1px; }
.chapter-row .lock { color: var(--muted-2); flex: none; }
.chapter-row.read .cname { color: var(--muted); }

/* ---------- Читалка ---------- */
.reader { background: #000; min-height: 100vh; }
.reader-pages { max-width: var(--maxw); margin: 0 auto; }
.reader-pages img {
  width: 100%; height: auto; display: block;
  margin: 0; padding: 0; border: 0;
  background: #0a0a0a;
}
.reader-panel {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: rgba(16, 10, 7, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
  transform: translateY(0); transition: transform .22s ease;
  padding-top: env(safe-area-inset-top);
}
.reader-panel.hidden-panel { transform: translateY(-110%); }
.reader-panel .inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
}
.reader-panel .meta { flex: 1; min-width: 0; }
.reader-panel .meta .t { font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-panel .meta .c { color: var(--muted); font-size: 12px; }
.scroll-top-btn {
  position: fixed; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 50;
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(28, 21, 16, .92); border: 1px solid var(--border); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.scroll-top-btn.show { opacity: 1; pointer-events: auto; }
.reader-end { max-width: var(--maxw); margin: 0 auto; padding: 26px 16px calc(40px + env(safe-area-inset-bottom)); text-align: center; }
.reader-end .hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* Экран «глава закрыта» */
.locked-screen { max-width: 480px; margin: 0 auto; padding-top: 12vh; text-align: center; }
.locked-screen .big { font-size: 44px; margin-bottom: 10px; }

/* ---------- Premium ---------- */
.level-card { position: relative; overflow: hidden; }
.level-card .price { font-size: 15px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.level-card .banner {
  height: 110px; border-radius: 10px; margin: 4px 0 12px;
  background:
    radial-gradient(180px 90px at 20% 30%, rgba(224,119,46,.35), transparent 70%),
    radial-gradient(220px 120px at 80% 80%, rgba(120, 60, 200, .25), transparent 70%),
    #140e0a;
  border: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: center;
}
.level-card .banner svg { width: 44px; height: 44px; color: #fff; opacity: .9; }
.provider-card .ic {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 18px; color: #fff;
}
.provider-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.provider-card .pname { font-weight: 800; }
.provider-card .peyebrow { font-size: 10px; font-weight: 800; letter-spacing: .14em; color: var(--accent); text-transform: uppercase; }
.provider-card.tint-blue { background: linear-gradient(160deg, rgba(40,90,160,.16), transparent 55%), var(--card); }
.provider-card.tint-warm { background: linear-gradient(160deg, rgba(224,90,40,.13), transparent 55%), var(--card); }
.code-input {
  width: 100%; background: var(--card-2); border: 1px solid var(--border);
  border-radius: 11px; color: var(--text); padding: 12px 13px; font-size: 15px;
  letter-spacing: .08em; text-transform: uppercase; outline: none; margin-bottom: 10px;
}
.code-input:focus { border-color: var(--accent); }

/* ---------- Аккаунт ---------- */
.profile-card { display: flex; align-items: center; gap: 12px; }
.profile-card .ava { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--card-2); }
.profile-card .info { flex: 1; min-width: 0; }
.profile-card .uname { font-weight: 800; font-size: 16px; }
.profile-card .uid { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.seg {
  display: flex; background: var(--card-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; gap: 4px; margin-top: 10px;
}
.seg button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  border-radius: 9px; padding: 9px 6px; font-weight: 700; font-size: 13px;
}
.seg button.on { background: linear-gradient(180deg, var(--accent), var(--accent-deep)); color: #fff; }
.setting-box { background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 12px; padding: 12px; margin-top: 10px; }
.setting-box .st { font-weight: 800; font-size: 14px; }
.setting-box .ss { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Вход ---------- */
.login-screen { max-width: 420px; margin: 0 auto; padding-top: 16vh; text-align: center; }
.login-screen .logo-big {
  width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent), #7a3a10);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 900; color: #fff;
  box-shadow: 0 8px 40px rgba(224,119,46,.35);
}
.login-screen h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: .02em; }
.login-screen .sub { color: var(--muted); margin-bottom: 26px; }
#tg-widget { display: flex; justify-content: center; min-height: 48px; }

/* ---------- Нижняя навигация ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: rgba(14, 9, 6, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-soft);
  display: flex; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted-2); font-size: 11px; font-weight: 700;
}
.tabbar .tab svg { width: 22px; height: 22px; }
.tabbar .tab.active { color: var(--accent); }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 100;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 11px 16px;
  font-size: 13.5px; font-weight: 600; max-width: 88vw;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}

.section-label {
  font-size: 11px; font-weight: 800; letter-spacing: .14em;
  color: var(--accent); text-transform: uppercase; margin: 18px 2px 8px;
}
.muted { color: var(--muted); }
.center { text-align: center; }

@media (min-width: 700px) {
  body { font-size: 15.5px; }
  .title-card .cover { width: 66px; height: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01s !important; }
}
