* {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: #1a1a2e;
  color: #e0e0e0;
  font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

a {
  color: #e94560;
  text-decoration: none;
}

/* ---- HEADER ---- */
.header {
  background: #16213e;
  padding: 14px 16px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  border-bottom: 2px solid #e94560;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 20px;
  color: #e94560;
  letter-spacing: 1px;
}

.header-actions {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  gap: 8px;
}

/* ---- SEARCH ---- */
.search-bar {
  padding: 12px 16px;
  background: #16213e;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  background: #0f3460;
  border: 1px solid #e94560;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
}

.search-bar input::-webkit-input-placeholder {
  color: #888;
}

/* ---- Continue reading banner ---- */
.continue-card {
  margin: 12px 16px 0;
  background: #0f3460;
  border-radius: 10px;
  padding: 10px 12px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  gap: 12px;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.continue-card-cover {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: #1a1a2e;
}

.continue-card-info {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
}

.continue-card-label {
  font-size: 11px;
  color: #e94560;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.continue-card-title {
  font-size: 14px;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- LIBRARY (series grid) ---- */
.library {
  padding: 12px;
}

.series-grid {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 12px;
}

/* Series card */
.series-card {
  width: calc(33.333% - 8px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #16213e;
  -webkit-transition: opacity 0.15s;
  transition: opacity 0.15s;
}

.series-card:active {
  opacity: 0.75;
}

/* Capa: aspect ratio 2:3 via padding hack (iOS 9 compat) */
.series-cover-wrap {
  position: relative;
  width: 100%;
  padding-top: 150%;
  background: #0f3460;
  overflow: hidden;
}

.series-cover-wrap img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
  object-fit: cover;
  display: block;
}

.series-cover-placeholder {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  font-size: 40px;
}

.series-count-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.7);
  color: #e0e0e0;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
}

.series-card-info {
  padding: 7px 8px 9px;
}

.series-card-name {
  font-size: 11px;
  color: #e0e0e0;
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- ISSUE LIST (série detalhe) ---- */
.issue-grid {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
}

.issue-card {
  width: calc(33.333% - 8px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #16213e;
  -webkit-transition: opacity 0.15s;
  transition: opacity 0.15s;
}

.issue-card:active {
  opacity: 0.75;
}

.issue-cover-wrap {
  position: relative;
  width: 100%;
  padding-top: 150%;
  background: #0f3460;
  overflow: hidden;
}

.issue-cover-wrap img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
  object-fit: cover;
  display: block;
}

.issue-cover-placeholder {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  font-size: 32px;
}

.issue-read-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  color: transparent;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  font-size: 13px;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}

.issue-read-badge.is-read {
  background: rgba(76, 175, 80, 0.9);
  border-color: transparent;
  color: #fff;
}

.issue-card-title {
  padding: 6px 8px 8px;
  font-size: 11px;
  color: #e0e0e0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- LOADING / EMPTY ---- */
.loading {
  text-align: center;
  padding: 60px 16px;
  color: #888;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #0f3460;
  border-top-color: #e94560;
  border-radius: 50%;
  margin: 0 auto 16px;
  -webkit-animation: spin 0.8s linear infinite;
  animation: spin 0.8s linear infinite;
}

@-webkit-keyframes spin {
  to { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-msg {
  text-align: center;
  padding: 60px 16px;
  color: #888;
  line-height: 1.6;
}

/* ---- READER ---- */
.reader-wrap {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.reader-header {
  background: rgba(0,0,0,0.85);
  padding: 10px 14px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  z-index: 10;
  -webkit-transition: opacity 0.3s;
  transition: opacity 0.3s;
}

.reader-header.hidden {
  opacity: 0;
  pointer-events: none;
}

.reader-title {
  font-size: 14px;
  color: #e0e0e0;
  -webkit-flex: 1;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0 10px;
}

.btn-icon {
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 22px;
  padding: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 36px;
  min-height: 36px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.reader-main {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.page-img {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.page-img img {
  max-width: 100%;
  max-height: 100%;
  -webkit-user-select: none;
  user-select: none;
  display: block;
}

/* Vertical scroll reading mode (virtualized: only slots near the viewport
   keep a real <img>, so long volumes stay light on low-memory devices) */
.vscroll {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.vscroll-slot {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  overflow: hidden;
}

.vscroll-slot img {
  max-width: 100%;
  display: block;
  -webkit-user-select: none;
  user-select: none;
}

.vscroll-end-slot {
  position: relative;
  min-height: 1px;
}

/* Touch zones */
.touch-prev, .touch-next {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
}

.touch-prev { left: 0; }
.touch-next { right: 0; }

/* Reader footer */
.reader-footer {
  background: rgba(0,0,0,0.85);
  padding: 8px 14px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  gap: 12px;
  -webkit-transition: opacity 0.3s;
  transition: opacity 0.3s;
}

.reader-footer.hidden {
  opacity: 0;
  pointer-events: none;
}

.page-counter {
  font-size: 13px;
  color: #aaa;
  white-space: nowrap;
}

.progress-bar-wrap {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  height: 4px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #e94560;
  border-radius: 2px;
  -webkit-transition: width 0.2s;
  transition: width 0.2s;
}

/* ---- PDF viewer ---- */
.pdf-wrap {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  overflow: hidden;
}

.pdf-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ---- Toasts / overlay ---- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  -webkit-transition: opacity 0.3s;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* ---- End screen (tela de fim de volume) ---- */
.end-screen {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #1a1a2e;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-animation: fadeIn 0.25s ease;
  animation: fadeIn 0.25s ease;
}

@-webkit-keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.end-screen-inner {
  text-align: center;
  padding: 24px 28px;
  max-width: 340px;
  width: 100%;
}

.end-screen-check {
  font-size: 48px;
  color: #e94560;
  margin-bottom: 8px;
}

.end-screen-done {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #888;
  margin-bottom: 6px;
}

.end-screen-title {
  font-size: 15px;
  color: #aaa;
  margin-bottom: 28px;
  line-height: 1.4;
}

.end-screen-next-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #e94560;
  margin-bottom: 6px;
}

.end-screen-next-title {
  font-size: 16px;
  color: #e0e0e0;
  font-weight: bold;
  margin-bottom: 16px;
  line-height: 1.4;
}

.end-screen-btn {
  display: block;
  width: 100%;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 20px;
  font-size: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 10px;
}

.end-screen-btn:active {
  background: #c73450;
}

.end-screen-btn-outline {
  background: transparent;
  border: 1px solid #444;
  color: #aaa;
  font-size: 14px;
  padding: 11px 20px;
}

.end-screen-btn-outline:active {
  background: #222;
}

.end-screen-library {
  display: block;
  margin-top: 18px;
  font-size: 13px;
  color: #666;
  text-decoration: underline;
}

/* ---- Filter drawer ---- */
.drawer-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
}

.drawer-backdrop.open {
  display: block;
}

.filter-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #16213e;
  border-top: 2px solid #e94560;
  border-radius: 14px 14px 0 0;
  padding: 10px 20px 32px;
  z-index: 201;
  -webkit-transform: translateY(100%);
  transform: translateY(100%);
  -webkit-transition: -webkit-transform 0.28s ease;
  transition: transform 0.28s ease;
}

.filter-drawer.open {
  -webkit-transform: translateY(0);
  transform: translateY(0);
}

.drawer-handle {
  width: 40px;
  height: 4px;
  background: #444;
  border-radius: 2px;
  margin: 0 auto 14px;
}

.drawer-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #888;
  margin-bottom: 16px;
}

.publisher-chips {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: #0f3460;
  border: 1px solid #0f3460;
  color: #aaa;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-transition: background 0.15s, color 0.15s;
  transition: background 0.15s, color 0.15s;
}

.chip-active {
  background: #e94560;
  border-color: #e94560;
  color: #fff;
}

/* ---- Install banner ---- */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0f3460;
  border-top: 1px solid #e94560;
  padding: 12px 16px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  font-size: 13px;
  color: #e0e0e0;
  z-index: 150;
}

.install-banner button {
  background: none;
  border: none;
  color: #aaa;
  font-size: 18px;
  padding: 4px 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Auth (login / admin forms) ---- */
.auth-wrap {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  width: 100%;
  max-width: 340px;
  background: #16213e;
  border-radius: 10px;
  padding: 20px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.auth-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin: 14px 0 6px;
}

.auth-label:first-of-type {
  margin-top: 0;
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  background: #0f3460;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
}

.auth-input:focus {
  border-color: #e94560;
}

.auth-error {
  background: rgba(233, 69, 96, 0.15);
  border: 1px solid #e94560;
  color: #e94560;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 4px;
}

/* ---- Page jump input ---- */
.page-jump {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  gap: 4px;
}

.page-jump input {
  width: 48px;
  padding: 4px 6px;
  background: #222;
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  text-align: center;
  -webkit-appearance: none;
}
