/* Pro Manage — Futuristic Dark UI v2 */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
  --ink-950:  #080c14;
  --ink-900:  #0d1220;
  --ink-800:  #111827;
  --ink-700:  #1c2535;
  --ink-600:  #253047;
  --ink-500:  #334155;
  --ink-400:  #475569;
  --ink-300:  #64748b;
  --ink-200:  #94a3b8;
  --ink-100:  #cbd5e1;
  --ink-050:  #f1f5f9;

  --gold:      #c9a84c;
  --gold-soft: rgba(201,168,76,.14);
  --gold-glow: rgba(201,168,76,.28);

  --emerald:      #10b981;
  --emerald-soft: rgba(16,185,129,.12);
  --emerald-glow: rgba(16,185,129,.28);

  --amber:      #f59e0b;
  --amber-soft: rgba(245,158,11,.12);

  --violet:      #8b5cf6;
  --violet-soft: rgba(139,92,246,.12);

  --sky:      #38bdf8;
  --sky-soft: rgba(56,189,248,.12);

  --glass-bg:     rgba(17,24,39,.72);
  --glass-border: rgba(255,255,255,.07);

  --surface-1: #111827;

  --shadow-sm:  0 2px 8px rgba(0,0,0,.4);
  --shadow-md:  0 8px 32px rgba(0,0,0,.48);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.6);

  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  18px;
  --r-xl:  22px;
  --r-2xl: 28px;

  --font-sans: 'Sora', 'SF Pro Display', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --safe-top:    env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-sans);
  color: var(--ink-050);
  background: var(--ink-950);
  background-image:
    radial-gradient(ellipse 110% 55% at 50% -15%, rgba(56,189,248,.08) 0%, transparent 60%),
    radial-gradient(ellipse 65% 45% at 88% 85%, rgba(201,168,76,.06) 0%, transparent 55%),
    radial-gradient(ellipse 55% 40% at 8%  65%, rgba(139,92,246,.05) 0%, transparent 55%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.hidden { display: none !important; }

/* ─── Grid texture ───────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.008) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.008) 1px, transparent 1px);
  background-size: 52px 52px;
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1024px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* ─── Topbar ────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: var(--safe-top);
  background: rgba(8,12,20,.68);
  -webkit-backdrop-filter: blur(36px) saturate(200%);
  backdrop-filter: blur(36px) saturate(200%);
  border-bottom: 1px solid rgba(255,255,255,.055);
}

.topbar-inner {
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ── Brand ── */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 0 16px rgba(34,197,94,.22), 0 2px 8px rgba(0,0,0,.5);
}

.topbar-wordmark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: #fff;
  white-space: nowrap;
}

.topbar-user-btn {
  appearance: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 999px;
  padding: 0 14px;
  height: 32px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s;
  line-height: 1;
}
.topbar-user-btn:hover { background: rgba(255,255,255,.11); }

.topbar-logout-btn {
  appearance: none;
  font-family: var(--font-sans);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 999px;
  color: var(--ink-300);
  cursor: pointer;
  transition: background .18s, color .18s;
  padding: 0;
  flex-shrink: 0;
}
.topbar-logout-btn:hover { background: rgba(255,255,255,.13); color: #fff; }
.topbar-logout-btn .logout-label { display: none; }

.topbar-logout-icon {
  font-size: 16px;
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

@media (max-width: 340px) { .topbar-wordmark { display: none; } }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--ink-100);
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-sans);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.06);
  cursor: pointer;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  letter-spacing: .01em;
}
.btn:hover {
  border-color: rgba(255,255,255,.14);
  background: rgba(28,37,53,.9);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.08);
  transform: translateY(-1px);
  color: #fff;
}
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn.pill, .btn.logout { padding: 9px 16px; }

.btn.verify {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-color: rgba(201,168,76,.25);
  color: var(--gold);
}
.btn.verify:hover {
  border-color: rgba(201,168,76,.5);
  background: var(--gold-soft);
  color: var(--gold);
}

.divider-vert {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,.1);
}

