:root {
  --c-bg: #09090b;
  --c-surface: #0f0f12;
  --c-border: rgba(255,255,255,0.06);
  --c-text: #fafafa;
  --c-muted: #71717a;
  --c-dim: #3f3f46;
  --c-accent: #818cf8;
  --c-accent-dim: rgba(99,102,241,0.15);
  --font-head: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #6366f1; color: #fff; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #27272a; border-radius: 3px; }

.ambient {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 15% -5%, rgba(99,102,241,0.05) 0%, transparent 45%),
              radial-gradient(ellipse at 85% 105%, rgba(139,92,246,0.03) 0%, transparent 40%);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes spotlightPulse { 0%,100% { box-shadow: 0 0 20px rgba(59,130,246,0.1); } 50% { box-shadow: 0 0 30px rgba(59,130,246,0.2); } }
@keyframes goldShimmer { 0%,100% { border-color: rgba(245,158,11,0.25); box-shadow: 0 0 12px rgba(245,158,11,0.08); } 50% { border-color: rgba(245,158,11,0.45); box-shadow: 0 0 20px rgba(245,158,11,0.15); } }
@keyframes scrollTopIn { from { opacity:0; transform: translateY(20px) scale(0.8); } to { opacity:1; transform: translateY(0) scale(1); } }
.fade-in { animation: fadeIn .25s ease; }
.slide-up { animation: slideUp .3s ease both; }
.spinner { animation: spin .7s linear infinite; display: inline-block; }

/* Rating Glow */
.entry-card.rating-gold { border-color: rgba(245,158,11,0.25) !important; animation: goldShimmer 3s ease infinite; }
.entry-card.rating-low { border-color: rgba(239,68,68,0.15) !important; box-shadow: inset 0 0 30px rgba(239,68,68,0.03); }

/* NSFW Blur */
body.nsfw-blur .nsfw-cover { filter: blur(12px) brightness(0.7); transition: filter 0.3s ease; }
body.nsfw-blur .nsfw-cover:hover { filter: blur(0) brightness(1); }

/* Search Highlight */
mark.search-hl { background: rgba(250,204,21,0.3); color: var(--c-text); padding: 0 2px; border-radius: 2px; }

/* Scroll to Top */
#scroll-top-btn {
  position: fixed; bottom: 24px; right: 24px; width: 44px; height: 44px;
  border-radius: 50%; background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff; border: none; cursor: pointer; font-size: 18px; z-index: 900;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4); transition: transform 0.2s;
  animation: scrollTopIn 0.25s ease;
}
#scroll-top-btn:hover { transform: scale(1.1); }
#scroll-top-btn.visible { display: flex; }

/* Multi-Select */
.multi-select-check {
  position: absolute; top: 10px; left: 10px; width: 22px; height: 22px;
  border-radius: 6px; border: 2px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.6); z-index: 10; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: transparent; transition: all 0.15s; backdrop-filter: blur(4px);
}
.multi-select-check:hover { border-color: rgba(129,140,248,0.5); }
.multi-select-check.checked { background: #6366f1; border-color: #818cf8; color: #fff; }

.multi-select-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 800;
  background: rgba(15,15,18,0.95); backdrop-filter: blur(16px);
  border-top: 1px solid rgba(99,102,241,0.3); padding: 12px 20px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  animation: slideUp 0.2s ease; flex-wrap: wrap;
}

/* Drag Reorder */
.entry-card.drag-over { border-top: 2px solid var(--c-accent) !important; }
.entry-card.dragging { opacity: 0.4; transform: scale(0.98) !important; }

/* Inline Quick Rate */
.inline-star { cursor: pointer; transition: all 0.12s; display: inline-block; font-size: 13px; }
.inline-star:hover { transform: scale(1.3); }
.inline-star.lit { color: #f59e0b; }
.inline-star.unlit { color: #27272a; }

/* Pinned Card */
.pinned-card {
  background: linear-gradient(135deg, rgba(139,92,246,0.08), rgba(99,102,241,0.06), rgba(59,130,246,0.04));
  border: 1px solid rgba(139,92,246,0.2); border-radius: 16px;
  padding: 22px; cursor: pointer; transition: all .3s; position: relative; overflow: hidden;
  margin-bottom: 10px;
}
.pinned-card::before {
  content: ''; position: absolute; top: -40%; right: -20%; width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(139,92,246,0.06), transparent 70%); pointer-events: none;
}
.pinned-card:hover { border-color: rgba(139,92,246,0.4); transform: translateY(-2px); }
.pin-badge {
  padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.25);
  color: #c084fc; letter-spacing: 0.5px; text-transform: uppercase; font-family: var(--font-head);
}

