/* ── Design tokens ────────────────────────────────────────────────── */
:root {
  --bg:            #080808;
  --surface:       rgba(10, 10, 10, 0.72);
  --surface-hi:    rgba(18, 18, 18, 0.80);
  --border:        rgba(255, 255, 255, 0.07);
  --border-hi:     rgba(255, 255, 255, 0.14);
  --text:          #ffffff;
  --text-dim:      rgba(255, 255, 255, 0.45);
  --text-faint:    rgba(255, 255, 255, 0.2);
  --accent:        #C8A96E;
  --accent-dim:    rgba(200, 169, 110, 0.12);
  --accent-glow:   rgba(200, 169, 110, 0.25);
  --fps-good:      #32D74B;
  --fps-warn:      #FF9F0A;
  --fps-bad:       #FF453A;
  --blur:          blur(24px) saturate(160%);
  --r:             14px;
  --r-sm:          9px;
  --r-pill:        100px;
  --ease:          cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --bottom-inset:  60px; /* space for OEM nav bar — adjust in Fully Kiosk */
}

/* ── Reset / base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Kiosk hardening */
body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

/* Prevent context menu & image save */
body { -webkit-touch-callout: none; }

/* ── Ambient background glow ──────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 70% 55% at 50% 48%, rgba(200,169,110,0.045) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── 3-D Viewport ─────────────────────────────────────────────────── */
#viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg);
  --mv-background-color: #080808;
  z-index: 0;
}

/* ── Image / Video viewers ────────────────────────────────────────── */
#media-image,
#media-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg);
  z-index: 0;
  display: none;
}

/* ── Loading overlay ──────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
  z-index: 2;
}
.loading-overlay.visible { opacity: 1; }

.ring-spinner {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── First-run init overlay ───────────────────────────────────────── */
.init-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.5s var(--ease);
}
.init-overlay[hidden] { display: none; }
.init-overlay.fading  { opacity: 0; pointer-events: none; }

.init-box {
  width: min(480px, 82vw);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.init-eyebrow {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  color: var(--text-faint);
}

.init-bar-track {
  height: 2px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 1px;
  overflow: hidden;
}

.init-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.12s linear;
}

.init-status-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.init-percent {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 4ch;
  line-height: 1;
  letter-spacing: -0.02em;
}

.init-file {
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  letter-spacing: 0.04em;
}

/* ── Glass mixin (applied via class) ─────────────────────────────── */
.glass {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
}

/* ── Top bar ──────────────────────────────────────────────────────── */
.top-bar {
  position: fixed;
  top: 20px;
  left: 24px;
  z-index: 10;
  pointer-events: none;
}

/* Performance toggle chip */
.perf-chip {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-dim);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.perf-chip:hover,
.perf-chip[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--border-hi);
  background: var(--surface-hi);
}
.perf-chip[aria-expanded="true"] { color: var(--accent); }

/* ── Info side panel (glass) ──────────────────────────────────────── */
.info-panel {
  position: fixed;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 340px;
  z-index: 10;
  pointer-events: none;
  border-radius: 22px;
  overflow: hidden;

  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.09) 0%,
    rgba(255, 255, 255, 0.04) 50%,
    rgba(200, 169, 110, 0.06) 100%
  );
  backdrop-filter: blur(44px) saturate(200%);
  -webkit-backdrop-filter: blur(44px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow:
    0 28px 72px rgba(0, 0, 0, 0.6),
    0 6px 20px rgba(0, 0, 0, 0.35),
    0 0 0 0.5px rgba(200, 169, 110, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 0 70px rgba(200, 169, 110, 0.03);

  animation: infoPanelIn 0.55s var(--ease) both;
}

/* Top shimmer line */
.info-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1.5px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(200, 169, 110, 0.5) 25%,
    rgba(220, 195, 140, 1) 50%,
    rgba(200, 169, 110, 0.5) 75%,
    transparent 100%
  );
  z-index: 2;
}

/* Inner ambient glow */
.info-panel::after {
  content: '';
  position: absolute;
  top: -40%;
  left: -20%;
  width: 140%;
  height: 80%;
  background: radial-gradient(
    ellipse at 45% 65%,
    rgba(200, 169, 110, 0.09) 0%,
    transparent 65%
  );
  pointer-events: none;
  z-index: 0;
}

