:root {
  --bg: #0b1120;
  --bg-elev: #111a2e;
  --bg-card: #162238;
  --bg-card-hover: #1c2b47;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #f59e0b;
  --accent-bright: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.16);
  --sky: #38bdf8;
  --purple: #a855f7;
  --emerald: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(2, 6, 23, 0.5);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button, input, select {
  font: inherit;
  color: inherit;
}

/* Prevent iOS Safari zoom on focus */
input[type="text"],
input[type="password"],
input[type="search"],
select {
  font-size: 16px;
}

/* ===== LOCK SCREEN ===== */
.lock-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(circle at top, rgba(245, 158, 11, 0.14), transparent 55%), var(--bg);
}

.lock-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px 24px 26px;
  text-align: center;
  box-shadow: var(--shadow);
}

.lock-logo {
  margin-bottom: 14px;
}

.lock-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lock-sub {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  text-align: center;
  letter-spacing: 0.18em;
  font-weight: 600;
  outline: none;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.lock-meta {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.form-msg {
  font-size: 13px;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(52, 211, 153, 0.14);
  color: var(--emerald);
}

.form-msg.error {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  color: #0b1120;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-size: 18px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent-bright);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
}

/* ===== APP SHELL & TOPBAR ===== */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-shell.has-player .main-content {
  padding-bottom: calc(108px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(11, 17, 32, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}

.brand-icon {
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--emerald);
}

.status-pill.status-offline {
  color: var(--danger);
}

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

/* ===== SEARCH BAR ===== */
.search-bar-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 4px 16px 12px;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 13px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-input-box input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  outline: none;
}

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

.clear-search-btn {
  position: absolute;
  right: 6px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.filter-pills {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filter-pills::-webkit-scrollbar {
  display: none;
}

.pill {
  flex-shrink: 0;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

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

/* ===== MAIN CONTENT ===== */
.main-content {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + var(--safe-bottom));
  flex: 1;
}

.section-block {
  margin-bottom: 24px;
}

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

.section-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.muted-meta {
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== OFFLINE BANNER ===== */
.offline-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.offline-icon {
  font-size: 28px;
}

.offline-banner h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.offline-banner p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== SHARE CARDS ===== */
.share-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.share-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: transform 0.14s ease, border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.share-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.share-card:active {
  transform: scale(0.99);
}

.share-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  background: rgba(245, 158, 11, 0.14);
}

.share-card-body {
  min-width: 0;
  flex: 1;
}

.share-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.share-card-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.share-chevron {
  color: var(--text-dim);
  font-size: 20px;
}

/* ===== CONTINUE LISTENING ===== */
.continue-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.continue-list::-webkit-scrollbar {
  display: none;
}

.continue-card {
  flex: 0 0 250px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
}

.continue-art {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-elev);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

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

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

.continue-sub {
  font-size: 12px;
  color: var(--accent-bright);
  margin-bottom: 6px;
}

.continue-bar {
  height: 4px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

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

.index-bar {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 4px;
}

/* ===== BREADCRUMBS & FOLDER HERO ===== */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
  scrollbar-width: none;
  white-space: nowrap;
}

.breadcrumbs::-webkit-scrollbar {
  display: none;
}

.crumb-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.crumb-btn.current {
  background: var(--accent-soft);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--accent-bright);
}

.crumb-sep {
  color: var(--text-dim);
  font-size: 13px;
  flex-shrink: 0;
}

.folder-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(56, 189, 248, 0.06)), var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.folder-cover {
  width: 78px;
  height: 78px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

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

.folder-hero-info h2 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.folder-hero-info p {
  margin: 0 0 10px;
}

.folder-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== TOOLBAR ===== */
.toolbar-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-filter {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  outline: none;
}

.inline-filter:focus {
  border-color: var(--accent);
}

.sort-select {
  height: 42px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  outline: none;
  flex-shrink: 0;
}

/* ===== FILE LIST ===== */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.file-row:hover {
  background: var(--bg-card-hover);
}

.file-row.playing {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
}

.file-main-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 2px 0;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.file-badge {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: rgba(148, 163, 184, 0.12);
}

.file-badge.cat-folder { background: rgba(245, 158, 11, 0.16); }
.file-badge.cat-audio  { background: rgba(168, 85, 247, 0.18); }
.file-badge.cat-ebook  { background: rgba(56, 189, 248, 0.18); }
.file-badge.cat-image  { background: rgba(52, 211, 153, 0.16); }
.file-badge.cat-video  { background: rgba(244, 63, 94, 0.18); }
.file-badge.cat-text   { background: rgba(148, 163, 184, 0.18); }
.file-badge.cat-archive { background: rgba(251, 146, 60, 0.18); }

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

.file-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
  margin-bottom: 3px;
}

.file-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ext-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--text);
  letter-spacing: 0.04em;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.row-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

.row-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: 14px;
}