/* Sequel Prompt */
.sequel-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 14px 20px; background: #18181b; border: 1px solid rgba(99,102,241,0.3);
  border-radius: 14px; color: #fafafa; font-size: 13px; font-family: var(--font-body);
  z-index: 3000; animation: slideUp 0.25s ease; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  max-width: 420px; width: calc(100vw - 32px);
}

/* Undo Toast */
.undo-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 12px 20px; background: #18181b; border: 1px solid rgba(251,191,36,0.3);
  border-radius: 12px; color: #fafafa; font-size: 13px; font-family: var(--font-body);
  z-index: 3001; animation: slideUp 0.25s ease; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  display: flex; align-items: center; gap: 12px; max-width: 400px; width: calc(100vw - 32px);
  overflow: hidden;
}
.undo-toast .undo-btn {
  padding: 4px 14px; border-radius: 8px; background: rgba(251,191,36,0.15);
  border: 1px solid rgba(251,191,36,0.3); color: #fbbf24; font-size: 12px;
  font-weight: 700; cursor: pointer; white-space: nowrap; font-family: var(--font-body);
}
.undo-toast .undo-btn:hover { background: rgba(251,191,36,0.25); }
.undo-toast .undo-progress {
  position: absolute; bottom: 0; left: 0; height: 2px; background: #fbbf24;
  border-radius: 0 0 12px 12px; transition: width linear;
}

/* Rewatch Counter Badge */
.rewatch-badge {
  padding: 2px 7px; border-radius: 5px; font-size: 10px; font-weight: 700;
  background: rgba(124,58,237,0.12); border: 1px solid rgba(124,58,237,0.25);
  color: #a78bfa; font-family: var(--font-mono);
}

/* Form Controls */
.form-label {
  display: block; font-size: 11px; color: #52525b; margin-bottom: 6px;
  font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
}
.form-input {
  width: 100%; padding: 9px 12px; background: rgba(255,255,255,0.03);
  border: 1px solid var(--c-border); border-radius: 10px;
  color: var(--c-text); font-size: 13px; outline: none;
  font-family: var(--font-body); transition: border-color .25s, box-shadow .25s;
}
.form-input:focus { border-color: rgba(129,140,248,0.5); box-shadow: 0 0 0 3px rgba(129,140,248,0.08); }
.form-input::placeholder { color: #3f3f46; }
textarea.form-input { resize: vertical; min-height: 70px; line-height: 1.5; }
select.form-input {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2371717a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px; cursor: pointer;
}
select.form-input:hover { border-color: rgba(255,255,255,0.12); }
select.form-input option { background: #18181b; color: #fafafa; }

.custom-check {
  width: 18px; height: 18px; border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.03);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s; flex-shrink: 0; font-size: 10px;
}
.custom-check:hover { border-color: rgba(255,255,255,0.25); }
.custom-check.checked { border-color: var(--check-color, var(--c-accent)); background: color-mix(in srgb, var(--check-color, var(--c-accent)) 15%, transparent); }
.custom-check.checked::after { content: '✓'; color: var(--check-color, var(--c-accent)); font-weight: 800; font-size: 10px; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { opacity: 1; height: 28px; }
input[type="date"] { cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.6); cursor: pointer; padding: 2px; border-radius: 4px; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { filter: invert(0.8); background: rgba(255,255,255,0.05); }

/* Buttons */
.btn-primary {
  padding: 9px 24px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff; cursor: pointer; font-size: 13px; font-weight: 700;
  font-family: var(--font-head); transition: all .2s;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(99,102,241,0.35); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .35; cursor: default; transform: none; box-shadow: none; }

.btn-ghost {
  padding: 7px 16px; border-radius: 10px;
  border: 1px solid var(--c-border); background: transparent;
  color: var(--c-muted); cursor: pointer; font-size: 12px;
  font-weight: 600; transition: all .2s; font-family: var(--font-body);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--c-text); border-color: rgba(255,255,255,0.12); transform: translateY(-1px); }
.btn-ghost:active { transform: translateY(0); }

.btn-danger {
  padding: 8px 18px; border-radius: 10px;
  border: 1px solid rgba(239,68,68,0.25); background: rgba(239,68,68,0.06);
  color: #f87171; cursor: pointer; font-size: 12px;
  font-weight: 600; font-family: var(--font-body); transition: all .2s;
}
.btn-danger:hover { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); }