/* ─── Status pill ───────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-200);
  letter-spacing: .01em;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-300);
  box-shadow: 0 0 0 3px rgba(100,116,139,.18);
  flex-shrink: 0;
  transition: background .3s ease, box-shadow .3s ease;
}
#connectionStatus.is-online .status-dot {
  background: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-soft), 0 0 8px var(--emerald-glow);
}
#connectionStatus.is-offline .status-dot {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,.18);
}
#connectionStatus.is-syncing .status-dot {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}
.status-pill-inline {
  padding: 6px 8px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
  line-height: 1;
}

/* icon-only wifi status */
.status-icon-on,
.status-icon-off {
  display: none;
  font-size: 17px;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  line-height: 1;
}

#connectionStatus .status-dot { display: none !important; }
#connectionStatus .status-text { display: none !important; }

#connectionStatus.is-online  .status-icon-on  { display: inline; color: var(--emerald); filter: drop-shadow(0 0 5px rgba(16,185,129,.5)); }
#connectionStatus.is-offline .status-icon-off { display: inline; color: #ef4444; }
#connectionStatus:not(.is-online):not(.is-offline) .status-icon-on { display: inline; color: var(--ink-400); }

/* ─── Glass Panel ───────────────────────────────────────── */
.panel {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.055);
  padding: 22px;
  position: relative;
}
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.12), transparent);
  border-radius: 1px;
}

.pending-panel {
  border-color: rgba(245,158,11,.22) !important;
  background: rgba(245,158,11,.06) !important;
}

/* ─── Hero ──────────────────────────────────────────────── */
.hero { padding-top: 44px; padding-bottom: 8px; }

.hero-panel {
  position: relative;
  text-align: center;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.hero-panel::before { display: none; }

.hero-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  width: 500px;
  height: 220px;
  background: radial-gradient(ellipse, rgba(201,168,76,.11) 0%, transparent 65%);
  pointer-events: none;
}

.hero-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.hero-title {
  margin: 0;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -.045em;
  background: linear-gradient(150deg, #ffffff 0%, rgba(201,168,76,.9) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
@media (min-width: 640px) { .hero-title { font-size: 48px; } }

.hero-subtitle {
  margin: 10px 0 0;
  font-size: 13.5px;
  color: var(--ink-300);
  line-height: 1.55;
  font-weight: 400;
  max-width: 380px;
}

.badge-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-400);
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ─── Home Shell ─────────────────────────────────────────── */
.home-shell {
  padding-top: 28px;
  padding-bottom: 80px;
}

/* ─── App Sections ──────────────────────────────────────── */
.app-section { margin-bottom: 32px; }

.section-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-400);
  margin-bottom: 16px;
  padding-left: 2px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-eyebrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,.07) 0%, transparent 75%);
}

/* ─── App Icon Grid ─────────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px 2px;
}
@media (min-width: 420px) { .app-grid { grid-template-columns: repeat(5, 1fr); gap: 8px 4px; } }
@media (min-width: 600px) { .app-grid { grid-template-columns: repeat(6, 1fr); gap: 10px 6px; } }
@media (min-width: 900px) { .app-grid { grid-template-columns: repeat(7, 1fr); gap: 12px 8px; } }

/* ─── Card Links — iOS icon style ──────────────────────── */
.card-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 4px 10px;
  gap: 9px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: transparent;
  transition: background .18s ease, border-color .18s ease;
  overflow: visible;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card-link:hover {
  background: rgba(255,255,255,.032);
  border-color: rgba(255,255,255,.065);
}
.card-link:active .icon-chip-wrap { transform: scale(0.9); }

.card-title {
  font-weight: 600;
  font-size: 11px;
  color: var(--ink-100);
  letter-spacing: -.01em;
  line-height: 1.3;
  max-width: 74px;
  transition: color .18s;
}
.card-link:hover .card-title { color: #fff; }

/* kept in DOM for JS — not shown */
.card-sub { display: none; }

/* ─── Icon Chip Wrap ────────────────────────────────────── */
.icon-chip-wrap {
  position: relative;
  flex-shrink: 0;
  transition: transform .24s cubic-bezier(.34,1.56,.64,1);
}
.card-link:hover .icon-chip-wrap {
  transform: scale(1.08) translateY(-3px);
}

/* ─── Icon Chip — big iOS square ─────────────────────────── */
.icon-chip {
  display: grid;
  place-items: center;
  height: 68px;
  width: 68px;
  border-radius: 18px;
  border: 1.5px solid transparent;
  font-size: 40px;
  flex-shrink: 0;
  transition: box-shadow .22s ease;
  -webkit-font-smoothing: subpixel-antialiased;
}

.icon-chip .material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 100, 'GRAD' -25, 'opsz' 48;
  font-size: inherit;
  line-height: 1;
  opacity: .82;
}

