:root {
  --bg-main: #09090b;
  --bg-card: #121215;
  --bg-card-hover: #1a1a1f;
  --bg-surface: #1f1f24;
  --bg-glass: rgba(12, 12, 15, 0.82);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 255, 255, 0.28);
  --primary: #f4f4f5;
  --primary-hover: #e4e4e7;
  --primary-glow: rgba(255, 255, 255, 0.14);
  --accent: #f4f4f5;
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-surface);
  border-radius: 999px;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.app-icon {
  width: 32px;
  height: 32px;
}

.header-search {
  flex: 1;
  max-width: 640px;
  position: relative;
  display: flex;
  align-items: center;
}

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

.header-search input {
  width: 100%;
  padding: 9px 0px 9px 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-main);
  font-size: 0.92rem;
  outline: none;
  transition: var(--transition);
}

.header-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  user-select: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--primary);
  color: #09090b;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
}
.btn-icon:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
  transition: var(--transition);
}

.view-btn.active {
  background: var(--primary);
  color: #09090b;
}

.icon {
  width: 18px;
  height: 18px;
}

/* Banner */
.scan-banner {
  background: rgba(39, 39, 42, 0.65);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  padding: 10px 20px;
}
.scan-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.88rem;
  color: var(--accent);
}
.scan-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}
.scan-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* Filter Section */
.filter-section {
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(18, 18, 21, 0.7);
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.type-pills {
  display: flex;
  background: var(--bg-surface);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
}

.pill {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 0.82rem;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}

.pill.active {
  background: var(--primary);
  color: #09090b;
  font-weight: 600;
}

.pill-toggle {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.pill-toggle:hover {
  color: var(--text-main);
  border-color: var(--border-active);
}

.pill-toggle.active {
  background: var(--primary);
  color: #09090b;
  border-color: var(--primary);
  font-weight: 600;
}

.audio-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #222228 0%, #101014 100%);
  color: #a1a1aa;
}

.audio-icon-wrap img,
.mini-player-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.lightbox-btn.fav-active {
  color: #f43f5e;
  border-color: rgba(244, 63, 94, 0.5);
  background: rgba(244, 63, 94, 0.14);
}

.lightbox-btn.fav-active svg {
  fill: #f43f5e;
}

.badge-fav {
  position: absolute;
  bottom: 8px;
  right: 8px;
  color: #f43f5e;
  font-size: 0.9rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  z-index: 2;
}

.card-fav-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  aspect-ratio: 1 / 1;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(12, 12, 15, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #e4e4e7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: var(--transition);
}

.card-fav-btn svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.card-fav-btn:hover {
  transform: scale(1.08);
  border-color: #f43f5e;
  background: rgba(12, 12, 15, 0.88);
}

.card-fav-btn.active {
  color: #f43f5e;
  border-color: rgba(244, 63, 94, 0.65);
  background: rgba(244, 63, 94, 0.2);
}

.card-fav-btn.active svg {
  fill: #f43f5e;
}

.gallery-grid.list-view .card-fav-btn {
  position: static;
  flex-shrink: 0;
}

.gallery-grid.list-view .badge-type {
  top: 6px;
  left: 6px;
  right: auto;
}

.media-card.selected {
  outline: 2px solid #f4f4f5;
  outline-offset: -2px;
  background: #222228;
}

.media-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 6;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f4f4f5;
  color: #09090b;
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.folder-nav {
  margin-bottom: 16px;
}

.folder-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.86rem;
}

.crumb-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
}

