/* ==========================================================================
   Best-Self.AI – Global Styles (Sphere Aesthetic) [patched]
   Changes:
   • Touch targets: ensure ≥44px (nav links + .btn)
   • Mobile menu: allow scroll if long (overflow-y:auto)
   • Gallery grid: fit small phones (minmax 140px)
   Everything else retained.
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }
html, body { height: 100%; }
html:focus-within { scroll-behavior: smooth; }

body {
  margin: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  color: #e8ebf0;
  background: radial-gradient(1200px 800px at 10% -10%, rgba(88, 147, 255, 0.25), transparent 60%),
              radial-gradient(900px 700px at 110% 10%, rgba(214, 94, 255, 0.18), transparent 60%),
              linear-gradient(180deg, #0a0d14 0%, #090a10 60%, #07080c 100%);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  overflow-y: auto;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }

:root {
  --bg-0: #07080c;
  --bg-1: #0b0f18;
  --bg-2: #0e1420;
  --card: #0e1320;
  --muted: #a6afbf;
  --muted-2: #93a0b5;
  --brand: #8ab4ff;
  --brand-2: #b58bff;
  --accent: #5de5c9;
  --danger: #ff5c7a;
  --warn: #ffd66b;
  --success: #56f59a;
  --outline: rgba(255,255,255,0.08);
  --glow: 0 0 0 1px rgba(138,180,255,0.22), 0 10px 30px -10px rgba(138,180,255,0.35);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 30px rgba(0,0,0,0.45);
  --radius: 16px;
  --radius-xl: 22px;
}

/* ------------------------------
   Layout: Shell & Header
   ------------------------------ */
.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background:
    radial-gradient(600px 200px at 0% -40%, rgba(138,180,255,0.25), transparent 60%),
    linear-gradient(180deg, rgba(12,16,26,0.8), rgba(12,16,26,0.6));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--outline);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Brand */
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  white-space: nowrap;
}
.brand-title {
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: clamp(18px, 2.8vw, 22px);
  line-height: 1.1;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #fff, #8ab4ff);
  box-shadow: 0 0 20px #8ab4ff;
  flex: 0 0 auto;
}

/* Desktop nav left-aligned */
.nav-desktop {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: 12px;
}
.nav-desktop a, .nav-desktop button.nav-btn {
  text-decoration: none;
  color: #dfe7ff;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  transition: 120ms ease;
  min-height: 44px;           /* touch target */
  display: inline-flex;
  align-items: center;
}
.nav-desktop a:hover,
.nav-desktop button.nav-btn:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--outline);
}

/* Right side (token badge) */
.header-spacer { flex: 1; }
.header-right { display: flex; align-items: center; gap: 10px; }

/* Token badge (live balance) */
.token-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(138,180,255,0.15), rgba(138,180,255,0.08));
  border: 1px solid rgba(138,180,255,0.35);
  box-shadow: var(--glow);
  font-weight: 600;
}
.token-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: linear-gradient(180deg, #8ab4ff, #b58bff);
}

/* Hamburger (mobile) */
.hamburger {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.04));
  cursor: pointer;
}
.hamburger .bars { width: 18px; height: 12px; position: relative; }
.hamburger .bars::before,
.hamburger .bars::after,
.hamburger .bars span {
  content: ""; position: absolute; left: 0; right: 0; height: 2px; background: #dfe7ff; border-radius: 2px;
}
.hamburger .bars::before { top: 0; }
.hamburger .bars::after  { bottom: 0; }
.hamburger .bars span     { top: 50%; transform: translateY(-50%); }