/* Sky — finance/transactions/accounts */
.icon-sky {
  background: linear-gradient(145deg, rgba(2,132,199,.55) 0%, rgba(56,189,248,.75) 100%);
  border-color: rgba(125,211,252,.22);
  color: #e0f7ff;
  box-shadow: 0 6px 22px rgba(56,189,248,.28), inset 0 1px 0 rgba(255,255,255,.2);
}
.card-link:hover .icon-sky {
  box-shadow: 0 10px 36px rgba(56,189,248,.42), inset 0 1px 0 rgba(255,255,255,.25);
}

/* Cyan — invoices/payroll */
.icon-cyan {
  background: linear-gradient(145deg, rgba(8,105,149,.55) 0%, rgba(6,182,212,.75) 100%);
  border-color: rgba(34,211,238,.22);
  color: #cffafe;
  box-shadow: 0 6px 22px rgba(6,182,212,.28), inset 0 1px 0 rgba(255,255,255,.2);
}
.card-link:hover .icon-cyan {
  box-shadow: 0 10px 36px rgba(6,182,212,.42), inset 0 1px 0 rgba(255,255,255,.25);
}

/* Amber — analytics/dashboards */
.icon-amber {
  background: linear-gradient(145deg, rgba(161,98,7,.6) 0%, rgba(245,158,11,.75) 100%);
  border-color: rgba(251,191,36,.22);
  color: #fef9c3;
  box-shadow: 0 6px 22px rgba(245,158,11,.28), inset 0 1px 0 rgba(255,255,255,.2);
}
.card-link:hover .icon-amber {
  box-shadow: 0 10px 36px rgba(245,158,11,.42), inset 0 1px 0 rgba(255,255,255,.25);
}

/* Emerald — people/contacts/attendance */
.icon-emerald {
  background: linear-gradient(145deg, rgba(4,120,87,.55) 0%, rgba(16,185,129,.75) 100%);
  border-color: rgba(52,211,153,.22);
  color: #d1fdf0;
  box-shadow: 0 6px 22px rgba(16,185,129,.28), inset 0 1px 0 rgba(255,255,255,.2);
}
.card-link:hover .icon-emerald {
  box-shadow: 0 10px 36px rgba(16,185,129,.42), inset 0 1px 0 rgba(255,255,255,.25);
}

/* Purple — categories/hall */
.icon-purple {
  background: linear-gradient(145deg, rgba(91,33,182,.55) 0%, rgba(139,92,246,.75) 100%);
  border-color: rgba(167,139,250,.22);
  color: #ede9fe;
  box-shadow: 0 6px 22px rgba(139,92,246,.28), inset 0 1px 0 rgba(255,255,255,.2);
}
.card-link:hover .icon-purple {
  box-shadow: 0 10px 36px rgba(139,92,246,.42), inset 0 1px 0 rgba(255,255,255,.25);
}

/* Green — catalogue/menu */
.icon-green {
  background: linear-gradient(145deg, rgba(20,83,45,.55) 0%, rgba(34,197,94,.7) 100%);
  border-color: rgba(74,222,128,.22);
  color: #dcfce7;
  box-shadow: 0 6px 22px rgba(34,197,94,.24), inset 0 1px 0 rgba(255,255,255,.2);
}
.card-link:hover .icon-green {
  box-shadow: 0 10px 36px rgba(34,197,94,.36), inset 0 1px 0 rgba(255,255,255,.25);
}

/* Rose — admin/system */
.icon-rose {
  background: linear-gradient(145deg, rgba(136,19,55,.55) 0%, rgba(244,63,94,.7) 100%);
  border-color: rgba(251,113,133,.22);
  color: #ffe4e6;
  box-shadow: 0 6px 22px rgba(244,63,94,.24), inset 0 1px 0 rgba(255,255,255,.2);
}
.card-link:hover .icon-rose {
  box-shadow: 0 10px 36px rgba(244,63,94,.36), inset 0 1px 0 rgba(255,255,255,.25);
}

