/* ========== RESET & BASE ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: var(--color-bg);
  --text: var(--color-text);
  --text-dim: var(--color-text-dim);
  --glass-bg: var(--color-hover);
  --glass-border: var(--color-border-strong);
  --glass-bg-hover: var(--color-hover-strong);
  --accent: var(--color-accent);
  --radius: var(--radius-lg);
  --bar-h: 56px;
}

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
}

body {
  background: #2a2a2a;
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

html {
  overflow-x: hidden;
  background: #2a2a2a;
  touch-action: manipulation;
  -ms-touch-action: manipulation;
}

img, video {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  pointer-events: auto;
}

/* Prevent background scroll while overlay/lightbox is open */
/* .grid / .site-footer rules are grid-specific and stay here. The shared
   html:has(body.scroll-locked) rule now lives in overlay.css. */
body.scroll-locked .grid,
body.scroll-locked .site-footer {
  touch-action: none !important;
}

/* ========== SQUARE GRID ========== */
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 120px 24px 80px;
  max-width: 1800px;
  margin: 0 auto;
  min-height: 60vh;
  transition: opacity 0.25s ease;
}

.grid-item {
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  cursor: pointer;
  transform-origin: center center;
  aspect-ratio: 1 / 1;
  background: transparent;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  contain: layout style paint;
  container-type: inline-size;
}

.grid-item img,
.grid-item video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 2px;
}

