:root {
  /* Суворо темна палітра в стилі Senkuro (незалежно від теми Telegram) */
  color-scheme: dark;
  --bg: #0e0f13;
  --surface: #16181f;
  --surface-2: #20232d;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --stars: #f59e0b;
  --stars-soft: rgba(245, 158, 11, 0.16);
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.small {
  font-size: 12px;
  display: block;
  margin-top: 2px;
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(14, 15, 19, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
}

.stars-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--stars-soft);
  color: var(--stars);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.view-root {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 14px 24px;
}

/* Секції та заголовки */
.section {
  margin-bottom: 22px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

/* Горизонтальний скрол карток */
.h-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.h-scroll::-webkit-scrollbar {
  display: none;
}

/* Постерна картка 2:3 (як у Senkuro) */
.poster-card {
  flex: 0 0 118px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 10px;
}

@media (max-width: 360px) {
  .poster-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.poster-grid .poster-card {
  flex: unset;
  width: 100%;
}

.poster-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.poster-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(14, 15, 19, 0.82);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
}

.poster-rating {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(14, 15, 19, 0.85);
  color: var(--stars);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
}

.poster-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.poster-sub {
  font-size: 11px;
  color: var(--muted);
}

/* Список останніх оновлень */
.update-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.update-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.update-row img {
  width: 48px;
  height: 68px;
  object-fit: cover;
  border-radius: 7px;
  flex-shrink: 0;
}

.update-info {
  flex: 1;
  min-width: 0;
}

.update-info h4 {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.update-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

/* Пошук та фільтри каталогу */
.search-box {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin-bottom: 10px;
}

.search-box:focus {
  border-color: var(--accent);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.chip {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.chip.active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--accent);
}

/* Сторінка тайтлу */
.title-hero {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 14px;
}

.title-hero-cover {
  width: 104px;
  height: 152px;
  object-fit: cover;
  border-radius: 9px;
  flex-shrink: 0;
}

.title-hero-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.title-hero-info h2 {
  font-size: 17px;
  line-height: 1.25;
  margin-bottom: 6px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

.action-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.status-toggle-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.status-pill {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.status-pill.active {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--accent);
}

.alt-titles-box {
  margin-top: 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.alt-titles-box h4 {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text);
}

.alt-title-row {
  font-size: 12px;
  color: var(--muted);
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.alt-title-row:last-child {
  border-bottom: none;
}

.vip-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
}

.vip-card.is-active {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), var(--surface));
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.full-width {
  width: 100%;
}

.flex-1 {
  flex: 1;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.chapter-row.locked {
  border-color: rgba(245, 158, 11, 0.3);
}

.chapter-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chapter-num {
  font-size: 14px;
  font-weight: 600;
}

.lock-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--stars);
  background: var(--stars-soft);
  padding: 4px 8px;
  border-radius: 6px;
}

/* Профіль */
.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
}

.avatar-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
}

/* Нижня навігація */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(14, 15, 19, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 0 max(8px, env(safe-area-inset-bottom));
}

.nav-item {
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.nav-icon {
  font-size: 18px;
  line-height: 1;
}

.nav-item.active {
  color: var(--accent);
}

/* Модалки (Онбординг + Stars) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-option {
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-option span {
  font-size: 11px;
  color: var(--muted);
}

.mode-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stars-plans {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.btn-stars {
  background: var(--stars);
  color: #111;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.stars-status {
  font-size: 13px;
  color: #34d399;
  text-align: center;
}

/* Повноекранний ридер */
.reader-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #0a0a0c;
  overflow-y: auto;
}

.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(14, 15, 19, 0.9);
  backdrop-filter: blur(10px);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hud-top {
  top: 0;
  border-bottom: 1px solid var(--border);
}

.hud-bottom {
  bottom: 0;
  border-top: 1px solid var(--border);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.reader-screen.hud-hidden .hud-top {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.reader-screen.hud-hidden .hud-bottom {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.hud-title-group {
  flex: 1;
  min-width: 0;
}

.title-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-label {
  font-size: 12px;
  color: var(--muted);
}

.icon-btn, .nav-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
}

.progress-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#page-indicator {
  font-size: 12px;
  color: var(--muted);
}

.progress-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.reader-container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 56px 0 68px;
}

.reader-container.mode-vertical {
  display: flex;
  flex-direction: column;
}

.reader-container.mode-paged .page-wrapper {
  display: none;
}

.reader-container.mode-paged .page-wrapper.is-active {
  display: block;
}

.page-wrapper {
  position: relative;
  width: 100%;
  background: #141519;
}

.page-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.page-wrapper img.is-loaded {
  opacity: 1;
}

.page-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.page-wrapper.loaded .page-placeholder {
  display: none;
}
