:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #111827;
  --panel2: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);
  --brand: #38bdf8;
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel2: #f8fafc;
  --text: #0b1220;
  --muted: rgba(15, 23, 42, 0.65);
  --border: rgba(15, 23, 42, 0.12);
  --brand: #0284c7;
  --danger: #e11d48;
  --ok: #16a34a;
  --shadow: 0 10px 26px rgba(2, 6, 23, 0.1);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(1200px 800px at 20% 0%, rgba(56, 189, 248, 0.12), transparent 55%),
    radial-gradient(1200px 800px at 80% 0%, rgba(244, 114, 182, 0.08), transparent 55%), var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.4;
}
html[data-theme="light"] body {
  background: radial-gradient(1200px 800px at 20% 0%, rgba(2, 132, 199, 0.1), transparent 55%),
    radial-gradient(1200px 800px at 80% 0%, rgba(79, 70, 229, 0.08), transparent 55%), var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
  background: rgba(11, 15, 20, 0.6);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  max-width: 1100px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand-badge {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 5px rgba(56, 189, 248, 0.15);
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.tab {
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.5);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.tab.active {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.12);
  color: #e6fbff;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.5);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(156, 163, 175, 0.7);
  box-shadow: 0 0 0 4px rgba(156, 163, 175, 0.12);
}
.status-dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
}
.status-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.15);
}
.status-text {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 520px) {
  .status-text {
    display: none;
  }
}

.grid {
  display: grid;
  gap: 14px;
}
.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .grid.cols-4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid.cols-4.always-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 680px) {
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid.cols-4.always-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .grid.cols-2 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

.panel {
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.5);
  box-shadow: var(--shadow);
  border-radius: 14px;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
}
.panel-title {
  font-size: 14px;
  color: #f3f4f6;
  font-weight: 650;
  letter-spacing: 0.2px;
}
.panel-body {
  padding: 14px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.row.stretch {
  align-items: stretch;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
  flex: 1;
}
.label {
  font-size: 12px;
  color: var(--muted);
}
.input,
.select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
  padding: 10px 10px;
  outline: none;
}
.input:focus,
.select:focus {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.08);
}

.btn {
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.65);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.btn.primary {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.12);
}
.btn.danger {
  border-color: rgba(251, 113, 133, 0.55);
  background: rgba(251, 113, 133, 0.12);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}
.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.55);
}
.toast.error {
  border-color: rgba(251, 113, 133, 0.5);
  background: rgba(251, 113, 133, 0.08);
}
.toast.ok {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.07);
}
.toast-title {
  font-size: 13px;
  font-weight: 650;
}
.toast-body {
  font-size: 12px;
  color: var(--muted);
}

.book {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.4);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.book:hover {
  border-color: rgba(56, 189, 248, 0.4);
}
.cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: rgba(0, 0, 0, 0.2);
  display: block;
  object-fit: cover;
}
.book-body {
  padding: 10px 10px 12px 10px;
}
.book-name {
  font-size: 13px;
  font-weight: 650;
  color: #f3f4f6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.book-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skeleton {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.35);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}
html[data-theme="light"] .skeleton {
  background: rgba(2, 6, 23, 0.06);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.2s infinite;
}
html[data-theme="light"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(2, 6, 23, 0.08), transparent);
}
@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}
.skeleton-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: rgba(0, 0, 0, 0.18);
}
html[data-theme="light"] .skeleton-cover {
  background: rgba(2, 6, 23, 0.08);
}
.skeleton-lines {
  padding: 10px;
  display: grid;
  gap: 8px;
}
.skeleton-line {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
html[data-theme="light"] .skeleton-line {
  background: rgba(2, 6, 23, 0.10);
}
.empty {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 18px;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.25);
}
html[data-theme="light"] .empty {
  background: rgba(2, 6, 23, 0.04);
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.kv .k {
  color: var(--muted);
}

.episodes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 720px) {
  .episodes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.ep {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.45);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
}
.ep:hover {
  border-color: rgba(56, 189, 248, 0.4);
}
.ep-title {
  font-size: 13px;
  font-weight: 650;
}
.ep-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.reader {
  display: grid;
  gap: 10px;
}
.page {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  object-fit: contain;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: rgba(11, 15, 20, 0.82);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.bottom-bar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
.sheet {
  width: 100%;
  max-width: 900px;
  max-height: 75vh;
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  overflow: hidden;
}
.sheet-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sheet-title {
  font-size: 14px;
  font-weight: 700;
}
.sheet-body {
  padding: 12px 14px;
  overflow: auto;
  max-height: calc(75vh - 52px);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.65);
  animation: spin 0.9s linear infinite;
}
html[data-theme="light"] .spinner {
  border-color: rgba(2, 6, 23, 0.16);
  border-top-color: rgba(2, 6, 23, 0.6);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.loading-card {
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.9);
  border-radius: 14px;
  padding: 14px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
html[data-theme="light"] .loading-card {
  background: rgba(255, 255, 255, 0.92);
}

.book:active {
  transform: scale(0.99);
}

.reader-full .container {
  max-width: 100%;
  padding: 0;
}
@media (max-width: 720px) {
  .reader-full .topbar {
    display: none;
  }
}
.reader-full .panel {
  border-radius: 0;
  box-shadow: none;
}
.reader-full .panel-header {
  border-radius: 0;
}
.reader-full .panel-body {
  padding: 10px;
}
.reader-full .page {
  border-radius: 0;
}

.reader-hidden .panel-header,
.reader-hidden .bottom-bar {
  display: none;
}