/* ===== MINI AUDIO PLAYER ===== */
.mini-player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: rgba(17, 26, 46, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-strong);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -10px 28px rgba(2, 6, 23, 0.55);
}

.mini-progress-track {
  height: 3px;
  background: rgba(148, 163, 184, 0.2);
  width: 100%;
}

.mini-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-bright);
  transition: width 0.2s linear;
}

.mini-player-row {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-info-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.mini-cover, .mini-fallback-icon {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.mini-meta {
  min-width: 0;
  flex: 1;
}

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

.mini-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.mini-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.player-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.player-icon-btn.muted {
  color: var(--text-dim);
}

.player-play-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent-bright);
  color: #0b1120;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

/* ===== MODALS & SHEETS ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: var(--safe-bottom);
  box-shadow: var(--shadow);
}

@media (min-width: 640px) {
  .modal-sheet {
    border-radius: 22px;
  }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ===== FULL PLAYER SHEET ===== */
.player-sheet-card {
  max-width: 480px;
  overflow-y: auto;
}

.player-art-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 20px 12px;
}

.player-art, .player-art-fallback {
  width: 190px;
  height: 190px;
  border-radius: 18px;
  object-fit: cover;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
}

.player-titles {
  padding: 0 20px;
  text-align: center;
}

.player-titles h3 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.player-titles p {
  margin: 0;
}

.scrubber-wrap {
  padding: 16px 20px 8px;
}

.scrubber-wrap input[type="range"] {
  width: 100%;
  accent-color: var(--accent-bright);
  height: 28px;
  cursor: pointer;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.transport-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px 16px;
}

.transport-btn {
  min-width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.transport-play-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  color: #0b1120;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35);
}

