:root {
  --bg: #0f0f12;
  --surface: #1a1a22;
  --surface2: #252530;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #818cf8;
  --accent2: #6366f1;
  --danger: #f87171;
  --radius: 14px;
  --fab-size: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.boot-loader--hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-loader__ring {
  position: relative;
  width: 96px;
  height: 96px;
}

.boot-loader__ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.boot-loader__track {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 8;
}

.boot-loader__progress {
  fill: none;
  stroke: var(--accent2);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.25s ease;
}

.boot-loader__pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { padding-bottom: calc(var(--fab-size) + 24px + var(--safe-bottom)); }

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
}

.header__title {
  flex: 1;
  min-width: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  border: none;
  background: var(--surface2);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hamburger {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 86vw);
  background: var(--surface);
  z-index: 50;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
}

.drawer--open {
  transform: translateX(0);
}

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

.drawer__head h2 {
  font-size: 1.1rem;
  color: #fff;
}

.drawer__list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
}

.drawer__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border: none;
  background: transparent;
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.drawer__item--active {
  background: var(--surface2);
}

.drawer__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

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

.drawer__count {
  color: var(--muted);
  font-size: 0.8rem;
}

.folders-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 16px 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.folders-bar::-webkit-scrollbar { display: none; }

.folder-chip {
  flex-shrink: 0;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.folder-chip--active {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 12px 16px;
}

.grid-panel[hidden] {
  display: none !important;
}

@media (min-width: 480px) {
  .grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
}

.card {
  position: relative;
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface2);
  border: none;
  cursor: pointer;
  text-align: left;
  color: inherit;
  padding: 0;
  content-visibility: auto;
  contain-intrinsic-size: auto 180px;
}

.grid-sentinel {
  height: 1px;
  margin: 0;
}

.grid-more {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 4px 16px 20px;
}

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

.card--game img {
  object-fit: contain;
  background: linear-gradient(180deg, #1e1e28 0%, #121218 100%);
}

.card--game .card__placeholder {
  background: linear-gradient(180deg, #252530 0%, #1a1a22 100%);
}

.movie-detail__hero--game {
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.movie-detail__hero--game img {
  object-fit: contain;
  aspect-ratio: auto;
  max-height: 220px;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  display: block;
}

.preview--game img {
  object-fit: contain;
  background: var(--bg);
}

.card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: linear-gradient(135deg, var(--surface2), var(--surface));
}

.card__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.65rem;
  color: #fff;
}

.card__overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 24px 8px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  font-size: 0.7rem;
  line-height: 1.25;
  font-weight: 600;
  color: #fff;
}

.card__year {
  opacity: 0.75;
  font-weight: 400;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 24px;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  border: none;
  background: var(--accent2);
  color: #fff;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
  cursor: pointer;
  z-index: 20;
}

.fab__plus {
  display: block;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  transform: translateY(-1px);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(34, 197, 94, 0.95);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--in-modal {
  bottom: calc(20px + var(--safe-bottom));
  z-index: 10;
}

.modal {
  border: none;
  padding: 0;
  max-width: 100%;
  width: min(480px, 100%);
  background: transparent;
  color: var(--text);
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}
.modal--sheet {
  width: 100%;
  max-width: 100%;
  margin: auto 0 0;
}
.modal--sheet .modal__inner {
  border-radius: 20px 20px 0 0;
  max-height: 92vh;
  overflow-y: auto;
}
.modal__inner {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px;
  color: var(--text);
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal__head h2 {
  font-size: 1.15rem;
  color: #fff;
}
.modal__close { flex-shrink: 0; }
.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  border: none;
}
.field span, .field legend {
  font-size: 0.8rem;
  color: var(--muted);
}
.field input[type="text"],
.field input[type="search"] {
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 1rem;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.field--checkbox span {
  color: #fff;
  font-size: 0.95rem;
}
.field--checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent2);
}

.suggest {
  list-style: none;
  background: var(--surface2);
  border-radius: 10px;
  margin: -8px 0 12px;
  max-height: 220px;
  overflow-y: auto;
}
.suggest li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg);
  color: #fff;
}
.suggest li span { color: #fff; }
.suggest li:last-child { border-bottom: none; }
.suggest li:active { background: var(--bg); }
.suggest-loading,
.suggest-manual { color: var(--muted) !important; font-size: 0.875rem; }
.suggest-manual { border-top: 1px solid var(--bg); margin-top: 4px; }
.suggest img {
  width: 36px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg);
}

.suggest--game img {
  object-fit: contain;
  background: #1a1a22;
}

.preview {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px;
  background: var(--surface2);
  border-radius: 10px;
}
.preview img {
  width: 56px;
  height: 84px;
  object-fit: cover;
  border-radius: 6px;
}
.preview strong { color: #fff; }

.checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.875rem;
  cursor: pointer;
  color: #fff;
}
.checkboxes input { accent-color: var(--accent2); }

.checkboxes label.check--dup {
  background: rgba(248, 113, 113, 0.18);
  outline: 1px solid rgba(248, 113, 113, 0.55);
  color: #fecaca;
}

.dup-warn {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.875rem;
}
.dup-warn strong { color: #fff; font-size: 0.9rem; }

.suggest--dup { background: rgba(248, 113, 113, 0.08); }
.suggest-dup {
  color: #fca5a5;
  font-style: normal;
  font-size: 0.75rem;
  margin-left: 4px;
}

.field--file input[type="file"] {
  color: var(--text);
  font-size: 0.85rem;
}

.cover-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  cursor: pointer;
}

.links-preview { margin-bottom: 14px; }
.links-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.link-chip {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--accent);
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn--ghost {
  background: var(--surface2);
  color: var(--text);
}
.btn--primary {
  background: var(--accent2);
  color: #fff;
}
.btn--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn--danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.muted { color: var(--muted); font-size: 0.85rem; }

.movie-detail {
  position: relative;
  padding-top: 8px;
  color: var(--text);
}
.movie-detail__hero {
  width: 140px;
  margin: 0 auto 16px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.movie-detail__hero img {
  width: 100%;
  display: block;
  aspect-ratio: 2/3;
  object-fit: cover;
}
.movie-detail__title {
  text-align: center;
  font-size: 1.25rem;
  margin-bottom: 4px;
  color: #fff;
}
.movie-detail__meta {
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 16px;
}
.movie-detail__overview {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 20px;
}

.watch-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.watch-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.watch-btn--primary {
  background: linear-gradient(135deg, var(--accent2), #4f46e5);
  color: #fff;
}
.watch-btn span:last-child { opacity: 0.6; font-size: 1.1rem; }

.detail-section { margin-bottom: 16px; }
.detail-section h3 {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.detail-folders {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.detail-folder-tag {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 999px;
  color: #fff;
}
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: var(--safe-bottom);
}

.edit-folders label {
  display: block;
  margin: 8px 0;
  color: #fff;
}
.edit-folders h2 {
  color: #fff;
  margin-bottom: 12px;
}
