/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0d0d0d;
  --surface:    #1a1a1a;
  --surface-2:  #242424;
  --border:     #2e2e2e;
  --accent:     #e1306c;       /* Instagram-ish pink */
  --accent-dim: #b02456;
  --text:       #f0f0f0;
  --text-muted: #888;
  --radius:     12px;
  --header-h:   64px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* ── Page nav ─────────────────────────────────────────── */
.page-nav {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.page-nav-link {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.page-nav-link:hover { color: var(--text); }

.page-nav-link.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

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

.search-wrap {
  flex: 1;
  max-width: 360px;
}

#search {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text-muted); }

/* ── Main ─────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ── Grid ─────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

/* ── Card ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s, border-color 0.18s;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-3px);
  border-color: #444;
}

.card-thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  background: #111;
  overflow: hidden;
}

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

.card-thumb .play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  opacity: 1;
  transition: opacity 0.15s;
  pointer-events: none;
}

.card:hover .play-icon { opacity: 0; }

.play-icon svg {
  width: 48px;
  height: 48px;
  fill: rgba(255,255,255,0.9);
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

.card-body {
  padding: 12px 14px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-author {
  font-size: 11px;
  color: var(--text-muted);
}

.author-link {
  color: var(--text-muted);
  text-decoration: none;
}
.author-link:hover { color: var(--text); }

.card-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: auto;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn {
  background: var(--accent);
  color: #fff;
}
.btn:hover { background: var(--accent-dim); }

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

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 6px;
  flex: 1;
}

.btn-sm-header {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-sm-header.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-full {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  border-radius: 8px;
}

.add-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ── Empty states ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 2;
}

.empty-state strong { color: var(--text); }

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

.hidden { display: none !important; }

/* ── Modal ────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
}

#modal-video {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 60vh;
  background: #000;
  display: block;
  object-fit: contain;
}

.modal-meta {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn,
.modal-actions .btn-outline {
  flex: 1;
  padding: 9px 14px;
  font-size: 13px;
}

.modal-date {
  font-size: 11px;
  color: var(--text-muted);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}

.modal-close:hover { background: rgba(0,0,0,0.9); }

/* ── Copy feedback ────────────────────────────────────── */
.btn.copied { background: #2a7d4f; }

/* ── Floating add button ──────────────────────────────── */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  border: none;
  cursor: pointer;
  z-index: 150;
  box-shadow: 0 4px 20px rgba(225, 48, 108, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.fab:hover { background: var(--accent-dim); transform: scale(1.08); }

/* ── Add reel modal ───────────────────────────────────── */
.add-modal-content {
  padding: 28px 24px 24px;
  gap: 16px;
  display: flex;
  flex-direction: column;
  max-width: 420px;
}

.add-modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.url-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.url-input:focus { border-color: var(--accent); }
.url-input::placeholder { color: var(--text-muted); }

.add-status {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  line-height: 1.5;
}
.add-status.status-loading {
  background: var(--surface-2);
  color: var(--text-muted);
}
.add-status.status-success {
  background: rgba(42, 125, 79, 0.2);
  color: #5dba87;
  border: 1px solid rgba(42, 125, 79, 0.3);
}
.add-status.status-error {
  background: rgba(200, 50, 50, 0.15);
  color: #e06060;
  border: 1px solid rgba(200, 50, 50, 0.25);
}

/* ── Embed card ───────────────────────────────────────── */
.card-thumb.embed-thumb {
  background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
  position: relative;
}

/* Actual thumbnail image — sits on top of gradient fallback */
.embed-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Overlay: IG badge + optional label — always visible */
.embed-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0,0,0,0.28);
  transition: background 0.15s;
}

.card:hover .embed-overlay { background: rgba(0,0,0,0.15); }

.embed-badge {
  width: 36px;
  height: 36px;
  opacity: 0.9;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.4));
}

.embed-label {
  font-size: 10px;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

/* embed modal — native image view */
.modal-embed-wrap {
  width: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-thumb-img {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  display: block;
}

.modal-thumb-placeholder {
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ── Carousel count badge on cards ───────────────────── */
.carousel-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  z-index: 3;
  pointer-events: none;
}

/* ── Delete button on cards ───────────────────────────── */
.card-delete {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(180, 30, 30, 0.85);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background 0.15s, transform 0.15s;
  backdrop-filter: blur(4px);
}
.card-delete:hover { background: #c0392b; transform: scale(1.1); }

body.edit-mode .card-delete { display: flex; }
body.edit-mode .card { cursor: default; }
body.edit-mode .card:hover { transform: none; }

/* ── Repo size ────────────────────────────────────────── */
.repo-size {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Modal prev/next navigation ───────────────────────── */
.modal-nav {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
  position: relative;
}
.modal-nav:hover { background: rgba(0,0,0,0.9); }
.modal-nav.hidden { visibility: hidden; pointer-events: none; }

/* ── Carousel in modal ────────────────────────────────── */
.modal-carousel-wrap {
  width: 100%;
  background: #000;
  position: relative;
  overflow: hidden;
}

.carousel-track {
  display: flex;
  transition: transform 0.3s ease;
}

.carousel-item { min-width: 100%; }

.carousel-media {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  display: block;
}

.carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 2;
}

.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}
.carousel-dot.active { background: #fff; }

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.carousel-btn:hover { background: rgba(0,0,0,0.85); }
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }

/* ── Responsive tweaks ────────────────────────────────── */
@media (max-width: 500px) {
  .header-inner { gap: 12px; }
  h1 { font-size: 16px; }
  .search-wrap { max-width: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .fab { bottom: 20px; right: 20px; width: 50px; height: 50px; font-size: 24px; }
}