/* ─── Admin divider ──────────────────────────────────────── */
.admin-divider { padding: 4px 0 0; }

.divider-h {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.08) 30%, rgba(255,255,255,.08) 70%, transparent 100%);
  position: relative;
}
.divider-h::after {
  content: 'SYSTEM';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .2em;
  color: var(--ink-400);
  background: var(--ink-950);
  padding: 0 12px;
  font-family: var(--font-sans);
}

/* ─── Versions Panel ────────────────────────────────────── */
.versions { padding-bottom: 40px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-kicker {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-100);
  font-family: var(--font-sans);
}
.version-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 6px;
  font-family: var(--font-mono);
}
.version-item {
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: rgba(8,12,20,.5);
  color: var(--ink-200);
  font-size: 12.5px;
}
.verify-out {
  margin-top: 18px;
  font-size: 13px;
  color: var(--ink-300);
  overflow-x: auto;
  font-family: var(--font-mono);
}
.verify-out table { color: var(--ink-200); border-collapse: collapse; width: 100%; }
.verify-out th { color: var(--ink-300); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.verify-out td, .verify-out th { padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,.04); text-align: left; }

/* ─── Pending Banner ────────────────────────────────────── */
#pendingBanner .panel { border-color: rgba(245,158,11,.22); background: rgba(245,158,11,.06); }
#pendingBanner .material-symbols-outlined { color: var(--amber); font-size: 22px; }

/* ─── Auth page ─────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px 14px; }
.auth-shell { width: min(980px, 100%); }
.auth-card {
  width: min(460px, 100%);
  margin: 0 auto;
  border-radius: var(--r-xl);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.07);
  border: 1px solid var(--glass-border);
  padding: 26px;
  position: relative;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 20px; right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201,168,76,.3), transparent);
}
.auth-logo { width: 52px; height: 52px; border-radius: var(--r-md); overflow: hidden; display: grid; place-items: center; background: var(--gold-soft); border: 1px solid rgba(201,168,76,.25); }
.auth-logo img { width: 100%; height: 100%; object-fit: cover; }
.auth-title { margin: 14px 0 0; font-size: 17px; font-weight: 800; letter-spacing: -.02em; color: #fff; }
.auth-subtitle { margin: 8px 0 0; color: var(--ink-300); font-size: 13px; line-height: 1.5; }
.auth-error { margin: 10px 0 0; color: #f87171; font-size: 13px; min-height: 18px; }
.auth-form { margin-top: 16px; display: grid; gap: 0; }
.auth-form .row { display: grid; gap: 10px; }
.auth-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: rgba(8,12,20,.6);
  color: var(--ink-050);
  font: 500 14px/1 var(--font-sans);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.auth-form input::placeholder { color: var(--ink-400); }
.auth-form input:focus { border-color: rgba(201,168,76,.35); box-shadow: 0 0 0 3px rgba(201,168,76,.1); }
.auth-actions button {
  width: 100%;
  justify-content: center;
  border-radius: 999px;
  padding: 14px;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--ink-100);
  transition: all .2s cubic-bezier(.4,0,.2,1);
  letter-spacing: .01em;
}
.auth-actions button:hover { transform: translateY(-1px); }
.auth-actions button:active { transform: translateY(0); }
#btn-google { border-color: rgba(16,185,129,.3); background: rgba(16,185,129,.12); color: #fff; box-shadow: 0 0 30px rgba(16,185,129,.12); }
#btn-google:hover { background: rgba(16,185,129,.2); border-color: rgba(16,185,129,.5); box-shadow: 0 4px 24px rgba(16,185,129,.2); }
#btn-email-login { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.1); color: var(--ink-100); }
#btn-email-login:hover { background: rgba(255,255,255,.07); color: #fff; }
.auth-hint { margin: 12px 0 0; color: var(--ink-400); font-size: 11.5px; line-height: 1.45; }

/* ─── iOS PWA fix ───────────────────────────────────────── */
body.ios .topbar,
body.ios .panel,
body.ios .card-link {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  background: var(--ink-800) !important;
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); }

