/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --bg:          #0b1020;
  --bg-elev:    #11172a;
  --bg-elev-2:  #161e36;
  --line:       #1f2a44;
  --line-strong:#2c3a5e;
  --text:       #e6ebf5;
  --text-dim:   #94a3b8;
  --text-mute:  #64748b;
  --brand:      #6366f1;
  --brand-hi:   #818cf8;
  --brand-soft: rgba(99, 102, 241, 0.12);
  --success:    #22c55e;
  --warn:       #f59e0b;
  --danger:     #ef4444;
  --radius-lg:  16px;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 12px 40px rgba(0, 0, 0, 0.45);
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 14px;
  background: radial-gradient(1200px 700px at 80% -10%,
                rgba(99,102,241,0.15), transparent 60%),
              radial-gradient(900px 600px at -10% 110%,
                rgba(56,189,248,0.10), transparent 60%),
              var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--brand); color: white; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 6px;
  color: #c7d2fe;
}

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

[hidden] { display: none !important; }

/* ============================================================
   Views & layout shells
   ============================================================ */
.view { min-height: 100vh; display: flex; flex-direction: column; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Splash ---------------------------------------------------- */
.splash { align-items: center; justify-content: center; gap: 24px; }
.spinner {
  width: 28px; height: 28px;
  border: 2px solid rgba(255,255,255,0.12);
  border-top-color: var(--brand-hi);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Auth split layout ----------------------------------------- */
.auth-layout {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .brand-panel { display: none; }
}

.brand-panel {
  position: relative;
  padding: 40px 48px;
  background:
    radial-gradient(800px 400px at 20% 0%, rgba(99,102,241,0.30), transparent 60%),
    radial-gradient(800px 400px at 80% 100%, rgba(56,189,248,0.22), transparent 60%),
    linear-gradient(180deg, #0a0f1f 0%, #0b1224 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.brand-panel::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  pointer-events: none;
}
.brand-panel > * { position: relative; }

.brand-mark {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; letter-spacing: -0.01em;
}
.brand-mark.sm { font-size: 14px; }
.logo-dot {
  width: 22px; height: 22px;
  background: linear-gradient(135deg, var(--brand) 0%, #38bdf8 100%);
  border-radius: 6px;
  box-shadow: 0 0 24px rgba(99,102,241,0.55);
  position: relative;
}
.logo-dot::after {
  content: ""; position: absolute; inset: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 3px;
}
.brand-mark.sm .logo-dot { width: 18px; height: 18px; border-radius: 5px; }
.brand-mark.sm .logo-dot::after { inset: 3px; border-radius: 2px; }

.brand-hero h1 {
  font-size: 40px; line-height: 1.08; margin: 0 0 14px;
  letter-spacing: -0.02em; font-weight: 700;
  background: linear-gradient(180deg, #fff 0%, #c7d2fe 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-hero p { margin: 0; max-width: 380px; color: var(--text-dim); line-height: 1.55; }

.brand-feats { display: flex; flex-direction: column; gap: 14px; }
.feat {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
.feat-dot {
  width: 8px; height: 8px; margin-top: 7px; border-radius: 50%;
  background: var(--brand-hi);
  box-shadow: 0 0 0 4px var(--brand-soft);
  flex-shrink: 0;
}
.feat h4 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.feat p  { margin: 0; font-size: 12px; color: var(--text-dim); }
.brand-foot { color: var(--text-mute); font-size: 12px; }

/* Form panel ------------------------------------------------ */
.form-panel {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 32px; gap: 18px;
}
.form-card {
  width: 100%; max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  animation: rise 320ms cubic-bezier(.2,.7,.2,1);
}
.form-card header { margin-bottom: 22px; }
.form-card h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.form-card .muted { font-size: 13px; }

/* Form fields ----------------------------------------------- */
.field { display: block; margin-bottom: 14px; }
.field span {
  display: block; margin-bottom: 6px;
  font-size: 12px; color: var(--text-dim); font-weight: 500;
  letter-spacing: 0.01em;
}
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder { color: var(--text-mute); }
input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Buttons --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font-family: var(--font-sans);
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-primary {
  width: 100%;
  background: linear-gradient(180deg, var(--brand) 0%, #4f46e5 100%);
  color: white;
  box-shadow: 0 6px 18px rgba(99,102,241,0.35);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--brand-hi) 0%, var(--brand) 100%);
}
.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255,255,255,0.04);
  border-color: var(--text-mute);
}
.btn-sm { padding: 7px 12px; font-size: 12px; }

.btn-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.04); color: var(--text); }

/* Alert ----------------------------------------------------- */
.alert {
  margin-top: 16px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: rgba(11, 16, 32, 0.80);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px; color: var(--text-dim);
}
.status-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-mute);
  box-shadow: 0 0 0 3px transparent;
  transition: all 200ms ease;
}
.status-pill.is-up .dot { background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }
.status-pill.is-down .dot { background: var(--danger);  box-shadow: 0 0 0 3px rgba(239,68,68,0.18); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, #38bdf8 100%);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; color: white;
  text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta span:first-child { font-size: 12px; font-weight: 500; }

/* ============================================================
   Dashboard / zip list
   ============================================================ */
.dashboard {
  flex: 1;
  padding: 32px 28px 60px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  animation: rise 320ms cubic-bezier(.2,.7,.2,1);
}

.page-head { margin-bottom: 24px; }
.page-head h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -0.015em;
}
.page-head p { margin: 0; }

