.filter-stage {
  --skoptra-stick: max(4.85rem, calc(env(safe-area-inset-top) + 4.35rem));
  --skoptra-workspace: calc(100dvh - var(--skoptra-stick) - 1.35rem);
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(17.5rem, 0.68fr);
  gap: clamp(1rem, 2.4vw, 1.6rem);
  align-items: stretch;
  width: min(1080px, 100%);
  height: var(--skoptra-workspace);
  min-height: 28rem;
  margin: 0.4rem 0 1.5rem;
}

.filter-frame {
  position: sticky;
  top: var(--skoptra-stick);
  height: 100%;
  min-height: 0;
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(103, 232, 249, 0.08), transparent 46%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 24px 60px rgba(0, 0, 0, 0.28);
}

.filter-frame.is-hot {
  border-color: rgba(103, 232, 249, 0.45);
}

.filter-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #07080c;
  touch-action: none;
}

.filter-example {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  margin: 0;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.38);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  pointer-events: none;
}

.filter-frame:not(.is-example) .filter-example {
  display: none;
}

.filter-controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  max-height: 100%;
  padding: 0 1rem 1.1rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.32) transparent;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.filter-controls::-webkit-scrollbar {
  width: 8px;
}

.filter-controls::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 99px;
}

.filter-controls-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0 -1rem;
  padding: 0.85rem 1rem 0.7rem;
  background: rgba(8, 10, 14, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.filter-reset {
  flex: 0 0 auto;
  padding: 0.45rem 0.75rem;
  letter-spacing: 0.12em;
}

.filter-kicker {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.46);
}

.filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-preset {
  font: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
}

.filter-preset[aria-pressed="true"] {
  border-color: rgba(103, 232, 249, 0.7);
  background: rgba(103, 232, 249, 0.12);
  color: #fff;
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.16);
}

.filter-strength {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.filter-strength input {
  width: 100%;
  accent-color: #67e8f9;
}

.filter-strength input[type="range"] {
  touch-action: none;
  min-height: 1.75rem;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-fold {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.45rem;
  background: transparent;
  color: inherit;
}

.filter-fold summary {
  cursor: pointer;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.46);
}

.filter-fold summary:focus-visible {
  outline: 1px solid rgba(103, 232, 249, 0.7);
  outline-offset: 3px;
}

.filter-degree {
  display: grid;
  grid-template-columns: 1fr 4.2rem;
  gap: 0.45rem;
  align-items: center;
}

.filter-degree input[type="number"] {
  font: inherit;
  font-size: 0.72rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.35rem 0.45rem;
  text-align: center;
}

.filter-path {
  margin: 0.2rem 0 0;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}

.filter-readout {
  position: absolute;
  left: 16px;
  bottom: 28px;
  z-index: 3;
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.82);
  pointer-events: none;
}

.filter-exit {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  z-index: 400000;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
}

body.filter-clean .filter-exit {
  display: grid;
  place-items: center;
  pointer-events: auto;
}

body.filter-clean.filter-exit-hot .filter-exit {
  opacity: 1;
}

body.filter-clean.filter-cursor-hide,
body.filter-clean.filter-cursor-hide * {
  cursor: none !important;
}

.filter-frame.filter-bg-black { background: #000; }
.filter-frame.filter-bg-white { background: #fff; }
.filter-frame.filter-bg-dark { background: #0c0d10; }
.filter-frame.filter-bg-ambient {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(103, 232, 249, 0.08), transparent 46%),
    #07080c;
}
.filter-frame.filter-bg-custom { background: var(--filter-bg, #07080c); }

.filter-colors {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.filter-colors input[type="color"] {
  width: 100%;
  height: 1.55rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.filter-strength input[type="number"],
.filter-strength input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
}

.filter-note {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.75rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.48);
}

.filter-timeline {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 12px;
  z-index: 2;
  margin: 0;
}

.filter-timeline input[type="range"] {
  width: 100%;
  height: 2px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.32);
  border-radius: 99px;
  accent-color: #67e8f9;
  cursor: pointer;
}

.filter-timeline input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(103, 232, 249, 0.18);
}

.gadget-btn[aria-pressed="true"] {
  border-color: rgba(103, 232, 249, 0.7);
  background: rgba(103, 232, 249, 0.12);
}

body.filter-present .top-glass-dock,
body.filter-present .gadget-hero,
body.filter-present .filter-controls,
body.filter-present .filter-timeline,
body.filter-present .bottom-glass,
body.filter-present .audio-corner,
body.filter-present .gadget-skip,
body.filter-present .alma-breathe-trigger {
  display: none !important;
}

body.filter-present {
  overflow: hidden;
}

body.filter-present .gadget-main {
  max-width: none;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
}

body.filter-present .filter-stage {
  display: block;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0;
}

body.filter-present .filter-frame,
body.filter-present .filter-canvas {
  position: relative;
  top: auto;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  border: 0;
  border-radius: 0;
}

body.filter-present .filter-example {
  display: none;
}

@media (max-width: 980px) {
  .filter-stage {
    gap: 0.75rem;
  }

  .filter-preset {
    padding: 0.4rem 0.6rem;
  }
}

@media (max-width: 760px) {
  .filter-stage {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    margin-bottom: 1rem;
  }

  .filter-frame {
    position: sticky;
    top: var(--skoptra-stick);
    z-index: 4;
    height: clamp(210px, 40dvh, 380px);
  }

  .filter-controls {
    max-height: calc(100dvh - var(--skoptra-stick) - clamp(210px, 40dvh, 380px) - 0.85rem - env(safe-area-inset-bottom));
  }

  .filter-preset {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .filter-stage {
    grid-template-columns: minmax(0, 1.15fr) minmax(15rem, 0.85fr);
    height: calc(100dvh - var(--skoptra-stick) - 0.45rem);
    min-height: 0;
  }

  .filter-frame {
    position: sticky;
    height: 100%;
  }

  .filter-controls {
    max-height: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .filter-preset,
  .filter-frame {
    transition: none;
  }
}