/* ─── Favourites Section ────────────────────────────────── */
.favourites-section { padding-top: 16px; padding-bottom: 4px; }

.fav-header { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.fav-header-icon {
  font-size: 15px;
  color: var(--gold);
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}
.fav-header-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-100);
}

.favourites-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 2px;
}

.fav-item {
  flex: 1 0 88px;
  max-width: 112px;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 4px 10px;
  gap: 9px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: transparent;
  transition: background .18s ease, border-color .18s ease;
  overflow: visible;
}
.fav-item::before { display: none; }
.fav-item:hover {
  background: rgba(255,255,255,.032);
  border-color: rgba(255,255,255,.065);
}

.fav-title {
  font-weight: 600;
  font-size: 11px;
  color: var(--ink-100);
  letter-spacing: -.01em;
  line-height: 1.3;
  max-width: 74px;
  transition: color .18s;
}
.fav-item:hover .fav-title { color: #fff; }
.fav-sub { display: none; }

/* Favourites: slightly larger icons + filled (smarter) variant */
.fav-item .icon-chip {
  height: 72px;
  width: 72px;
}
.fav-item .icon-chip .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 200, 'GRAD' 0, 'opsz' 48;
  opacity: 1;
}
/* Usage-driven size tiers (0 taps=xs, 1-2=lg, 3+=xl) */
.fav-item.fav-size-xs { flex: 0.8 0 80px; max-width: 102px; }
.fav-item.fav-size-xs .icon-chip { height: 65px; width: 65px; font-size: 34px; }
.fav-item.fav-size-xs .fav-title { font-size: 10.5px; max-width: 76px; }
.fav-item.fav-size-lg { flex: 1.4 1 104px; max-width: 142px; }
.fav-item.fav-size-lg .icon-chip { height: 86px; width: 86px; font-size: 48px; border-radius: 22px; }
.fav-item.fav-size-lg .fav-title { font-size: 12px; max-width: 108px; }
.fav-item.fav-size-xl { flex: 1.85 1 122px; max-width: 168px; }
.fav-item.fav-size-xl .icon-chip { height: 102px; width: 102px; font-size: 58px; border-radius: 26px; }
.fav-item.fav-size-xl .fav-title { font-size: 13px; max-width: 136px; }

.fav-remove {
  position: absolute;
  top: -4px; right: -4px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(8,12,20,.75);
  cursor: pointer;
  padding: 0;
  z-index: 2;
  opacity: 0;
  transition: opacity .15s, background .15s, border-color .15s;
  font-family: inherit;
}
.fav-item:hover .fav-remove { opacity: 1; }
.fav-remove:hover { background: rgba(239,68,68,.25); border-color: rgba(239,68,68,.4); }
.fav-remove .material-symbols-outlined {
  font-size: 11px;
  color: rgba(255,255,255,.7);
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}
.fav-remove:hover .material-symbols-outlined { color: #f87171; }
.fav-remove::after { content: ""; position: absolute; inset: -8px; }

/* ─── Star button ───────────────────────────────────────── */
.fav-star {
  position: absolute;
  top: -5px; right: -5px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.14);
  background: rgba(8,12,20,.88);
  cursor: pointer;
  padding: 0;
  z-index: 2;
  opacity: 0;
  transition: opacity .15s, background .15s, border-color .15s, box-shadow .15s;
}
.fav-star::before {
  content: '★';
  font-size: 12px;
  line-height: 1;
  color: rgba(255,255,255,.45);
  transition: color .15s;
}
.card-link:hover .fav-star { opacity: 1; }
.fav-star:hover { background: rgba(201,168,76,.22); border-color: rgba(201,168,76,.45); }
.fav-star:hover::before { color: var(--gold); }
.card-link.is-favourite .fav-star {
  background: rgba(201,168,76,.22);
  border-color: rgba(201,168,76,.55);
  box-shadow: 0 0 8px rgba(201,168,76,.32);
  opacity: 1;
}
.card-link.is-favourite .fav-star::before {
  color: var(--gold);
  filter: drop-shadow(0 0 5px rgba(201,168,76,.55));
}
.fav-star::after { content: ""; position: absolute; inset: -8px; }

