:root {
  color-scheme: light;
  --bg: #f2f3ed;
  --paper: #fcfcf8;
  --ink: #202b2a;
  --muted: #737971;
  --line: #d9ddd3;
  --lime: #c8f08e;
  --dark: #23312c;
  --accent: #3a7046;
  --focus: #518435;
  --hover: #e8eddf;
  --panel: #e4e7df;
  --bar: #edf0e7;
  --bar-ink: #5b655c;
  --stage: #d6dcd1;
  --stage-check: #cdd5c833;
  --overlay: #fcfcf8ea;
  --field: #fff;
  --row: #f4f5ef;
  --row-sel: #e8f1db;
  --row-sel-line: #a9c989;
  --faint: #8a9284;
  --hb-bg: #edf4e2;
  --hb-line: #8d9d7b;
  --art1: #5a7450;
  --art2: #355b60;
  --art-shadow: #c8dd9d;
  --tile-bg: #e2e8db;
  --tile-ink: #3e5545;
  --tile-hover: #849d73;
  --tile-active: #719157;
  --state: #698153;
  --note-bg: #e9eddf;
  --note-line: #d9e2cc;
  --dash: #b9c6aa;
  --on-dark: #f5f9ec;
  --busy: #5b9347;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 14px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
[hidden] {
  display: none !important;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}
button,
summary {
  cursor: pointer;
}
button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 5px;
  padding: 8px 12px;
  color: var(--ink);
  transition: background 0.12s;
}
button:hover {
  background: var(--hover);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button.primary {
  background: var(--dark);
  color: var(--lime);
  border-color: var(--dark);
}
a {
  color: inherit;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  color: var(--ink);
  padding: 7px;
  max-width: 100%;
}
input[type="checkbox"],
input[type="range"] {
  accent-color: var(--accent);
}
input[type="number"] {
  width: 75px;
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  width: 100%;
  padding: 0;
  cursor: ew-resize;
}
input[type="color"] {
  padding: 2px;
  width: 100%;
  height: 32px;
}
textarea {
  resize: vertical;
  width: 100%;
}
select {
  width: 100%;
  text-overflow: ellipsis;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -1.2px;
}
h2 {
  font-size: 13px;
  font-weight: 650;
}
.app-header {
  height: 40px;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--paper);
}
.brand {
  font-size: 15px;
  font-weight: 720;
  letter-spacing: -0.5px;
  text-decoration: none;
  display: flex;
  gap: 8px;
  align-items: center;
}
.brand-mark {
  display: grid;
  place-items: center;
  font-size: 17px;
  width: 22px;
  height: 22px;
  background: var(--dark);
  color: var(--lime);
  border-radius: 4px;
  line-height: 1;
}
.app-header nav {
  display: flex;
  gap: 20px;
  height: 100%;
}
.app-header nav a {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.app-header nav a.active {
  border-color: var(--accent);
}
.home {
  max-width: 960px;
  margin: 8vh auto;
  padding: 30px;
}
.home h1 {
  margin-bottom: 36px;
  font-size: 40px;
}
.home-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.home-button {
  min-height: 290px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  background: var(--paper);
}
.home-button:hover {
  border-color: var(--hb-line);
  background: var(--hb-bg);
}
.home-button strong {
  font-size: 26px;
  font-weight: 550;
  letter-spacing: -0.7px;
}
.home-art {
  font-size: 92px;
  font-family: monospace;
  line-height: 1;
  color: var(--art1);
  grid-column: 1/-1;
}
.archive-art {
  color: var(--art2);
}
.home-button-luts {
  grid-column: 1 / -1;
  width: calc(50% - 10px);
  justify-self: center;
}
.lut-art {
  color: var(--accent);
}
.arrow {
  font-size: 28px;
}
.topbar {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.menu {
  position: relative;
}
.menu summary {
  list-style: none;
  padding: 4px 6px;
  font-size: 13px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.menu summary .chev {
  display: block;
  flex: none;
}
.menu summary::-webkit-details-marker {
  display: none;
}
.menu-items {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  min-width: 240px;
  padding: 5px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 35px #0002;
}
.menu-items button {
  display: flex;
  text-align: left;
  justify-content: space-between;
  gap: 16px;
  border: none;
  width: 100%;
  font-size: 13px;
}
.menu-items hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 5px;
}
kbd {
  font-family: inherit;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.seed-control {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  font-size: 12px;
}
/* a thin divider before every topbar group except the first */
.topbar .menu + .menu,
.seed-control {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  height: 24px;
  border-left: 1px solid var(--line);
}
.topbar .menu + .menu {
  padding-left: 16px;
}
.seed-control input {
  width: 64px;
  padding: 2px 5px;
}
.dice {
  display: block;
}
.icon-button {
  padding: 2px 8px;
  font-size: 17px;
  border-color: transparent;
  background: transparent;
  line-height: 1.1;
}
.current-name {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workspace {
  display: grid;
  grid-template-columns: 265px minmax(300px, 1fr) 230px;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
  min-height: 440px;
  height: min(58vh, 660px);
}
.panel {
  background: var(--paper);
  min-width: 0;
  overflow: auto;
}
.adjustments {
  border-right: 1px solid var(--line);
}
.order-panel {
  border-left: 1px solid var(--line);
  padding-bottom: 15px;
}
.panel-heading {
  padding: 17px 16px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 2;
}
.panel-heading span {
  font-size: 11px;
  color: var(--muted);
}
.subtle {
  border: 0;
  padding: 0;
  background: none;
  font-size: 11px;
  color: var(--muted);
}
#controls {
  padding: 6px 16px 20px;
}
.empty-controls {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  padding: 22px 4px;
}
.control-row {
  padding: 13px 0 3px;
}
.control-label {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: space-between;
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 6px;
}
.control-range {
  display: flex;
  align-items: center;
  gap: 9px;
}
.control-range input[type="number"] {
  width: 68px;
  font-size: 11px;
  padding: 5px;
}
.lock {
  font-size: 12px;
  border: 0;
  padding: 0 2px;
  background: transparent;
  opacity: 0.35;
}
.lock.locked {
  opacity: 1;
  color: var(--accent);
}
.control-row .check-label {
  font-size: 12px;
}
.control-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 20px 0 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
/* the first section heading needs no divider above it */
#controls > .control-sub:first-child {
  border-top: 0;
  margin-top: 4px;
  padding-top: 0;
}
.help {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 8px;
}
.image-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.image-toolbar,
.image-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 4px 14px;
  font-size: 11px;
  background: var(--bar);
  color: var(--bar-ink);
  min-height: 35px;
}
.image-toolbar > span {
  max-width: 40%;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.image-toolbar > div {
  display: flex;
  align-items: center;
  gap: 10px;
}
.image-toolbar button {
  padding: 4px 7px;
  font-size: 11px;
  background: transparent;
}
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
.check-label input {
  margin: 0;
}
.image-stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 0;
  background-color: var(--stage);
  background-image:
    linear-gradient(45deg, var(--stage-check) 25%, transparent 25%),
    linear-gradient(-45deg, var(--stage-check) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--stage-check) 75%),
    linear-gradient(-45deg, transparent 75%, var(--stage-check) 75%);
  background-size: 20px 20px;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
}
.image-stage canvas {
  /* fit: fill the whole stage, enlarging small results (aspect ratio kept) */
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.image-stage.actual canvas {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  flex: none;
  margin: auto;
}
.open-overlay {
  position: absolute;
  bottom: 30px;
  background: var(--overlay);
  box-shadow: 0 2px 10px #0002;
}
.image-footer {
  font-size: 10px;
  min-height: 26px;
  padding: 2px 14px;
}
.image-footer #cancel-render {
  padding: 2px 7px;
  font-size: 11px;
}
#palette-strip {
  display: flex;
  max-width: 42%;
  overflow: hidden;
  height: 12px;
}
#palette-strip i {
  display: block;
  min-width: 9px;
  flex: 1;
}
.order-hint {
  font-size: 11px;
  color: var(--muted);
  padding: 13px 16px 8px;
}
#order {
  padding: 2px 10px;
  position: relative;
  min-height: 80px;
}
.order-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 5px 7px;
  margin: 5px 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--row);
  cursor: grab;
  position: relative;
  font-size: 11px;
  touch-action: none;
  user-select: none;
}
.order-row.selected {
  background: var(--row-sel);
  border-color: var(--row-sel-line);
}
.order-row.dragging {
  opacity: 0.35;
}
.order-grip {
  font-size: 14px;
  color: var(--faint);
}
/* Icon buttons in the flow: a fixed square, the SVG centred by the grid, no font metrics. */
.order-row button.order-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 4px;
  line-height: 0;
  color: var(--muted);
}
.order-icon svg {
  display: block;
}
.order-row button.order-icon:hover {
  color: var(--ink);
}
.order-row.off button.order-eye {
  color: var(--faint);
}
.order-row.off .order-label {
  opacity: 0.5;
  text-decoration: line-through;
}
.order-label {
  flex: 1;
  text-align: left;
  line-height: 1.4;
}
.order-row button {
  border: 0;
  background: none;
  padding: 0 3px;
  color: var(--muted);
  font-size: 17px;
}
.order-help {
  font-size: 10px;
  line-height: 1.6;
  color: var(--faint);
  padding: 10px 16px;
}
.drop-line {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 3px;
  background: var(--accent);
  border-radius: 3px;
  pointer-events: none;
  z-index: 5;
}
.drop-line:before {
  content: "";
  position: absolute;
  left: -2px;
  top: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.order-empty {
  font-size: 12px;
  padding: 16px 6px;
  color: var(--muted);
  line-height: 1.5;
}
.effect-browser {
  padding: 12px 24px 24px;
}
.effect-category {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 10px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 15px 0 13px;
}
.effect-category:after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 12px;
}
.effect-tile {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  position: relative;
  background: var(--paper);
  min-width: 0;
}
.effect-tile:hover {
  border-color: var(--tile-hover);
  background: var(--paper);
}
.effect-tile.active {
  border-color: var(--tile-active);
  box-shadow: 0 0 0 1px var(--tile-active);
}
.tile-image {
  width: 100%;
  aspect-ratio: 1.65;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--tile-bg);
}
.tile-image canvas,
.tile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}
.tile-image svg {
  width: 64px;
  height: 64px;
  stroke: var(--tile-ink);
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tile-name {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  padding: 11px 10px;
  font-size: 11px;
  font-weight: 550;
  line-height: 1.25;
}
.tile-state {
  color: var(--state);
  font-size: 14px;
  font-weight: 400;
}
.experiments {
  border-top: 1px solid var(--line);
  padding: 15px 24px 30px;
}
.experiments summary {
  font-size: 12px;
  color: var(--muted);
}
.experiment-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 15px 0;
  font-size: 12px;
}
.experiment-toolbar > span {
  font-size: 11px;
  color: var(--muted);
}
.experiment-toolbar input[type="number"] {
  width: 54px;
}
.library-page {
  min-height: calc(100vh - 40px);
}
#preset-count {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 16px 18px 24px;
}
.preset-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  min-width: 0;
  position: relative;
}
.preset-open {
  padding: 0;
  width: 100%;
  border: 0;
  background: none;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
  display: block;
}
.preset-card .tile-image {
  aspect-ratio: 4 / 3;
}
.preset-card footer {
  min-height: 52px;
  padding: 6px 4px 6px 12px;
  background: var(--bar);
  border-radius: 0 0 10px 10px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.preset-card footer .preset-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  border: 0;
  background: transparent;
  padding: 3px 0;
  text-align: left;
  font-size: 13px;
  font-weight: 620;
  color: var(--ink);
}
.preset-card .preset-menu {
  position: relative;
}
.preset-menu summary {
  list-style: none;
  font-size: 18px;
  padding: 0 7px;
}
.preset-menu .menu-items {
  left: auto;
  right: 0;
  top: 100%;
  min-width: 185px;
}
.preset-menu summary::-webkit-details-marker {
  display: none;
}
.storage-note {
  font-size: 11px;
  color: var(--muted);
  padding: 0 18px 32px;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: var(--on-dark);
  padding: 12px 20px;
  max-width: min(90vw, 640px);
  font-size: 12px;
  border-radius: 6px;
  box-shadow: 0 5px 25px #0002;
  z-index: 100;
  line-height: 1.5;
  white-space: pre-line;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  width: min(440px, 90vw);
}
dialog::backdrop {
  background: #15231966;
  backdrop-filter: blur(3px);
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.dialog-heading h2 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.4px;
}
.field-label {
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
}
#preset-name {
  width: 100%;
}
.preview-check {
  margin-top: 20px;
  font-size: 13px;
}
.dialog-note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 8px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 30px;
}
.mutation-dialog {
  width: min(1000px, 95vw);
  max-height: 90vh;
}
.mutation-dialog .dialog-heading {
  margin-bottom: 0;
}
#mutation-tree {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.mutation-node {
  padding: 0;
  text-align: left;
  overflow: hidden;
}
.mutation-node canvas {
  width: 100%;
  aspect-ratio: 1.5;
  object-fit: cover;
  image-rendering: pixelated;
}
.mutation-node strong,
.mutation-node small {
  display: block;
  margin: 8px 10px;
}
.mutation-node small {
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted);
}
.mutation-label {
  grid-column: 1/-1;
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
}
.source-drag .image-stage {
  outline: 3px dashed var(--accent);
  outline-offset: -8px;
}
.busy #render-status:before {
  content: "●";
  color: var(--busy);
  margin-right: 6px;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}
