:root {
  --bg-primary: #08080c;
  --bg-secondary: #0e0e16;
  --bg-tertiary: #161622;
  --text-primary: #e0ddd8;
  --text-secondary: #8a8a8a;
  --text-dim: #555;
  --accent: #00ff88;
  --accent-glow: rgba(0, 255, 136, 0.25);
  --accent-dim: #00aa5a;
  --panel-bg: rgba(12, 12, 20, 0.92);
  --panel-border: rgba(255, 255, 255, 0.07);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  transition: filter 0.4s ease;
}

body.dither-active {
  filter: url(#bayer-dither);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Ensure nearest-neighbor interpolation for the dither pattern in SVG filters */
svg feImage {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.pixel-font {
  font-family: 'Press Start 2P', monospace;
}

.mono-font {
  font-family: 'IBM Plex Mono', monospace;
}

/* ======== CONTROL PANEL WRAPPER ======== */
.control-panel-wrapper {
  position: relative;
  z-index: 10001;
  filter: none !important;
  isolation: isolate;
}

/* ======== GEAR BUTTON ======== */
.gear-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.gear-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 24px rgba(0, 255, 136, 0.15);
}

.gear-btn:hover svg {
  transform: rotate(90deg);
}

.gear-btn svg {
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* ======== CONTROL PANEL ======== */
.control-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--panel-border);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.04);
}

.desktop-panel {
  position: fixed;
  top: 72px;
  right: 16px;
  width: 300px;
  max-height: calc(100vh - 88px);
  border-radius: 16px;
  z-index: 10000;
  overflow-y: auto;
}

.mobile-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  border-radius: 20px 20px 0 0;
  z-index: 10003;
  overflow-y: auto;
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10002;
}

.panel-inner {
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-title {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 1px;
}

.panel-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.panel-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

/* ======== SECTION LABEL ======== */
.section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-top: 18px;
  margin-bottom: 8px;
}

/* ======== TOGGLE ======== */
.toggle-track {
  width: 52px;
  height: 28px;
  min-width: 52px;
  border-radius: 14px;
  background: #2a2a3a;
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease;
}

.toggle-track.active {
  background: var(--accent);
}

.toggle-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.toggle-track.active .toggle-thumb {
  transform: translateX(24px);
}

/* ======== SLIDER ======== */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #2a2a3a;
  border-radius: 3px;
  outline: none;
  margin: 4px 0;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* ======== RADIO GROUP ======== */
.radio-group {
  display: flex;
  gap: 4px;
  background: #14142a;
  border-radius: 10px;
  padding: 3px;
}

.radio-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  white-space: nowrap;
  min-height: 36px;
}

.radio-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 700;
}

.radio-btn:hover:not(.active) {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

/* ======== PRESET GRID ======== */
.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.02);
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 36px;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 255, 136, 0.05);
}

.preset-btn.active {
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.1);
  color: var(--accent);
}

/* ======== INFO BOX ======== */
.info-box {
  margin-top: 18px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  border: 1px solid var(--panel-border);
}

.info-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--accent-dim);
  display: block;
  margin-bottom: 6px;
}

.info-text {
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ======== SCREENSHOT BUTTON ======== */
.screenshot-btn {
  margin-top: 16px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
}

.screenshot-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 255, 136, 0.05);
}

/* ======== HERO SECTION ======== */
.hero-section {
  position: relative;
  overflow: hidden;
}

.hero-gradient {
  min-height: 340px;
  background: linear-gradient(
    135deg,
    #ff006e 0%,
    #fb5607 15%,
    #ffbe0b 30%,
    #00f5d4 50%,
    #00bbf9 65%,
    #9b5de5 80%,
    #f15bb5 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-content {
  text-align: center;
  padding: 40px 20px;
  position: relative;
  z-index: 1;
}

.hero-title {
  font-size: 28px;
  color: white;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.4);
  margin-bottom: 16px;
  letter-spacing: 4px;
}

.hero-subtitle {
  font-size: 8px;
  color: white;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
  opacity: 0.9;
  letter-spacing: 2px;
  line-height: 2;
  max-width: 500px;
  margin: 0 auto;
}

.hero-desc {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  margin-top: 12px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.hero-dots {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
}

.hero-dot {
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 3px;
}

/* ======== CONTENT SECTIONS ======== */
.content-section {
  padding: 48px 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.section-title {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.section-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  max-width: 560px;
  line-height: 1.6;
}

/* ======== GRADIENT STRIPS ======== */
.gradient-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gradient-bar {
  height: 48px;
  border-radius: 10px;
}

/* ======== PHOTO GRID ======== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.photo-card {
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--panel-border);
}

.photo-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

/* ======== TYPOGRAPHY ======== */
.type-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.type-hero {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 36px;
  font-weight: 700;
  color: white;
}

.type-sub {
  font-size: 20px;
  font-weight: 300;
  color: var(--text-secondary);
}

.type-body {
  font-size: 15px;
  color: #999;
  max-width: 640px;
  line-height: 1.7;
}

.type-meta {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 640px;
  line-height: 1.6;
}

.type-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: baseline;
  margin-top: 8px;
}

.type-sample {
  color: white;
  font-weight: 700;
}

/* ======== SWATCH GRID ======== */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.color-swatch {
  border-radius: 8px;
  aspect-ratio: 1;
  transition: transform 0.2s;
  cursor: default;
}

.color-swatch:hover {
  transform: scale(1.08);
}

/* ======== GRADIENT BUILDER ======== */
.gradient-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.color-pick {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-input {
  -webkit-appearance: none;
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  width: 44px;
  height: 36px;
  cursor: pointer;
  background: transparent;
  padding: 2px;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.color-hex {
  font-size: 12px;
  color: var(--text-secondary);
}

.arrow-sep {
  color: var(--text-dim);
  font-size: 18px;
}

.gradient-preview-main {
  height: 100px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
}

.gradient-angles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.gradient-angle-box {
  height: 64px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
}

/* ======== FOOTER ======== */
.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--panel-border);
  padding: 32px 20px;
  text-align: center;
  margin-top: 48px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.footer-tag {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.footer-sub {
  font-size: 7px;
  color: #333;
  letter-spacing: 1px;
}

.footer-link-wrap {
  margin-top: 12px;
}

.footer-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

.footer-link:hover {
  opacity: 0.7;
}

/* ======== SCROLLBAR ======== */
.desktop-panel::-webkit-scrollbar,
.mobile-panel::-webkit-scrollbar {
  width: 4px;
}

.desktop-panel::-webkit-scrollbar-track,
.mobile-panel::-webkit-scrollbar-track {
  background: transparent;
}

.desktop-panel::-webkit-scrollbar-thumb,
.mobile-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
}

/* ======== RESPONSIVE ======== */
@media (max-width: 768px) {
  .hero-title {
    font-size: 18px;
    letter-spacing: 2px;
  }

  .hero-subtitle {
    font-size: 7px;
  }

  .hero-desc {
    font-size: 12px;
  }

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

  .content-section {
    padding: 32px 16px;
  }

  .section-title {
    font-size: 9px;
  }

  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .swatch-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }

  .type-hero {
    font-size: 24px;
  }

  .type-sub {
    font-size: 16px;
  }

  .gradient-angles {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .gradient-preview-main {
    height: 80px;
  }

  .gradient-angle-box {
    height: 52px;
  }

  .gradient-bar {
    height: 36px;
  }
}

@media (max-width: 400px) {
  .swatch-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }
}