:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #111321;
  color: #f6f7fa;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; overflow: hidden; }
#field { position: fixed; inset: 0; display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #e0e8ff; outline-offset: 2px; }
canvas:focus-visible { outline-offset: -3px; }

.dock {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
}
.icon-group, .palette > .icon {
  background: rgb(13 16 23 / 58%);
  border: 1px solid rgb(255 255 255 / 20%);
  backdrop-filter: blur(12px);
}
.palette { display: grid; align-self: stretch; align-items: center; }
.icon-group { display: flex; gap: 1px; border-radius: 13px; padding: 2px; }
.icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgb(245 248 255 / 76%);
}
.icon:hover, .icon[aria-pressed="true"], .icon[aria-expanded="true"] {
  color: #fff;
  background-color: rgb(66 72 88 / 72%);
}
.icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
#palette-toggle { display: flex; width: auto; gap: 8px; padding: 0 12px; font-size: .82rem; }

.popover {
  position: absolute;
  z-index: 1;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-bottom: 8px;
  width: min(364px, calc(100vw - 24px));
}
.panel {
  padding: 15px;
  max-height: calc(100dvh - 70px - env(safe-area-inset-bottom));
  overflow: auto;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 14px;
  background: rgb(15 17 24 / 94%);
  box-shadow: 0 10px 30px rgb(0 0 0 / 24%);
  backdrop-filter: blur(18px);
}
.panel label { display: block; font-size: .83rem; margin-bottom: 6px; }
.palette-header, .hue-control { display: flex; align-items: center; justify-content: space-between; }
.palette-header h2 { font-size: 1.12rem; letter-spacing: -.025em; margin: 0; }
.subtle { border: 1px solid #ffffff25; border-radius: 7px; background: #ffffff09; padding: 6px 9px; font-size: .75rem; }
.subtle:hover { background: #ffffff1c; }
.themes { margin: 12px 0 15px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.theme { position: relative; isolation: isolate; overflow: hidden; min-width: 0; padding: 0; border: 0; border-radius: 8px; background: #151820; }
.preset-preview { display: block; aspect-ratio: 2.8; background: url("presets.webp") no-repeat; background-size: 300% 200%; }
.theme span { display: block; padding: 4px 7px 6px; color: white; text-align: left; font-size: .75rem; font-weight: 600; overflow-wrap: anywhere; }
.theme::after { content: ""; position: absolute; inset: 0; border: 1px solid #ffffff32; border-radius: inherit; }
.theme:hover::after { border-color: #ffffffaa; }
.theme[aria-pressed="true"]::after { border: 2px solid white; }
.theme[aria-pressed="true"]::before { content: "✓"; position: absolute; top: 4px; right: 4px; border-radius: 50%; background: #fff; color: #151820; width: 15px; line-height: 15px; font-weight: 700; }
.hue-control { flex-wrap: wrap; gap: 7px; }
.hue-control label { margin: 0; }
.hue-control output { color: #b6bccb; font: .72rem ui-monospace, monospace; }
#palette-hue { width: 100%; margin: 0; cursor: pointer; appearance: none; height: 22px; background: transparent; border: 0; --spectrum: linear-gradient(90deg,#da8295,#c49a6a,#a0be76,#68bbac,#80a5d4,#b390d6,#da8295); }
#palette-hue::-webkit-slider-runnable-track { height: 6px; border-radius: 4px; background: var(--spectrum); }
#palette-hue::-moz-range-track { height: 6px; border-radius: 4px; background: var(--spectrum); }
#palette-hue::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -5px; border: 3px solid white; border-radius: 50%; background: #242633; }
#palette-hue::-moz-range-thumb { width: 11px; height: 11px; border: 3px solid white; border-radius: 50%; background: #242633; }
.picker { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: stretch; gap: 6px; }
input, textarea {
  border: 1px solid rgb(255 255 255 / 17%);
  background-color: rgb(255 255 255 / 7%);
  border-radius: 8px;
}
input[type="color"] { width: 34px; min-width: 0; height: 34px; padding: 3px; cursor: pointer; }
input[type="text"], textarea { min-width: 0; width: 100%; padding: 8px; font: .85rem ui-monospace, monospace; }
input[aria-invalid="true"] { border-color: #ffaea1; }
.swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 12px 0 7px; }
.swatch { display: flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid #ffffff20; border-radius: 7px; background: transparent; color: #cfd2de; padding: 6px 2px; font-size: .75rem; }
.swatch[aria-pressed="true"] { background: #ffffff12; border-color: #ffffff75; color: white; }
.swatch i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #ffffff55; }
.exports { display: flex; flex-wrap: wrap; gap: 7px 13px; padding-top: 11px; }
.exports button { background: transparent; border: 0; padding: 3px 0; color: #c5ccdc; font-size: .78rem; }
.exports button:hover { color: white; text-decoration: underline; }
.feedback { margin: 8px 0 0; font-size: .78rem; }
#copy-fallback { margin-top: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-height: 480px) {
  .panel { max-height: calc(100dvh - 78px); overflow: auto; }
}