.zip-list {
  display: grid; gap: 12px;
  grid-template-columns: 1fr;
}

.zip-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color 200ms;
}
.zip-card:hover { border-color: var(--line-strong); }

.zip-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, rgba(99,102,241,0.20), rgba(56,189,248,0.12));
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.zip-meta h4 {
  margin: 0 0 4px;
  font-size: 14px; font-weight: 600;
  word-break: break-all;
}
.zip-meta .meta-row {
  display: flex; gap: 14px; align-items: center;
  font-size: 12px; color: var(--text-dim);
  flex-wrap: wrap;
}
.zip-meta .meta-row .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  font-size: 11.5px;
}
.pill.is-success { color: #86efac; border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.08); }
.pill.is-pending { color: var(--text-mute); }
.pill.is-mine    { color: #c7d2fe; border-color: rgba(99,102,241,0.4); background: rgba(99,102,241,0.10); }
.pill.is-shared  { color: #fde68a; border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.10); }

.zip-actions { display: flex; gap: 8px; }

/* Empty state ----------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  background: var(--bg-elev);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}
.empty-art { font-size: 56px; margin-bottom: 18px; opacity: 0.7; }
.empty-state h3 { margin: 0 0 8px; font-size: 16px; }
.empty-state p  { margin: 0; }

/* ============================================================
   Gallery & lightbox
   ============================================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.gallery-tile {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 140ms, border-color 140ms;
}
.gallery-tile:hover { transform: translateY(-2px); border-color: var(--brand); }
.gallery-tile img {
  width: 100%; height: 180px; object-fit: cover;
  display: block;
  background: var(--bg);
}
.gallery-tile .gallery-name {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.lightbox {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.94);
  display: grid;
  grid-template-rows: auto 1fr auto;
  animation: rise 160ms ease;
}

.lightbox-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  z-index: 2;
}

.lightbox-stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  padding: 16px 60px;
  overflow: hidden;
}
.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
  background: #1a1a1a;
  display: block;
}

.lightbox-meta {
  display: flex; gap: 12px; align-items: baseline;
  color: var(--text-dim);
  font-size: 13px;
}

.filter-bar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 18px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  z-index: 2;
}
.filter-row, .slider-row {
  display: flex; gap: 14px; align-items: center;
  flex-wrap: wrap; justify-content: center;
}
.slider-row { padding-top: 4px; }

.slider-control {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
}
.slider-label {
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10.5px;
  color: var(--text-mute);
  min-width: 70px;
}
.slider-value {
  font-family: var(--font-mono);
  color: var(--text);
  min-width: 32px;
  text-align: right;
  font-size: 11px;
}
.slider-control input[type="range"] {
  width: 140px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  margin: 0;
  padding: 0;
}
.slider-control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}
.slider-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--brand-hi);
  border-radius: 50%;
  border: 2px solid #fff;
  margin-top: -5px;
  box-shadow: 0 2px 6px rgba(99,102,241,0.5);
}
.slider-control input[type="range"]::-moz-range-track {
  height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}
.slider-control input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--brand-hi);
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(99,102,241,0.5);
}
.slider-control.is-active { border-color: var(--brand); background: rgba(99,102,241,0.10); }
.filter-bar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 600;
}
.filter-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
  text-transform: capitalize;
}
.filter-btn:hover:not(:disabled) {
  border-color: var(--brand-hi);
  color: var(--text);
  background: rgba(255,255,255,0.04);
}
.filter-btn.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.filter-btn:disabled { opacity: 0.5; cursor: wait; }
.lightbox-close, .lightbox-prev, .lightbox-next {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover {
  background: rgba(255,255,255,0.14);
}
.lightbox-close {
  width: 36px; height: 36px;
  font-size: 22px;
}
.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px;
  font-size: 26px;
  z-index: 1;
}
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }

/* ============================================================
   Modal (OTP)
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: rise 200ms ease;
}
.modal-card {
  width: 100%; max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h3 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.modal-card .muted {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
}
#otp-code {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  margin-bottom: 12px;
}

/* ============================================================
   Fun unlock modal
   ============================================================ */
.fun-card { max-width: 480px; position: relative; overflow: hidden; }

.fun-target {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.5px;
  margin: 14px 0 12px;
  text-align: center;
  padding: 18px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  user-select: none;
  line-height: 1.6;
}
.fun-target span {
  display: inline-block;
  transition: color 120ms, text-shadow 200ms, transform 120ms;
}
.fun-target span.matched {
  color: #22c55e;
  text-shadow: 0 0 12px rgba(34,197,94,0.55);
  transform: translateY(-1px);
}
.fun-target span.pending { color: var(--text-mute); }
.fun-target span.wrong {
  color: var(--danger);
  animation: fun-shake 0.35s;
}

#fun-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.5px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  margin-top: 4px;
}
#fun-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.fun-progress {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 6px;
}
#fun-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), #22c55e);
  transition: width 180ms ease;
  box-shadow: 0 0 12px rgba(99,102,241,0.4);
}