/* Touch devices: suppress ALL hover visual changes so iOS navigates on first tap.
   Also pull overlay buttons' touch areas outward so they don't steal the card tap. */
@media (hover: none) {
  .card-link:hover { background: transparent; border-color: transparent; box-shadow: none; transform: none; }
  .card-link:hover .icon-chip-wrap { transform: none; }
  .fav-star { opacity: 0; }
  .card-link.is-favourite .fav-star { opacity: 1; }
  .card-link:hover .fav-star { opacity: 0; }
  .fav-star::after { inset: -10px -10px 4px 4px; }

  .fav-item:hover { background: transparent; border-color: transparent; }
  .fav-item:hover .fav-title { color: inherit; }
  .fav-remove { opacity: .32; }
  .fav-item:hover .fav-remove { opacity: .32; }
  .fav-remove::after { inset: -10px -10px 4px 4px; }
}

.card-link, .fav-item { touch-action: manipulation; }

/* ── Long-press wiggle + drag reorder (favs + main grid) ──────────────────── */
/* Prevent iOS callout and text selection during drag */
.fav-item, .card-link {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

@keyframes fav-wiggle {
  0%, 100% { transform: rotate(-3deg) scale(.96) translateX(-2px); }
  50%       { transform: rotate( 3deg) scale(.96) translateX( 2px); }
}

.favourites-list.is-editing { touch-action: none; }

.favourites-list.is-editing .fav-item:not(.fav-drag-src) {
  animation: fav-wiggle .38s ease-in-out infinite;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.favourites-list.is-editing .fav-item:nth-child(2n):not(.fav-drag-src) { animation-delay: -.19s; }
.favourites-list.is-editing .fav-item:nth-child(3n):not(.fav-drag-src) { animation-delay: -.095s; }

/* Source item during drag: fades in place to show destination slot */
.fav-drag-src {
  opacity: .22 !important;
  animation: none !important;
  pointer-events: none !important;
}

/* Ghost clone: elevated card that follows the finger */
.fav-ghost {
  border-radius: 12px !important;
  box-shadow: 0 8px 28px rgba(0,0,0,.32), 0 2px 8px rgba(0,0,0,.2) !important;
  transform: scale(1.07) rotate(2deg) !important;
  animation: none !important;
  transition: none !important;
  will-change: left, top;
  backdrop-filter: none !important;
}

/* Main grid: wiggle + drag in edit mode */
.home-shell.is-editing .card-link:not(.fav-drag-src) {
  animation: fav-wiggle .38s ease-in-out infinite;
  cursor: grab;
  touch-action: none;
}
.home-shell.is-editing .card-link:nth-child(2n):not(.fav-drag-src) { animation-delay: -.19s; }
.home-shell.is-editing .card-link:nth-child(3n):not(.fav-drag-src) { animation-delay: -.095s; }

/* Cross-zone drop indicator: shown in favs list when dragging a grid card over it */
.drag-cross-ph {
  border-radius: 10px;
  border: 2px dashed rgba(59,130,246,.55);
  background: rgba(59,130,246,.08);
  min-height: 56px;
}

/* Floating Done button — shown whenever edit mode is active */
.edit-done-floating {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 0 32px;
  height: 44px;
  border-radius: 22px;
  background: #3b82f6;
  color: #fff;
  font: 700 13px/1 var(--font-sans, 'Sora', sans-serif);
  letter-spacing: .05em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(59,130,246,.45), 0 2px 8px rgba(0,0,0,.25);
  white-space: nowrap;
}

/* ─── Versions panel collapse ──────────────────────────── */
.versions-toggle {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  justify-content: space-between;
}
.versions-toggle:hover .panel-kicker { color: var(--ink-050); }
.version-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-400);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 6px;
  padding: 2px 7px;
  letter-spacing: .03em;
}
.versions-chevron {
  font-size: 16px;
  color: var(--ink-400);
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
  transition: transform .28s ease;
  flex-shrink: 0;
}
.versions.is-expanded .versions-chevron { transform: rotate(180deg); }
.versions-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}
.versions-body > div { overflow: hidden; min-height: 0; }
.versions.is-expanded .versions-body { grid-template-rows: 1fr; }
#verifyBtn { display: none; }
.versions.is-expanded #verifyBtn { display: inline-flex; }
