:root {
  --bg-top: #ddfafd;
  --bg-bottom: #fecba9;

  --text: #4a3f36;
  --text-faint: #786b61;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: system-ui;
  background: #f7f1ea;
  background: linear-gradient(var(--bg-top), var(--bg-bottom));
  color: #4a3f36;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header {
  text-align: center;
  padding: 10px 0 0;
}

.header h1 {
  margin: 0;
  font-size: 24px;
}

.header p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text-faint);
}

.workspace {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 1200px;
  padding: 10px 20px 20px;
}

.canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

canvas {
  aspect-ratio: 1 / 1;
  width: min(70vh, 650px);
  height: auto;
  max-width: 100%;
  border-radius: 20px;
  background: white;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.08);
  max-height: 90vh;
  max-width: 90vh;
}

#settings {
  width: 440px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  border-radius: 16px;
  /*background: #fffaf5;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.08);*/
}

#globalPresets {
  margin-bottom: 16px;
}

.settings-section {
  padding: 10px 0;
  border-bottom: 1px solid #f0e6dc;

  padding: 14px 14px 16px;
  margin-bottom: 14px;

  background: rgba(255, 255, 255, 0.55);
  border: 1px solid #f0e6dc;
  border-radius: 16px;

  backdrop-filter: blur(6px);
}

.settings-section:last-child {
  border-bottom: none;
}

label {
  display: block;
  font-size: 12px;
  margin: 6px 0 2px;
  color: var(--text);
  line-height: 1.2;
}

label:hover {
    color: #c97a92;
}

.tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(255, 250, 245, 0.98);
    border: 1px solid #eadfd4;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 12px;
    color: #5a4d44;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    max-width: 220px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.12s ease, transform 0.12s ease;
    z-index: 10;
}

.tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

select,
input[type="button"] {
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #e7d8cd;
  background: white;
  cursor: pointer;
}

input[type="button"]:hover {
    transform:translateY(-1px);
    box-shadow:0 6px 14px rgba(0,0,0,0.06);
}

input[type="color"] {
  width: 100%;
  height: 32px;
  border: none;
  background: none;
}

textarea {
  width: 100%;
  min-height: 120px;
  border-radius: 12px;
  border: 1px solid #eadfd4;
  padding: 10px;
  font-family: monospace;
  resize: none;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: #e3c7b5;
  border-radius: 10px;
}

@media (max-width: 900px) {
  html,
  body {
    overflow: hidden;
  }

  .workspace {
    flex-direction: column;
    height: 100vh;
    gap: 10px;
    padding: 10px;
  }

  .canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0;
  }

  canvas {
    width: 92vw;
    height: 92vw;
    max-height: 55vh;
    max-width: 55vh;
  }

  #settings {
    width: 100%;
    flex: 1;
    max-height: none;

    overflow-y: auto;
    overflow-x: hidden;
  }
}

.section-title {
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 6px 0 10px;
}

/* Color picker */
input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  width: 100%;
  height: 30px;
  padding: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

/* hide native wrapper */
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* Checkbox */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 24px;
  background: #e7d8cd;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  vertical-align: middle;
}

/* knob */
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

/* checked state */
input[type="checkbox"]:checked {
  background: #d98da3;
}

input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

/* Sliders */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 22px;
    background: transparent;
    cursor: pointer;

    /* prevents weird compositing issues */
    isolation: isolate;
}

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

    background: linear-gradient(
        90deg,
        #e9b6c6 0%,
        #e9b6c6 var(--p, 50%),
        #f3e7de var(--p, 50%),
        #f3e7de 100%
    );

    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

input[type="range"]::-moz-range-track {
    height: 8px;
    border-radius: 999px;

    background: linear-gradient(
        90deg,
        #e9b6c6 0%,
        #e9b6c6 var(--p, 50%),
        #f3e7de var(--p, 50%),
        #f3e7de 100%
    );
}

/* remove default Firefox fill layer */
input[type="range"]::-moz-range-progress {
    background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;

    width: 18px;
    height: 18px;
    border-radius: 50%;

    background: #fff;

    border: 1px solid rgba(160, 100, 120, 0.25);

    box-shadow: 0 2px 6px rgba(0,0,0,0.12);

    margin-top: -5px;

    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;

    background: #fff;

    border: 1px solid rgba(160, 100, 120, 0.25);

    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

input[type="range"]:focus {
    outline: none;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow:
        0 0 0 4px rgba(233, 182, 198, 0.35),
        0 2px 6px rgba(0,0,0,0.12);
}

.slider {
  width: 100%;
  display: flex;
}

.slider input[type="range"] {
  width: 100%;
  flex: 1;
}


/* Preset grids */
.preset-grid{
    margin-bottom:10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}

.preset{
    color: var(--text);
    padding:10px;
    border-radius:12px;
    border:1px solid #eadfd4;
    background:#fff;
    cursor:pointer;
    font-size:13px;
    transition:all 0.15s ease;
    text-align: center;
}

.preset:hover{
    transform:translateY(-1px);
    box-shadow:0 6px 14px rgba(0,0,0,0.06);
}

.preset.active{
    background:#f3c7d4;
    border-color:#e3a9bc;
    font-weight:600;
    box-shadow: 0 6px 14px rgba(227, 169, 188, 0.25);
}

#globalPresets{
    display:none;
}


/* Control rows */
.control-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 12px;

  padding: 6px 0;
}

/* mobile stack */
@media (max-width: 900px) {
  .control-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

.control-row + .control-row {
  margin-top: 4px;
}

#randomimze {
    font-weight: bold;
    color: white;
    background: #3F5EFB;
    background: radial-gradient(circle, rgb(226 111 255) 0%, rgb(201 161 255) 100%);
}

.header-links {
    display: flex;
    gap: 6px;
    align-items: center;
}

.header-links a,
.header-links button {
    font-size: 12px;
    color: var(--text-faint);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgb(255 255 255 / 34%);
    backdrop-filter: blur(6px);
    transition: all 0.15s ease;
    border: 1px solid transparent;
    cursor: pointer;
}

.header-links a:hover,
.header-links button:hover {
    color: var(--text);
    border-color: rgba(160, 143, 130, 0.35);

    background: rgb(255 255 255 / 50%);
    transform: translateY(-1px);

    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

@media (min-width: 900px) {
    .header-links
    {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 1000;
    }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: min(520px, 90vw);
    background: rgba(255, 250, 245, 0.9);
    backdrop-filter: blur(10px);

    border: 1px solid #eadfd4;
    border-radius: 16px;

    padding: 18px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);

    color: var(--text);
}

.modal-content h2 {
    margin-top: 0;
    font-size: 18px;
}

.modal-content h3 {
    margin-top: 0;
    font-size: 16px;
}

.modal-content p,
.modal-content ul {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-faint);
}

.modal-content button {
    margin-top: 12px;
}