@keyframes infoPanelIn {
  from { opacity: 0; transform: translateY(-50%) translateX(-20px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}

/* Left accent stripe */
.info-panel-accent {
  position: absolute;
  top: 22px;
  bottom: 22px;
  left: 0;
  width: 2px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(200, 169, 110, 0.8) 20%,
    var(--accent) 50%,
    rgba(200, 169, 110, 0.8) 80%,
    transparent 100%
  );
  border-radius: 0 2px 2px 0;
  z-index: 2;
}

.info-panel-content {
  position: relative;
  z-index: 1;
  padding: 22px 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: 'Almarai', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

/* ── Model identity ───────────────────────────────────────────────── */
.model-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: rgba(200, 169, 110, 0.12);
  border: 1px solid rgba(200, 169, 110, 0.22);
  border-radius: var(--r-pill);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  align-self: flex-start;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
}

.name-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.model-name {
  font-family: 'Almarai', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  font-size: clamp(1.2rem, 2vw, 1.65rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.45;
  text-align: justify;
  /* gradient shimmer: bright white fading to warm gold */
  background: linear-gradient(160deg, #ffffff 15%, rgba(230, 210, 170, 0.92) 65%, rgba(200, 169, 110, 0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: opacity 0.25s var(--ease);
  max-width: 100%;
  white-space: normal;
  overflow: visible;
}
.model-name.fading { opacity: 0; }


.model-desc {
  font-family: 'Almarai', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 300;
  line-height: 1.9;
  color: rgba(255, 255, 255, 0.52);
  text-align: justify;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: opacity 0.25s var(--ease);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 11px;
  margin-top: 2px;
}
.model-desc[hidden] { display: none; }
.model-desc.fading  { opacity: 0; }

/* ── Gesture hints ────────────────────────────────────────────────── */
.gesture-hints {
  position: fixed;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 10;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s var(--ease);
}
.gesture-hints.hidden { opacity: 0; }

.hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
}
.hint-sep {
  width: 1px;
  height: 12px;
  background: rgba(255,255,255,0.12);
}

/* ── Performance panel ────────────────────────────────────────────── */
.perf-panel {
  position: fixed;
  top: 68px;
  left: 24px;
  width: 248px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: slideDown 0.22s var(--ease);
}
.perf-panel[hidden] { display: none; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.perf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-eyebrow {
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.icon-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* FPS block */
.fps-block { display: flex; flex-direction: column; gap: 6px; }
.fps-label-row { display: flex; align-items: center; }

.fps-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.fps-big {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
  transition: color 0.3s;
  min-width: 3ch;
}
.fps-big.good  { color: var(--fps-good); }
.stat-val.good { color: var(--fps-good); }
.stat-val.warn { color: var(--fps-warn); }
.stat-val.bad  { color: var(--fps-bad); }
.fps-big.warn  { color: var(--fps-warn); }
.fps-big.bad   { color: var(--fps-bad); }

.fps-subs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fps-sub-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.fps-sub-label {
  font-size: 0.5625rem;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  min-width: 2ch;
}

/* Perf stats */
.perf-stat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.perf-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-val {
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-val.mono {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.75rem;
}

/* Eyebrow / label style */
.eyebrow {
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.perf-divider {
  height: 1px;
  background: var(--border);
}

/* Auto mode toggle */
.auto-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--text-dim);
  width: 100%;
  transition: color 0.2s;
}
.auto-btn:hover { color: var(--text); }
.auto-btn[aria-checked="true"] { color: var(--accent); }

.auto-icon { flex-shrink: 0; }
.auto-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  flex: 1;
  text-align: left;
}

.pill {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
  transition: background 0.25s var(--ease);
}
.auto-btn[aria-checked="true"] .pill { background: var(--accent); }

.pill-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.auto-btn[aria-checked="true"] .pill-thumb { transform: translateX(16px); }

/* ── Clear cache button ───────────────────────────────────────────── */
.clear-cache-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}
.clear-cache-btn:hover { color: var(--accent); }
.clear-cache-btn span { flex: 1; text-align: left; }

/* ── Top HUD rail ─────────────────────────────────────────────────── */
.hud-rail {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  z-index: 10;
}

.hud-btn {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
}
.hud-btn:hover {
  color: var(--text);
  border-color: var(--border-hi);
  background: var(--surface-hi);
  transform: scale(1.06);
}
.hud-btn:active { transform: scale(0.96); }

.hud-btn--accent { color: var(--accent); border-color: rgba(200,169,110,0.2); }
.hud-btn--accent:hover { border-color: var(--accent); background: var(--accent-dim); }

.hud-sep {
  width: 1px;
  height: 36px;
  background: var(--border);
}

/* ── Category dock background — arch shape ───────────────────────────── */
/* Separate element so clip-path can arch the glass without conflicting    */
/* with overflow-x: auto on the scroll container.                          */
.category-filter-bg {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 92px;
  z-index: 9;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.11) 0%,
    rgba(255, 255, 255, 0.05) 100%);
  backdrop-filter: blur(36px) saturate(210%);
  -webkit-backdrop-filter: blur(36px) saturate(210%);
  /* border-top follows the arch curve because clip-path clips it too */
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  /* Dome arch: ellipse centred at the bottom edge, peaking in the middle.  */
  /* At centre: full 92 px tall. At edges: ≈ 64 px tall. 28 px of arch.   */
  clip-path: ellipse(72% 92px at 50% 100%);
  transition: transform 0.38s var(--ease), opacity 0.32s var(--ease);
}
.category-filter-bg.bar-hidden {
  transform: translateY(calc(100% + 20px));
  opacity: 0;
}

