:root {
  color-scheme: dark;
  --bg: #0d0f13;
  --panel: #15181e;
  --panel-strong: #1b1f27;
  --panel-soft: #11141a;
  --line: #292e38;
  --line-strong: #3a414d;
  --text: #f4f6f8;
  --muted: #9ca5b4;
  --accent: #8de5c5;
  --accent-strong: #4ac99e;
  --accent-ink: #07150f;
  --danger: #ff8b8b;
  --warning: #f5c76f;
  --radius: 16px;
  --shadow: 0 20px 60px rgb(0 0 0 / 0.28);
  --sidebar-width: 252px;
  --control-width: 330px;
  --pane-resizer-size: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

/* Font-size preferences affect text only. Keep spacing, controls, and pane
 * geometry unchanged so a larger label never changes the interaction target. */
#app {
  --ui-font-scale: 1;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

:where(
  input:not([type]),
  input:is([type="text"], [type="search"], [type="email"], [type="url"], [type="tel"], [type="password"]),
  textarea,
  [contenteditable]:not([contenteditable="false"])
) {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"],
.drop-zone {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled,
fieldset:disabled {
  opacity: 0.55;
}

.a11y-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100dvh;
  background:
    radial-gradient(circle at 62% 0%, rgb(82 188 151 / 0.09), transparent 34rem),
    var(--bg);
}

.global-drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 100;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.992);
  border: 2px dashed transparent;
  border-radius: 20px;
  background: rgb(7 21 15 / 0);
  backdrop-filter: blur(0);
  transition: opacity 140ms ease, transform 140ms ease, border-color 140ms ease, background 140ms ease, backdrop-filter 140ms ease;
}

.global-drop-overlay.is-active {
  opacity: 1;
  transform: scale(1);
  border-color: var(--accent);
  background: rgb(7 21 15 / 0.72);
  backdrop-filter: blur(5px);
}

.global-drop-card {
  display: grid;
  min-width: min(360px, calc(100vw - 64px));
  place-items: center;
  gap: 7px;
  padding: 30px 34px;
  border: 1px solid rgb(141 229 197 / 0.42);
  border-radius: 18px;
  background: rgb(17 28 24 / 0.94);
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.44);
  text-align: center;
}

.global-drop-card .drop-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 5px;
  font-size: calc(26px * var(--ui-font-scale, 1));
  background: var(--accent);
  color: var(--accent-ink);
}

.global-drop-card strong {
  font-size: calc(17px * var(--ui-font-scale, 1));
}

.topbar {
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 68px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgb(13 15 19 / 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand img {
  border-radius: 10px;
  box-shadow: 0 6px 18px rgb(80 218 168 / 0.16);
}

.brand div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand strong {
  min-width: 0;
  overflow: hidden;
  font-size: calc(15px * var(--ui-font-scale, 1));
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-version {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: calc(10px * var(--ui-font-scale, 1));
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.selected-copy span,
.sidebar-heading span,
.range-labels,
.control-card p,
.face-model-line,
.field-row {
  color: var(--muted);
  font-size: calc(12px * var(--ui-font-scale, 1));
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.button,
.icon-button {
  border: 0;
  color: var(--text);
  cursor: pointer;
}

.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: calc(13px * var(--ui-font-scale, 1));
  font-weight: 750;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:not(:disabled):active {
  transform: translateY(1px);
}

.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button.primary:hover:not(:disabled) {
  background: #a2efd3;
}

.button.secondary {
  border-color: var(--line-strong);
  background: #232833;
}

.button.secondary:hover:not(:disabled),
.button.secondary.is-active {
  border-color: rgb(141 229 197 / 0.55);
  background: rgb(141 229 197 / 0.1);
}

.button.ghost {
  border-color: var(--line);
  background: transparent;
  color: #c9cfda;
}

.button.ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgb(255 255 255 / 0.04);
}

.button.compact {
  min-height: 32px;
  padding: 5px 10px;
  font-size: calc(11px * var(--ui-font-scale, 1));
}

.button.full {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: calc(20px * var(--ui-font-scale, 1));
}

.icon-button:hover {
  background: rgb(255 255 255 / 0.06);
  color: var(--text);
}

.compatibility-warning {
  padding: 8px 16px;
  border-bottom: 1px solid rgb(255 139 139 / 0.25);
  background: rgb(255 139 139 / 0.09);
  color: #ffd5d5;
  font-size: calc(12px * var(--ui-font-scale, 1));
  text-align: center;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(180px, min(var(--sidebar-width), 32vw)) var(--pane-resizer-size) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: rgb(17 20 26 / 0.78);
}

.drop-zone {
  display: grid;
  min-height: 112px;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 1px dashed #414957;
  border-radius: 14px;
  background: rgb(255 255 255 / 0.018);
  color: var(--text);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.drop-zone:focus-within,
.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent-strong);
  background: rgb(141 229 197 / 0.07);
  transform: translateY(-1px);
}

.drop-zone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.thumbnail-add-tile:focus-within {
  outline: none;
}

.thumbnail-add-tile:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.thumbnail-add-tile:hover,
.thumbnail-add-tile:focus-within,
.thumbnail-add-tile.is-dragging {
  transform: none;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-zone strong {
  font-size: calc(13px * var(--ui-font-scale, 1));
}

.thumbnail-add-tile {
  grid-template-columns: 58px minmax(0, 1fr);
  min-height: 60px;
  place-items: center stretch;
  align-content: center;
  gap: 9px;
  padding: 7px;
  border-radius: 11px;
}

.thumbnail-add-tile .drop-icon {
  width: 58px;
  height: 46px;
  margin: 0;
  border-radius: 8px;
}

.thumbnail-add-tile strong {
  font-size: calc(11px * var(--ui-font-scale, 1));
  line-height: 1.2;
}

.drop-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: calc(21px * var(--ui-font-scale, 1));
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1px 2px;
}

.sidebar-heading strong {
  font-size: calc(13px * var(--ui-font-scale, 1));
}

.thumbnail-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.thumbnail-item {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 26px;
  gap: 9px;
  align-items: center;
  margin-bottom: 7px;
  padding: 7px;
  content-visibility: auto;
  contain-intrinsic-block-size: 60px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
}

.thumbnail-item:hover {
  background: rgb(255 255 255 / 0.03);
}

.thumbnail-item.is-selected {
  border-color: rgb(141 229 197 / 0.32);
  background: rgb(141 229 197 / 0.075);
}

.thumbnail-image-wrap {
  position: relative;
  width: 58px;
  height: 46px;
  overflow: hidden;
  border-radius: 8px;
  background: #080a0d;
}

.thumbnail-image,
.thumbnail-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-placeholder {
  background: linear-gradient(135deg, #1c2028, #101319);
}

.thumbnail-status {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 2px 4px;
  border-radius: 5px;
  background: rgb(0 0 0 / 0.72);
  color: #dfe5ec;
  font-size: calc(8px * var(--ui-font-scale, 1));
  font-weight: 750;
}

.thumbnail-status.error {
  color: #ffc1c1;
}

.thumbnail-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.thumbnail-copy strong {
  overflow: hidden;
  font-size: calc(11px * var(--ui-font-scale, 1));
  white-space: nowrap;
  text-overflow: ellipsis;
}

.thumbnail-copy span {
  color: var(--muted);
  font-size: calc(9px * var(--ui-font-scale, 1));
}

.remove-thumbnail {
  width: 26px;
  height: 26px;
  opacity: 0;
  font-size: calc(16px * var(--ui-font-scale, 1));
}

.thumbnail-item:hover .remove-thumbnail,
.thumbnail-item:focus-within .remove-thumbnail {
  opacity: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--pane-resizer-size) minmax(260px, min(var(--control-width), 38vw));
  min-width: 0;
  min-height: 0;
}

.pane-resizer {
  position: relative;
  z-index: 3;
  display: block;
  width: var(--pane-resizer-size);
  min-width: var(--pane-resizer-size);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.pane-resizer::before {
  position: absolute;
  inset: 0 4px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.08);
  content: "";
  transition: background 120ms ease, transform 120ms ease;
}

.pane-resizer:hover::before,
.pane-resizer:focus-visible::before,
.pane-resizer.is-active::before {
  background: var(--accent-strong);
  transform: scaleX(1.35);
}

.pane-resizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

body.is-pane-resizing,
body.is-pane-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  padding: 14px;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 2px 10px;
}

.selected-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.selected-copy strong,
.selected-copy span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.selected-copy strong {
  font-size: calc(13px * var(--ui-font-scale, 1));
}

.preview-stage {
  position: relative;
  min-width: 0;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid #242a33;
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, #0c0e12 25%, transparent 25%),
    linear-gradient(-45deg, #0c0e12 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0c0e12 75%),
    linear-gradient(-45deg, transparent 75%, #0c0e12 75%),
    #101318;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  box-shadow: inset 0 0 80px rgb(0 0 0 / 0.18);
  --compare-split-position: 50%;
}

.preview-content {
  --preview-scale: 1;
  --preview-pan-x: 0px;
  --preview-pan-y: 0px;
  --compare-split-local-position: 50%;
  position: absolute;
  inset: 0;
  transform: translate3d(var(--preview-pan-x), var(--preview-pan-y), 0) scale(var(--preview-scale));
  transform-origin: center;
  will-change: transform;
}

.preview-stage.is-zoomed {
  cursor: grab;
  touch-action: none;
}

.preview-stage.is-panning {
  cursor: grabbing;
  user-select: none;
}

.preview-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.preview-image.original {
  z-index: 1;
}

.preview-image.processed {
  z-index: 2;
  transition: opacity 100ms linear;
}

.preview-stage.show-original .preview-image.processed {
  opacity: 0;
}

/* Before/after comparison is controlled by a tap on the image. The original
   remains below the processed frame; clipping only the processed layer keeps
   both images on the same transformed content while the divider stays fixed
   to the viewport for reliable dragging at any zoom level. */
.preview-stage.is-split-compare .preview-image.processed {
  /* The image layer is zoom/pan transformed. Use the inverse-mapped local
     position so the fixed stage divider remains aligned while moving. */
  clip-path: inset(0 0 0 var(--compare-split-local-position));
}

.compare-split {
  position: absolute;
  z-index: 7;
  inset: 0;
  pointer-events: none;
}

.compare-split-label {
  position: absolute;
  top: 12px;
  max-width: 42%;
  padding: 5px 8px;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 999px;
  background: rgb(11 13 17 / 0.78);
  box-shadow: 0 4px 18px rgb(0 0 0 / 0.2);
  color: #f3f6fa;
  font-size: calc(11px * var(--ui-font-scale, 1));
  font-weight: 750;
  line-height: 1.1;
  overflow: hidden;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-split-label--original {
  left: 12px;
}

.compare-split-label--processed {
  right: 12px;
}

.compare-split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--compare-split-position);
  width: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ew-resize;
  pointer-events: auto;
  touch-action: none;
  transform: translateX(-50%);
}

.compare-split-divider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #f5f8fb;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35), 0 0 14px rgb(0 0 0 / 0.42);
  transform: translateX(-50%);
}

.compare-split-divider-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 42px;
  border: 1px solid rgb(255 255 255 / 0.75);
  border-radius: 999px;
  background: rgb(11 13 17 / 0.86);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.32);
  transform: translate(-50%, -50%);
}