/* Mobile menu sheet */
.mobile-menu {
  display: none;
  position: fixed; inset: 0;
  z-index: 60;
  background:
    radial-gradient(800px 240px at 20% -20%, rgba(138,180,255,0.22), transparent 60%),
    linear-gradient(180deg, rgba(10,13,20,0.88), rgba(10,13,20,0.88));
  backdrop-filter: blur(8px);
  overflow-y: auto;        /* allow scroll on small screens */
}
.mobile-menu[data-open="true"] { display: block; }
.mobile-menu .sheet {
  max-width: 1100px; margin: 64px auto 16px; padding: 0 16px;
}
.mobile-menu .list {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid var(--outline);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.mobile-menu a {
  display: block;
  padding: 14px 16px;
  color: #e8ebf0;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: 44px;        /* touch target */
}
.mobile-menu a:last-child { border-bottom: 0; }
.mobile-menu a:hover { background: rgba(255,255,255,0.06); }

/* Hide nav on auth pages */
body.auth .nav-desktop { display: none; }
body.auth .hamburger { display: none; }
body.auth .header-right { display: none; }

/* ------------------------------
   Main Container + Cards
   ------------------------------ */
.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px 64px;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.card.pad { padding: 18px; }
.card.pad-lg { padding: 22px; }
.card + .card { margin-top: 18px; }

/* ------------------------------
   Forms
   ------------------------------ */
.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 8px; }
.label { font-size: 14px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--outline);
  color: #e8ebf0;
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  transition: 120ms ease;
  min-height: 44px;                 /* touch */
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(138,180,255,0.55);
  box-shadow: 0 0 0 4px rgba(138,180,255,0.15);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(138,180,255,0.18), rgba(138,180,255,0.14));
  color: #f2f6ff; cursor: pointer; font-weight: 600; transition: 120ms ease;
  min-height: 44px;                 /* touch */
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.04));
  border: 1px solid var(--outline);
}
.btn-danger {
  background: linear-gradient(180deg, rgba(255,92,122,0.2), rgba(255,92,122,0.14));
  border: 1px solid rgba(255,92,122,0.45);
}
.btn-success {
  background: linear-gradient(180deg, rgba(86,245,154,0.18), rgba(86,245,154,0.14));
  border: 1px solid rgba(86,245,154,0.45);
}

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

/* ------------------------------
   Grid / Tiles
   ------------------------------ */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); }
.col-12 { grid-column: span 12; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }
@media (max-width: 900px) {
  .col-md-12 { grid-column: span 12; }
  .col-md-6  { grid-column: span 6; }
  .col-md-4  { grid-column: span 4; }
}
@media (max-width: 640px) {
  .col-sm-12 { grid-column: span 12; }
  .col-sm-6  { grid-column: span 6; }
}

.tile {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid var(--outline);
  border-radius: 18px;
  padding: 16px; min-height: 120px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow-card); transition: 150ms ease;
  text-decoration: none; color: inherit;
}
.tile:hover { transform: translateY(-2px); border-color: rgba(138,180,255,0.35); box-shadow: var(--glow); }
.tile-title { font-weight: 700; letter-spacing: 0.2px; }
.tile-sub { color: var(--muted); font-size: 13px; }

.tile.locked { opacity: 0.8; border-style: dashed; border-color: rgba(255,255,255,0.18); }
.lock-badge {
  position: absolute; top: 12px; right: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid rgba(255,214,107,0.5);
  background: linear-gradient(180deg, rgba(255,214,107,0.18), rgba(255,214,107,0.1));
  font-size: 12px; color: #ffe6a1;
}

/* ------------------------------
   Media: 16:9 Responsive Embeds
   ------------------------------ */
.embed-16x9 {
  position: relative; width: 100%; padding-top: 56.25%;
  border-radius: 14px; overflow: hidden; background: #0b0f18;
  border: 1px solid var(--outline); box-shadow: var(--shadow-card);
}
.embed-16x9 > iframe, .embed-16x9 > video {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}

/* ------------------------------
   Uploader (Vision Board)
   ------------------------------ */
.dropzone {
  display: grid; align-items: center; justify-items: center; text-align: center; gap: 10px;
  padding: 22px; border: 1.5px dashed rgba(255,255,255,0.22);
  border-radius: 18px;
  background:
    radial-gradient(300px 100px at 10% -20%, rgba(138,180,255,0.2), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
}
.dropzone.dragover { border-color: rgba(138,180,255,0.6); box-shadow: 0 0 0 6px rgba(138,180,255,0.15); }

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

/* User image grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); /* was 160px */
  gap: 12px;
}
.gallery-item {
  background: #0b0f18; border: 1px solid var(--outline);
  border-radius: 12px; overflow: hidden;
}
.gallery-item a { display: block; }