@media (min-width: 1650px) {
  .workspace {
    grid-template-columns: 295px minmax(300px, 1fr) 265px;
  }
  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  }
}
@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 230px minmax(200px, 1fr) 200px;
  }
  .image-toolbar {
    flex-wrap: wrap;
  }
  .image-toolbar > span {
    max-width: 100%;
  }
  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  }
  .topbar {
    gap: 8px;
    padding: 0 14px;
  }
}
@media (max-width: 760px) {
  .app-header {
    padding: 0 14px;
    gap: 18px;
    height: 40px;
  }
  .app-header nav {
    margin-left: auto;
    gap: 16px;
  }
  .brand {
    font-size: 15px;
  }
  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 40px;
    padding: 3px 12px;
    gap: 5px;
  }
  .seed-control {
    padding: 0 8px;
  }
  .menu summary {
    gap: 10px;
  }
  .current-name {
    display: none;
  }
  .topbar #undo {
    margin-left: auto;
  }
  .workspace {
    height: auto;
    grid-template-rows: auto;
    grid-template-columns: minmax(0, 1fr) 185px;
    min-height: 0;
  }
  .image-panel {
    grid-column: 1/-1;
    grid-row: 1;
    height: 50vh;
    min-height: 300px;
  }
  .adjustments {
    grid-column: 1;
    grid-row: 2;
    max-height: 390px;
    border-top: 1px solid var(--line);
  }
  .order-panel {
    grid-column: 2;
    grid-row: 2;
    max-height: 390px;
    border-top: 1px solid var(--line);
  }
  .image-toolbar {
    flex-wrap: nowrap;
  }
  .image-stage {
    padding: 12px;
  }
  .effect-browser {
    padding: 10px 15px 20px;
  }
  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
  }
  .home {
    margin: 6vh auto;
    padding: 24px;
  }
  .home h1 {
    font-size: 32px;
  }
  .home-choices {
    grid-template-columns: 1fr;
  }
  .home-button {
    min-height: 205px;
  }
  .home-button-luts {
    width: 100%;
  }
  .home-art {
    font-size: 70px;
  }
  .library-topbar {
    flex-wrap: wrap;
  }
  .preset-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 12px 12px 20px;
  }
  .experiments {
    padding: 15px;
  }
  .order-row {
    font-size: 10px;
    padding: 5px;
    gap: 5px;
  }
  #mutation-tree {
    grid-template-columns: repeat(2, 1fr);
  }
  .mutation-root {
    grid-column: 1/-1 !important;
  }
  .mutation-generation {
    grid-column: auto !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
.history-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 3px;
}
@media (max-width: 760px) {
  .history-actions {
    margin-left: auto;
  }
  .topbar #undo {
    margin-left: 0;
  }
}

