:root {
  --slider-bg: #ccc;
  --slider-hue: 0;
  --slider-saturation: 0;
  --slider-lightness: 0;
  --lightness-min: 0;
  --lightness-max: 100;
  --saturation-min: 0;
  --saturation-max: 100;
}

/* Base styles */
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background-color: #f4f4f4;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  padding: 0;
  transition:
    background-color 1s ease,
    color 1s ease;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Layout components */
.slidecontainer {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  width: 800px;
  padding: 20px;
  height: 100vh;
  box-sizing: border-box;
  justify-content: flex-start;
  margin: 0 auto;
}

.slidecontainer h1 {
  margin: 0 0 10px 0;
  flex-shrink: 0;
}

.slidecontainer p {
  margin: 0 0 0 0;
  flex-shrink: 0;
}

.slidecontainer .controls-wrapper {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  overflow-y: auto;
  align-items: stretch;
  transition: all 0.3s ease;
}

.slidecontainer .controls-wrapper > span {
  flex: 0 0 auto;
}

/* Form elements */
label {
  display: inline-block;
  float: left;
  font-weight: 600;
  margin: 0 10px 20px 0;
  max-width: 30%;
  text-align: right;
  text-transform: uppercase;
  width: 110px;
  top: 5px;
  position: relative;
}

.text-input {
  float: left;
  width: 100%;
  max-width: 80%;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid #ccc;
  font-family: menlo, "Courier New", Courier, monospace;
  font-size: 0.9em;
  box-sizing: border-box;
}

.import-button {
  background: transparent;
  border-radius: 6px;
  border: 1px solid #ccc;
  padding: 4px 12px;
  font-size: 0.9em;
  cursor: pointer;
}

.black .import-button {
  color: #fff;
  border-color: #666;
}

.import-dialog {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.import-dialog[aria-hidden="false"] {
  display: flex;
}

.import-dialog-content {
  background: #fff;
  color: #333;
  padding: 20px;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.black .import-dialog-content {
  background: #333;
  color: #fff;
}

.import-dialog-content h2 {
  margin: 0 0 10px 0;
  font-size: 1.1em;
}

.import-dialog-content p {
  margin: 0 0 10px 0;
  font-size: 0.9em;
}

.import-dialog-content .text-input {
  max-width: 100%;
  float: none;
  width: 100%;
}

.import-dialog-actions {
  margin-top: 15px;
  text-align: right;
}

.import-dialog-button {
  background-color: #222;
  color: #dedede;
  border-radius: 6px;
  border: 1px solid #ccc;
  cursor: pointer;
  font-size: 0.9em;
  margin-left: 8px;
  padding: 4px 12px;
}

.import-dialog-button.primary {
  background: #12cbdd;
  color: #fff;
  border-color: #12cbdd;
}

.black .import-dialog-button.primary {
  background: #12cbdd;
  color: #000;
}

#output {
  color: #333;
  font-family: menlo, "Courier New", Courier, monospace;
  line-height: 2;
  max-width: 100%;
  font-size: 1.2em;
}

.black #output {
  color: #fff;
}

/* Slider styles */
.slider {
  -webkit-appearance: none;
  appearance: none;
  background: #d3d3d3;
  border-radius: 5px;
  border: solid 1px #ccc;
  filter: saturate(3);
  float: left;
  height: 20px;
  margin-top: 4px;
  max-width: 80%;
  opacity: 0.7;
  outline: none;
  transition: opacity 0.2s;
  width: 100%;
}

.slider::-webkit-slider-thumb,
.slider::-moz-range-thumb {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--slider-bg);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* Special sliders */
#hue.slider {
  background: linear-gradient(
    to right,
    hsl(0, var(--slider-saturation), var(--slider-lightness)),
    hsl(60, var(--slider-saturation), var(--slider-lightness)),
    hsl(120, var(--slider-saturation), var(--slider-lightness)),
    hsl(180, var(--slider-saturation), var(--slider-lightness)),
    hsl(240, var(--slider-saturation), var(--slider-lightness)),
    hsl(300, var(--slider-saturation), var(--slider-lightness)),
    hsl(360, var(--slider-saturation), var(--slider-lightness))
  );
}

#saturation.slider {
  background: linear-gradient(
    to right,
    hsl(var(--slider-hue), var(--saturation-min), var(--slider-lightness)),
    hsl(var(--slider-hue), var(--saturation-max), var(--slider-lightness))
  );
}

#lightness.slider {
  background: linear-gradient(
    to right,
    hsl(var(--slider-hue), var(--slider-saturation), var(--lightness-min)),
    hsl(var(--slider-hue), var(--slider-saturation), var(--lightness-max))
  );
}

/* Button styles */
.copy-button {
  background: transparent;
  border-radius: 10px;
  border: solid 1px #ccc;
  color: #333;
  font-size: 20px;
  height: 2.4em;
  line-height: 2.5;
  margin-left: 10px;
  padding: 4px 10px;
  text-decoration: none;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  float: none;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.copy-button:hover,
.copy-button:focus {
  background-color: rgba(0, 0, 0, 0.05);
  color: #000;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.copy-button.success {
  background-color: #fff;
  color: #000;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.black .copy-button {
  color: #fff;
}

/* Dark theme */
.black {
  color: #fff;
}

.black .slider {
  filter: saturate(1.5);
}

.black #output {
  background: #333;
  color: #fff;
}

