/* ============================================================
   Vaultmall — flat, minimal, rounded. No glows, no gradients.
   ============================================================ */

:root {
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --gap: 16px;
  --sidebar-w: 264px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --speed: 0.28s;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---- Dark theme (default) ---- */
[data-theme="dark"] {
  --bg: #0e1013;
  --surface: #16191e;
  --surface-2: #1d2127;
  --surface-3: #262b33;
  --border: #2a2f37;
  --text: #eef1f5;
  --muted: #9aa3af;
  --faint: #6b7280;
  --accent: #6366f1;
  --accent-ink: #ffffff;
  --danger: #ef4444;
  --ok: #22c55e;
}

/* ---- Light theme ---- */
[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --surface-3: #e7e9ee;
  --border: #e2e5ea;
  --text: #14171c;
  --muted: #5b6572;
  --faint: #8b94a1;
  --accent: #5b5bd6;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
a { color: var(--accent); }

/* ---------- Logo mark (flat) ---------- */
.logo-mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--accent);
  position: relative;
  flex-shrink: 0;
}
.logo-mark::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 5px;
  background: var(--accent-ink);
  opacity: 0.92;
}
.logo-mark.small { width: 30px; height: 30px; border-radius: 9px; }
.logo-mark.small::after { inset: 8px; border-radius: 4px; }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity 0.4s var(--ease);
}
.splash.fade { opacity: 0; pointer-events: none; }
.splash-logo {
  display: flex; align-items: center; gap: 14px;
  font-size: 26px; font-weight: 800; letter-spacing: -0.02em;
  animation: floatUp 0.6s var(--ease);
}
.splash-logo .logo-mark { animation: pulseScale 1.4s var(--ease) infinite; }

@keyframes pulseScale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@keyframes floatUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   AUTH
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  animation: fadeIn 0.5s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.auth-brand {
  background: var(--surface);
  padding: 64px 56px;
  display: flex; flex-direction: column; justify-content: center;
  border-right: 1px solid var(--border);
}
.auth-brand .logo-mark { width: 54px; height: 54px; border-radius: 16px; margin-bottom: 28px; }
.auth-brand .logo-mark::after { inset: 15px; border-radius: 7px; }
.auth-brand h1 { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; }
.auth-brand > p { color: var(--muted); font-size: 18px; margin-top: 10px; max-width: 420px; }
.auth-points { list-style: none; margin-top: 40px; display: grid; gap: 16px; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-a { background: #6366f1; }
.dot-b { background: #14b8a6; }
.dot-c { background: #f59e0b; }

.auth-card {
  display: flex; flex-direction: column; justify-content: center;
  padding: 64px 56px;
  max-width: 480px; width: 100%; margin: 0 auto;
}
.auth-tabs {
  display: flex; background: var(--surface-2); border-radius: var(--radius);
  padding: 5px; margin-bottom: 28px;
}
.auth-tab {
  flex: 1; padding: 11px; border-radius: 10px; font-weight: 600; color: var(--muted);
  transition: all var(--speed) var(--ease);
}
.auth-tab.is-active { background: var(--surface); color: var(--text); }

.auth-form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .config-body input, .config-body select {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  color: var(--text);
  font-size: 15px;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
  outline: none;
  width: 100%;
}
.field input:focus, .config-body input:focus, .config-body select:focus {
  border-color: var(--accent);
  background: var(--surface);
}
.auth-error {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
}
.auth-fineprint { color: var(--faint); font-size: 12.5px; text-align: center; margin-top: 20px; }

/* ---------- Buttons ---------- */
.btn {
  padding: 12px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 15px;
  transition: transform var(--speed) var(--ease), background var(--speed) var(--ease), opacity var(--speed) var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.6; pointer-events: none; }

.link-btn { color: var(--accent); font-size: 12.5px; font-weight: 600; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
}
.sidebar-top { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; }
.sidebar-brand { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-heading {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--faint); padding: 18px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: 14.5px;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
  padding: 1px 8px; border-radius: 999px;
}

.sidebar-bottom { display: flex; flex-direction: column; gap: 3px; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 10px 8px 2px; }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent);
  color: var(--accent-ink); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0; text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-weight: 600; font-size: 14px; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 20px 28px; border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.count-pill {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); padding: 3px 11px; border-radius: 999px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.search { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 13px; color: var(--faint); font-size: 16px; }
.search input {
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 14px 10px 36px; color: var(--text); font-size: 14px; width: 240px;
  transition: border-color var(--speed) var(--ease), width var(--speed) var(--ease);
  outline: none;
}
.search input:focus { border-color: var(--accent); width: 280px; }

.segmented { display: flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; }
.seg {
  padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted);
  transition: all var(--speed) var(--ease);
}
.seg.is-active { background: var(--surface); color: var(--text); }

/* ---------- Content / grid ---------- */
.content { flex: 1; overflow-y: auto; padding: 24px 28px 60px; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--gap);
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease);
  animation: cardIn 0.4s var(--ease) backwards;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.card-thumb {
  aspect-ratio: 1 / 1; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.card-thumb img, .card-thumb video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.5s var(--ease);
}
.card:hover .card-thumb img { transform: scale(1.05); }
.card-thumb .placeholder-icon { font-size: 34px; color: var(--faint); }
.card-badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--surface); color: var(--text);
  font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 7px;
  display: flex; align-items: center; gap: 5px;
}
.card-badge .swatch { width: 7px; height: 7px; border-radius: 2px; }
.type-tag {
  position: absolute; bottom: 8px; right: 8px;
  background: var(--surface); color: var(--muted);
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; text-transform: uppercase;
}
.card-meta { padding: 10px 12px; }
.card-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

