:root {
  --bg-main: #050811;
  --bg-surface: #0c1222;
  --bg-surface-elevated: #121a30;
  --bg-glass: rgba(12, 18, 34, 0.88);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(0, 242, 254, 0.35);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --accent-glow: 0 0 20px rgba(0, 242, 254, 0.3);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #223049;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}

/* Top App Header */
.app-header {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  flex-shrink: 0;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-icon {
  font-size: 22px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.5));
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  background: rgba(0, 242, 254, 0.1);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-accent);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-main);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.tab-badge {
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.online-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* Views */
.app-view {
  display: none;
  flex: 1;
  overflow: hidden;
}
.app-view.active {
  display: flex;
  flex-direction: column;
}

.view-content {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Search Section */
.search-bar-wrap {
  margin-bottom: 28px;
  position: relative;
}

.search-input-group {
  display: flex;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 6px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transition: border-color 0.2s ease;
}

.search-input-group:focus-within {
  border-color: var(--accent-cyan);
  box-shadow: var(--accent-glow);
}

.search-input-group input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
}

.search-autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.6);
  z-index: 100;
  max-height: 400px;
  overflow-y: auto;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.2s ease;
}
.search-item:hover {
  background: rgba(0, 242, 254, 0.06);
}

.search-item-cover {
  width: 44px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  background: #020617;
}

.search-item-info h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}
.search-item-info span {
  font-size: 12px;
  color: var(--text-dim);
}

/* Series Detail Main Card */
.series-overview-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 32px;
  display: flex;
  gap: 32px;
  margin-bottom: 32px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.4);
}

.series-cover-wrap {
  width: 240px;
  flex-shrink: 0;
}

.series-cover {
  width: 100%;
  height: 340px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 12px 32px rgba(0,0,0,0.7);
  border: 1px solid var(--border-subtle);
}

.series-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.series-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}
.status-badge.ongoing {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-badge.completed {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.total-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(0, 242, 254, 0.1);
  color: var(--accent-cyan);
  border: 1px solid var(--border-accent);
}

.series-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 8px;
}

.series-author {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 16px;
}

.series-synopsis {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
  max-height: 100px;
  overflow-y: auto;
}

.series-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  flex-wrap: wrap;
}

/* Chapter Selection Section */
.chapters-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
}

.chapters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chapters-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
}

.chapter-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chapter-filter-input {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.chapter-card-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.chapter-card-btn:hover {
  background: var(--accent-blue);
  color: #000;
  transform: translateY(-2px);
}

/* Read Offline Tab */
.offline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.offline-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}
.offline-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-accent);
}

.offline-cover {
  width: 100%;
  height: 280px;
  object-fit: cover;
  background: #020617;
}

.offline-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.offline-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.3;
}

.offline-stats {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 14px;
}

/* Update Alert Banner on Offline Card */
.update-available-banner {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.update-badge-text {
  color: var(--warning);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-update-manhwa {
  background: var(--warning);
  color: #000;
  font-weight: 700;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: filter 0.2s ease;
}
.btn-update-manhwa:hover {
  filter: brightness(1.15);
}

.offline-footer {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* Notifications Tab */
.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.notif-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
}
.notif-card.unread {
  border-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.03);
}

.notif-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.notif-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 242, 254, 0.1);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.notif-info h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}
.notif-info p {
  font-size: 12px;
  color: var(--text-dim);
}

/* Immersive Reader View */
#view-reader {
  position: relative;
  background: #000;
}

.reader-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  transition: transform 0.3s ease;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
}

.hud-title-wrap h2 {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.hud-title-wrap span {
  font-size: 11px;
  color: var(--text-dim);
}

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

.chapter-dropdown {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  cursor: pointer;
  max-width: 240px;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.zoom-controls input[type="range"] {
  width: 70px;
  accent-color: var(--accent-cyan);
}

/* Reader Canvas (Zero Seams) */
.reader-scroll-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 56px;
  background: #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
}

.reader-canvas.webtoon-mode {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.webtoon-page {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  vertical-align: bottom;
  background: #000000;
  outline: none;
  border: none;
}

/* Chapter End Action Card */
.chapter-end-nav {
  width: 100%;
  max-width: 800px;
  padding: 60px 20px 100px;
  text-align: center;
}
.end-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Floating Controls */
.floating-reader-controls {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}
.float-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 14px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.float-btn:hover {
  background: var(--accent-blue);
  color: #000;
  transform: scale(1.1);
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  transition: all 0.2s ease;
}
.btn-primary {
  background: var(--accent-gradient);
  color: #030712;
  font-weight: 700;
  box-shadow: var(--accent-glow);
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  background: #192338;
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.btn-icon {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  padding: 0;
}
.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--accent-cyan);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 28px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 20px;
}

/* Progress Bar */
.progress-bar-wrap {
  height: 8px;
  background: var(--bg-main);
  border-radius: 6px;
  overflow: hidden;
  margin: 16px 0 8px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  transition: width 0.2s ease;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-accent);
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 1000;
}

.hidden {
  display: none !important;
}