.grid-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(255,255,255,0.8) 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.grid-item .item-label {
  position: absolute;
  top: auto;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 8px 10px;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 0;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  line-height: 1.25;
  max-width: calc(100% - 28px);
}
.grid-item .item-label-tag {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}
.grid-item .item-label-name {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.hover-video-wrap {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  bottom: 12px;
  border-radius: 2px;
  overflow: hidden;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hover-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.grid-item:hover {
  background: #3a3a3a;
}

.grid-item:hover .item-label {
  opacity: 1;
  transform: translateY(0);
}

.grid-item .item-label.lab-label {
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  font-family: var(--font-display);
  font-size: 30cqi;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
  padding: 16px;
  min-width: auto;
  max-width: none;
  width: calc(100% - 32px);
  text-align: center;
}

/* divider & slider in bar */
.bar-divider {
  width: 1px;
  height: 24px;
  background: rgba(0,0,0,0.1);
  margin: 0 6px;
  flex-shrink: 0;
}

.bar-slider {
  display: flex;
  align-items: center;
  padding: 0 8px;
  position: relative;
}

.bar-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  background: rgba(0,0,0,0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.bar-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #111;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
  position: relative;
  z-index: 3;
}


.bar-slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #111;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.bar-slider input[type="range"]::-moz-range-track {
  background: rgba(0,0,0,0.15);
  height: 4px;
  border-radius: 2px;
}

/* dots for each step */
.slider-dots {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 1;
}

.slider-dot {
  width: 1px;
  height: 8px;
  background: rgba(0,0,0,0.12);
  transition: background 0.15s;
}

.slider-dot.filled {
  background: rgba(255,255,255,0.25);
}


/* skeleton loader */
.grid-item.loading img {
  opacity: 0;
}

.grid-item.loading::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 10px;
  background: linear-gradient(110deg, #eee 30%, #f5f5f5 50%, #eee 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

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

/* filtered-out state */
.grid-item.hiding {
  animation: gridItemOut 0.35s cubic-bezier(0.32,0.72,0,1) forwards;
}

.grid-item.showing {
  animation: gridItemIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

.grid-item.hidden {
  display: none !important;
}

@keyframes gridItemOut {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0; }
}

@keyframes gridItemIn {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

/* ========== FLOATING BOTTOM BAR ========== */

/* Grid-specific bar overrides */
.bar-toggle.active {
  background: rgba(0,0,0,0.05);
  color: #000;
}

.bar-toggle.has-filter {
  color: #000;
}

.bar-reset {
  background: none;
  border: none;
  color: #222;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: var(--radius-pill);
  transition: background 0.2s, color 0.2s;
  display: none;
  animation: barItemPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

.bar-reset:hover {
  background: rgba(0,0,0,0.05);
  color: #000;
}

/* dropdown menus */
.bar-dropdown {
  position: absolute;
  bottom: calc(100% + 18px);
  left: 50%;
  transform: translateX(-50%) scale(0.92) translateY(8px);
  transform-origin: bottom center;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: visibility 0s 0.3s, opacity 0.3s cubic-bezier(0.32,0.72,0,1),
              transform 0.3s cubic-bezier(0.32,0.72,0,1);
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  will-change: transform, opacity;
}

.bar-dropdown::before {
  content: '';
  position: absolute;
  bottom: -18px;
  left: 0;
  right: 0;
  height: 18px;
}

.bar-dropdown.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 9999;
  transform: translateX(-50%) scale(1) translateY(0);
  transition: visibility 0s, opacity 0.3s cubic-bezier(0.34,1.56,0.64,1),
              transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.bar-dropdown button {
  background: none;
  border: none;
  color: rgba(0,0,0,0.5);
  font-family: var(--font-body);
  font-size: 0.75rem;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.bar-dropdown button:hover {
  background: rgba(0,0,0,0.05);
  color: #111;
}

.bar-dropdown button.active {
  color: var(--accent);
  background: rgba(0,102,255,0.08);
}

/* color swatches in dropdown */
#menu-nav,
#menu-category,
.bar-dropdown.color-grid {
  max-height: none;
  overflow: visible;
}

/* nav links in dropdown */
.bar-nav-link {
  display: block;
  color: #222;
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.75rem;
  padding: 8px 14px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.bar-nav-link:hover {
  background: rgba(0,0,0,0.05);
  color: #111;
}

.bar-nav-link.active {
  background: rgba(0,0,0,0.08);
  color: #111;
  font-weight: 600;
}



/* project filter buttons with thumbnails */
.proj-filter-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: rgba(0,0,0,0.5);
  font-family: var(--font-body);
  font-size: 0.75rem;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.proj-filter-btn:hover {
  background: rgba(0,0,0,0.05);
  color: #111;
}

.proj-filter-btn.active {
  color: #111;
  background: rgba(0,0,0,0.08);
}

.proj-filter-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

/* bar transitions */
@keyframes barItemPop {
  0% { transform: scale(0); opacity: 0; max-width: 0; padding: 12px 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; max-width: 200px; padding: 12px 16px; }
}

@keyframes barItemOut {
  0% { transform: scale(1); opacity: 1; max-width: 200px; padding: 12px 16px; }
  100% { transform: scale(0); opacity: 0; max-width: 0; padding: 12px 0; }
}

.bottom-bar {
  transition: padding 0.35s cubic-bezier(0.34,1.56,0.64,1),
              gap 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.bar-toggle, .bar-reset {
  transition: background 0.2s, transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

.bar-toggle:active {
  transform: scale(0.92);
}

.bar-toggle.has-filter {
  animation: barPulse 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes barPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* project toggle thumbnail */
.proj-toggle-thumb {
  display: none;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  margin: -4px 8px -4px 0;
  flex-shrink: 0;
}

.proj-toggle-thumb.visible {
  display: inline-block;
  animation: colorPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

#projectToggle {
  display: flex;
  align-items: center;
}

/* color indicator in nav button */
.color-indicator {
  display: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin: -4px 8px -4px 0;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.2);
}

.color-indicator.visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: colorPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes colorPop {
  0% { transform: scale(0); opacity: 0; width: 0; margin-right: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; width: 24px; margin-right: 8px; }
}


.color-indicator.visible:hover {
  position: relative;
}

.color-indicator.visible:hover::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='2' y1='2' x2='10' y2='10'/%3E%3Cline x1='10' y1='2' x2='2' y2='10'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.bar-toggle[data-menu="color"] {
  display: flex;
  align-items: center;
}

/* color swatch grid */
.bar-dropdown.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  min-width: 160px;
  padding: 8px;
}

.color-swatch-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  outline: none;
}

.color-swatch-btn:hover {
  transform: scale(1.2);
  border-color: rgba(255,255,255,0.4);
}

.color-swatch-btn.active {
  border-color: #fff;
  transform: scale(1.15);
}

/* Footer styles in footer.css */




/* ========== MOBILE TOP SLIDER ========== */
.mobile-slider-pill {
  display: none;
}

@media (max-width: 768px) {
  .mobile-slider-pill {
    display: flex;
    position: fixed;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    z-index: 90;
    align-items: center;
    justify-content: center;
    padding: 70px 14px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 0;
    box-shadow: var(--shadow-sm);
    transition: opacity 0.3s ease, transform 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
  }

  .mobile-slider-pill input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    transform: rotate(-90deg);
    margin: 0 -50px;
    height: 6px;
    background: rgba(0,0,0,0.08);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    position: relative;
    z-index: 2;
    touch-action: none;
  }

  .mobile-slider-pill input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.04);
  }


  .mobile-slider-pill input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    background: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  }



  .mobile-slider-pill .slider-dots {
    display: flex;
    position: absolute;
    top: 70px;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 0;
  }

  .mobile-slider-pill .slider-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(0,0,0,0.15);
  }

  /* hide desktop slider on mobile */
  .bottom-bar .bar-slider {
    display: none;
  }
  .bottom-bar .bar-divider,
  .bottom-bar .bar-reset {
    display: none !important;
  }


  /* nav text on mobile — match home/about */
  .bar-toggle, .bar-reset {
    font-size: 0.9rem !important;
    padding: 12px 16px !important;
  }
}

/* ========== LAYOUT TOGGLE — sharp, mono, no glass ========== */
.layout-toggle {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 90;
  display: flex;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 0;
  padding: 0;
  gap: 0;
  box-shadow: var(--shadow-sm);
}

.layout-btn {
  background: none;
  border: none;
  color: rgba(0,0,0,0.4);
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, color 0.18s ease;
}

.layout-btn:hover {
  color: #000;
}

.layout-btn.active {
  background: #000;
  color: #fff;
}

/* list view mode */
.grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 24px;
  padding-right: 24px;
}