/* Skeleton */
.skel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.skel-thumb { aspect-ratio: 1/1; background: var(--surface-2); animation: shimmer 1.3s var(--ease) infinite; }
.skel-line { height: 10px; margin: 12px; border-radius: 6px; background: var(--surface-2); animation: shimmer 1.3s var(--ease) infinite; }
.skel-line.short { width: 55%; }
@keyframes shimmer { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 80px 20px; gap: 8px; animation: fadeIn 0.5s var(--ease);
}
.empty-illustration {
  width: 90px; height: 90px; border-radius: var(--radius-lg);
  background: var(--surface-2); border: 2px dashed var(--border); margin-bottom: 14px;
  position: relative;
}
.empty-illustration::after {
  content: "▦"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: var(--faint);
}
.empty-state h3 { font-size: 20px; font-weight: 700; }
.empty-state p { color: var(--muted); margin-bottom: 12px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, #000 55%, transparent);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.2s var(--ease);
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto; padding: 26px;
  animation: modalIn 0.3s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.modal-sub { color: var(--muted); font-size: 14px; margin-top: 6px; margin-bottom: 20px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--muted);
  transition: background var(--speed) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.provider-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.provider {
  display: flex; align-items: center; gap: 13px; padding: 15px;
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--radius);
  transition: border-color var(--speed) var(--ease), transform var(--speed) var(--ease);
  text-align: left; position: relative;
}
.provider:hover { border-color: var(--accent); transform: translateY(-2px); }
.provider .p-icon {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; color: #fff;
}
.provider .p-name { font-weight: 700; font-size: 14.5px; }
.provider .p-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.provider.soon { opacity: 0.62; pointer-events: none; }
.provider .soon-tag {
  position: absolute; top: 10px; right: 10px; font-size: 9.5px; font-weight: 700;
  background: var(--surface-3); color: var(--muted); padding: 2px 7px; border-radius: 6px; text-transform: uppercase;
}
.provider.connected .p-check {
  position: absolute; top: 10px; right: 10px; color: var(--ok); font-weight: 800;
}

.config-body { display: grid; gap: 16px; }
.config-body .field { display: grid; gap: 7px; }
.config-body label > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.config-hint { font-size: 12.5px; color: var(--faint); line-height: 1.55; }
.config-hint code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.config-actions { display: flex; gap: 10px; margin-top: 6px; }
.config-note {
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 13px 15px;
  font-size: 12.5px; color: var(--muted); line-height: 1.6;
}
.config-note strong { color: var(--text); }

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: color-mix(in srgb, #000 88%, transparent);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s var(--ease);
}
.lightbox-stage { max-width: 88vw; max-height: 82vh; display: flex; align-items: center; justify-content: center; }
.lightbox-stage img, .lightbox-stage video {
  max-width: 88vw; max-height: 82vh; border-radius: var(--radius); object-fit: contain;
  animation: modalIn 0.3s var(--ease);
}
.lightbox-close { position: absolute; top: 22px; right: 22px; background: var(--surface); }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border-radius: 50%; background: var(--surface); color: var(--text);
  font-size: 28px; display: flex; align-items: center; justify-content: center;
  transition: transform var(--speed) var(--ease);
}
.lightbox-nav:hover { transform: translateY(-50%) scale(1.08); }
.lightbox-nav.prev { left: 22px; }
.lightbox-nav.next { right: 22px; }
.lb-loading {
  color: var(--text); background: var(--surface);
  padding: 22px 28px; border-radius: var(--radius); font-weight: 600;
  animation: shimmer 1.3s var(--ease) infinite;
}
.lightbox-caption {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface); padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 500;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 13px 17px; font-size: 14px; font-weight: 500;
  min-width: 240px; max-width: 340px;
  animation: toastIn 0.3s var(--ease);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast .toast-title { font-weight: 700; margin-bottom: 2px; }
.toast .toast-msg { color: var(--muted); font-size: 12.5px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut 0.3s var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; z-index: 40;
    flex-direction: row; padding: 8px; border-right: none; border-top: 1px solid var(--border);
    height: auto; overflow-x: auto;
  }
  .sidebar-top, .sidebar-bottom .user-chip, .nav-heading { display: none; }
  .nav { flex-direction: row; }
  .sidebar-bottom { flex-direction: row; border-top: none; padding-top: 0; }
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .topbar-right { flex-wrap: wrap; }
  .search input, .search input:focus { width: 100%; }
  .content { padding-bottom: 90px; }
  .provider-grid { grid-template-columns: 1fr; }
}
