:root {
  --bg: #0a0a0c;
  --panel: #141417;
  --panel-alt: #1c1c21;
  --border: #232327;
  --text: #f5f5f7;
  --muted: #93939c;
  --accent: #ff2d78;
  --accent-2: #ff5fa8;
  --accent-deep: #c2185b;
  --ok: #3ddc84;
  --ko: #e0616b;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[x-cloak] { display: none !important; }

a { color: inherit; }

.app-shell { display: flex; min-height: 100vh; }

/* ---- Motion ---- */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes badgePop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* opacity-only on purpose: a `transform` here would make this element a
   containing block for the modal's position:fixed, breaking it */
.content > * { animation: fadeIn 0.35s ease both; }

a, button, input, select,
.navitem, .card, .mini-card, .feed-item, .bubble, .bubble-add,
.mode-btn, .kpi, .mission-card, .status-pill {
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease,
              transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(0) scale(0.97); }

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #0d0d10;
  border-right: 1px solid #202024;
  display: flex;
  flex-direction: column;
  padding: 26px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .logo { padding: 0 0 20px; }
.sidebar .logo img { width: 100%; height: auto; display: block; }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }

.navitem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.navitem:hover { color: var(--text); background: #1a1a1f; transform: translateX(2px); }

.navitem.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 45, 120, 0.18), rgba(255, 45, 120, 0.02));
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.navitem svg { flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  animation: badgePop 0.35s ease;
}

.sidebar .profile {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid #202024;
}

.avatar-fallback {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ---- Main content ---- */

.content { flex: 1; min-width: 0; padding: 32px 40px 48px; }
.content > * { max-width: 1400px; margin-left: auto; margin-right: auto; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-header .subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

.status-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 999px; font-size: 12px; font-weight: 600;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-ok { color: var(--ok); }
.status-ok .status-dot { background: var(--ok); }
.status-ko { color: var(--ko); }
.status-ko .status-dot { background: var(--ko); }

h2.section-label {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; margin: 0 0 16px;
}

input, select, button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

button {
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button:disabled { opacity: 0.4; cursor: not-allowed; }

button.secondary { background: var(--panel); border-color: var(--border); color: var(--text); font-weight: 500; }

/* ---- Channel bubbles ---- */

.bubble-row { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 32px; }

.bubble-item { display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer; }

.bubble {
  width: 92px; height: 92px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-deep));
  background-size: cover; background-position: center;
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative;
}

.bubble-item:hover .bubble { transform: scale(1.06); box-shadow: 0 6px 18px rgba(255, 45, 120, 0.25); }

.bubble-item.selected .bubble {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent);
  transform: scale(1.04);
}

.bubble-add:hover { border-color: var(--accent-2); transform: scale(1.06); }

.bubble-check {
  position: absolute; bottom: -2px; right: -2px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
}

.bubble-label { font-size: 13px; font-weight: 600; color: #c7c7cf; }
.bubble-item.selected .bubble-label { color: #fff; }

.bubble-add {
  width: 92px; height: 92px; border-radius: 50%;
  border: 2px dashed #33333a;
  display: flex; align-items: center; justify-content: center;
}

/* ---- Collection mode ---- */

.mode-row { display: flex; gap: 10px; max-width: 640px; margin-bottom: 28px; flex-wrap: wrap; align-items: center; }

.mode-btn {
  flex: 1; text-align: center; padding: 12px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  white-space: nowrap;
}

.mode-btn:hover { border-color: var(--accent-2); color: var(--text); }
.mode-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.mode-btn.on:hover { color: #fff; }

.mode-btn input { width: 60px; margin-left: 6px; padding: 4px 6px; }

/* ---- Missions ---- */

/* ---- Dashboard ---- */

.hero {
  border-radius: 18px;
  padding: 40px;
  background: linear-gradient(120deg, #2a0716 0%, #0a0a0c 65%);
  border: 1px solid #2a1420;
  position: relative;
  overflow: hidden;
  margin-bottom: 30px;
}

.hero::after {
  content: "";
  position: absolute; right: -60px; top: -80px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 45, 120, 0.35), transparent 70%);
}

.hero .eyebrow { font-size: 11px; letter-spacing: 3px; color: var(--accent-2); font-weight: 600; position: relative; }
.hero h1 { font-size: 40px; font-weight: 800; margin: 6px 0 10px; letter-spacing: 0.5px; position: relative; }
.hero p { font-size: 15px; color: #c7c7cf; max-width: 440px; margin-bottom: 22px; position: relative; }

.hero .cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
  padding: 12px 22px; border-radius: 999px; text-decoration: none; position: relative;
}

.kpi-row { display: flex; gap: 16px; margin-bottom: 32px; flex-wrap: wrap; }

.kpi { flex: 1; min-width: 140px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.kpi .n { font-size: 26px; font-weight: 700; color: #fff; }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 4px; }

.section-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-row .link { font-size: 12px; color: var(--accent-2); font-weight: 600; text-decoration: none; }

.mini-card-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 4px; }
.mini-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; width: 170px; flex-shrink: 0; cursor: pointer; animation: fadeInUp 0.35s ease both; }
.mini-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35); }
.mini-card img { width: 170px; height: 170px; object-fit: cover; display: block; background: #000; }
.mini-card .body { padding: 10px 12px; }
.mini-card strong { display: block; font-size: 12px; }
.mini-card .meta { font-size: 10px; color: var(--muted); margin: 4px 0 6px; }
.mini-card .metrics { font-size: 10px; }

/* ---- Flux ---- */

.live-indicator { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(61, 220, 132, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); }
}