.player-extras {
  padding: 0 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.extra-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.accent-text {
  color: var(--accent-bright);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

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

.queue-section {
  border-top: 1px solid var(--border);
  padding: 14px 20px 20px;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}

.queue-item.active {
  border-color: var(--accent);
  color: var(--accent-bright);
}

/* ===== PREVIEW MODAL ===== */
.preview-sheet {
  max-width: 720px;
}

.preview-meta {
  padding: 10px 16px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.preview-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 160px;
}

.preview-img {
  display: block;
  max-width: 100%;
  max-height: 62dvh;
  margin: 0 auto;
  border-radius: 12px;
}

.preview-video {
  width: 100%;
  max-height: 62dvh;
  border-radius: 12px;
  background: #000;
}

.preview-pdf {
  width: 100%;
  height: 62dvh;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.preview-text {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60dvh;
  overflow-y: auto;
}

.preview-download-card {
  text-align: center;
  padding: 28px 16px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.preview-download-card .big-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.preview-download-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 8px 0 0;
  line-height: 1.5;
}

/* ===== LINKS & SETTINGS ===== */
.link-card {
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.link-card-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.link-copy-row {
  display: flex;
  gap: 8px;
}

.link-copy-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.helper-text {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.settings-block {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.settings-block:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.settings-block h4 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  outline: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-muted);
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-row .btn {
  flex: 1;
  min-width: 150px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 90;
  background: #1e293b;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
  text-align: center;
}

.app-shell.has-player ~ .toast {
  bottom: calc(96px + var(--safe-bottom));
}

/* ===== PRIMARY MEDIA TABS ===== */
.primary-tabs {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.primary-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-bright);
}

.tab-count {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.8;
}

/* ===== VISUAL BOOK & COMIC COVER GRID ===== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 560px) {
  .media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 820px) {
  .media-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
  }
}

.book-card {
  display: flex;
  flex-direction: column;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  text-align: left;
  padding: 0;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.book-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.book-card:active {
  transform: scale(0.985);
}

.book-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  overflow: hidden;
}

.book-cover-wrap.ratio-square {
  aspect-ratio: 1 / 1;
}

.book-cover-wrap.ratio-video {
  aspect-ratio: 16 / 10;
}

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

.book-badge-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(11, 17, 32, 0.82);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.book-play-overlay {
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.94);
  color: #0b1120;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.book-card-body {
  padding: 10px 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.book-card-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.book-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* ===== BOOK DETAIL SHEET ===== */
.book-detail-sheet {
  max-width: 520px;
}

.book-detail-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.book-detail-cover {
  width: 112px;
  height: 148px;
  border-radius: 13px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

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

.book-detail-info h3 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.book-detail-info p {
  margin: 0 0 4px;
}

.book-detail-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.book-tracks-wrap {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ===== FULL-SCREEN COMIC BOOK READER ===== */
.comic-reader {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #020617;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}

.comic-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

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

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

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

.comic-title-wrap {
  flex: 1;
  min-width: 0;
}

.comic-title {
  font-size: 14px;
  font-weight: 700;
}

.comic-sub {
  font-size: 12px;
  color: var(--accent-bright);
}

.comic-hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.comic-select {
  max-width: 130px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 0 8px;
  font-size: 13px;
}

.comic-stage {
  position: relative;
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y pinch-zoom;
}

.comic-page-img {
  display: block;
  margin: auto;
  transition: opacity 0.15s ease;
}

.comic-page-img.fit-screen {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.comic-page-img.fit-width {
  width: 100%;
  height: auto;
  align-self: flex-start;
}

.comic-scroll-strip {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0 40px;
  align-self: flex-start;
}

.comic-scroll-strip img {
  width: 100%;
  height: auto;
  display: block;
  background: #0f172a;
  min-height: 220px;
}

.comic-tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
}

.comic-tap-prev { left: 0; width: 28%; }
.comic-tap-center { left: 28%; width: 44%; }
.comic-tap-next { right: 0; width: 28%; }

.comic-spinner {
  position: absolute;
  z-index: 3;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

#comicSlider {
  flex: 1;
  accent-color: var(--accent-bright);
  height: 28px;
}

/* ===== BUILT-IN EPUB READER ===== */
.epub-reader {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
}

.epub-reader.theme-dark { background: #0f172a; color: #e2e8f0; }
.epub-reader.theme-sepia { background: #f4ecd8; color: #3b2f21; }
.epub-reader.theme-light { background: #ffffff; color: #1e293b; }

.epub-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.94);
  color: #f8fafc;
}

.epub-title-wrap {
  flex: 1;
  min-width: 0;
}

.epub-controls {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.epub-toc-drawer {
  max-height: 45dvh;
  overflow-y: auto;
  background: #111a2e;
  color: #f8fafc;
  border-bottom: 1px solid var(--border-strong);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.epub-content {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 18px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.epub-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px auto;
  border-radius: 8px;
}

.epub-content p {
  margin: 0 0 1em;
}

.epub-content h1, .epub-content h2, .epub-content h3 {
  line-height: 1.3;
  margin: 1.2em 0 0.6em;
}

.epub-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px max(10px, var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.94);
  color: #f8fafc;
}

/* ===== COLLECTION COLLAGE CARDS & VISUAL FOLDER BROWSING ===== */
.sub-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 560px) {
  .collection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.collection-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: transform 0.13s ease, border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.collection-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.collection-card:active {
  transform: scale(0.99);
}

.collage-box {
  width: 74px;
  height: 74px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
}

.collage-box.single {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.collage-box.one-img {
  display: block;
}

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

.collection-body {
  min-width: 0;
  flex: 1;
}

.collection-title {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.collection-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

.view-toggle {
  display: inline-flex;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  overflow: hidden;
  flex-shrink: 0;
}

.view-toggle-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 17px;
  cursor: pointer;
}

.view-toggle-btn.active {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.book-folder-peek {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(11, 17, 32, 0.8);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}

.book-folder-peek:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}

.file-thumb {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
