/* ==========================================================================
   Student Organizations Hub — Design System, 3D Surface & Mobile-First CSS
   ========================================================================== */

:root {
  /* Core Surfaces & Neutrals (No pure #000000) */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --surface-elevated: #ffffff;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.17);

  /* Typography Ink */
  --text: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;

  /* Calibrated Singular Primary Accent (Deep Emerald-Teal) */
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --accent-border: rgba(15, 118, 110, 0.24);
  --accent-ink: #ffffff;

  /* Feedback States */
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.11);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.09);
  --danger-border: rgba(185, 28, 28, 0.24);

  /* Tinted Shadows & Glass Refraction */
  --glass-bg: rgba(248, 250, 252, 0.84);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --shadow-card: 0 14px 32px -18px rgba(15, 23, 42, 0.09), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 24px 44px -20px rgba(15, 23, 42, 0.16), 0 6px 14px -6px rgba(15, 23, 42, 0.06);
  --shadow-float: 0 28px 56px -16px rgba(15, 23, 42, 0.22);

  /* Geometry */
  --radius-xl: 1.5rem;
  --radius-lg: 1rem;
  --radius-md: 0.75rem;
  --radius-sm: 0.55rem;
  --radius-pill: 9999px;

  /* Typography */
  --font-sans: "Vazirmatn", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Motion Tokens (Emil Kowalski / Apple-grade curves) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-fast: 150ms;
  --dur-base: 220ms;
  --dur-slow: 320ms;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #131317;
  --surface-subtle: #1c1c22;
  --surface-elevated: #17171c;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-soft: #71717a;

  --accent: #14b8a6;
  --accent-hover: #2dd4bf;
  --accent-soft: rgba(20, 184, 166, 0.14);
  --accent-border: rgba(20, 184, 166, 0.3);
  --accent-ink: #042f2e;

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --danger-border: rgba(248, 113, 113, 0.28);

  --glass-bg: rgba(9, 9, 11, 0.82);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-card: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 36px -18px rgba(0, 0, 0, 0.65);
  --shadow-card-hover: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 28px 52px -18px rgba(0, 0, 0, 0.82);
  --shadow-float: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 32px 64px -14px rgba(0, 0, 0, 0.85);
}

/* ==========================================================================
   Base Reset & Cross-OS Stability
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (min-width: 1024px) {
  html {
    scrollbar-gutter: stable;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  transition: background-color var(--dur-base) ease, color var(--dur-base) ease;
}

body.modal-open {
  overflow: hidden;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fixed Ambient Depth Layer (GPU-safe, pointer-events-none, outside scroller) */
.bg-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(640px 380px at 85% -4%, rgba(15, 118, 110, 0.08), transparent 70%),
    radial-gradient(520px 360px at 10% 18%, rgba(14, 116, 144, 0.05), transparent 72%);
}

[data-theme="dark"] .bg-ambient {
  background:
    radial-gradient(700px 420px at 84% -6%, rgba(20, 184, 166, 0.11), transparent 70%),
    radial-gradient(520px 380px at 12% 20%, rgba(56, 189, 248, 0.06), transparent 72%);
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Topbar & Layout Shell (Mobile-First)
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--glass-inset);
}

.topbar-inner {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.72rem max(1rem, env(safe-area-inset-right, 0px)) 0.72rem max(1rem, env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 0.96rem;
  letter-spacing: -0.015em;
  min-width: 0;
}

.brand-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.68rem;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.page-container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  flex: 1;
  padding-top: 0;
  padding-bottom: calc(3.25rem + env(safe-area-inset-bottom, 0px));
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
}

/* ==========================================================================
   Buttons & Tactile Controls
   ========================================================================== */

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.2;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition:
    transform var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease;
}

.btn:active,
.icon-btn:active {
  transform: scale(0.97);
}

.btn {
  padding: 0.62rem 0.95rem;
  min-height: 2.55rem;
}

