:root {
  color-scheme: dark;
  --bg: #000000;
  --panel: #111111;
  --panel-soft: #1d1d1d;
  --field: #1f1f1f;
  --field-hover: #262626;
  --line: #2d2d2d;
  --line-strong: #555555;
  --text: #f5f5f5;
  --muted: #a6a6a6;
  --muted-soft: #707070;
  --accent: #9b7cff;
  --accent-blue: #2997ff;
  --radius: 7px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 18px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    opacity 140ms ease;
}

button:hover:not(:disabled) {
  background: var(--field-hover);
  border-color: var(--line-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

h1,
h2,
p {
  margin: 0;
}

.app-topbar {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr) auto;
  align-items: center;
  height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid #1b1b1b;
  background: #050505;
}

.topbar-brand,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand strong {
  font-size: 16px;
  font-weight: 760;
  line-height: 1;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 0;
  background: url("./logo.svg") center / 20px 20px no-repeat;
}

.beta-badge {
  display: inline-grid;
  place-items: center;
  height: 23px;
  padding: 0 9px;
  border: 1px solid #2f2f2f;
  border-radius: 999px;
  background: #242424;
  color: #8f8f8f;
  font-size: 11px;
  font-weight: 700;
}

.showcase-title {
  overflow: hidden;
  padding-left: 28px;
  border-left: 1px solid #1f1f1f;
  color: #f2f2f2;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.batch-action {
  min-width: 72px;
  border: 0;
  background: var(--accent);
  color: #ffffff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(360px, 1fr) 288px;
  gap: 16px;
  min-height: calc(100vh - 48px);
  padding: 12px 13px 17px;
  background: var(--bg);
}

.style-selector,
.controls {
  height: calc(100vh - 77px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  scrollbar-color: #4a4a4a transparent;
}

.selector-heading,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.selector-heading h2,
.panel-header h2 {
  color: var(--text);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
}

.collapse-button {
  display: grid;
  place-items: center;
  min-width: 30px;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #bdbdbd;
  font-size: 13px;
  line-height: 1;
}

.collapse-icon {
  display: block;
  width: 16px;
  color: currentColor;
  font-family: Arial, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 16px;
  text-align: center;
}

.collapse-button:hover:not(:disabled) {
  background: #202020;
  border-color: transparent;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 86px;
  margin: 12px 8px 16px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: #1b1b1b;
  text-align: center;
  cursor: pointer;
}

.drop-zone.is-dragging {
  border-color: var(--accent-blue);
  background: rgba(41, 151, 255, 0.09);
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 24px;
  font-weight: 400;
  line-height: 24px;
}

.drop-zone strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 760;
}

.drop-zone small {
  margin-top: 2px;
  color: var(--muted-soft);
  font-size: 10px;
  font-weight: 600;
}

.selector-section {
  padding: 10px 8px 16px;
}

.selector-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--muted-soft);
  font-size: 11px;
  line-height: 1;
}

.selector-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #2a2a2a;
}

.selector-label span {
  order: -1;
}

.selector-label b {
  color: var(--muted-soft);
  font-size: 10px;
  font-weight: 600;
}

.effect-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.effect-tile {
  display: grid;
  align-content: stretch;
  min-height: 95px;
  overflow: hidden;
  padding: 0;
  border-radius: 5px;
  background: #202020;
  text-align: left;
}

.effect-tile {
  border: 1px solid var(--line-strong);
}

.effect-tile.is-active {
  border-color: #d8d8d8;
}

.effect-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1.35;
  background:
    linear-gradient(45deg, #242424 25%, transparent 25%),
    linear-gradient(-45deg, #242424 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #242424 75%),
    linear-gradient(-45deg, transparent 75%, #242424 75%),
    #1d1d1d;
  background-position:
    0 0,
    0 6px,
    6px -6px,
    -6px 0;
  background-size: 12px 12px;
}

.effect-thumb-dither {
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.42) 1px, transparent 1px),
    linear-gradient(135deg, #d8b45c, #4b692c 55%, #111111);
  background-size:
    4px 4px,
    auto;
}

.effect-thumb-image-dither {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.56) 1px, transparent 1.5px),
    url("/effect-covers/image-dithering.jpg") center / cover no-repeat;
  background-size:
    4px 4px,
    cover;
  background-blend-mode: soft-light, normal;
}