.grid.list-view .grid-item {
  aspect-ratio: auto;
  border-radius: 0;
  padding: 10px 0;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  grid-template-rows: auto auto;
  gap: 0 12px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: transparent;
  overflow: visible;
  contain: none;
  content-visibility: visible;
}

.grid.list-view .grid-item:hover {
  background: rgba(0,0,0,0.02);
}

.grid.list-view .grid-item img,
.grid.list-view .grid-item video {
  width: 40px;
  height: 40px;
  max-width: 40px;
  max-height: 40px;
  object-fit: cover;
  border-radius: 6px;
  grid-row: 1 / 3;
  align-self: center;
}

.grid.switching .grid-item .item-label {
  display: none !important;
}

.grid.list-view .grid-item .item-label {
  position: static;
  opacity: 1 !important;
  transform: none !important;
  color: #333;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  white-space: nowrap;
  text-align: left;
  min-width: 0;
  max-width: none;
  pointer-events: none;
  grid-column: 2;
  grid-row: 1;
  align-self: end;
}

.grid.list-view .grid-item .item-meta {
  display: flex;
  gap: 16px;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  grid-column: 2;
  grid-row: 2;
  align-self: start;
}

.grid.list-view .grid-item::after {
  display: none;
}

.grid.list-view .hover-video {
  display: none;
}

/* hide meta in grid mode */
.grid-item .item-meta {
  display: none;
}

/* ========== NO RESULTS ========== */
.no-results {
  display: none;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #999;
  font-weight: 500;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.no-results.visible {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.no-results-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 0;
  padding: 9px 18px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #555;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  pointer-events: auto;
}

.no-results-btn:hover {
  background: #000;
  color: #fff;
  border-color: #000;
}

/* ========== WATERMARK ========== */
.watermark {
  position: fixed;
  top: 20px;
  left: 24px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #111;
  z-index: 90;
  text-decoration: none;
  cursor: pointer;
  height: 36px;
  display: flex;
  align-items: center;
}

.watermark .wm-letter {
  display: inline-block;
  transform-origin: bottom center;
  transition: transform 0.6s cubic-bezier(0.34,1.56,0.64,1);
  will-change: transform;
}


/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
  .grid { grid-template-columns: repeat(3, 1fr); padding: 80px 16px 90px; gap: 6px; }
  .grid-item { border-radius: 10px; padding: 4px; }
  .grid-item img, .grid-item video { border-radius: 8px; }
  .hover-video-wrap { top: 4px; left: 4px; right: 4px; bottom: 4px; border-radius: 8px; }
  .bottom-bar { max-width: calc(100vw - 24px); width: auto; }
  .bar-toggle, .bar-reset { font-size: 0.9rem; padding: 10px 16px; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 80px 16px 90px; }
  .bar-toggle, .bar-reset { font-size: 0.9rem; padding: 10px 16px; }
}