.btn-sm {
  padding: 0.48rem 0.78rem;
  min-height: 2.2rem;
  font-size: 0.82rem;
}

.icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn.is-copied {
  background: var(--success-soft);
  border-color: rgba(21, 128, 61, 0.3);
  color: var(--success);
}

.btn:disabled,
.icon-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   Hero Section & Interactive 3D Stage (Mobile-First)
   ========================================================================== */

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1.25rem 0 1.25rem;
  align-items: stretch;
}

.hero-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.65rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  padding: 0.28rem 0.72rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.eyebrow-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.hero-title {
  margin: 0.25rem 0 0.25rem;
  font-size: clamp(1.5rem, 4.8vw, 2.75rem);
  line-height: 1.22;
  letter-spacing: -0.025em;
  font-weight: 800;
}

.hero-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 58ch;
}

/* 3D Interactive Stage Card */
.hero-stage {
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 185px;
}

.hero-canvas-wrap {
  position: relative;
  width: 100%;
  height: 135px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, var(--accent-soft), transparent 70%),
    var(--surface-subtle);
}

.hero-3d-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 420ms var(--ease-out);
}

.hero-3d-canvas.is-ready {
  opacity: 1;
}

/* Static Geometric Fallback when WebGL unavailable or reduced-motion active */
.hero-3d-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background-image:
    radial-gradient(circle at 50% 50%, var(--accent-soft) 0%, transparent 62%),
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 100% 100%, 28px 28px, 28px 28px;
  transition: opacity 320ms ease;
}

.hero-3d-fallback.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.hero-3d-fallback svg {
  width: 84px;
  height: 84px;
  color: var(--accent);
  opacity: 0.72;
}

.hero-3d-caption {
  position: absolute;
  bottom: 0.6rem;
  right: 0.75rem;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  pointer-events: none;
}

.hero-stage-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.stat-cell {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.8rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.hero-note {
  display: none;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ==========================================================================
   Search & Horizontal Snap Filter Strip (Mobile-First)
   ========================================================================== */

.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.9rem 0 1.25rem;
  border-top: 1px solid var(--border);
}

.search-wrap {
  position: relative;
  width: 100%;
}

.search-wrap svg {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.68rem 2.55rem 0.68rem 2.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px; /* Prevents iOS Safari auto-zoom */
  transition: border-color var(--dur-fast) ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-clear {
  position: absolute;
  left: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-clear[hidden] {
  display: none;
}

.filter-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding-bottom: 0.15rem;
}

.filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  width: max-content;
}

.filter-pill {
  scroll-snap-align: start;
  padding: 0.44rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition:
    background-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out);
}

.filter-pill:active {
  transform: scale(0.97);
}

.filter-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.filter-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  opacity: 0.82;
}

/* ==========================================================================
   Bento Grid & Student Organization Cards (with 3D Tilt & Spotlight)
   ========================================================================== */

.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.entity-card {
  position: relative;
  grid-column: span 12;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.15rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  overflow: hidden;
  transform-style: preserve-3d;
  transition:
    transform var(--dur-base) var(--ease-out),
    border-color var(--dur-base) ease;
}

/* Staggered entry runs ONLY on initial data hydration (not during search typing) */
.entity-card.is-entering {
  animation: cardReveal 360ms var(--ease-out) both;
  animation-delay: calc(var(--stagger, 0) * 45ms);
}

/* Isolated Leaf Spotlight Overlay (zero inherited CSS variables on children) */
.card-spotlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-base) ease;
  border-radius: inherit;
}

.entity-top {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.entity-identity {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  min-width: 0;
}

.entity-avatar,
.entity-avatar-fallback {
  width: 3.85rem;
  height: 3.85rem;
  border-radius: 0.95rem;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.entity-avatar {
  object-fit: cover;
  background: var(--surface-subtle);
}

.entity-avatar-fallback {
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.25rem;
}

.entity-meta {
  min-width: 0;
  flex: 1;
}

.entity-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  color: var(--text-muted);
  border: 1px solid transparent;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.4;
}

.badge-platform {
  background: transparent;
  border-color: var(--border);
  color: var(--text-soft);
  font-weight: 600;
}

/* Calibrated Semantic Tones for Student Organization Types */
.badge-pill[data-cat-tone="scientific"] {
  background: rgba(15, 118, 110, 0.11);
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.2);
}