.effect-thumb-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.effect-thumb-mesh {
  background:
    radial-gradient(circle at 20% 72%, rgba(235, 240, 255, 0.92), transparent 32%),
    radial-gradient(circle at 72% 20%, rgba(246, 70, 145, 0.9), transparent 42%),
    linear-gradient(135deg, #b7a1ff, #7d31bd);
  filter: blur(0.2px);
}

.effect-thumb-static-mesh {
  background:
    radial-gradient(ellipse at 55% 46%, rgba(132, 43, 255, 0.82), transparent 30%),
    radial-gradient(circle at 20% 78%, rgba(255, 173, 10, 0.95), transparent 20%),
    linear-gradient(135deg, #d9859b, #d768d4 52%, #9c2eff);
}

.effect-thumb-radial {
  background:
    radial-gradient(circle at 50% 60%, #ffffff 0 8%, #00ffe1 18%, #00bbff 35%, transparent 56%),
    #000000;
  filter: blur(1px);
}

.effect-thumb-grain {
  background:
    radial-gradient(circle at 85% 10%, rgba(0, 191, 255, 0.95), transparent 32%),
    radial-gradient(circle at 5% 94%, rgba(115, 0, 255, 0.95), transparent 38%),
    radial-gradient(circle at 50% 50%, rgba(235, 168, 255, 0.7) 1px, transparent 1px),
    #000000;
  background-size:
    auto,
    auto,
    3px 3px,
    auto;
}

.effect-thumb-dot-grid {
  background:
    radial-gradient(circle, #f5f5f5 1.4px, transparent 1.8px),
    #000000;
  background-size: 20px 20px;
}

.effect-thumb-warp {
  background:
    radial-gradient(ellipse at 25% 55%, rgba(148, 112, 255, 0.9), transparent 26%),
    radial-gradient(ellipse at 70% 24%, rgba(136, 56, 255, 0.85), transparent 30%),
    repeating-radial-gradient(ellipse at 56% 50%, #221638 0 8px, #5d3bb3 10px 16px, #111111 19px 28px);
  filter: blur(0.4px);
}

.effect-tile span:last-child {
  overflow: hidden;
  min-height: 24px;
  padding: 5px 7px;
  color: #cfcfcf;
  font-size: 11px;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  position: relative;
  display: grid;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: calc(100vh - 77px);
  padding: 24px;
}

.empty-state.is-hidden {
  display: none;
}

.shader-stage {
  width: min(920px, 88%);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000000;
  transition: width 180ms ease;
}

.sample-stage {
  width: min(920px, 88%);
  aspect-ratio: 735 / 475;
  overflow: hidden;
  background: #000000;
  cursor: zoom-in;
  transition: width 180ms ease;
}

.sample-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.shader-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000000;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-content: center;
  gap: 16px;
  min-height: calc(100vh - 77px);
  padding: 24px;
}

.image-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}

.canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 220px;
  background:
    linear-gradient(45deg, #151515 25%, transparent 25%),
    linear-gradient(-45deg, #151515 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151515 75%),
    linear-gradient(-45deg, transparent 75%, #151515 75%),
    #0c0c0c;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
  cursor: zoom-in;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
}

.card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
}

.file-meta {
  min-width: 0;
}

.file-meta strong,
.file-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta strong {
  color: var(--text);
  font-size: 12px;
}

.file-meta span {
  margin-top: 2px;
  color: var(--muted-soft);
  font-size: 11px;
}

.controls {
  align-self: start;
}

body.is-left-collapsed .app-shell {
  grid-template-columns: 46px minmax(360px, 1fr) 288px;
}

body.is-right-collapsed .app-shell {
  grid-template-columns: 256px minmax(360px, 1fr) 46px;
}

body.is-left-collapsed.is-right-collapsed .app-shell {
  grid-template-columns: 46px minmax(360px, 1fr) 46px;
}

body.is-left-collapsed .style-selector,
body.is-right-collapsed .controls {
  overflow: hidden;
}

body.is-left-collapsed .selector-heading,
body.is-right-collapsed .panel-header {
  justify-content: center;
  padding: 0;
}

body.is-left-collapsed .selector-heading h2,
body.is-left-collapsed .selector-section,
body.is-right-collapsed .panel-header h2,
body.is-right-collapsed .control-group {
  display: none;
}

body.is-left-collapsed .shader-stage,
body.is-right-collapsed .shader-stage {
  width: min(96%, 1500px, calc(178vh - 171px));
}

body.is-left-collapsed .sample-stage,
body.is-right-collapsed .sample-stage {
  width: min(96%, 1500px, calc(155vh - 149px));
}

.control-group {
  margin: 0;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.is-hidden {
  display: none !important;
}

.control-group .drop-zone {
  min-height: 112px;
  margin: 0;
}

.control-group .drop-zone .drop-icon {
  display: grid;
  align-items: center;
  justify-content: center;
}

.control-group:first-of-type {
  border-top: 0;
}

.control-group h2 {
  margin-bottom: 13px;
  color: var(--text);
  font-size: 15px;
  font-weight: 760;
  letter-spacing: 0;
}

.control-group label {
  display: grid;
  gap: 8px;
  margin-top: 15px;
  color: #8d8d8d;
  font-size: 12px;
  font-weight: 600;
}

.control-group label:first-of-type {
  margin-top: 0;
}

.control-group label > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.2;
}

.control-group label b {
  color: #a8a8a8;
  font-size: 12px;
  font-weight: 500;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.preset-button {
  min-height: 29px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: #b8b8b8;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
}

.preset-button:last-child {
  border-right: 0;
}

.preset-button.is-active {
  background: #213040;
  color: #f2f2f2;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: #d6d6d6;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background: #8a8a8a;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 8px;
  height: 8px;
  margin-top: -3px;
  border: 0;
  border-radius: 2px;
  background: #eeeeee;
}

input[type="range"]::-moz-range-track {
  height: 2px;
  border-radius: 999px;
  background: #8a8a8a;
}

input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 2px;
  background: #eeeeee;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
.canvas-wrap:focus-visible,
.sample-stage:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.switch {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch input {
  width: 20px;
  height: 20px;
  accent-color: #eeeeee;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 9px;
  margin-top: 14px;
}

.swatches label {
  margin: 0;
  gap: 7px;
}

.swatches label:nth-child(3) {
  grid-column: 1 / 2;
}

.color-field {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  min-height: 32px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.color-field input[type="color"] {
  width: 32px;
  height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  padding: 7px;
}

.color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

.color-field input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 4px;
}

.static-color-swatch {
  display: block;
  width: 32px;
  height: 32px;
  border-right: 1px solid var(--line);
}

.color-value {
  overflow: hidden;
  padding: 0 10px;
  color: #dcdcdc;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
}

.lightbox.is-open {
  display: grid;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
}

.lightbox-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, calc(100vw - 48px));
  height: min(840px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.lightbox-header h2 {
  overflow: hidden;
  max-width: min(720px, 60vw);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-header p {
  margin-top: 3px;
  color: var(--muted-soft);
  font-size: 12px;
}

#lightboxImage {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050505;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 220px minmax(320px, 1fr) 280px;
    gap: 12px;
  }
}

@media (max-width: 900px) {
  .app-topbar {
    grid-template-columns: 1fr auto;
  }

  .showcase-title {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .style-selector,
  .controls {
    height: auto;
  }

  .empty-state {
    min-height: 520px;
  }
}