/* ========== CONTROL PANEL — top-right unified controls ========== */
.control-panel {
  position: fixed;
  top: clamp(20px, 3vh, 32px);
  right: clamp(20px, 3vw, 32px);
  z-index: 200;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 10px;
  background: rgba(8, 8, 10, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  font-family: ui-monospace, "IBM Plex Mono", Menlo, Consolas, monospace;
  color: #f0f0f0;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.04);
  transform-origin: top right;
  transform: scale(1);
  opacity: 1;
  transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.22s ease 0.04s,
              clip-path 0.36s cubic-bezier(0.16, 1, 0.3, 1);
  clip-path: inset(0 0 0 0);
}
/* Collapsed: pinch into the handle's footprint at the top-right corner.
   The clip-path keeps the inner content from poking out while it scales. */
.control-panel.is-collapsed {
  transform: scale(0.18);
  opacity: 0;
  clip-path: inset(0 0 calc(100% - 28px) calc(100% - 64px));
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.7, 0, 0.32, 1),
              opacity 0.18s ease,
              clip-path 0.28s cubic-bezier(0.7, 0, 0.32, 1);
}

/* tiny corner ticks for tech feel */
.control-panel::before,
.control-panel::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(74, 222, 128, 0.55);
  pointer-events: none;
}
.control-panel::before {
  top: -1px;
  left: -1px;
  border-right: none;
  border-bottom: none;
}
.control-panel::after {
  bottom: -1px;
  right: -1px;
  border-left: none;
  border-top: none;
}

.cp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.14);
}
.cp-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.7);
  animation: cpPulse 1.7s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes cpPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.cp-title {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #4ade80;
  flex: 1;
}
.cp-collapse {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.7);
  width: 22px;
  height: 18px;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cp-collapse:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
.cp-collapse-glyph { display: block; transform: translateY(-1px); }

.cp-meter {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 0 6px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.10);
}
.cp-meter-num {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.cp-meter-total { color: rgba(255, 255, 255, 0.35); }
.cp-meter-sep { color: rgba(255, 255, 255, 0.3); }
.cp-meter-label {
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-left: auto;
}

.cp-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  position: relative;
}
.cp-row-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  flex-shrink: 0;
  width: 44px;
}

.cp-toggle-pair {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.cp-icon-btn {
  width: 28px;
  height: 24px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.cp-icon-btn + .cp-icon-btn { border-left: 1px solid rgba(255, 255, 255, 0.16); }
.cp-icon-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.04); }
.cp-icon-btn.active {
  background: #4ade80;
  color: #000;
}

.cp-section-cols { gap: 10px; }
.cp-slider-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  height: 16px;
}
.control-panel #gridSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  margin: 0;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.control-panel #gridSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  background: #4ade80;
  border-radius: 0;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}
.control-panel #gridSlider::-moz-range-thumb {
  width: 10px; height: 10px;
  background: #4ade80; border: none; border-radius: 0;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}
.control-panel .slider-dots {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 1;
}
.control-panel .slider-dot {
  width: 1px;
  height: 6px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.15s, height 0.15s;
}
.control-panel .slider-dot.filled {
  background: rgba(74, 222, 128, 0.7);
  height: 8px;
}
.cp-slider-val {
  font-size: 0.66rem;
  font-weight: 600;
  color: #fff;
  width: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cp-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 2px;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: rgba(74, 222, 128, 0.7);
}
.cp-divider span { flex-shrink: 0; }
.cp-divider::before,
.cp-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(74, 222, 128, 0.18);
}

.cp-filter-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 5px 8px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.cp-filter-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
.cp-filter-btn.has-filter {
  border-color: #4ade80;
  color: #fff;
  box-shadow: inset 2px 0 0 #4ade80;
}
.cp-filter-btn .cp-caret {
  margin-left: auto;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
}
.cp-filter-btn .proj-toggle-thumb {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  display: none;
  object-fit: cover;
}
.cp-filter-btn .proj-toggle-thumb.visible { display: block; }
.cp-filter-btn .color-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.cp-filter-btn .color-indicator.visible { display: block; }

