/* Mesh gradient studio — layout & UI */

.mgs-tool {
  max-width: 52rem;
}

.mgs-layout {
  display: grid;
  gap: 1.5rem;
}

.mgs-layout > .mgs-tool-directions {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

@media (min-width: 960px) {
  .mgs-layout {
    grid-template-columns: minmax(300px, 380px) 1fr;
    align-items: start;
    gap: 1.75rem;
  }

  .mgs-controls-wrap {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding-right: 0.25rem;
    margin-right: -0.25rem;
    scrollbar-gutter: stable;
  }

  .mgs-controls-wrap::-webkit-scrollbar {
    width: 6px;
  }

  .mgs-controls-wrap::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.2);
    border-radius: 99px;
  }
}

.mgs-controls {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.mgs-section {
  padding: 1rem 1rem 1.05rem;
  border-radius: 10px;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.1));
  background: rgba(255, 255, 255, 0.45);
}

.mgs-section__title {
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
}

.mgs-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mgs-field + .mgs-field {
  margin-top: 0.65rem;
}

.mgs-field label,
.mgs-field .mgs-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.mgs-field .muted,
.mgs-hint {
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.mgs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.mgs-row--swatches {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

@media (min-width: 360px) {
  .mgs-row--swatches {
    grid-template-columns: repeat(4, 1fr);
  }
}

.mgs-swatch {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.mgs-swatch__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.mgs-swatch__row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mgs-row input[type="color"],
.mgs-swatch__row input[type="color"] {
  width: 2.5rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}

.mgs-hex {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: rgba(255, 255, 255, 0.7);
}

.mgs-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mgs-preset {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.15));
  background: rgba(255, 255, 255, 0.75);
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.mgs-preset:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.35);
}

.mgs-preset:active {
  transform: scale(0.98);
}

.mgs-preset[aria-pressed="true"] {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
}

.mgs-slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mgs-slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent, #2563eb);
}

.mgs-slider-row output {
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  min-width: 2.75rem;
  text-align: right;
  font-weight: 600;
  color: var(--muted);
}

.mgs-seed-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: stretch;
}

.mgs-seed-row input[type="text"] {
  flex: 1;
  min-width: 8rem;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
}

.mgs-btn-small {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.15));
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  color: inherit;
}

.mgs-btn-small:hover {
  background: rgba(15, 23, 42, 0.06);
}

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

.mgs-actions--primary {
  padding-top: 0.25rem;
  border-top: 1px solid var(--border, rgba(15, 23, 42, 0.08));
  margin-top: 0.25rem;
}

.mgs-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.mgs-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.mgs-preview-toolbar__label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--muted);
  margin-right: 0.15rem;
}

.mgs-aspect-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.mgs-aspect {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  color: inherit;
}

.mgs-aspect:hover {
  border-color: rgba(99, 102, 241, 0.35);
}

.mgs-aspect[aria-pressed="true"] {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
}

.mgs-preview-wrap {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  box-shadow:
    0 4px 6px -1px rgba(15, 23, 42, 0.06),
    0 12px 40px -12px rgba(15, 23, 42, 0.15);
}

.mgs-preview {
  width: 100%;
  min-height: 200px;
  position: relative;
  transition: filter 0.2s ease;
  box-sizing: border-box;
}

.mgs-preview--ar-hero {
  aspect-ratio: 21 / 9;
  min-height: 0;
}

.mgs-preview--ar-wide {
  aspect-ratio: 16 / 9;
  min-height: 0;
}

.mgs-preview--ar-box {
  aspect-ratio: 1;
  min-height: 0;
  max-height: 420px;
}

.mgs-preview--ar-tall {
  aspect-ratio: 4 / 5;
  min-height: 0;
  max-height: 480px;
}

.mgs-preview--ar-free {
  aspect-ratio: auto;
  min-height: 320px;
}

@media (prefers-reduced-motion: reduce) {
  .mgs-preview--anim {
    animation: none !important;
  }
}

.mgs-preview--anim {
  animation: mgs-hue 22s ease-in-out infinite;
}

@keyframes mgs-hue {
  0%,
  100% {
    filter: hue-rotate(0deg);
  }
  50% {
    filter: hue-rotate(var(--mgs-hue-amt, 14deg));
  }
}

.mgs-preview--grain::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='128' height='128'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")
    repeat;
  background-size: 128px 128px;
  mix-blend-mode: overlay;
}

.mgs-preview-label {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.4);
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.mgs-output {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.mgs-output--card {
  padding: 1.1rem 1.15rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.1));
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.mgs-output__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.mgs-output__head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.mgs-output textarea {
  width: 100%;
  min-height: 240px;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  resize: vertical;
  background: rgba(15, 23, 42, 0.03);
}

.mgs-output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.mgs-copy-status {
  font-size: 0.8125rem;
  min-height: 1.25rem;
  flex: 1;
  min-width: 8rem;
}

.mgs-copy-status[hidden] {
  display: none;
}

.mgs-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  line-height: 1.35;
}

.mgs-check input {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.12rem;
  flex-shrink: 0;
  accent-color: var(--accent, #2563eb);
}

.mgs-check-grid {
  display: grid;
  gap: 0.5rem;
}

.mgs-select {
  width: 100%;
  max-width: 100%;
  font-size: 0.875rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: rgba(255, 255, 255, 0.85);
}

.mgs-class-input {
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
}

details.mgs-advanced {
  border-radius: 10px;
  border: 1px dashed var(--border, rgba(15, 23, 42, 0.18));
  padding: 0.35rem 0.85rem 0.85rem;
  background: rgba(255, 255, 255, 0.25);
}

details.mgs-advanced summary {
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.45rem 0;
  list-style-position: outside;
}

details.mgs-advanced[open] summary {
  margin-bottom: 0.5rem;
}