.compare-split-divider-grip::before,
.compare-split-divider-grip::after {
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  border: solid #dce2ea;
  border-width: 1px 0 0 1px;
  content: '';
}

.compare-split-divider-grip::before {
  left: 5px;
  transform: translateY(-50%) rotate(-45deg);
}

.compare-split-divider-grip::after {
  right: 5px;
  transform: translateY(-50%) rotate(135deg);
}

.compare-split-divider:hover .compare-split-divider-grip,
.compare-split-divider:focus-visible .compare-split-divider-grip {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(141 229 197 / 0.2), 0 4px 16px rgb(0 0 0 / 0.32);
}

.compare-split-divider:focus-visible {
  outline: none;
}

.preview-stage.is-mosaic-pending .preview-content {
  visibility: hidden;
}

/* Keep the manual face overlay usable while a high-resolution frame is being
   replaced.  The old pixels stay hidden, so adding a region cannot expose a
   stale un-mosaicked frame, while the user can still draw the next region. */
.preview-stage.is-mosaic-pending.is-manual-mode .preview-content {
  visibility: visible;
}

.preview-stage.is-mosaic-pending.is-manual-mode .preview-image {
  opacity: 0;
}

.preview-stage.is-mosaic-pending.is-manual-mode .face-region {
  visibility: hidden;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.preview-empty strong {
  max-width: 430px;
  color: #c7ced8;
  font-size: calc(14px * var(--ui-font-scale, 1));
}

.preview-empty span:last-child {
  font-size: calc(11px * var(--ui-font-scale, 1));
}

.ui-icon.preview-empty-icon {
  display: block;
  width: 46px;
  height: 46px;
  color: #596272;
  stroke-width: 1.45;
}

.preview-empty-action {
  min-height: 38px;
  margin-top: 5px;
  padding: 9px 16px;
  cursor: pointer;
}

.preview-busy {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(11 13 17 / 0.86);
  box-shadow: var(--shadow);
  color: #dce2ea;
  font-size: calc(11px * var(--ui-font-scale, 1));
  backdrop-filter: blur(12px);
}

.preview-stage.is-mosaic-pending .preview-busy {
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  padding: 10px 14px;
  transform: translate(-50%, -50%);
}

.zoom-reset-button {
  position: absolute;
  z-index: 5;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(11 13 17 / 0.86);
  box-shadow: var(--shadow);
  color: #dce2ea;
  font: inherit;
  font-size: calc(11px * var(--ui-font-scale, 1));
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.zoom-reset-button:hover,
.zoom-reset-button:focus-visible {
  border-color: rgb(141 229 197 / 0.48);
  color: white;
  outline: none;
}

.zoom-reset-button span:first-child {
  min-width: 34px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.face-overlay {
  position: absolute;
  z-index: 4;
  overflow: visible;
  pointer-events: none;
}

.face-overlay.manual-mode {
  cursor: crosshair;
  pointer-events: auto;
}

.face-overlay:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.face-region,
.face-box {
  pointer-events: auto;
  cursor: grab;
}

.face-region.is-moving,
.face-region.is-moving .face-box {
  cursor: grabbing;
}

.face-box {
  fill: rgb(141 229 197 / 0.08);
  stroke: var(--accent);
  stroke-width: 0.004;
  vector-effect: non-scaling-stroke;
}

.face-box.is-manual {
  stroke: #f3c875;
}

.face-region:hover .face-box {
  fill: rgb(141 229 197 / 0.16);
  stroke-width: 0.006;
}

.face-label {
  fill: white;
  font-size: calc(0.028px * var(--ui-font-scale, 1));
  font-weight: 800;
  paint-order: stroke;
  pointer-events: none;
  stroke: rgb(0 0 0 / 0.8);
  stroke-width: 0.006px;
}

.drag-box {
  fill: rgb(243 200 117 / 0.16);
  stroke: #f3c875;
  stroke-dasharray: 0.012 0.008;
  stroke-width: 0.004;
  vector-effect: non-scaling-stroke;
}

.warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 9px 2px 0;
  padding: 9px 11px;
  border: 1px solid rgb(245 199 111 / 0.25);
  border-radius: 9px;
  background: rgb(245 199 111 / 0.075);
  color: #f7d99d;
  font-size: calc(11px * var(--ui-font-scale, 1));
}

.control-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 18px 0;
  border-left: 1px solid var(--line);
  background: rgb(17 20 26 / 0.58);
  scrollbar-width: thin;
}

.control-selection-status {
  margin: 0 0 10px 14px;
  padding: 9px 11px;
  border: 1px solid rgb(141 229 197 / 0.28);
  border-radius: 9px;
  background: rgb(141 229 197 / 0.07);
  color: #b8e9d7;
  font-size: calc(11px * var(--ui-font-scale, 1));
  line-height: 1.45;
}

.control-panel fieldset {
  display: grid;
  gap: 10px;
  padding-left: 14px;
}

.control-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.control-card.hero-control {
  background:
    radial-gradient(circle at 50% 12%, rgb(141 229 197 / 0.08), transparent 58%),
    var(--panel);
}

/* A+ finish control: the continuous adjustment stays above the visual
   presets so the slider remains the source of truth and the cards are quick
   landmarks, not a second editing model. */
.finish-adjustment {
  margin-top: 12px;
  padding: 10px 11px 9px;
  border: 1px solid rgb(141 229 197 / 0.18);
  border-radius: 11px;
  background: linear-gradient(150deg, rgb(141 229 197 / 0.07), rgb(255 255 255 / 0.018));
}

.finish-adjustment-heading,
.finish-selection-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.finish-adjustment-heading {
  color: #dce7e3;
  font-size: calc(10px * var(--ui-font-scale, 1));
  font-weight: 750;
}

.finish-adjustment-hint,
.finish-selection-heading > span:last-child {
  color: var(--muted);
  font-size: calc(9px * var(--ui-font-scale, 1));
  font-variant-numeric: tabular-nums;
}

.finish-adjustment .main-range {
  margin: 3px 0 0;
}

.finish-adjustment .range-labels {
  color: var(--muted);
  font-size: calc(9px * var(--ui-font-scale, 1));
}

.finish-selection-heading {
  margin-top: 15px;
  color: var(--text);
  font-size: calc(11px * var(--ui-font-scale, 1));
  font-weight: 750;
}

.finish-selection-heading output {
  color: var(--accent);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.finish-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.finish-preset {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 50px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.035);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 130ms ease, background 130ms ease, transform 130ms ease;
}

.finish-preset:hover:not(:disabled) {
  border-color: rgb(141 229 197 / 0.48);
  background: rgb(141 229 197 / 0.08);
}

.finish-preset:active:not(:disabled) {
  transform: translateY(1px);
}

.finish-preset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.finish-preset.is-selected {
  border-color: var(--accent-strong);
  background: rgb(141 229 197 / 0.13);
  box-shadow: inset 0 0 0 1px rgb(141 229 197 / 0.15);
}

.finish-preset:disabled {
  cursor: default;
  opacity: 0.55;
}

.finish-preset-swatch {
  display: block;
  width: 38px;
  height: 34px;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 7px;
  box-shadow: inset 0 0 12px rgb(0 0 0 / 0.22);
}

.finish-preset-swatch--original {
  background-image: var(--finish-preview-image, linear-gradient(135deg, #343a46, #6d7883 45%, #b0a88d));
  background-position: center;
  background-size: cover;
  filter: saturate(0.72) brightness(0.94);
}

.finish-preset-swatch--natural {
  background-image: var(--finish-preview-image, linear-gradient(135deg, #244865, #4c91aa 42%, #d4b46b 78%, #274b3f));
  background-position: center;
  background-size: cover;
  filter: saturate(1.05) contrast(1.03);
}

.finish-preset-swatch--crisp {
  background-image: var(--finish-preview-image, linear-gradient(135deg, #122c4c, #277f9d 40%, #f0ba55 72%, #19392f));
  background-position: center;
  background-size: cover;
  filter: saturate(1.28) contrast(1.1);
}

.finish-preset-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.finish-preset-copy strong {
  overflow: hidden;
  font-size: calc(10px * var(--ui-font-scale, 1));
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finish-preset-copy small {
  color: var(--muted);
  font-size: calc(9px * var(--ui-font-scale, 1));
  font-variant-numeric: tabular-nums;
}

.control-card h2,
.control-card h3,
.dialog-heading h2 {
  margin: 0;
}

.control-card h2 {
  font-size: calc(18px * var(--ui-font-scale, 1));
}

.control-card h3 {
  font-size: calc(13px * var(--ui-font-scale, 1));
}

.control-card p {
  margin: 10px 0 0;
  line-height: 1.55;
}

.control-title,
.switch-row,
.field-row,
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.control-title output {
  min-width: 58px;
  color: var(--accent);
  font-size: calc(34px * var(--ui-font-scale, 1));
  font-weight: 800;
  letter-spacing: -0.05em;
  text-align: right;
}

.control-title.small span {
  color: var(--muted);
  font-size: calc(10px * var(--ui-font-scale, 1));
}

.direction-card-heading,
.direction-compass-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.direction-card-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: calc(10px * var(--ui-font-scale, 1));
  line-height: 1.4;
}

.processing-status {
  margin: 9px 2px 0;
  padding: 8px 10px;
  border: 1px solid rgb(141 229 197 / 0.28);
  border-radius: 9px;
  background: rgb(141 229 197 / 0.07);
  color: var(--accent);
  font-size: calc(11px * var(--ui-font-scale, 1));
  line-height: 1.4;
}

.processing-status.is-warning {
  border-color: rgb(245 199 111 / 0.42);
  background: rgb(245 199 111 / 0.09);
  color: #f5cf87;
}

.settings-hint.is-warning {
  color: #f5cf87;
}

.direction-card {
  container-name: direction-card;
  container-type: inline-size;
}

.direction-compass-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.direction-editor {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.direction-compass-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.direction-compass-heading {
  align-items: baseline;
}

.direction-compass-heading strong {
  font-size: calc(11px * var(--ui-font-scale, 1));
}

.direction-compass-heading output {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  color: var(--accent);
  font-size: calc(9px * var(--ui-font-scale, 1));
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.direction-pad-wrap {
  position: relative;
  width: min(140px, 100%);
  aspect-ratio: 1;
  margin: 8px auto 0;
  padding: 16px;
}

.direction-axis {
  position: absolute;
  z-index: 2;
  color: var(--muted);
  font-size: calc(9px * var(--ui-font-scale, 1));
  pointer-events: none;
}

.direction-axis-top {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.direction-axis-right {
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

.direction-axis-bottom {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.direction-axis-left {
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.direction-pad {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background:
    linear-gradient(90deg, transparent 49%, var(--line) 49.5% 50.5%, transparent 51%),
    linear-gradient(0deg, transparent 49%, var(--line) 49.5% 50.5%, transparent 51%),
    #191e26;
  box-shadow: inset 0 0 24px rgb(0 0 0 / 0.24);
  cursor: crosshair;
  touch-action: none;
}

.direction-pad::before,
.direction-pad::after {
  position: absolute;
  border: 1px solid rgb(255 255 255 / 0.06);
  content: "";
  pointer-events: none;
}

.direction-pad::before {
  inset: 12.5%;
}

.direction-pad::after {
  inset: 25%;
}

.direction-recommendation,
.direction-puck {
  position: absolute;
  top: var(--direction-y);
  left: var(--direction-x);
  border-radius: 0;
  transform: translate(-50%, -50%);
}

.direction-recommendation {
  width: 18px;
  height: 18px;
  border: 1px solid var(--accent-strong);
  border-radius: 50%;
  opacity: 0.62;
  pointer-events: none;
}

.direction-recommendation::after {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--accent-strong);
  content: "";
}

.direction-puck {
  width: 21px;
  height: 21px;
  padding: 0;
  border: 3px solid #191e26;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-strong), 0 4px 10px rgb(0 0 0 / 0.4);
  cursor: grab;
}

.direction-puck:active {
  cursor: grabbing;
}

.direction-pad[data-direction-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.62;
}

.direction-puck:disabled {
  cursor: not-allowed;
  opacity: 0.76;
}

fieldset:disabled .direction-pad {
  pointer-events: none;
}

@container direction-card (min-width: 390px) {
  .direction-editor {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .direction-compass-item {
    min-width: 0;
    padding: 9px;
  }

  .direction-compass-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .direction-compass-heading output {
    width: 100%;
    text-align: left;
  }

  .direction-compass-actions {
    width: 100%;
  }
}

@container direction-card (min-width: 660px) {
  .direction-editor {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .direction-compass-heading {
    align-items: baseline;
    flex-direction: row;
    gap: 6px;
  }

  .direction-compass-heading output {
    width: auto;
    text-align: right;
  }
}

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 6px 0;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

input[type="range"]:active {
  cursor: grabbing;
}

.main-range {
  margin-top: 2px;
}

.range-labels {
  display: flex;
  justify-content: space-between;
}

.switch-row p {
  margin-top: 4px;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 25px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #303641;
  cursor: pointer;
  transition: background 130ms ease;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: white;
  content: "";
  transition: transform 130ms ease;
}

.switch input:checked + span {
  background: var(--accent-strong);
}

.switch input:checked + span::after {
  transform: translateX(19px);
}

.face-model-line {
  margin-top: 9px;
  padding: 8px 9px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.face-model-line strong {
  color: #dce3eb;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.manual-hint {
  color: #f3d8a2 !important;
}

.field-row {
  margin-top: 12px;
}

.field-row select,
.export-dialog select {
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #20252e;
  color: var(--text);
}

.field-row input[type="range"] {
  max-width: 150px;
}

.recipe-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.recipe-card {
  container-name: recipe-card;
  container-type: inline-size;
  /* Fine-adjustment labels are intentionally a little larger than the rest
     of the UI while still following the global text-size preference. */
  --recipe-font-scale: calc(var(--ui-font-scale, 1) * 1.2);
}

.recipe-card-heading > div {
  display: grid;
  gap: 2px;
}

.recipe-card-heading span,
.recipe-group-header small {
  color: var(--muted);
  font-size: calc(9px * var(--recipe-font-scale, 1));
}

.recipe-reset-all,
.recipe-auto-button {
  border: 1px solid rgb(141 229 197 / 0.28);
  border-radius: 999px;
  background: rgb(141 229 197 / 0.06);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.recipe-reset-all {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 9px;
  font-size: calc(9px * var(--recipe-font-scale, 1));
  font-weight: 700;
}

.recipe-reset-all:hover:not(:disabled),
.recipe-auto-button:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: rgb(141 229 197 / 0.12);
}

.recipe-reset-all:disabled {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  cursor: default;
  opacity: 0.6;
}

.recipe-editor {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.recipe-editor > .muted {
  margin: 0;
}

.recipe-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.recipe-group-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 8px 9px;
  user-select: none;
}

.recipe-group-header span {
  font-size: calc(10px * var(--recipe-font-scale, 1));
  font-weight: 750;
}

.recipe-group-header > .recipe-group-toggle {
  justify-self: start;
  margin: 0;
}

.recipe-group-controls {
  padding: 0 9px 6px;
}
.recipe-subgroup {
  margin: 4px 0;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.075);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.018);
}

.recipe-subgroup summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: calc(9px * var(--recipe-font-scale, 1));
  list-style: none;
  user-select: none;
}

.recipe-subgroup summary::-webkit-details-marker {
  display: none;
}

.recipe-subgroup summary::before {
  color: var(--muted);
  content: "›";
  font-size: calc(13px * var(--recipe-font-scale, 1));
  line-height: 1;
  transition: transform 120ms ease;
}

.recipe-subgroup[open] summary::before {
  transform: rotate(90deg);
}

.recipe-subgroup summary:focus-visible {
  border-radius: 7px;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.recipe-subgroup summary span {
  font-weight: 700;
}

.recipe-subgroup summary small {
  color: var(--muted);
  font-size: calc(8px * var(--recipe-font-scale, 1));
}

.recipe-subgroup-controls {
  padding: 0 7px 4px;
}
.grading-studio,
.hsl-studio {
  padding: 5px 2px 7px;
}

.grading-wheels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.grading-wheel-card {
  min-width: 0;
  padding: 7px 5px 5px;
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 9px;
  background: linear-gradient(145deg, rgb(255 255 255 / 0.065), rgb(255 255 255 / 0.018));
}

.grading-wheel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  padding-inline: 10px;
  margin-bottom: 6px;
}

.grading-wheel-heading strong {
  font-size: calc(9px * var(--recipe-font-scale, 1));
  font-weight: 760;
}

.grading-wheel-heading span {
  color: var(--muted);
  font-size: calc(8px * var(--recipe-font-scale, 1));
  white-space: nowrap;
}

.color-wheel {
  position: relative;
  width: min(100%, 132px);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgb(19 22 28 / 0.98) 0 9%, transparent 10% 54%, rgb(12 14 18 / 0.5) 55% 100%),
    conic-gradient(from -90deg, #ff3939, #ffd23f, #55df75, #40d7ff, #5e76ff, #c56bff, #ff4fb4, #ff3939);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.42), 0 5px 12px rgb(0 0 0 / 0.24);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.color-wheel::before {
  position: absolute;
  inset: 12%;
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.color-wheel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.color-wheel-puck {
  position: absolute;
  z-index: 1;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgb(20 22 28 / 0.5);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.58), 0 2px 7px rgb(0 0 0 / 0.52);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.color-wheel-center-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border: 1px solid rgb(255 255 255 / 0.8);
  border-radius: 50%;
  background: rgb(0 0 0 / 0.35);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.52);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.grading-wheel-controls .recipe-control {
  padding: 4px 10px 3px;
}

.grading-wheel-controls .recipe-control-heading {
  gap: 3px;
}

.grading-wheel-controls .recipe-control-label-text {
  overflow: hidden;
  font-size: calc(8px * var(--recipe-font-scale, 1));
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grading-wheel-controls .recipe-control input[type="range"] {
  height: 18px;
  width: 100%;
  margin: 1px 0 0;
}

.grading-wheel-controls .recipe-auto-button {
  min-width: 28px;
  min-height: 18px;
  padding: 1px 4px;
  font-size: calc(8px * var(--recipe-font-scale, 1));
}

.grading-balance {
  margin-top: 6px;
  padding: 4px 7px 2px;
  border-top: 1px solid rgb(255 255 255 / 0.08);
}
.hsl-spectrum {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 3px;
  padding: 2px;
}

.hsl-band-button {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 5px 2px 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: rgb(255 255 255 / 0.025);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: calc(8px * var(--recipe-font-scale, 1));
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}

.hsl-band-button:hover {
  background: rgb(255 255 255 / 0.07);
  color: var(--text);
}

.hsl-band-button:active {
  transform: translateY(1px);
}

.hsl-band-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hsl-band-button.is-selected {
  border-color: rgb(141 229 197 / 0.5);
  background: rgb(141 229 197 / 0.12);
  color: var(--text);
}

.hsl-band-swatch,
.hsl-band-large-swatch {
  display: block;
  background: var(--hsl-band-color, hsl(var(--hsl-band-hue) 86% 56%));
}

.hsl-band-button[data-hsl-band="Red"] .hsl-band-swatch, .hsl-band-controls[data-hsl-controls="Red"] .hsl-band-large-swatch { background: #ef3030; }
.hsl-band-button[data-hsl-band="Orange"] .hsl-band-swatch, .hsl-band-controls[data-hsl-controls="Orange"] .hsl-band-large-swatch { background: #f28a2c; }
.hsl-band-button[data-hsl-band="Yellow"] .hsl-band-swatch, .hsl-band-controls[data-hsl-controls="Yellow"] .hsl-band-large-swatch { background: #f5d447; }
.hsl-band-button[data-hsl-band="Green"] .hsl-band-swatch, .hsl-band-controls[data-hsl-controls="Green"] .hsl-band-large-swatch { background: #54c85e; }
.hsl-band-button[data-hsl-band="Cyan"] .hsl-band-swatch, .hsl-band-controls[data-hsl-controls="Cyan"] .hsl-band-large-swatch { background: #45d6d1; }
.hsl-band-button[data-hsl-band="Blue"] .hsl-band-swatch, .hsl-band-controls[data-hsl-controls="Blue"] .hsl-band-large-swatch { background: #4f7ee8; }
.hsl-band-button[data-hsl-band="Purple"] .hsl-band-swatch, .hsl-band-controls[data-hsl-controls="Purple"] .hsl-band-large-swatch { background: #9d5fde; }
.hsl-band-button[data-hsl-band="Magenta"] .hsl-band-swatch, .hsl-band-controls[data-hsl-controls="Magenta"] .hsl-band-large-swatch { background: #e74b9f; }
.hsl-band-swatch {
  width: 100%;
  height: 12px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.28), 0 1px 4px rgb(0 0 0 / 0.2);
}

.hsl-band-controls {
  margin-top: 6px;
  padding: 7px 8px 3px;
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: 8px;
  background: linear-gradient(145deg, rgb(255 255 255 / 0.055), rgb(255 255 255 / 0.018));
}

.hsl-band-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: calc(8px * var(--recipe-font-scale, 1));
}

.hsl-band-heading strong {
  color: var(--text);
  font-size: calc(9px * var(--recipe-font-scale, 1));
}

.hsl-band-large-swatch {
  width: 16px;
  height: 16px;
  border: 1px solid rgb(255 255 255 / 0.38);
  border-radius: 5px;
  box-shadow: 0 2px 5px rgb(0 0 0 / 0.22);
}

.hsl-band-controls .recipe-control {
  padding: 5px 0 3px;
}


.recipe-control {
  display: grid;
  grid-template-rows: auto auto;
  padding: 6px 0 4px;
  border-top: 1px solid rgb(255 255 255 / 0.045);
}

.recipe-control--sub {
  margin: -1px 0 2px 11px;
  padding: 4px 7px 3px 9px;
  border-top: 0;
  border-left: 2px solid rgb(141 229 197 / 0.42);
  border-radius: 0 7px 7px 0;
  background: rgb(255 255 255 / 0.025);
}

.recipe-control-heading {
  grid-row: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.recipe-control--sub .recipe-control-heading {
  gap: 4px;
}

.recipe-control--sub label {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.recipe-control label {
  overflow: hidden;
  font-size: calc(10px * var(--recipe-font-scale, 1));
  white-space: nowrap;
  text-overflow: ellipsis;
}

.recipe-control--sub .recipe-control-branch {
  color: var(--muted);
  font-size: calc(11px * var(--recipe-font-scale, 1));
  font-weight: 700;
  line-height: 1;
}

.recipe-control--sub .recipe-control-label-text {
  flex: 0 0 auto;
}

.recipe-control--sub .recipe-control-context {
  overflow: hidden;
  color: var(--muted);
  font-size: calc(8px * var(--recipe-font-scale, 1));
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-control output {
  min-width: 42px;
  color: #c8cfd8;
  font-size: calc(10px * var(--recipe-font-scale, 1));
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.recipe-control--sub output {
  min-width: 36px;
  font-size: calc(9px * var(--recipe-font-scale, 1));
}

.recipe-control--sub .recipe-auto-button {
  min-width: 32px;
  min-height: 20px;
  padding: 1px 5px;
  font-size: calc(8px * var(--recipe-font-scale, 1));
}

.recipe-control.is-manual output {
  color: var(--accent);
  font-weight: 750;
}

.recipe-effect-toggle {
  position: relative;
  display: grid;
  width: 18px;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.recipe-effect-toggle-placeholder {
  width: 18px;
  min-width: 18px;
  height: 18px;
  pointer-events: none;
}

.recipe-effect-toggle-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px rgb(7 10 13 / 0.4);
}

.recipe-effect-toggle[aria-pressed="false"] {
  background: transparent;
  color: var(--muted);
}

.recipe-effect-toggle[aria-pressed="false"] .recipe-effect-toggle-dot {
  width: 8px;
  height: 8px;
  background: transparent;
  border: 1px solid currentColor;
  box-shadow: none;
}

.recipe-effect-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.recipe-control.is-disabled {
  /* The effect is inactive, but its slider must remain visibly usable so a
     user can move away from the neutral value to reactivate it. */
  opacity: 1;
}

.recipe-control.is-disabled input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  opacity: 1;
  accent-color: var(--accent-strong);
  background: transparent;
}

.recipe-control.is-disabled .recipe-control-heading > label,
.recipe-control.is-disabled .recipe-control-heading > output,
.recipe-control.is-disabled .recipe-control-heading > .recipe-auto-button,
.recipe-control.is-disabled .recipe-control-heading > .recipe-effect-toggle {
  opacity: 0.64;
}

.recipe-control.is-disabled input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border: 1px solid #626873;
  border-radius: 999px;
  background: #2a2e34;
}

.recipe-control.is-disabled input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 2px solid var(--accent-strong);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgb(7 10 13 / 0.45);
  cursor: pointer;
  -webkit-appearance: none;
}

.recipe-control.is-disabled input[type="range"]::-moz-range-track {
  height: 5px;
  border: 1px solid #626873;
  border-radius: 999px;
  background: #2a2e34;
}

.recipe-control.is-disabled input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent-strong);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgb(7 10 13 / 0.45);
  cursor: pointer;
}

/* An explicit OFF is different from a neutral value: the whole slider,
   including its thumb, is shown as inactive while remaining reversible via
   the effect toggle. */
.recipe-control.is-explicitly-disabled input[type="range"] {
  accent-color: var(--muted);
}

.recipe-control.is-explicitly-disabled input[type="range"]::-webkit-slider-thumb {
  border-color: #626873;
  background: #737b86;
  box-shadow: none;
}

.recipe-control.is-explicitly-disabled input[type="range"]::-moz-range-thumb {
  border-color: #626873;
  background: #737b86;
  box-shadow: none;
}

.recipe-auto-button {
  min-width: 38px;
  min-height: 24px;
  padding: 2px 6px;
  font-size: calc(9px * var(--recipe-font-scale, 1));
}

.recipe-auto-button:disabled {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  cursor: default;
  opacity: 0.68;
}

.recipe-control input[type="range"] {
  grid-row: 2;
  height: 24px;
  margin: 1px 0 0;
}

.recipe-control--sub input[type="range"] {
  height: 18px;
  margin: 0;
}

.notice,
.export-progress {
  position: fixed;
  z-index: 50;
  left: 50%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgb(25 29 36 / 0.95);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  transform: translateX(-50%);
}

.notice {
  bottom: 22px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 15px;
  color: #e7ebf0;
  font-size: calc(12px * var(--ui-font-scale, 1));
  text-align: center;
}

.export-progress {
  bottom: 22px;
  display: grid;
  grid-template-columns: auto auto minmax(120px, 260px);
  gap: 10px;
  align-items: center;
  padding: 10px 13px;
  font-size: calc(11px * var(--ui-font-scale, 1));
}

.export-progress progress {
  width: 100%;
  accent-color: var(--accent-strong);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #48505c;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

.export-dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #171b21;
  color: var(--text);
  box-shadow: var(--shadow);
}

.settings-dialog {
  width: min(440px, calc(100vw - 28px));
  height: 70dvh;
  max-height: 70dvh;
  min-height: 0;
  overflow: hidden;
}

.export-dialog::backdrop {
  background: rgb(0 0 0 / 0.66);
  backdrop-filter: blur(4px);
}

.export-dialog form {
  display: grid;
  gap: 15px;
  padding: 20px;
}

.settings-dialog form {
  height: 100%;
  min-height: 0;
  overflow: auto;
  gap: 0;
  align-content: start;
  background:
    linear-gradient(180deg, transparent 0 58%, rgb(141 229 197 / 0.018) 100%),
    radial-gradient(circle at 50% 100%, rgb(141 229 197 / 0.045), transparent 42%);
}

.settings-dialog .dialog-heading {
  margin-bottom: 12px;
}

.settings-tabs {
  display: grid;
  align-self: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101318;
}

.settings-tab {
  min-width: 0;
  height: 36px;
  min-height: 36px;
  padding: 7px 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: calc(11px * var(--ui-font-scale, 1));
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.settings-tab:hover:not(:disabled) {
  background: rgb(255 255 255 / 0.04);
  color: var(--text);
}

.settings-tab.is-active {
  border-color: rgb(141 229 197 / 0.48);
  background: rgb(141 229 197 / 0.1);
  color: var(--accent);
}

.settings-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px 1px 3px;
}

.settings-panel-heading {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-bottom: 2px;
}

.settings-panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.settings-panel-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: calc(13px * var(--ui-font-scale, 1));
}

.settings-panel-status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: calc(10px * var(--ui-font-scale, 1));
  white-space: nowrap;
}

.settings-panel-heading p {
  margin: 0;
  color: var(--muted);
  font-size: calc(10px * var(--ui-font-scale, 1));
  line-height: 1.45;
}

.settings-subsection {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.settings-subsection--first {
  padding-top: 0;
  border-top: 0;
}

.settings-subsection > h3 {
  margin: 0;
  color: var(--text);
  font-size: calc(12px * var(--ui-font-scale, 1));
}

.export-dialog label {
  display: grid;
  gap: 7px;
  color: #cbd2dc;
  font-size: calc(12px * var(--ui-font-scale, 1));
}

.export-dialog label > span {
  display: flex;
  justify-content: space-between;
}

.export-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: calc(10px * var(--ui-font-scale, 1));
  line-height: 1.5;
}

.settings-hint {
  padding-top: 2px;
  border-top: 1px solid rgb(255 255 255 / 0.06);
}

.noise-reduction-card {
  container-name: noise-reduction-card;
  container-type: inline-size;
}

.noise-recipe-card {
  container-name: noise-recipe-card;
  container-type: inline-size;
  --recipe-font-scale: calc(var(--ui-font-scale, 1) * 1.2);
}

.noise-recipe-card > .recipe-editor {
  margin-top: 0;
}

.noise-reduction-card .settings-subsection {
  gap: 10px;
}

.noise-reduction-card label {
  display: grid;
  gap: 7px;
  color: #cbd2dc;
  font-size: calc(12px * var(--ui-font-scale, 1));
}

.noise-reduction-card label > span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.noise-reduction-card select {
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #20252e;
  color: var(--text);
}

.noise-reduction-card .settings-hint {
  margin: 0;
  color: var(--muted);
  font-size: calc(10px * var(--ui-font-scale, 1));
  line-height: 1.5;
}

.settings-checkbox {
  display: flex !important;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  gap: 8px !important;
  min-height: 24px;
  cursor: pointer;
}

.settings-checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent-strong);
}

.settings-checkbox > span {
  display: block !important;
  color: #cbd2dc;
}

.settings-checkbox:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.55;
}

.settings-model-section {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.settings-diagnostics {
  display: grid;
  gap: 9px;
  min-width: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.diagnostic-status {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: calc(10px * var(--ui-font-scale, 1));
  white-space: nowrap;
}

.diagnostic-status.is-success {
  border-color: rgb(141 229 197 / 0.55);
  color: var(--accent);
}

.diagnostic-status.is-warning {
  border-color: rgb(242 199 112 / 0.55);
  color: #f2c770;
}

.diagnostic-status.is-error {
  border-color: rgb(255 139 139 / 0.6);
  color: #ffb0b0;
}

.diagnostic-status.is-busy {
  border-color: rgb(141 229 197 / 0.35);
  color: var(--accent);
}

.diagnostic-hint {
  padding-top: 8px;
}

.diagnostic-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 7px;
}

.diagnostic-summary {
  min-height: 30px;
  margin: 0 !important;
  padding: 8px 9px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: #cbd2dc;
  font-size: calc(10px * var(--ui-font-scale, 1));
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.diagnostic-output {
  max-height: 240px;
  min-height: 92px;
  margin: 0;
  padding: 9px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101318;
  color: #b9f3dd;
  font: 10px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: calc(10px * var(--ui-font-scale, 1));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.muted {
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1050px) {
  .app-shell {
    --sidebar-width: 220px;
    --control-width: 300px;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .app-layout,
  .workspace {
    display: block;
  }

  .pane-resizer {
    display: none;
  }

  .sidebar {
    display: block;
    padding-bottom: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .drop-zone {
    min-height: 86px;
  }

  .drop-zone.thumbnail-add-tile {
    min-height: 60px;
  }

  .sidebar-heading {
    display: none;
  }

  .thumbnail-list {
    display: flex;
    gap: 7px;
    margin-top: 9px;
    overflow-x: auto;
  }

  .thumbnail-item {
    flex: 0 0 168px;
    grid-template-columns: 48px minmax(0, 1fr);
    margin: 0;
    padding-right: 34px;
  }

  .thumbnail-add-tile {
    flex: 0 0 168px;
    grid-template-columns: 48px minmax(0, 1fr);
    margin: 0;
    padding-right: 7px;
  }

  .thumbnail-add-tile .drop-icon {
    width: 48px;
    height: 42px;
  }

  .thumbnail-image-wrap {
    width: 48px;
    height: 42px;
  }

  .remove-thumbnail {
    position: absolute;
    top: 50%;
    right: 4px;
    display: grid;
    opacity: 0.78;
    transform: translateY(-50%);
  }

  .preview-panel {
    min-height: 60vh;
  }

  .preview-stage {
    min-height: 48vh;
  }

  .control-panel {
    padding: 0 14px 30px;
    border-left: 0;
  }

  .control-panel fieldset {
    grid-template-columns: 1fr 1fr;
    padding-left: 0;
  }

  .hero-control {
    grid-column: auto;
    grid-row: auto;
  }

  .direction-card {
    grid-column: auto;
    grid-row: auto;
  }

  .face-card {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .recipe-card {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .noise-recipe-card {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

@media (max-width: 580px) {
  .topbar {
    min-height: 60px;
    padding: 8px 10px;
  }

  .topbar .ghost {
    display: none;
  }

  .topbar #settings-button {
    display: inline-flex;
  }

  .preview-panel {
    padding: 10px;
  }

  .preview-heading {
    padding-bottom: 8px;
  }

  .control-panel {
    padding: 0 10px 24px;
  }

  .finish-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finish-preset:nth-child(3) {
    grid-column: 1 / -1;
  }

  .control-panel fieldset {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-control,
  .direction-card,
  .face-card,
  .recipe-card,
  .noise-recipe-card {
    grid-column: auto;
    grid-row: auto;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .export-progress {
    grid-template-columns: auto 1fr;
    width: calc(100vw - 28px);
  }

  .export-progress progress {
    grid-column: 1 / -1;
  }

  /* Narrow desktop windows are still pointer/touch targets. Keep the full
   * slider hit area even when the browser reports a fine pointer (the E2E
   * harness and hybrid laptops can switch input modalities at runtime). */
  .recipe-control input[type="range"],
  .recipe-control--sub input[type="range"] {
    height: 44px;
    min-height: 44px;
  }
}

@media (max-width: 360px) {
  .finish-presets {
    grid-template-columns: 1fr;
  }

  .finish-preset:nth-child(3) {
    grid-column: auto;
  }
}

@media (hover: none) {
  .remove-thumbnail {
    opacity: 0.78;
  }
}

@media (pointer: coarse) {
  .button,
  .icon-button,
  .recipe-reset-all,
  .recipe-auto-button,
  .recipe-effect-toggle,
  .preview-empty-action,
  .preview-zoom-toolbar > button {
    min-height: 44px;
  }

  .icon-button,
  .remove-thumbnail,
  .recipe-effect-toggle,
  .preview-zoom-toolbar > button {
    min-width: 44px;
  }

  input[type="range"] {
    min-height: 44px;
  }

  select,
  input[type="search"],
  input[type="text"],
  input[type="number"],
  textarea {
    min-height: 44px;
  }

  .edit-rail button,
  .mobile-bottom-nav button,
  .settings-tab,
  .pane-resizer {
    min-width: 44px;
    min-height: 44px;
  }

  .recipe-control input[type="range"] {
    height: 44px;
  }

  .recipe-auto-button {
    min-width: 44px;
    min-height: 44px;
  }
  .recipe-effect-toggle {
    min-width: 44px;
    height: 44px;
  }

  .finish-preset {
    min-height: 54px;
  }
  .recipe-control--sub .recipe-auto-button {
    min-width: 44px;
    min-height: 44px;
    font-size: calc(9px * var(--recipe-font-scale, 1));
  }
}

.device-benchmark {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgb(7 10 13 / 92%);
  overflow: auto;
}

.device-benchmark-card {
  width: min(720px, 100%);
  max-height: 100%;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgb(0 0 0 / 45%);
  overflow: auto;
}

.device-benchmark-card header,
.device-benchmark-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.device-benchmark-card h1 {
  margin: 2px 0 0;
  font-size: clamp(22px, 5vw, 32px);
}

.device-benchmark-card small {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.14em;
}

.device-benchmark-card p,
.device-benchmark-card output {
  color: var(--muted);
  line-height: 1.65;
}

.device-benchmark-card [data-close] {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: calc(24px * var(--ui-font-scale, 1));
}

.device-benchmark-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 18px 0;
}

.device-benchmark-card [data-start] {
  background: var(--accent);
  color: #07110e;
}

.device-benchmark-card output {
  display: block;
  min-height: 26px;
  margin-bottom: 10px;
}

.device-benchmark-card pre {
  min-height: 180px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a0d11;
  color: #dce7e5;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: calc(12px * var(--ui-font-scale, 1));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

@media (max-width: 560px) {
  .device-benchmark {
    display: block;
    padding: 0;
  }

  .device-benchmark-card {
    min-height: 100%;
    max-height: none;
    padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
  }

  .device-benchmark-actions > button {
    flex: 1 1 160px;
    min-height: 46px;
  }
}


@media (max-width: 620px) {
  .settings-tab {
    height: 44px;
    min-height: 44px;
  }

  .grading-wheels {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .grading-wheel-card {
    display: block;
    padding: 6px 2px 5px;
  }

  .color-wheel {
    width: min(100%, 132px);
    max-width: 100%;
    min-width: 0;
  }

  .hsl-band-button {
    min-height: 42px;
  }
}

@media (pointer: coarse) {
  .settings-tab {
    height: 44px;
    min-height: 44px;
    padding-inline: 3px;
    font-size: calc(10px * var(--ui-font-scale, 1));
  }

  .color-wheel {
    min-width: min(92px, 100%);
  }

  .hsl-band-button {
    min-height: 40px;
  }
}

@container recipe-card (max-width: 540px) {
  .grading-wheels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .grading-wheel-card {
    padding: 6px 4px 5px;
  }

  .grading-wheel-heading {
    gap: 3px;
    margin-bottom: 5px;
  }

  .grading-wheel-heading strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .grading-wheel-heading span {
    flex: 0 0 auto;
    font-size: calc(7px * var(--recipe-font-scale, 1));
  }

  .grading-wheel-controls {
    min-width: 0;
  }

  .grading-wheel-controls .recipe-control {
    min-width: 0;
  }

  .grading-wheel-controls .recipe-control-heading {
    gap: 2px;
  }

 .grading-wheel-controls .recipe-control output {
    min-width: 30px;
    font-size: calc(8px * var(--recipe-font-scale, 1));
  }

 .grading-wheel-controls .recipe-auto-button {
    min-width: 24px;
    padding: 1px 3px;
    font-size: calc(7px * var(--recipe-font-scale, 1));
  }
}

@container recipe-card (max-width: 360px) {
  .grading-wheels {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .grading-wheel-card {
    display: block;
    padding: 6px 2px 5px;
  }

  .color-wheel {
    width: min(100%, 132px);
    max-width: 100%;
    min-width: 0;
  }

  .hsl-spectrum {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .hsl-band-button {
    min-height: 40px;
    padding-inline: 3px;
  }

  .hsl-band-controls {
    padding-inline: 7px;
  }
}

/* --------------------------------------------------------------------------
 * A+ workspace
 * --------------------------------------------------------------------------
 * This layer intentionally reshapes the existing functional DOM instead of
 * cloning controls into a second UI. The reference composition is one dense,
 * continuous editor: library | canvas | edit rail | inspector.
 */

@media (min-width: 821px) {
  body {
    display: grid;
    padding: 0;
    place-items: stretch;
    background:
      radial-gradient(circle at 50% 102%, rgb(28 54 81 / 0.42), transparent 48%),
      linear-gradient(145deg, #090d15, #111827 62%, #080b12);
  }

  #app {
    min-height: 0;
  }

  .app-shell {
    height: 100%;
    overflow: hidden;
    border: 1px solid #39414b;
    border-radius: 0;
    background: #15191e;
    box-shadow: 0 30px 90px rgb(0 0 0 / 0.46), inset 0 1px rgb(255 255 255 / 0.04);
  }
}

.app-shell {
  --sidebar-width: 214px;
  --control-width: 326px;
  --pane-resizer-size: 8px;
  grid-template-rows: 64px auto minmax(0, 1fr);
  background: #14181d;
}

.topbar {
  grid-row: 1;
}

.compatibility-warning {
  grid-row: 2;
}

.app-layout {
  grid-row: 3;
}

.topbar {
  min-height: 64px;
  padding: 0 18px;
  border-bottom-color: #30363e;
  background: linear-gradient(180deg, #1b2026, #171b20);
  backdrop-filter: none;
}

.brand {
  gap: 0;
}

.brand img {
  display: none;
}

.brand-name {
  font-size: calc(19px * var(--ui-font-scale, 1));
  letter-spacing: -0.035em;
}

.brand-name span {
  color: #5cd6c2;
}

.brand-version {
  margin-left: 8px;
  opacity: 0.58;
}

.topbar-tools,
.topbar-actions,
.toolbar-button,
.webgpu-pill,
.toolbar-icon-button {
  display: flex;
  align-items: center;
}

.topbar-tools {
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding-inline: 12px;
  border-inline: 1px solid #30363e;
  color: #c8ced4;
}

.toolbar-button,
.toolbar-icon-button {
  border: 1px solid transparent;
  background: transparent;
  color: #dfe4e8;
  cursor: pointer;
}

.toolbar-button {
  gap: 7px;
  min-height: 44px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: calc(12px * var(--ui-font-scale, 1));
}

.toolbar-button:hover:not(:disabled) {
  background: rgb(255 255 255 / 0.055);
}

.toolbar-button.is-active {
  border-color: rgb(82 219 192 / 0.44);
  background: rgb(82 219 192 / 0.1);
  color: #78e3cf;
}

.toolbar-icon-button {
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 9px;
}

/* The product ships a logo asset but no control icon font. Local SVG line
 * icons keep edit categories and header actions stable across platforms. */
.ui-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  overflow: visible;
}

.edit-tool > .ui-icon {
  width: 24px;
  height: 24px;
}

.toolbar-icon-button > .ui-icon {
  width: 20px;
  height: 20px;
}

.export-button > .ui-icon {
  width: 17px;
  height: 17px;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 9px;
}

.webgpu-pill {
  gap: 7px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid #303943;
  border-radius: 9px;
  color: #bdc4ca;
  font-size: 11px;
}

.webgpu-pill > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #52dbc0;
  box-shadow: 0 0 10px rgb(82 219 192 / 0.55);
}

.webgpu-pill.is-unavailable > span {
  background: var(--danger);
}

.clear-button {
  display: none;
}

.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding-inline: 16px;
  border-radius: 8px;
  background: #56cbbb !important;
  color: #081715 !important;
}

.export-chevron {
  margin-left: 5px;
  padding-left: 10px;
  border-left: 1px solid rgb(0 0 0 / 0.2);
}

.app-layout {
  grid-template-columns: minmax(180px, min(var(--sidebar-width), 28vw)) var(--pane-resizer-size) minmax(0, 1fr);
}

.sidebar {
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  gap: 9px;
  padding: 14px 10px 8px;
  border-right-color: #30363e;
  background: #15191e;
}

.sidebar-heading {
  padding: 0 4px 2px;
}

.sidebar-heading strong {
  font-size: calc(13px * var(--ui-font-scale, 1));
}

.library-tools {
  display: block;
}

.library-search {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  min-height: 36px;
  border: 1px solid #333a43;
  border-radius: 7px;
  background: #20252b;
  color: #99a2aa;
}

.library-search > span {
  text-align: center;
}

.library-search input {
  width: 100%;
  min-width: 0;
  padding: 0 7px 0 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #e7eaed;
  font-size: 11px;
}

.library-folder {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 25px;
  padding: 0 5px;
  color: #b7bec5;
  font-size: 10px;
}

.thumbnail-list {
  padding-right: 2px;
}

.thumbnail-item,
.thumbnail-add-tile {
  grid-template-columns: 92px minmax(0, 1fr) 24px;
  min-height: 74px;
  margin-bottom: 5px;
  padding: 5px;
  border-radius: 8px;
}

.thumbnail-item.is-selected {
  border-color: #58d4c0;
  background: #22282e;
  box-shadow: inset 0 0 0 1px rgb(88 212 192 / 0.2);
}

.thumbnail-image-wrap,
.thumbnail-add-tile .drop-icon {
  width: 92px;
  height: 62px;
  border-radius: 6px;
}

/* The add tile has no trailing remove action. Reclaim that column so the
 * short primary action stays on one line even at the minimum sidebar width. */
.thumbnail-add-tile {
  grid-template-columns: 92px minmax(0, 1fr);
}

.thumbnail-copy {
  gap: 5px;
}

.thumbnail-copy strong {
  font-weight: 500;
}

.thumbnail-copy span {
  color: #a7b0b8;
  font-size: 9px;
}

.thumbnail-status {
  display: none;
}

.workspace {
  grid-template-columns: minmax(0, 1fr) var(--pane-resizer-size) 68px minmax(286px, min(var(--control-width), 35vw));
  background: #11151a;
}

.preview-panel {
  position: relative;
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
  background: #0d1116;
}

.preview-panel > .processing-status,
.preview-panel > .warning {
  position: absolute;
  z-index: 9;
  bottom: 12px;
  max-width: min(46%, 310px);
  margin: 0;
  overflow: hidden;
  backdrop-filter: blur(10px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-panel > .processing-status {
  left: 12px;
}

.preview-panel > .warning {
  right: 12px;
}

.preview-heading {
  display: none;
}

.selected-copy strong {
  max-width: min(40vw, 300px);
  font-size: 10px;
}

.selected-copy span {
  display: none;
}

.preview-stage {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background-color: #0b1015;
  box-shadow: none;
}

.compare-split-label {
  top: 18px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: rgb(18 25 32 / 0.78);
}

.compare-split-label--original {
  left: 18px;
}

.compare-split-label--processed {
  right: 18px;
}

.preview-zoom-toolbar {
  position: absolute;
  z-index: 9;
  right: 50%;
  bottom: 18px;
  display: grid;
  grid-template-columns: 34px 48px 34px 48px 38px;
  min-height: 38px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 7px;
  background: rgb(15 20 26 / 0.84);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.28);
  transform: translateX(50%);
  backdrop-filter: blur(12px);
}

.preview-zoom-toolbar > button,
.preview-zoom-toolbar > output {
  display: grid;
  min-width: 0;
  min-height: 38px;
  place-items: center;
  border: 0;
  border-left: 1px solid rgb(255 255 255 / 0.12);
  background: transparent;
  color: #e2e7eb;
  font: inherit;
  font-size: calc(11px * var(--ui-font-scale, 1));
}

.preview-zoom-toolbar > :first-child {
  border-left: 0;
}

.preview-zoom-toolbar > button {
  cursor: pointer;
}

.preview-zoom-toolbar > button:hover:not(:disabled),
.preview-zoom-toolbar > button:focus-visible {
  background: rgb(255 255 255 / 0.08);
  color: #61ddc7;
  outline: 0;
}

.preview-zoom-toolbar > button:disabled {
  color: #6f7881;
  cursor: default;
}

.preview-zoom-toolbar > output {
  font-variant-numeric: tabular-nums;
}

.pane-resizer::before {
  inset-inline: 2px;
}

.edit-rail {
  display: grid;
  grid-template-rows: repeat(6, 72px);
  align-content: start;
  min-width: 0;
  border-right: 1px solid #30363e;
  border-left: 1px solid #30363e;
  background: #171b20;
}

.edit-tool {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  min-width: 0;
  padding: 8px 2px;
  border: 0;
  border-bottom: 1px solid #2a3037;
  background: transparent;
  color: #b7bec5;
  cursor: pointer;
}

.edit-tool > span {
  font-size: 24px;
  font-weight: 300;
}

.edit-tool small {
  font-size: 10px;
  white-space: nowrap;
}

.edit-tool.is-active {
  background: linear-gradient(90deg, rgb(86 211 190 / 0.08), rgb(86 211 190 / 0.14));
  color: #5bd9c3;
  box-shadow: inset -2px 0 #54d2bc;
}

.control-panel {
  padding: 0;
  border-left: 0;
  background: #171b20;
}

.control-panel fieldset {
  gap: 0;
  padding: 0;
}

.control-card {
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid #30363e;
  border-radius: 0;
  background: transparent;
}

.control-card.hero-control {
  background: transparent;
}

.control-card h2 {
  font-size: 14px;
}

.control-title output {
  min-width: 34px;
  font-size: 13px;
  letter-spacing: 0;
}

.finish-adjustment {
  margin-top: 8px;
  padding: 7px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.finish-selection-heading {
  margin-top: 10px;
}

.finish-presets {
  gap: 9px;
}

.finish-preset {
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: center;
}

.finish-preset.is-selected {
  background: transparent;
  box-shadow: none;
}

.finish-preset-swatch {
  width: 100%;
  height: auto;
  aspect-ratio: 1.24;
  border-radius: 7px;
}

.finish-preset.is-selected .finish-preset-swatch {
  border-color: #55d5bf;
  box-shadow: 0 0 0 2px #55d5bf;
}

.finish-preset-copy {
  display: block;
  margin-top: 7px;
}

.finish-preset-copy small {
  display: none;
}

.finish-preset-copy strong {
  font-size: 10px;
  font-weight: 500;
}

.recipe-card-heading {
  padding-bottom: 5px;
}

.recipe-card-heading > div > span {
  display: none;
}

.recipe-card-heading h3 {
  font-size: 12px;
}

.recipe-group {
  border: 0;
  border-top: 1px solid #30363e;
  border-radius: 0;
  background: transparent;
}

.recipe-group-header {
  min-height: 45px;
  padding-inline: 3px;
}

.recipe-group-controls {
  padding-inline: 3px;
}

/* Keep the inspector compact without making its hierarchy depend on tiny
 * platform glyphs. Primary parameter labels remain 12px at the default scale;
 * secondary headings/values stay just above 11px. */
.recipe-card-heading span,
.recipe-group-header small,
.recipe-subgroup summary {
  font-size: calc(9.25px * var(--recipe-font-scale, 1));
}

.grading-wheel-heading span,
.hsl-band-heading,
.recipe-subgroup summary small {
  font-size: calc(9px * var(--recipe-font-scale, 1));
}

.grading-wheel-controls .recipe-control-label-text,
.hsl-band-button {
  font-size: calc(9px * var(--recipe-font-scale, 1));
}

[data-edit-tool-panel] {
  display: none;
}

[data-active-edit-tool="basic"] [data-edit-tool-panel~="basic"],
[data-active-edit-tool="tone"] [data-edit-tool-panel~="tone"],
[data-active-edit-tool="color"] [data-edit-tool-panel~="color"],
[data-active-edit-tool="detail"] [data-edit-tool-panel~="detail"],
[data-active-edit-tool="noise"] [data-edit-tool-panel~="noise"],
[data-active-edit-tool="mask"] [data-edit-tool-panel~="mask"] {
  display: block;
}

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 820px) {
  body {
    padding: 0;
    background: #0c1118;
  }

  .app-shell {
    --mobile-bottom-nav-height: calc(
      max(62px, calc(40px + 18px * var(--ui-font-scale, 1)))
      + env(safe-area-inset-bottom)
    );
    grid-template-rows: 54px auto minmax(0, 1fr);
    min-height: 100dvh;
    padding-bottom: var(--mobile-bottom-nav-height);
    border-radius: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 54px;
    padding: 0 10px;
  }

  .brand-name {
    font-size: 15px;
  }

  .brand-version,
  .toolbar-icon-button,
  .webgpu-pill,
  .clear-button,
  .export-chevron {
    display: none;
  }

  .topbar-tools {
    justify-content: flex-end;
    padding-right: 7px;
  }

  .toolbar-button {
    min-height: 44px;
    border: 1px solid #303943;
  }

  .topbar-actions {
    gap: 0;
  }

  .export-button {
    min-height: 44px;
    padding: 6px 10px;
    font-size: 11px;
  }

  .app-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 84px minmax(0, 1fr);
  }

  .topbar #settings-button {
    display: none;
  }

  .sidebar {
    display: block;
    min-height: 84px;
    padding: 7px 8px;
    overflow: hidden;
    border-bottom: 1px solid #30363e;
  }

  .sidebar-heading,
  .library-tools,
  .library-folder {
    display: none;
  }

  .thumbnail-list {
    gap: 6px;
    margin: 0;
    padding: 0;
  }

  .thumbnail-item,
  .thumbnail-add-tile {
    flex: 0 0 70px;
    display: block;
    min-height: 62px;
    margin: 0;
    padding: 3px;
  }

  .thumbnail-image-wrap,
  .thumbnail-add-tile .drop-icon {
    width: 62px;
    height: 54px;
  }

  .thumbnail-copy,
  .thumbnail-add-tile strong {
    display: none;
  }

  .thumbnail-item .remove-thumbnail {
    position: absolute;
    top: -3px;
    right: -3px;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border: 1px solid rgb(255 255 255 / 0.18);
    border-radius: 50%;
    background: rgb(13 17 22 / 0.9);
    color: #d9dee2;
    opacity: 0.82;
  }

  .workspace {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows:
      minmax(390px, 51vh)
      minmax(56px, calc(44px + 16px * var(--ui-font-scale, 1)))
      auto;
  }

  .preview-panel {
    min-height: 0;
  }

  .preview-heading {
    display: none;
  }

  .preview-stage {
    min-height: 390px;
    margin: 10px;
    border-radius: 18px;
  }

  .preview-zoom-toolbar {
    right: 14px;
    bottom: 14px;
    grid-template-columns: 30px 44px 30px 42px 34px;
    transform: none;
  }

  .edit-rail {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: minmax(56px, calc(44px + 16px * var(--ui-font-scale, 1)));
    margin: 0 10px;
    overflow: hidden;
    border: 0;
    border-radius: 9px;
    background: #252a30;
  }

  .edit-tool {
    gap: 3px;
    min-height: max(56px, calc(44px + 16px * var(--ui-font-scale, 1)));
    padding: 5px 2px;
    border-bottom: 0;
  }

  .edit-tool > span {
    font-size: 18px;
  }

  .edit-tool small {
    font-size: calc(11px * var(--ui-font-scale, 1));
    line-height: 1.1;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .edit-tool.is-active {
    border-radius: 8px;
    box-shadow: none;
  }

  .control-panel {
    min-height: 0;
    padding: 0 10px calc(22px + var(--mobile-bottom-nav-height));
    scroll-padding-bottom: calc(22px + var(--mobile-bottom-nav-height));
    overflow: visible;
    background: #171b20;
  }

  .control-panel :is(button, input, select, textarea, [tabindex]) {
    scroll-margin-block-end: calc(16px + var(--mobile-bottom-nav-height));
  }

  .control-panel fieldset {
    display: block;
  }

  .control-card {
    padding-inline: 4px;
  }

  .finish-preset {
    min-height: 44px;
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: var(--mobile-bottom-nav-height);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid #30363e;
    background: rgb(20 25 30 / 0.96);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav button {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: #aab2ba;
  }

  .mobile-bottom-nav button.is-active {
    color: #55d5bf;
  }

  .mobile-bottom-nav span {
    font-size: 18px;
  }

  .mobile-bottom-nav small {
    font-size: calc(11px * var(--ui-font-scale, 1));
    line-height: 1.1;
    text-align: center;
    white-space: normal;
  }

  .control-selection-status {
    margin-left: 4px;
  }
}

@media (pointer: coarse) {
  .preview-zoom-toolbar {
    grid-template-columns: 44px 48px 44px 48px 44px;
    min-height: 44px;
  }

  .preview-zoom-toolbar > button,
  .preview-zoom-toolbar > output {
    min-height: 44px;
  }
}

@media (max-width: 430px) {
  .workspace {
    grid-template-rows: minmax(360px, 48vh) 56px auto;
  }

  .preview-stage {
    min-height: 360px;
  }

  .finish-presets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .finish-preset:nth-child(3) {
    grid-column: auto;
  }
}

@media (max-width: 900px) and (max-height: 520px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    --mobile-bottom-nav-height: calc(
      max(56px, calc(38px + 16px * var(--ui-font-scale, 1)))
      + env(safe-area-inset-bottom)
    );
    /* The 58px photo strip lives inside .app-layout. Reserving it here as
     * well would double-count the row and push preview/controls under nav. */
    grid-template-rows: 54px auto minmax(0, 1fr);
    min-width: 0;
    height: 100dvh;
    min-height: 100dvh;
    padding-bottom: var(--mobile-bottom-nav-height);
    overflow: hidden;
    border-radius: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 54px;
    padding: 0 10px;
  }

  .brand-version,
  .toolbar-icon-button,
  .webgpu-pill,
  .clear-button,
  .export-chevron,
  .pane-resizer,
  .sidebar-heading,
  .library-tools,
  .library-folder,
  .preview-heading,
  .thumbnail-copy,
  .thumbnail-add-tile strong {
    display: none;
  }

  .topbar-tools {
    justify-content: flex-end;
    padding-right: 7px;
  }

  .toolbar-button {
    min-height: 44px;
    border: 1px solid #303943;
  }

  .topbar-actions {
    gap: 0;
  }

  .export-button {
    min-height: 44px;
    padding: 6px 10px;
    font-size: 11px;
  }

  .app-layout {
    display: block;
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    display: block;
    height: 58px;
    min-height: 58px;
    padding: 5px 8px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid #30363e;
  }

  .thumbnail-list {
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
    overflow-x: auto;
  }

  .thumbnail-item,
  .thumbnail-add-tile {
    flex: 0 0 54px;
    display: block;
    min-height: 48px;
    margin: 0;
    padding: 2px;
  }

  .thumbnail-image-wrap,
  .thumbnail-add-tile .drop-icon {
    width: 48px;
    height: 44px;
  }

  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
    grid-template-rows:
      minmax(52px, calc(40px + 18px * var(--ui-font-scale, 1)))
      minmax(0, 1fr);
    height: calc(100dvh - 112px - var(--mobile-bottom-nav-height));
    min-height: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  .preview-panel {
    grid-column: 1;
    grid-row: 1 / 3;
    min-height: 0;
  }

  .preview-stage {
    min-height: 0;
    height: calc(100% - 8px);
    max-height: none;
    margin: 4px;
    border-radius: 12px;
  }

  .edit-rail {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: minmax(52px, calc(40px + 18px * var(--ui-font-scale, 1)));
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 9px;
    background: #252a30;
  }

  .edit-tool {
    gap: 3px;
    min-height: max(52px, calc(40px + 18px * var(--ui-font-scale, 1)));
    padding: 3px 2px;
    border-bottom: 0;
  }

  .edit-tool small {
    font-size: calc(11px * var(--ui-font-scale, 1));
    line-height: 1.1;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .control-panel {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    padding: 0 8px 12px;
    scroll-padding-bottom: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-left: 0;
    background: #171b20;
  }

  .control-panel :is(button, input, select, textarea, [tabindex]) {
    scroll-margin-block-end: 12px;
  }

  .control-panel fieldset {
    display: block;
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: var(--mobile-bottom-nav-height);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid #30363e;
    background: rgb(20 25 30 / 0.96);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav button {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: #aab2ba;
  }

  .mobile-bottom-nav button.is-active {
    color: #55d5bf;
  }

  .control-selection-status {
    margin-left: 4px;
  }
}