/* dropdown opens BELOW the trigger button, right-aligned to its section.
   Override every property the .bar-dropdown base rule sets so it doesn't
   try to fly upward like the old bottom-bar dropdowns. */
.cp-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: auto;
  bottom: auto;
  transform: translateY(-4px) scale(0.97);
  transform-origin: top right;
  background: rgba(12, 12, 14, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  padding: 6px;
  min-width: 180px;
  max-width: min(240px, calc(100vw - 60px));
  max-height: 320px;
  overflow-y: auto;
  z-index: 250;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: visibility 0s 0.2s, opacity 0.18s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.cp-dropdown::before { display: none; } /* kill the upward bridge from old dropdown */
.cp-dropdown.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: visibility 0s, opacity 0.18s ease, transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
.cp-dropdown button {
  color: rgba(255, 255, 255, 0.7);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: 0;
}
.cp-dropdown button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.cp-dropdown button.active {
  color: #000;
  background: #4ade80;
}
.cp-dropdown.color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 8px;
}
.cp-dropdown .proj-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.66rem;
}
.cp-dropdown .proj-filter-btn .proj-filter-thumb {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 2px;
}

/* Inline color swatches — replaces the color dropdown trigger */
.cp-section-color { align-items: flex-start; }
.cp-section-color .cp-row-label { padding-top: 4px; }
.cp-swatches {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.cp-swatch {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.cp-swatch:hover {
  transform: scale(1.18);
  border-color: rgba(255, 255, 255, 0.55);
}
.cp-swatch.active {
  border-color: #4ade80;
  box-shadow: 0 0 0 1px #4ade80, 0 0 8px rgba(74, 222, 128, 0.6);
  transform: scale(1.18);
}

.cp-sort {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}
.cp-sort-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.65);
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 5px 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.cp-sort-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}
.cp-sort-btn.active {
  background: #4ade80;
  color: #000;
  border-color: #4ade80;
}

.cp-search {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  padding: 4px 8px;
}
.cp-search-prompt {
  color: #4ade80;
  font-weight: 700;
}
.cp-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  padding: 2px 0;
  caret-color: #4ade80;
  min-width: 0;
}
.cp-search input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}
.cp-search-clear {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 2px;
  display: none;
}
.cp-search.has-text .cp-search-clear { display: inline-block; }
.cp-search-clear:hover { color: #fff; }

.cp-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.14);
}
.control-panel .cp-reset {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 5px 8px;
  cursor: pointer;
  display: none; /* shown by JS when filters are active */
  transition: all 0.12s ease;
}
.control-panel .cp-reset:hover {
  background: #4ade80;
  color: #000;
  border-color: #4ade80;
}
.cp-foot-status {
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.45);
  margin-left: auto;
}

/* Collapsed-state handle — the panel pinches into roughly this footprint. */
.cp-handle {
  position: fixed;
  top: clamp(20px, 3vh, 32px);
  right: clamp(20px, 3vw, 32px);
  z-index: 199;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(8, 8, 10, 0.85);
  border: 1px solid rgba(74, 222, 128, 0.55);
  color: #fff;
  font-family: ui-monospace, "IBM Plex Mono", Menlo, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  cursor: pointer;
  transform-origin: top right;
  transform: scale(0.6);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.18s ease,
              background 0.15s ease, border-color 0.15s ease;
}
.cp-handle.is-visible {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1) 0.18s,
              opacity 0.22s ease 0.18s,
              background 0.15s ease, border-color 0.15s ease;
}
.cp-handle[hidden] { display: none; }
.cp-handle:hover {
  background: #4ade80;
  color: #000;
}
.cp-handle:hover .cp-handle-pulse { background: #000; box-shadow: none; }
.cp-handle-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.7);
  animation: cpPulse 1.7s ease-in-out infinite;
}

/* Mobile: panel becomes a slide-down sheet from the top */
@media (max-width: 768px) {
  .control-panel {
    width: calc(100vw - 24px);
    right: 12px;
    top: 12px;
    padding: 10px 12px 8px;
  }
  .cp-section { gap: 6px; }
  .cp-row-label { width: 38px; font-size: 0.54rem; }
}
