:root {
  --size: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-style: normal;
  font-weight: 450;
  font-size: 11px;
  line-height: 16px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  font-optical-sizing: auto;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  cursor: default;
  color: var(--text-color);
  touch-action: manipulation;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

:focus {
  outline: none;
}

html {
  overscroll-behavior: none;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  padding: 0;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

.color-grid {
  display: flex;
  overflow: hidden;
  align-items: stretch;
  flex-wrap: nowrap;
  flex-direction: row;
  flex-direction: column-reverse;
  justify-content: space-between;
  flex: 1;
}

nav {
  max-width: 100%;
  user-select: none;
  white-space: nowrap;
  align-items: stretch;
  gap: 12px;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-content: center;
  max-width: 500px;
  margin: auto;
  padding: 20px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-radius: 5px;
  padding: 0px;
}

.tab {
  flex: 1;
  padding: 4px 8px;
  height: var(--size);
  background: transparent;
  border: none;
  border-radius: 5px;
  color: color-mix(in srgb, var(--text-color) 50%, transparent);
}

.tab:hover {
  background: color-mix(in srgb, var(--text-color) 5%, transparent);
}

.tab:active,
.tab.active {
  font-weight: 550;
  background: color-mix(in srgb, var(--text-color) 5%, transparent);
  color: var(--text-color);
}

.input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.icon {
  display: inline-grid;
  place-content: center;
}

[type="checkbox"] {
  display: none;
}

input ~ .checkmark {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--text-color) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--text-color) 5%, transparent);
}

input ~ .checkmark svg path {
  fill: none;
}

input:checked ~ .checkmark svg path {
  fill: var(--text-color);
}

.input-number {
  display: flex;
  align-items: center;
  fill: var(--text-color);
}

.input-number span {
  width: var(--size);
  height: var(--size);
  text-align: center;
  display: inline-grid;
  place-content: center;
}

button.btnicon {
  text-align: center;
  text-decoration: none;
  width: var(--size);
  height: var(--size);
  padding: 0px;
  background: none;
  border: 0;
  border-radius: 5px;
  margin: 0;
}

button.btnicon:hover:not(.disabled) {
  background: color-mix(in srgb, var(--text-color) 5%, transparent);
}

button.btnicon:active:not(.disabled) {
  background: color-mix(in srgb, var(--text-color) 10%, transparent);
}

button.btnicon.disabled svg path {
  fill: color-mix(in srgb, var(--text-color) 30%, transparent);
}

.color-input {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: var(--size);
  outline-offset: -1px;
  outline: 1px solid;
  outline-color: transparent;
  border-radius: 5px;
  gap: 1px;
  flex: 1;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--text-color) 5%, transparent);
}

.color-input:hover {
  outline-color: color-mix(in srgb, var(--text-color) 10%, transparent);
}

.color-input .text-wrapper:focus-within {
  outline: none;
}

.color-input:has(.text-wrapper:focus-within) {
  outline-color: color-mix(in srgb, var(--text-color) 30%, transparent);
}

.text-wrapper {
  flex: 1;
}

.colortext-wrapper {
  display: flex;
  align-items: center;
  height: 100%;
  background: color-mix(in srgb, var(--text-color) 5%, transparent);
  flex: 1;
}

.select-wrapper {
  position: relative;
  display: inline-block;
}

.color-select {
  /*background: none;*/
  border: none;
  padding: 0;
  margin: 0;
  width: var(--size);
  height: var(--size);
  color: transparent;
  background: color-mix(in srgb, var(--text-color) 5%, transparent);
  border-radius: 0;
}

.color-select:hover {
  background: color-mix(in srgb, var(--text-color) 10%, transparent);
}

.select-icon {
  position: absolute;
  right: 0px;
  width: var(--size);
  height: var(--size);
  text-align: center;
  display: inline-grid;
  place-content: center;
  pointer-events: none;
}

button.secondary {
  text-align: center;
  text-decoration: none;
  display: inline-block;
  min-height: var(--size);
  padding: 0px;
  border: 0px;
  border: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
  border-radius: 5px;
  flex: 1;
  background: transparent;
}

button.secondary:hover {
  background: color-mix(in srgb, var(--text-color) 5%, transparent);
}

button.secondary:active {
  background: color-mix(in srgb, var(--text-color) 10%, transparent);
}

.slider-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

input[type="color"] {
  width: var(--size);
  height: var(--size);
  padding: 0px;
  background: none;
  border: none;
  padding: 4px;
}

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

input[type="color"]::-webkit-color-swatch {
  border: none;
  border: 0;
  border-radius: 3px;
  outline-offset: -1px;
  outline: 1px solid;
  outline-color: color-mix(in srgb, var(--text-color) 10%, transparent);
}

input[type="text"] {
  background: none;
  border: none;
  margin: 0px;
}

input[type="text"] {
  width: 100%;
  min-width: 8ch;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 18px;
  border-radius: 9px;
  background: var(--track-bg);
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--text-color) 10%, transparent);
  overflow: hidden;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: white;
  box-shadow: 0px 0px 0.5px rgba(0, 0, 0, 0.18), 0px 3px 8px rgba(0, 0, 0, 0.1),
    0px 1px 3px rgba(0, 0, 0, 0.1);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: white;
  border: none;
  box-shadow: 0px 0px 0.5px rgba(0, 0, 0, 0.18), 0px 3px 8px rgba(0, 0, 0, 0.1),
    0px 1px 3px rgba(0, 0, 0, 0.1);
}

.color-swatch {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 5px 8px;
  padding: 5px calc(8px + env(safe-area-inset-right)) 5px
    calc(8px + env(safe-area-inset-left));
  justify-content: space-between;
  gap: 2ch;
}

.color-swatch:last-of-type {
  padding-top: 5px;
  padding-top: calc(5px + env(safe-area-inset-top));
}

body.text-mode .color-swatch {
  flex-direction: column;
}

.color-name {
  font-weight: 600;
}

.hex-value {
  grid-column: 2 / 3;
  grid-row: 1;
  text-align: right;
}

.color-name,
.hex-value {
  opacity: 0;
}

.color-swatch:hover .color-name,
.color-swatch:hover .hex-value {
  opacity: 1;
}

body.text-mode .color-name {
  font-size: 10vmin;
  line-height: 90%;
  word-wrap: break-word;
  grid-column: 1 / 3;
  grid-row: 1;
  overflow-wrap: break-word;
  opacity: 1;
}
body.text-mode .color-name {
  font-weight: 900;
  padding-right: 1ch;
}

@media (hover: none) {
  :root {
    --size: 32px;
  }

  input[type="color"] {
    padding: 7px;
  }

  input[type="color"]::-webkit-color-swatch {
    border-radius: 3px;
  }

  input[type="range"] {
    height: 24px;
    border-radius: 12px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    border-radius: 12px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 12px;
  }
  
  .slider-group {
    gap: 20px;
    padding-top: 8px;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .slider-group {
    flex-wrap: nowrap;
  }
}