.badge-pill[data-cat-tone="cultural"] {
  background: rgba(180, 83, 9, 0.1);
  color: #b45309;
  border-color: rgba(180, 83, 9, 0.2);
}

.badge-pill[data-cat-tone="research"] {
  background: rgba(3, 105, 161, 0.1);
  color: #0369a1;
  border-color: rgba(3, 105, 161, 0.2);
}

.badge-pill[data-cat-tone="guild"] {
  background: rgba(159, 18, 57, 0.09);
  color: #9f1239;
  border-color: rgba(159, 18, 57, 0.18);
}

.badge-pill[data-cat-tone="media"] {
  background: rgba(63, 98, 18, 0.1);
  color: #3f6212;
  border-color: rgba(63, 98, 18, 0.2);
}

.badge-pill[data-cat-tone="org"] {
  background: rgba(51, 65, 85, 0.11);
  color: #334155;
  border-color: rgba(51, 65, 85, 0.2);
}

[data-theme="dark"] .badge-pill[data-cat-tone="scientific"] {
  background: rgba(20, 184, 166, 0.15);
  color: #5eead4;
  border-color: rgba(20, 184, 166, 0.28);
}

[data-theme="dark"] .badge-pill[data-cat-tone="cultural"] {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.28);
}

[data-theme="dark"] .badge-pill[data-cat-tone="research"] {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.28);
}

[data-theme="dark"] .badge-pill[data-cat-tone="guild"] {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.28);
}

[data-theme="dark"] .badge-pill[data-cat-tone="media"] {
  background: rgba(132, 204, 22, 0.14);
  color: #bef264;
  border-color: rgba(132, 204, 22, 0.26);
}

[data-theme="dark"] .badge-pill[data-cat-tone="org"] {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.28);
}

.entity-title {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 800;
  line-height: 1.38;
  word-break: break-word;
}

.entity-desc {
  margin: 0.35rem 0 0;
  font-size: 0.87rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* QR Tile on Card (Mobile: sleek horizontal bar; Desktop: crisp square tile) */
.qr-trigger {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition:
    transform var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) ease,
    background-color var(--dur-fast) ease;
}

.qr-trigger:active {
  transform: scale(0.98);
}

.qr-trigger-svg {
  background: #ffffff;
  padding: 0.3rem;
  border-radius: 0.6rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}

.qr-trigger-svg svg {
  width: 56px;
  height: 56px;
  display: block;
}

.qr-trigger-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: right;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}

.qr-trigger-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.qr-trigger-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Card Footer (Mobile-First stacked actions, zero overflow) */
.entity-footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.entity-handle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.mono-handle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  direction: ltr;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.entity-buttons {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  width: 100%;
}

/* ==========================================================================
   Skeleton, Empty & Error States
   ========================================================================== */