/* ── Category dock scroll container — transparent, sits above bg ─────── */
.category-filter {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  z-index: 10;
  padding: 18px 0 12px;
  background: transparent;
  -webkit-mask-image: linear-gradient(to right,
    transparent 0%,
    black 5%,
    black 95%,
    transparent 100%);
  mask-image: linear-gradient(to right,
    transparent 0%,
    black 5%,
    black 95%,
    transparent 100%);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  touch-action: none;
  transition: transform 0.38s var(--ease), opacity 0.32s var(--ease);
}
.category-filter::-webkit-scrollbar { display: none; }
.category-filter:empty { display: none; }
.category-filter.bar-hidden {
  transform: translateY(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
}

.cat-spacer {
  flex-shrink: 0;
  pointer-events: none;
}

.filter-tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 24px 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.25s var(--ease);
  transform-origin: bottom center;  /* magnify upward from the dock base */
  will-change: transform, opacity;
}
.filter-tag.active {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
}
.filter-tag-icon {
  display: block;
  line-height: 1;
  font-size: 1.5rem;
}
.filter-tag-icon-img {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

/* ── Carousel ─────────────────────────────────────────────────────── */
.carousel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: var(--bottom-inset);
  width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.075) 0%,
    rgba(255,255,255,0.03)  55%,
    rgba(0,0,0,0.18)        100%);
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border-left: 1px solid rgba(255,255,255,0.09);
  border-radius: 18px 0 0 18px;
  box-shadow:
    -12px 0 48px rgba(0,0,0,0.55),
    -3px  0 12px rgba(0,0,0,0.3),
    inset 1px  0 0 rgba(255,255,255,0.09),
    inset -1px 0 0 rgba(0,0,0,0.2);
  /* infinity edges — content fades at top and bottom */
  -webkit-mask-image: linear-gradient(to bottom,
    transparent  0%,
    black        9%,
    black        91%,
    transparent  100%);
  mask-image: linear-gradient(to bottom,
    transparent  0%,
    black        9%,
    black        91%,
    transparent  100%);
  z-index: 10;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: none;             /* scroll handled in JS (wheel + pointer drag) */
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
  scrollbar-width: none;         /* Firefox */
  -webkit-overflow-scrolling: touch;
  transition: transform 0.38s var(--ease), opacity 0.32s var(--ease);
  will-change: transform;
}
.carousel::-webkit-scrollbar { display: none; }

.carousel-spacer {
  flex-shrink: 0;
  width: 100%;
  pointer-events: none;
}
.carousel.bar-hidden {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
}