/* Preview tray for selected images */
.preview-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.preview{
  position:relative;
  border:1px solid var(--outline);
  background:#0b0f18;
  border-radius:12px;
  overflow:hidden;
}
.preview img{
  display:block;
  width:100%; height:84px; object-fit:cover;
}
.preview-remove{
  position:absolute; top:6px; right:6px;
  width:26px; height:26px; border-radius:999px;
  border:1px solid var(--outline); background:rgba(0,0,0,.45);
  color:#fff; font-weight:700; line-height:1; cursor:pointer;
}

/* Keep CTA below the dashed border so no line crosses the button */
.vb-cta{
  position:relative;
  margin-top: 16px;    /* pushes CTA below the dashed border */
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  z-index: 1;
}

/* Small-screen padding tweak so footer line never overlaps CTA */
@media (max-width: 480px){
  .card.pad-lg { padding-bottom: 28px; }
}


/* ------------------------------
   Tables (Admin)
   ------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { border-bottom: 1px solid rgba(255,255,255,0.06); padding: 10px 8px; vertical-align: top; }
.table th { color: var(--muted-2); text-align: left; font-weight: 600; }
.table .num { text-align: right; }
.table .act { display: inline-flex; gap: 8px; }

/* ------------------------------
   Alerts / Messages
   ------------------------------ */
.alert {
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--outline);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}
.alert-info    { border-color: rgba(138,180,255,0.35); background: linear-gradient(180deg, rgba(138,180,255,0.14), rgba(138,180,255,0.08)); }
.alert-success { border-color: rgba(86,245,154,0.45); background: linear-gradient(180deg, rgba(86,245,154,0.14), rgba(86,245,154,0.08)); }
.alert-warn    { border-color: rgba(255,214,107,0.5); background: linear-gradient(180deg, rgba(255,214,107,0.14), rgba(255,214,107,0.08)); }
.alert-danger  { border-color: rgba(255,92,122,0.5); background: linear-gradient(180deg, rgba(255,92,122,0.14), rgba(255,92,122,0.08)); }

/* ------------------------------
   Footer
   ------------------------------ */
.footer {
  border-top: 1px solid var(--outline);
  background: linear-gradient(180deg, #0b0f18, #0a0d14);
  color: var(--muted);
  font-size: 13px;
}
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 18px 16px; }

/* ------------------------------
   Utilities
   ------------------------------ */
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.space { height: 14px; }
.space-lg { height: 22px; }
.badge { display: inline-block; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--outline); font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ------------------------------
   Accessibility
   ------------------------------ */
:focus-visible { outline: 2px solid #8ab4ff; outline-offset: 2px; border-radius: 6px; }

/* ------------------------------
   Responsive header behavior
   ------------------------------ */
@media (max-width: 860px) {
  .nav-desktop { display: none; }
  .hamburger { display: inline-flex; }
}
@media (max-width: 480px) {
  .header-inner { padding: 12px 14px; }
  .token-badge { padding: 5px 8px; }
  .container { margin-top: 18px; padding-bottom: 48px; }
  .tile { min-height: 110px; }
}

/* Inline success/error alert */
.inline-alert{
  margin-top:12px; padding:10px 12px; border-radius:12px;
  border:1px solid var(--outline);
  background: linear-gradient(180deg, rgba(86,245,154,.14), rgba(86,245,154,.08));
}
.inline-alert.error{
  background: linear-gradient(180deg, rgba(255,92,122,.14), rgba(255,92,122,.08));
  border-color: rgba(255,92,122,.45);
}

/* Keep CTA visually outside dashed dropzone */
.vb-cta{ position:relative; margin-top:16px; display:flex; align-items:center; gap:10px; flex-wrap:wrap; z-index:1; }

/* Busy spinner for buttons */
.btn[aria-busy="true"]{ position:relative; pointer-events:none; opacity:.85; }
.btn[aria-busy="true"]::after{
  content:""; position:absolute; right:10px; top:50%; width:14px; height:14px;
  border-radius:50%; border:2px solid #fff; border-top-color:transparent;
  transform:translateY(-50%); animation:spin 1s linear infinite;
}
@keyframes spin{ to{ transform:translateY(-50%) rotate(360deg); } }