.feed { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }

.feed-item {
  display: flex; gap: 16px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; cursor: pointer;
  animation: fadeInUp 0.4s ease both;
}

.feed-item:hover { transform: translateX(4px); border-color: var(--accent); }

.feed-item img { width: 88px; height: 88px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: #000; }
.feed-item .body { flex: 1; min-width: 0; }
.feed-item .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.feed-item .top strong { font-size: 13px; }
.feed-item .top span { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.feed-item p { font-size: 12px; color: #c7c7cf; margin: 6px 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.mission-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 14px;
  background: var(--panel);
  max-width: 760px;
}

.mission-card .top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.mission-card .who { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s;
}

.mission-stats { display: flex; gap: 20px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

.errors { color: var(--ko); font-size: 12px; margin: 10px 0 0; padding-left: 18px; }

/* ---- Library ---- */

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }

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

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
  animation: fadeInUp 0.35s ease both;
}

.card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35); }

.card img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #000;
  transition: transform 0.3s ease;
}

.card:hover img { transform: scale(1.05); }

.card-body { padding: 12px 14px; }
.card-body strong { display: block; font-size: 12px; }
.card-body span { font-size: 10px; color: var(--muted); }
.card-body p { font-size: 12px; margin: 6px 0; color: var(--text); }

.metrics { display: flex; gap: 10px; font-size: 11px; color: var(--muted); }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 10;
}

.modal-content {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 0; max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto;
  position: relative;
}

.modal-enter { transition: opacity 0.2s ease, transform 0.2s ease; }
.modal-enter-start { opacity: 0; transform: scale(0.94) translateY(8px); }
.modal-enter-end { opacity: 1; transform: scale(1) translateY(0); }

.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  width: 34px; height: 34px; border-radius: 50%; padding: 0;
  background: rgba(10, 10, 12, 0.65); border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-close:hover { background: var(--accent); border-color: var(--accent); }

.modal-photo-wrap {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  background: #000; max-height: 460px;
}

.modal-photo-wrap .photo-slide {
  position: relative; flex: 0 0 100%; scroll-snap-align: start;
  display: flex; align-items: center; justify-content: center;
}

.modal-photo-wrap img { width: 100%; max-height: 460px; object-fit: contain; display: block; }

.photo-download {
  position: absolute; bottom: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; padding: 0;
  background: rgba(10, 10, 12, 0.65); border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); text-decoration: none;
}

.photo-download:hover { background: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

.modal-body { padding: 22px; }

.modal-header-row { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }

.caption-box {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin: 16px 0;
}

.metric-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.metric-pill {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 13px; font-size: 12px; color: var(--text); font-weight: 500;
}

.full-caption { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }

.channel-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 8px;
}

.channel-row .name { font-weight: 600; flex: 1; }
.channel-row .count { color: var(--muted); font-size: 12px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 999px; transition: background 0.15s ease;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s ease;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