/* ---- custom effect editors (HSL, grading, mixer) ---- */
.editor {
  padding-top: 8px;
}
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  padding: 8px 0 10px;
}
.editor-title {
  font-size: 12px;
  font-weight: 650;
  margin: 14px 0 -4px;
}
.editor-reset {
  margin-top: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tinted input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  background: transparent;
}
.tinted input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: var(--track, var(--line));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18);
}
.tinted input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: var(--track, var(--line));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18);
}
.tinted input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -3px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
}
.tinted input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
}
.swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.swatch {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.25);
}
.swatch:hover {
  background: var(--c);
  filter: brightness(1.1);
}
.swatch.on {
  border-color: var(--paper);
  outline: 2px solid var(--ink);
}
.swatch i {
  display: none;
  position: absolute;
  right: -2px;
  top: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  border: 1.5px solid var(--paper);
}
.swatch.dirty i {
  display: block;
}
.seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.seg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 0;
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  min-width: 0;
}
.seg-btn.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  font-weight: 600;
}
.seg-btn i {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgb(0 0 0 / 0.3);
}
.wheel {
  position: relative;
  width: 176px;
  height: 176px;
  margin: 16px auto 0;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgb(128 128 128) 0%, rgb(128 128 128 / 0) 72%),
    conic-gradient(
      hsl(0 85% 55%),
      hsl(60 85% 55%),
      hsl(120 85% 50%),
      hsl(180 85% 50%),
      hsl(240 85% 60%),
      hsl(300 85% 55%),
      hsl(360 85% 55%)
    );
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.25);
  touch-action: none;
  cursor: crosshair;
}
.wheel:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.puck {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow:
    0 0 0 1px rgb(0 0 0 / 0.55),
    0 1px 4px rgb(0 0 0 / 0.4);
  pointer-events: none;
}
.wheel-help {
  text-align: center;
}
.matrix {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  font-size: 11px;
}
.matrix-head,
.matrix-row {
  display: grid;
  grid-template-columns: 12px 1fr repeat(3, 38px);
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 11px;
}
.matrix-head {
  padding-top: 0;
  padding-bottom: 0;
  font-size: 10px;
  color: var(--muted);
  text-align: right;
}
.matrix-head b {
  font-weight: 650;
}
.matrix-row {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  text-align: left;
}
.matrix-row.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.matrix-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgb(0 0 0 / 0.3);
}
.matrix-row em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.matrix-row em.off {
  color: var(--muted);
  opacity: 0.6;
}
.mix-total {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---- settings page ---- */
.settings {
  max-width: 880px;
  margin: 0 auto;
  padding: 36px 28px 60px;
}
.settings h1 {
  font-size: 28px;
  letter-spacing: -0.5px;
  margin-bottom: 26px;
}
.settings h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.settings h3 {
  font-size: 13px;
  margin: 22px 0 12px;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
}
.theme-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.theme-swatch {
  display: grid;
  grid-template-columns: 22px 1fr;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--p-bg);
}
.theme-swatch.split {
  background: linear-gradient(115deg, var(--p-bg) 50%, var(--p-bg2) 50%);
}
.theme-swatch .side {
  background: var(--p-dark);
}
.theme-swatch .body {
  display: flex;
  padding: 10px;
}
.theme-swatch .card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border-radius: 4px;
  background: var(--p-paper);
}
.theme-swatch .card i {
  display: block;
  height: 5px;
  width: 70%;
  border-radius: 3px;
  background: var(--p-ink);
  opacity: 0.55;
}
.theme-swatch .card i:last-child {
  width: 34%;
  background: var(--p-accent);
  opacity: 1;
}
.theme-card input:checked + .theme-swatch {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.theme-card input:focus-visible + .theme-swatch {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.theme-name {
  font-weight: 600;
}

.order-row.lut-row {
  min-height: 52px;
  padding: 8px 8px;
  font-size: 13px;
  cursor: default;
  touch-action: auto;
}
.order-row.lut-row .order-label {
  font-weight: 650;
  font-size: 13px;
}
.lut-pin {
  font-size: 11px;
  letter-spacing: 0;
}
.luts-page {
  min-height: calc(100vh - 40px);
}
.lut-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 16px;
  background: var(--bar);
  color: var(--bar-ink);
  border-bottom: 1px solid var(--line);
}
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.topbar-aside {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
#lut-open {
  flex: none;
}
#lut-image-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.lut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 16px 18px 32px;
}
.lut-empty,
.library-empty {
  grid-column: 1 / -1;
  min-height: calc(100vh - 170px);
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
}
.library-empty {
  min-height: calc(100vh - 230px);
}
.lut-empty button,
.library-empty button {
  margin-top: 6px;
}
.lut-empty strong,
.library-empty strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 620;
}
.lut-tile {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}
.lut-tile.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.lut-preview {
  padding: 0;
  border: 0;
  border-radius: 9px 9px 0 0;
  background: var(--stage);
  aspect-ratio: 4 / 3;
  width: 100%;
  display: block;
  overflow: hidden;
  position: relative;
}
.lut-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lut-tile.is-pending .lut-preview {
  opacity: 0.55;
}
.lut-tile.is-downloading {
  opacity: 0.7;
}
.lut-chin {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  min-height: 52px;
  padding: 6px 4px 6px 12px;
  background: var(--bar);
  border-radius: 0 0 9px 9px;
}
.lut-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 620;
  color: var(--ink);
  text-align: left;
}
.lut-actions {
  display: flex;
  gap: 4px;
  flex: none;
}
.lut-actions button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--ink);
}
.lut-like.on {
  color: var(--accent);
  background: var(--row-sel);
  border-color: var(--row-sel-line);
}
.lut-swap {
  width: 18px;
  height: 18px;
  overflow: hidden;
  display: block;
}
.lut-swap-track {
  display: flex;
  flex-direction: column;
  width: 18px;
  transform: translateY(-18px);
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}
.lut-tile.selected .lut-swap-track {
  transform: translateY(0);
}
.lut-no-motion .lut-swap-track {
  transition: none;
}
.lut-swap svg {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
}
.lut-report-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: 14px;
}
.replace-copy {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  margin-top: 0;
}
.lut-viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background: color-mix(in srgb, var(--dark) 82%, transparent);
  color: var(--on-dark);
}
.lut-viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  display: grid;
  place-items: center;
}
.lut-viewer-close svg {
  display: block;
}
.lut-tile .lut-name-input,
.lut-tile .preset-rename {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  padding: 3px 6px;
}
.lut-report-details {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  max-height: 160px;
  overflow: auto;
}
.lut-viewer-frame {
  margin: 0;
  max-width: min(1100px, calc(100vw - 48px));
  max-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lut-viewer-frame canvas {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  width: auto;
  height: auto;
  background: var(--paper);
  box-shadow: 0 18px 60px #0008;
}
.lut-viewer-frame figcaption {
  display: flex;
  gap: 14px;
  align-items: baseline;
  max-width: 100%;
  font-size: 13px;
}
#lut-viewer-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#lut-viewer-status {
  opacity: 0.8;
  flex: none;
}
@media (max-width: 760px) {
  .lut-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 12px 12px 28px;
  }
  .lut-topbar {
    padding: 8px 12px;
    gap: 8px;
  }
  .lut-viewer {
    padding: 18px 12px;
  }
}

.preset-card footer .preset-rename {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 3px 6px;
}