.crumb-btn:hover {
  border-color: var(--border-active);
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.folder-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.folder-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

.folder-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.folder-card-count {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.selection-bar {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 910;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(18, 18, 22, 0.96);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
}

.selection-count {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  margin-right: 4px;
}

.drawer-tag.active {
  background: var(--primary);
  color: #09090b;
  border-color: var(--primary);
  font-weight: 600;
}

.select-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

select {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  outline: none;
  max-width: 170px;
}

.tag-cloud {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tag-chip {
  background: rgba(255, 255, 255, 0.1);
  color: #e4e4e7;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.tag-chip:hover, .tag-chip.active {
  background: var(--accent);
  color: #09090b;
  border-color: var(--accent);
  font-weight: 600;
}

/* Gallery Grid */
.gallery-container {
  padding: 20px;
  max-width: 2400px;
  margin: 0 auto;
}

.gallery-meta-row {
  margin-bottom: 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.media-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
}

.media-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-active);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.media-thumb-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: #0c0c0f;
  overflow: hidden;
}

.media-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.media-card:hover .media-thumb {
  transform: scale(1.04);
}

.badge {
  position: absolute;
  top: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.badge-type {
  top: 8px;
  right: 8px;
  left: auto;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.badge-model {
  top: 34px;
  right: 8px;
  background: rgba(244, 244, 245, 0.92);
  color: #09090b;
  border: 1px solid rgba(255, 255, 255, 0.4);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-author {
  top: 34px;
  right: 8px;
  background: rgba(244, 244, 245, 0.92);
  color: #09090b;
  border: 1px solid rgba(255, 255, 255, 0.4);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 24px 10px 8px 10px;
  background: linear-gradient(to top, rgba(9, 9, 11, 0.95), transparent);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.card-tags {
  display: flex;
  gap: 4px;
  overflow: hidden;
  height: 20px;
}

.card-tag {
  font-size: 0.68rem;
  color: #f4f4f5;
  background: rgba(255, 255, 255, 0.18);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* List View */
.list-meta {
  display: none;
}

.gallery-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gallery-grid.list-view .media-card {
  aspect-ratio: auto;
  flex-direction: row;
  align-items: center;
  padding: 10px 14px;
  gap: 14px;
}

.gallery-grid.list-view .media-card:hover {
  transform: translateY(-1px);
}

.gallery-grid.list-view .media-thumb-wrap {
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.gallery-grid.list-view .badge-author,
.gallery-grid.list-view .badge-model,
.gallery-grid.list-view .card-overlay {
  display: none;
}

.gallery-grid.list-view .list-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
  line-height: 1.35;
}

.list-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.list-pill {
  background: rgba(244, 244, 245, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #09090b;
  text-transform: uppercase;
}

.list-author {
  color: #e4e4e7;
  font-weight: 600;
}

/* Lightbox Fullscreen */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  user-select: none;
  touch-action: pan-y;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1010;
}

.lightbox-file-name {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

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

.lightbox-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.lightbox-btn svg {
  width: 20px;
  height: 20px;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.lightbox-btn.close-btn:hover {
  background: var(--danger);
}

.media-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  overflow: hidden;
  position: relative;
}

.media-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  border-radius: 4px;
}

.media-stage video {
  max-width: 100%;
  max-height: 100%;
  outline: none;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.audio-player-card {
  background: linear-gradient(145deg, rgba(28, 28, 33, 0.94), rgba(9, 9, 11, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 36px 28px 28px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 92%;
  max-width: 500px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}

.audio-player-card audio {
  width: 100%;
  margin-top: 6px;
  color-scheme: dark;
  border-radius: 999px;
}

.audio-icon-wrap {
  width: 88px;
  height: 88px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e4e4e7;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.5);
}

.audio-title-display {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  color: var(--text-main);
  word-break: break-word;
}

.audio-meta-sub {
  font-size: 0.82rem;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 4px 12px;
  border-radius: 999px;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1005;
  transition: var(--transition);
}

.nav-arrow:hover {
  background: rgba(255, 255, 255, 0.2);
}

.left-arrow { left: 20px; }
.right-arrow { right: 20px; }

/* Info Drawer */
.info-drawer {
  position: absolute;
  top: 0;
  right: -520px;
  bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: rgba(14, 14, 17, 0.97);
  backdrop-filter: blur(24px);
  border-left: 1px solid var(--border-color);
  z-index: 1020;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.info-drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  user-select: text;
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-chip {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: #f4f4f5;
}

.drawer-section label {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 6px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.source-badge {
  background: rgba(244, 244, 245, 0.9);
  color: #09090b;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.source-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.84rem;
  word-break: break-all;
  display: block;
  margin-bottom: 8px;
}
.source-link:hover {
  text-decoration: underline;
}

.author-tag {
  color: #e4e4e7;
  font-weight: 600;
  font-size: 0.9rem;
}

.link-edit-box {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.link-edit-box input {
  flex: 1;
  padding: 7px 10px;
  background: #0c0c0f;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
}
.link-edit-box input:focus {
  border-color: var(--primary);
}

.copy-small-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
}

.copy-small-btn:hover {
  background: var(--accent);
  color: #000;
}

.code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  background: #0c0c0f;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #e4e4e7;
  word-break: break-all;
  border: 1px solid var(--border-color);
}

.prompt-text {
  font-size: 0.84rem;
  line-height: 1.5;
  background: #0c0c0f;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  border: 1px solid var(--border-color);
}

.lora-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lora-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0c0c0f;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
}

.lora-name {
  color: #d4d4d8;
  font-weight: 500;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lora-weights {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drawer-tag {
  background: rgba(255, 255, 255, 0.12);
  color: #f4f4f5;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.76rem;
  cursor: pointer;
}
.drawer-tag:hover {
  background: var(--accent);
  color: #09090b;
}

.actions-sec {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

/* Modal */
.modal-overlay, .overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card, .modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-card {
  max-width: 572px;
}

.brand-logo {
  text-align: center;
  margin-bottom: 12px;
}

.auth-card h2 {
  text-align: center;
  font-size: 1.5rem;
}
.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 22px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-group input,
.input-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  resize: vertical;
}
.input-group input:focus,
.input-group textarea:focus {
  border-color: var(--primary);
}

.error-msg {
  color: var(--danger);
  font-size: 0.82rem;
  margin-bottom: 12px;
  min-height: 18px;
}

.btn-block {
  width: 100%;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-status {
  font-size: 0.82rem;
  color: var(--accent);
  margin-top: 8px;
}

.modal-select {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.watched-dirs {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.watched-dirs-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 10px;
}

.watched-dirs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.watched-dir-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #0c0c0f;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.8rem;
}

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

.watched-dir-path {
  color: var(--text-main);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.watched-dir-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.load-more-trigger {
  padding: 30px;
  display: flex;
  justify-content: center;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

/* Mini Player (Floating Bottom-Right) */
.mini-player {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 340px;
  max-width: calc(100vw - 24px);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 13px;
  background: rgba(18, 18, 22, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.75);
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.mini-player:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.85);
}

.mini-player-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #e4e4e7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.mini-player-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player-sub {
  font-size: 0.72rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}

.mini-player-btn:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.mini-player-btn.close {
  padding: 4px 9px;
  font-size: 1rem;
  line-height: 1;
}

.mini-player-progress-bg {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.mini-player-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.25s linear;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f1f24;
  border: 1px solid var(--border-active);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  z-index: 3000;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none;
}

.mobile-menu-wrap {
  position: relative;
}

.mobile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 165px;
  background: #141418;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.85);
  padding: 6px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.mobile-dropdown-item:hover {
  background: var(--bg-surface);
}

.mobile-dropdown-item.danger {
  color: #f87171;
}

.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.mobile-drawer-header {
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: 1rem;
  font-weight: 700;
}

.mobile-filter-fab {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 890;
  align-items: center;
  gap: 7px;
  padding: 10px 15px;
  border-radius: 999px;
  background: var(--primary);
  color: #09090b;
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.75);
  cursor: pointer;
}

@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex;
  }
  .mobile-drawer-header.mobile-only {
    display: flex;
  }
  #backfillBtn,
  #scanBtn,
  #logoutBtn,
  #filterToggleBtn {
    display: none;
  }
  .app-header {
    padding: 10px 12px;
    gap: 8px;
  }
  .header-search {
    flex: 1;
    min-width: 0;
  }
  .header-search input {
    padding: 8px 0px 8px 34px;
    font-size: 0.85rem;
  }
  .search-icon {
    left: 10px;
    width: 16px;
    height: 16px;
  }
  .header-actions {
    gap: 6px;
  }
  .header-actions .btn,
  .header-actions .btn-icon {
    padding: 7px 9px;
  }
  .btn-text {
    display: none;
  }
  .filter-section {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84vw;
    max-width: 340px;
    z-index: 1050;
    background: rgba(14, 14, 17, 0.98);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    border-bottom: none;
    padding: 16px;
    gap: 14px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .filter-section.mobile-open {
    transform: translateX(0);
  }
  .filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .type-pills {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
  .pill {
    text-align: center;
    padding: 8px 4px;
    font-size: 0.78rem;
  }
  .select-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
  }
  .select-group .pill-toggle,
  .select-group select {
    width: 100%;
    max-width: 100%;
    padding: 9px 10px;
    font-size: 0.8rem;
    text-align: center;
  }
  .tag-cloud {
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 4px 0;
  }
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .gallery-grid.list-view .media-card {
    padding: 10px;
    gap: 10px;
  }
  .gallery-grid.list-view .media-thumb-wrap {
    width: 56px;
    height: 56px;
  }
  .folder-grid {
    grid-template-columns: 1fr;
  }
  .gallery-container {
    padding: 10px;
  }
  .info-drawer {
    width: 100vw;
    right: -100vw;
  }
  .nav-arrow {
    display: none;
  }
  .media-stage {
    padding: 40px 10px;
  }
  .mini-player {
    right: 12px;
    bottom: 14px;
    width: calc(100vw - 135px);
    max-width: 300px;
  }
  .selection-bar {
    left: 12px;
    right: 12px;
    bottom: 66px;
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}