.carousel-collapse-btn {
  position: fixed;
  right: 130px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 11;
  width: 22px;
  height: 52px;
  padding: 0;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.075) 0%,
    rgba(255,255,255,0.03)  55%,
    rgba(0,0,0,0.18)        100%);
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border: 1px solid rgba(255,255,255,0.09);
  border-right: none;
  border-radius: 10px 0 0 10px;
  box-shadow: -4px 0 16px rgba(0,0,0,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.45);
  transition: right 0.38s var(--ease), background 0.2s, color 0.2s;
}
.carousel-collapse-btn:hover {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.95);
}
.carousel-collapse-btn svg {
  transition: transform 0.32s var(--ease);
  transform: rotate(180deg); /* carousel visible → chevron points right (›) */
}
.carousel-collapse-btn.bar-hidden {
  right: 0;
}
.carousel-collapse-btn.bar-hidden svg {
  transform: rotate(0deg); /* carousel hidden → chevron points left (‹) */
}
@media (max-width: 480px) {
  .carousel-collapse-btn { right: 100px; }
  .carousel-collapse-btn.bar-hidden { right: 0; }
}

/* ── Mobile responsive adjustments ───────────────────────────────── */
@media (max-width: 480px) {
  .carousel {
    width: 100px;
    gap: 8px;
  }
  .card {
    width: 80px;
  }
  .card-thumb {
    width: 60px;
    height: 44px;
  }
  .hud-rail {
    top: 20px;
  }
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  flex-shrink: 0;
  scroll-snap-align: center;
  transform: scale(var(--card-scale, 0.82));
  transform-origin: center center;
  transition:
    background 0.22s var(--ease),
    border-color 0.22s var(--ease),
    box-shadow 0.22s var(--ease),
    transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
  width: 92px;
}

@keyframes update-dot-pulse {
  0%, 100% { opacity: 1;   transform: translateX(-50%) scale(1);   }
  50%       { opacity: 0.5; transform: translateX(-50%) scale(1.35); }
}
.update-dot {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f97316;
  z-index: 9999;
  pointer-events: none;
  animation: update-dot-pulse 1.4s ease-in-out infinite;
}
.card:not([aria-selected="true"]):hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--border-hi);
  transform: scale(var(--card-scale, 0.82)) translateY(-3px);
}
.card[aria-selected="true"] {
  background: rgba(200, 169, 110, 0.14);
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 10px 40px rgba(200, 169, 110, 0.28),
    0 0 20px rgba(200, 169, 110, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.card-thumb {
  width: 68px;
  height: 50px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.card-label {
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-align: center;
  transition: color 0.2s;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  max-height: 2.8em;
  word-break: break-word;
}
.card[aria-selected="true"] .card-label {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.card-label--arabic {
  font-family: 'Almarai', sans-serif;
  direction: rtl;
  letter-spacing: 0;
}

.filter-tag--arabic {
  font-family: 'Almarai', sans-serif;
  direction: rtl;
  letter-spacing: 0;
}

.card-tris {
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

/* ── Upload card ──────────────────────────────────────────────────── */
.card--upload {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
}
.card--upload:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  transform: translateY(-2px);
}

.card-thumb--upload {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-faint);
  transition: color 0.2s;
}
.card--upload:hover .card-thumb--upload { color: var(--text-dim); }

/* ── Cache badge ──────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  z-index: 1;
  animation: fadeUp 0.5s var(--ease);
}
.empty-state[hidden] { display: none; }
.empty-icon { opacity: 0.16; margin-bottom: 4px; }
.empty-title {
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.28);
}
.empty-sub { font-size: 0.75rem; color: rgba(255, 255, 255, 0.15); }
.empty-formats {
  font-size: 0.5625rem;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.09);
  margin-top: 2px;
}

/* ── Content fade on item switch ─────────────────────────────────── */
/* Fades only the viewer and info panel — carousel is untouched.     */
model-viewer,
#media-image,
#media-video,
.info-panel,
.hud-rail {
  transition: opacity 0.4s var(--ease);
}
body.content-fading model-viewer,
body.content-fading #media-image,
body.content-fading #media-video,
body.content-fading .info-panel,
body.content-fading .hud-rail {
  opacity: 0;
  pointer-events: none;
}

/* ── Utility ──────────────────────────────────────────────────────── */
button { cursor: pointer; }
svg { display: block; }