.skeleton-card {
  grid-column: span 12;
  height: 230px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: linear-gradient(
    90deg,
    var(--surface) 25%,
    var(--surface-subtle) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

.state-panel {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 2.5rem 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.state-panel h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.state-panel p {
  margin: 0;
  color: var(--text-muted);
  max-width: 44ch;
  font-size: 0.9rem;
}

/* ==========================================================================
   QR Fullscreen Modal (Mobile Scroll-Safe + Smooth Enter/Exit + 3D Card)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 9, 11, 0.66);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding:
    max(0.9rem, env(safe-area-inset-top, 0px))
    max(0.9rem, env(safe-area-inset-right, 0px))
    max(0.9rem, env(safe-area-inset-bottom, 0px))
    max(0.9rem, env(safe-area-inset-left, 0px));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--dur-base) var(--ease-out),
    visibility var(--dur-base) linear;
}

.modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-surface {
  width: 100%;
  max-width: 430px;
  max-height: min(92svh, 680px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-float);
  transform: translateY(10px) scale(0.96);
  opacity: 0;
  transition:
    transform var(--dur-slow) var(--ease-out),
    opacity var(--dur-base) var(--ease-out);
}

.modal-backdrop.is-open .modal-surface {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.modal-heading-group {
  min-width: 0;
  flex: 1;
}

.modal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.modal-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.35;
  word-break: break-word;
}

.modal-qr-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.15rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
  margin-bottom: 1rem;
  perspective: 900px;
}

.qr-card-3d {
  border-radius: 1.1rem;
  transform-style: preserve-3d;
  transition: transform var(--dur-base) var(--ease-out);
}

.qr-box-large {
  background: #ffffff;
  padding: 0.85rem;
  border-radius: 1rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 14px 28px -12px rgba(15, 23, 42, 0.16);
}

.qr-box-large svg {
  width: clamp(160px, 50vw, 224px);
  height: clamp(160px, 50vw, 224px);
  display: block;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.modal-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

/* ==========================================================================
   Admin Panel (/path) — Mobile-First Forms & Dropzone
   ========================================================================== */

.auth-shell {
  min-height: calc(100svh - 72px);
  display: grid;
  place-items: center;
  padding: 1.5rem 0;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.admin-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1.4rem 0 1.2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.35rem;
}

.admin-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.admin-header-actions .btn {
  flex: 1 1 auto;
}

.admin-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 2rem;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.2rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.panel-heading {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.form-grid {
  display: grid;
  gap: 0.95rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.95rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.field label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field textarea {
  width: 100%;
  padding: 0.68rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 16px; /* Prevents iOS auto-zoom */
  transition: border-color var(--dur-fast) ease;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.field-error {
  font-size: 0.82rem;
  color: var(--danger);
  font-weight: 600;
  min-height: 1.1em;
}

.ltr-input {
  direction: ltr;
  text-align: left;
  font-family: var(--font-mono);
}

/* Quick Category Preset Chips in /path */
.category-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.preset-chip {
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background-color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease;
}

.preset-chip.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Mobile-Safe Dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0.95rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition:
    border-color var(--dur-fast) ease,
    background-color var(--dur-fast) ease;
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-main {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.dropzone-preview {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 0.75rem;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.dropzone-text {
  min-width: 0;
  flex: 1;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.checkbox-line input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

/* Admin Saved Items List */
.admin-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.admin-list {
  display: grid;
  gap: 0.7rem;
}

.admin-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.admin-row-main {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.admin-thumb {
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 0.7rem;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  flex-shrink: 0;
}

.admin-row-info {
  min-width: 0;
  flex: 1;
}

.admin-row-title {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  word-break: break-word;
}

.admin-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.admin-row-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  width: 100%;
}

.status-dot {
  display: inline-block;
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.status-dot.is-hidden {
  background: var(--text-soft);
}

/* ==========================================================================
   Footer & Transition-Driven Toasts (Interruptible, No Keyframe Restart)
   ========================================================================== */

.site-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.toast-root {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  right: 1rem;
  left: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  max-width: 420px;
  width: fit-content;
  background: var(--text);
  color: var(--bg);
  padding: 0.68rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition:
    transform var(--dur-base) var(--ease-out),
    opacity var(--dur-base) var(--ease-out);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(10px) scale(0.96);
}

.toast.is-error {
  background: var(--danger);
  color: #ffffff;
}

/* ==========================================================================
   Tablet & Desktop Breakpoints (>= 768px & >= 1024px)
   ========================================================================== */

@media (min-width: 768px) {
  .topbar-inner {
    padding: 0.88rem 1.5rem;
  }

  .brand {
    font-size: 1.05rem;
  }

  .page-container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    padding-bottom: 4rem;
  }

  .hero-grid {
    grid-template-columns: 1.22fr 0.78fr;
    gap: 1.5rem;
    padding: 2.25rem 0 1.85rem;
  }

  .hero-stage {
    min-height: 280px;
  }

  .hero-canvas-wrap {
    height: 185px;
  }

  .hero-note {
    display: block;
  }

  .controls-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 1.05rem 0 1.6rem;
  }

  .search-wrap {
    flex: 0 1 380px;
  }

  .search-input,
  .field input[type="text"],
  .field input[type="password"],
  .field input[type="number"],
  .field textarea {
    font-size: 0.92rem;
  }

  .filter-scroll {
    width: auto;
    overflow: visible;
    padding-bottom: 0;
  }

  .filter-pills {
    flex-wrap: wrap;
    width: auto;
    justify-content: flex-end;
  }

  .bento-grid {
    gap: 1.25rem;
  }

  .entity-card,
  .skeleton-card {
    grid-column: span 6;
    padding: 1.35rem;
  }

  .entity-card.is-featured {
    grid-column: span 7;
  }

  .entity-card.is-companion {
    grid-column: span 5;
  }

  .entity-top {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }

  .entity-avatar,
  .entity-avatar-fallback {
    width: 4.35rem;
    height: 4.35rem;
  }

  .qr-trigger {
    width: auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 0.48rem;
    gap: 0.3rem;
  }

  .qr-trigger-svg {
    padding: 0;
    border: none;
    background: transparent;
  }

  .qr-trigger-svg svg {
    width: 82px;
    height: 82px;
  }

  .qr-trigger-copy {
    align-items: center;
    text-align: center;
  }

  .qr-trigger-title {
    display: none;
  }

  .qr-trigger-hint {
    font-size: 0.68rem;
    font-weight: 700;
    color: #334155;
  }

  .entity-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .entity-buttons {
    width: auto;
    display: flex;
    align-items: center;
  }

  .admin-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 2rem 0 1.4rem;
  }

  .admin-header-actions {
    width: auto;
  }

  .admin-header-actions .btn {
    flex: 0 0 auto;
  }

  .form-row-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dropzone {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .admin-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.95rem 1.1rem;
  }

  .admin-row-actions {
    width: auto;
    display: flex;
    align-items: center;
  }

  .toast-root {
    right: auto;
    left: 1.5rem;
    align-items: flex-start;
  }
}

@media (min-width: 1024px) {
  .admin-split {
    grid-template-columns: 1.15fr 0.85fr;
    gap: 1.5rem;
  }

  .panel-card {
    padding: 1.5rem;
  }

  .hero-canvas-wrap {
    height: 215px;
  }
}

/* ==========================================================================
   Pointer-Gated Hover Effects (Zero Sticky Hover on Touch Devices)
   ========================================================================== */

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover,
  .btn-secondary:hover {
    border-color: var(--border-strong);
    background: var(--surface-subtle);
  }

  .btn-primary:hover {
    background: var(--accent-hover);
  }

  .btn-ghost:hover {
    background: var(--surface-subtle);
    color: var(--text);
  }

  .btn-danger:hover {
    background: rgba(185, 28, 28, 0.16);
  }

  .filter-pill:not(.is-active):hover,
  .preset-chip:not(.is-selected):hover {
    border-color: var(--border-strong);
    color: var(--text);
  }

  .entity-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-card-hover);
  }

  .entity-card:hover .card-spotlight {
    opacity: 1;
  }

  .qr-trigger:hover {
    transform: translateY(-2px) scale(1.03);
    border-color: var(--accent);
  }
}

/* ==========================================================================
   Keyframes & Reduced Motion (Gentler Opacity, Zero Spatial Movement)
   ========================================================================== */

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

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .entity-card.is-entering {
    animation: fadeOnly 200ms ease both;
  }

  .skeleton-card {
    animation: none;
  }

  .modal-surface,
  .toast,
  .entity-card,
  .qr-card-3d {
    transform: none !important;
    transition: opacity 180ms ease !important;
  }
}

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