.pill {
  padding: 5px 14px; border-radius: 20px; border: 1px solid transparent;
  background: rgba(255,255,255,0.03); color: #52525b;
  cursor: pointer; font-size: 11px; font-weight: 600; transition: all .2s;
  font-family: var(--font-body);
}
.pill:hover { background: rgba(255,255,255,0.06); }
.pill.active { border-color: rgba(129,140,248,0.3); background: var(--c-accent-dim); color: var(--c-accent); }

.genre-pill {
  padding: 4px 12px; border-radius: 20px; font-size: 11px; cursor: pointer;
  border: 1px solid var(--c-border); font-weight: 500; transition: all .2s;
  background: transparent; color: #71717a; font-family: var(--font-body);
}
.genre-pill.active { border-color: rgba(129,140,248,0.4); background: var(--c-accent-dim); color: var(--c-accent); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(12px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; animation: fadeIn .15s ease; }
.modal-box {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 16px; width: 100%; max-height: 88vh; overflow: auto;
  animation: slideUp .25s ease;
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--c-border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: var(--c-surface); z-index: 2;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--c-text); font-family: var(--font-head); }
.modal-body { padding: 20px; }

/* Card Flip */
.card-flip-container { perspective: 1200px; position: relative; }
.card-flip-inner {
  position: relative; transition: transform 0.55s cubic-bezier(.4,0,.2,1);
  transform-style: preserve-3d;
}
.card-flip-container.flipped .card-flip-inner { transform: rotateY(180deg); }
.card-flip-front, .card-flip-back { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-flip-front { position: relative; z-index: 1; }
.card-flip-back {
  position: absolute; inset: 0; transform: rotateY(180deg);
  background: linear-gradient(145deg, #0f0f14, #12121a);
  border: 1px solid var(--c-border); border-radius: 14px;
  padding: 20px; display: flex; flex-direction: column;
  overflow: hidden; z-index: 2;
}
.gist-text {
  font-size: 12.5px; color: #a1a1aa; line-height: 1.7;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
}
.gist-loading { text-align: center; padding: 20px; color: #52525b; font-size: 12px; }

/* Entry Cards */
.entry-card {
  background: rgba(255,255,255,0.02); border: 1px solid var(--c-border);
  border-radius: 14px; cursor: pointer; transition: all .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden; position: relative; user-select: none; -webkit-user-select: none;
}
.entry-card:hover { background: rgba(255,255,255,0.045); border-color: rgba(255,255,255,0.1); transform: translateY(-3px); }
.entry-card.swiping { transition: none; }

.cover-img { border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.cover-fallback {
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #e2e8f0; font-family: var(--font-head); flex-shrink: 0;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.07) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s ease infinite; border-radius: 8px;
}
.skeleton-card {
  background: rgba(255,255,255,0.02); border: 1px solid var(--c-border);
  border-radius: 14px; padding: 20px; display: flex; gap: 18px; overflow: hidden;
}

/* Spotlight */
.spotlight-section { margin-bottom: 24px; }
.spotlight-card {
  background: linear-gradient(135deg, rgba(59,130,246,0.06), rgba(99,102,241,0.04), rgba(139,92,246,0.03));
  border: 1px solid rgba(59,130,246,0.18); border-radius: 16px;
  padding: 22px; cursor: pointer; transition: all .3s; position: relative; overflow: hidden;
  animation: spotlightPulse 4s ease infinite;
}
.spotlight-card::before {
  content: ''; position: absolute; top: -40%; right: -20%; width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(59,130,246,0.06), transparent 70%); pointer-events: none;
}
.spotlight-card:hover { border-color: rgba(59,130,246,0.35); transform: translateY(-2px); }
.spotlight-badge {
  padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700;
  background: rgba(59,130,246,0.12); border: 1px solid rgba(59,130,246,0.25);
  color: #60a5fa; letter-spacing: 0.5px; text-transform: uppercase; font-family: var(--font-head);
}

/* Context Menu */
.ctx-menu {
  position: fixed; z-index: 2000; min-width: 190px;
  background: #18181b; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  animation: slideUp .12s ease;
}
.ctx-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  font-size: 12px; color: #d4d4d8; cursor: pointer; border-radius: 8px;
  transition: background .15s; font-family: var(--font-body); border: none;
  background: transparent; width: 100%; text-align: left;
}
.ctx-item:hover { background: rgba(255,255,255,0.06); }
.ctx-item.danger { color: #f87171; }
.ctx-item.danger:hover { background: rgba(239,68,68,0.08); }
.ctx-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 4px 8px; }

/* Swipe hint */
.swipe-hint {
  position: absolute; top: 0; bottom: 0; width: 80px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; pointer-events: none; opacity: 0;
  transition: opacity .15s; z-index: 5; border-radius: 14px;
}
.swipe-hint.left { left: 0; background: linear-gradient(90deg, rgba(239,68,68,0.2), transparent); color: #f87171; }
.swipe-hint.right { right: 0; background: linear-gradient(-90deg, rgba(52,211,153,0.2), transparent); color: #34d399; }

/* Status sections */
.status-header {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 16px; cursor: pointer; transition: all .25s;
  font-family: var(--font-body); border: none;
}
.status-header .chevron { font-size: 12px; transition: transform .25s; }
.status-header .chevron.collapsed { transform: rotate(-90deg); }

.api-result {
  display: flex; gap: 10px; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--c-border); align-items: center;
  background: rgba(255,255,255,0.015); transition: background .15s;
}
.api-result:hover { background: rgba(255,255,255,0.05); }
.api-result:last-child { border-bottom: none; }

.star { cursor: pointer; transition: all .12s; display: inline-block; }
.star.readonly { cursor: default; }
.star.lit { color: #f59e0b; }
.star.unlit { color: #27272a; }

.roadmap-line {
  position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px;
  background: linear-gradient(to bottom, var(--c-accent-dim), rgba(99,102,241,0.05)); border-radius: 1px;
}
.roadmap-dot {
  position: absolute; left: -20px; top: 3px; width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 7px; font-weight: 800;
}

.container { max-width: 960px; margin: 0 auto; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 10px; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.mb-8 { margin-bottom: 8px; } .mb-10 { margin-bottom: 10px; } .mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.text-center { text-align: center; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; gap: 8px; }
  .entry-card > .flex { padding: 14px !important; gap: 12px !important; }
  .container { padding: 12px 12px 60px !important; }
  #app-header .container { padding: 10px 12px !important; }
  #app-header .btn-ghost { padding: 5px 8px !important; font-size: 10px !important; }
  #app-header .btn-primary { padding: 6px 12px !important; font-size: 11px !important; }
  .filter-row { flex-direction: column; gap: 8px !important; }
  .filter-row > * { width: 100%; }
  #cat-pills { flex-wrap: wrap; }
  .modal-box { max-width: 100% !important; border-radius: 12px; max-height: 92vh; }
  .modal-body { padding: 14px; }
  .spotlight-card { padding: 16px; }
  .pinned-card { padding: 16px; }
  .status-header { padding: 10px 12px; }
  #scroll-top-btn { bottom: 16px; right: 16px; width: 40px; height: 40px; font-size: 16px; }
  .ctx-menu { min-width: 170px; }
  #header-actions {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; max-width: 55vw; flex-shrink: 0;
  }
  #header-actions::-webkit-scrollbar { display: none; }
}

@media (max-width: 380px) {
  .grid-2 { grid-template-columns: 1fr; }
  #app-header .container { gap: 6px; }
  #header-actions { max-width: 50vw; }
}