.fun-status {
  text-align: center;
  font-size: 12px;
  font-family: var(--font-mono);
  margin: 4px 0 0;
}

.fun-card.is-unlocked {
  animation: fun-celebrate 900ms;
  border-color: var(--success) !important;
  box-shadow: 0 0 80px rgba(34,197,94,0.55) !important;
}
.fun-card.is-unlocked #fun-bar {
  background: linear-gradient(90deg, #22c55e, #84cc16);
}

@keyframes fun-celebrate {
  0%   { transform: scale(1); }
  20%  { transform: scale(1.04); }
  40%  { transform: scale(0.99); }
  60%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}
@keyframes fun-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

/* Confetti pieces — pure CSS bursts on unlock */
.fun-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.fun-confetti span {
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 12px;
  border-radius: 2px;
  opacity: 0;
}
.fun-card.is-unlocked .fun-confetti span {
  animation: confetti-fly 1100ms ease-out forwards;
}
@keyframes confetti-fly {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0;
         transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

/* ============================================================
   Toasts
   ============================================================ */
.toast-host {
  position: fixed; right: 22px; bottom: 22px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 50; pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 11px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  animation: rise 180ms ease;
  max-width: 360px;
}
.toast.is-success { border-color: rgba(34,197,94,0.4); }
.toast.is-error   { border-color: rgba(239,68,68,0.4); }