.black #blackwhite {
  color: #fff;
}

#blackwhite {
  font-size: 1em;
  font-weight: 600;
  border: solid 1px #ccc;
  border-radius: 4px;
  background: transparent;
}

#type {
  font-size: 1.2em;
  line-height: 1;
  height: 50px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: #333;
  top: -5px;
  position: relative;
}

.black #type {
  color: #fff;
}

.black .slider {
  border: solid 1px #999;
}

/* Gradient controls */
#gradient-container {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #ccc;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.3s ease,
    opacity 0.3s ease,
    margin 0.3s ease,
    padding 0.3s ease,
    border-width 0.3s ease;
  border-top-width: 0;
  border-top-style: solid;
  border-top-color: #ccc;
}

#gradient-container.visible {
  max-height: 500px;
  opacity: 1;
  border-top-width: 1px;
}

.black #gradient-container {
  border-top-color: #666;
}

.angle-dial-container {
  display: inline-flex;
  align-items: center;
  float: left;
  margin-top: 4px;
}

.angle-dial {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid #ccc;
  position: relative;
  cursor: pointer;
  background: #fff;
  display: inline-block;
}

.black .angle-dial {
  border-color: #999;
  background: #333;
}

.angle-dial-hand {
  position: absolute;
  width: 2px;
  height: 50%;
  background: #333;
  top: 50%;
  left: 50%;
  transform-origin: bottom center;
  transform: translateX(-50%) translateY(-100%) rotate(0deg);
  transition: transform 0.1s ease;
}

.black .angle-dial-hand {
  background: #fff;
}

#gradient-angle {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 1em;
}

.black #gradient-angle {
  background: #333;
  color: #fff;
  border-color: #666;
}

#intensity-value {
  font-weight: 600;
  min-width: 50px;
  display: inline-block;
}

#gradient-output {
  color: #333;
  display: inline-block;
  margin-left: 10px;
  font-size: 0.9em;
  white-space: pre;
  width: 65%;
  overflow: auto;
  flex: 1;
  min-width: 0;
}

.black #gradient-output {
  color: #fff;
}

.gradient-copy-button {
  float: none;
  position: relative;
  font-size: 1em;
  white-space: pre;
  width: fit-content;
  display: block;
  margin-top: 10px;
  margin-left: 130px;
  clear: both;
  flex-basis: 100%;
  min-width: 0;
  text-align: center;
}

#gradient-intensity {
  flex: 1;
  min-width: 0;
}

/* Intensity slider gradient - white mode (reverse: light to dark) */
body.white #gradient-intensity.slider {
  background: linear-gradient(
    to right,
    hsl(
      var(--slider-hue),
      var(--slider-saturation),
      var(--intensity-light-end)
    ),
    hsl(var(--slider-hue), var(--slider-saturation), var(--intensity-dark-end))
  );
}

/* Intensity slider gradient - black mode (mirror: same as lightness) */
body.black #gradient-intensity.slider {
  background: linear-gradient(
    to right,
    hsl(var(--slider-hue), var(--slider-saturation), var(--intensity-dark-end)),
    hsl(var(--slider-hue), var(--slider-saturation), var(--intensity-light-end))
  );
}

#gradient-container > span:nth-child(1) > label:nth-child(1) {
  top: 25px;
}

#gradient-container > span:nth-child(2) {
  top: 20px;
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
}

#gradient-container > span:nth-child(2) > label {
  float: none;
  margin: 0 10px 0 0;
  flex-shrink: 0;
}

.intensity-controls {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 10px;
  width: 100%;
}

#intensity-value {
  flex-shrink: 0;
  white-space: nowrap;
}

#gradient-container > span:nth-child(3) {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  float: left;
  clear: both;
  margin-top: 10px;
}

#gradient-container > span:nth-child(3) > label {
  margin-top: 0;
  align-self: flex-start;
}

@media screen and (max-width: 644px) {
  label {
    margin: 10px 0 0 0 auto;
    text-align: left;
    top: 6px;
  }

  .slider {
    max-width: 100%;
    width: 99%;
  }

  /* Intensity controls - move to own row on narrow viewports */
  #gradient-container > span:nth-child(2) {
    width: 100%;
    clear: both;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  #gradient-container > span:nth-child(2) > label {
    margin-bottom: 10px;
  }

  .intensity-controls {
    width: 100%;
    min-width: 0;
    display: flex;
  }

  #gradient-intensity {
    width: 100%;
    flex: 1;
    max-width: none;
  }

  /* Gradient CSS row - allow button to wrap but keep left-justified */
  #gradient-container > span:nth-child(3) {
    width: 100%;
    margin-top: 20px;
  }

  #gradient-output {
    width: 100%;
    display: block;
    margin-left: 0;
    margin-bottom: 10px;
    flex: 1;
  }

  .gradient-copy-button {
    display: block;
    float: none;
    clear: both;
    margin-left: 0;
    margin-top: 10px;
    flex-basis: 100%;
    text-align: center;
  }
}
