:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f5f5f5;
  --surface-soft: #fafafa;
  --border: #d4d4d4;
  --border-strong: #737373;
  --selection: #171717;
  --text: #171717;
  --muted: #525252;
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.06);
  --swatch-size: 42px;
  --ui-gap-xs: 8px;
  --ui-gap-sm: 10px;
  --ui-gap-md: 12px;
  --ui-gap-lg: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
output {
  font: inherit;
}

.app-shell {
  max-width: 1720px;
  margin: 0 auto;
  padding: 24px;
}

.app-header {
  display: grid;
  gap: 6px;
  justify-items: start;
  align-items: start;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 4px 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.76rem;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  line-height: 1;
}

.header-note {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 296px max-content 304px;
  gap: 16px;
  align-items: start;
  justify-content: start;
}

.tools-column,
.canvas-column,
.color-column {
  display: grid;
}

.tools-column,
.color-column {
  gap: 12px;
}

.canvas-column {
  gap: 12px;
  justify-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-prominent {
  padding: 16px;
}

.panel-secondary {
  padding: 14px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.panel-head h2,
.panel-head span {
  margin: 0;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.92rem;
}

.toolbar,
.custom-color-panel {
  display: grid;
  gap: 12px;
}

.toolbar-section {
  display: grid;
  gap: 8px;
}

.toolbar-section + .toolbar-section {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.toolbar-section-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.toolbar-grid {
  display: grid;
  gap: 8px;
}

.toolbar-grid--tools,
.toolbar-grid--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toolbar-grid--tools > *,
.toolbar-grid--compact > * {
  width: 100%;
  min-width: 0;
}

.toolbar-stack {
  display: grid;
  gap: 8px;
}

.toolbar button,
.mono-button,
.hex-input,
.palette-swatch,
.tone-button,
.custom-slot-button,
.recent-swatch,
.color-preview,
.color-slider-input {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

.toolbar button,
.mono-button {
  min-height: 40px;
  padding: 9px 12px;
  line-height: 1.2;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.tool-button {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  justify-content: start;
  text-align: left;
}

.tool-button-icon {
  width: 14px;
  height: 14px;
  display: inline-grid;
  place-items: center;
  justify-self: start;
  color: currentColor;
}

.tool-button-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.tool-button-label {
  display: block;
  min-width: 0;
  justify-self: start;
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.1;
  white-space: nowrap;
}

.toolbar button:hover:not(:disabled),
.mono-button:hover:not(:disabled),
.hex-input:hover,
.palette-swatch:hover,
.tone-button:hover:not(:disabled),
.custom-slot-button:hover:not(:disabled),
.recent-swatch:hover:not(:disabled),
.color-preview:hover {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.toolbar button.is-active,
.mono-button.is-active {
  border-color: var(--selection);
  background: var(--selection);
  color: #ffffff;
}

.toolbar button:disabled,
.mono-button:disabled,
.tone-button:disabled,
.custom-slot-button:disabled,
.recent-swatch:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.palette {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.palette--compact {
  grid-template-columns: repeat(4, var(--swatch-size));
  justify-content: start;
  gap: 8px;
}

.palette-swatch,
.custom-slot-button,
.recent-swatch {
  cursor: pointer;
}

.palette-swatch {
  width: var(--swatch-size);
  height: var(--swatch-size);
  aspect-ratio: 1;
}

.palette-swatch.is-active,
.tone-button.is-active,
.custom-slot-button.is-active,
.recent-swatch.is-active {
  outline: 2px solid var(--selection);
  outline-offset: 2px;
  border-color: var(--border-strong);
  box-shadow: none;
}

.recent-colors {
  display: grid;
  grid-template-columns: repeat(6, var(--swatch-size));
  gap: 8px;
  justify-content: start;
  min-height: calc(var(--swatch-size) * 2 + 8px);
}

.recent-swatch {
  width: var(--swatch-size);
  height: var(--swatch-size);
  min-height: var(--swatch-size);
  background:
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%),
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
}

.recent-swatch.is-empty {
  opacity: 0.08;
  border-color: #ececec;
  background: var(--surface);
}

.recent-swatch.is-empty:hover {
  opacity: 0.12;
  background: var(--surface-soft);
  border-color: #e2e2e2;
}

.tools-panel {
  padding: 16px;
}

.tools-panel .toolbar {
  gap: 12px;
}

.tools-panel .toolbar button:not(.tool-button),
.tools-panel .mono-button {
  min-height: 39px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.12;
  letter-spacing: 0.01em;
}

.tools-panel .toolbar button.tool-button {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  justify-content: start;
  text-align: left;
}

.guide-panel {
  padding: 11px 15px;
}

.tools-help {
  margin: 0;
  position: relative;
}

.tools-help summary {
  cursor: pointer;
  list-style: none;
  min-height: 28px;
  display: flex;
  align-items: center;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-right: 18px;
}

.tools-help summary::-webkit-details-marker {
  display: none;
}

.tools-help summary::after {
  content: "+";
  position: absolute;
  right: 0;
  color: var(--border-strong);
}

.tools-help[open] summary::after {
  content: "-";
}

.tools-help ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.editor-panel {
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  justify-self: start;
  padding: 11px;
}

.editor-panel-head {
  margin-bottom: 0px;
  align-items: start;
}

.editor-head-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.editor-model-switch {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
  padding: 0px 45px;
}

.editor-model-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor-model-segment {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.editor-model-button {
  min-height: 24px;
  padding: 6px 12px;
  justify-content: center;
  text-align: center;
  font-size: 0.8rem;
  line-height: 0.1;
}

.editor-topbar {
  display: grid;
  gap: 8px;
  margin-bottom: 6px;
  padding: 3px 2px 1px;
}

.editor-topbar-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.95fr) minmax(220px, 1.05fr) minmax(260px, 1.25fr);
  gap: 10px;
  align-items: start;
}

.editor-info-block {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 6px 6px;
  border: none;
  border-radius: 15px;
  background: linear-gradient(180deg, #ffffff, #fbfbfb);
}

.editor-info-row {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.editor-info-row--double {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-chip {
  display: grid;
  gap: 1px;
  min-width: 0;
  min-height: 40px;
  padding: 5px 10px;
  border: 1px solid rgba(212, 212, 212, 0.95);
  border-radius: 12px;
  background: var(--surface);
}

.info-chip--full {
  grid-column: 1 / -1;
}

.info-chip--action {
  background: linear-gradient(180deg, #ffffff, #fcfcfc);
}

.info-chip--status {
  min-height: 0;
}

.info-chip-label {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.info-chip-value {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  min-width: 0;
}

.info-chip-value--status {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.34;
}

.info-chip--button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 7px 10px;
  text-align: center;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.12;
}

.info-chip--button.is-ready {
  background: linear-gradient(180deg, rgba(23, 23, 23, 0.06), rgba(23, 23, 23, 0.02));
  border-color: rgba(23, 23, 23, 0.22);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(23, 23, 23, 0.03);
}

.info-chip--button.is-active {
  border-color: var(--selection);
  background: var(--selection);
  color: #ffffff;
  box-shadow: none;
}

.info-chip--button.is-inactive {
  background: linear-gradient(180deg, #fbfbfb, #f5f5f5);
  border-color: rgba(212, 212, 212, 0.85);
  color: var(--muted);
  opacity: 1;
  box-shadow: none;
}

.custom-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.hex-input {
  min-height: 44px;
  padding: 0 12px;
  outline: none;
}

.hex-input.is-invalid {
  border-color: #b91c1c;
}

.color-adjust-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.color-adjust-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.color-adjust-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.color-adjust-preview {
  width: 56px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%),
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
}

.color-slider-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

.color-slider-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.color-slider-input {
  width: 100%;
  height: 10px;
  padding: 0;
  border-radius: 999px;
  background: #e5e5e5;
  accent-color: #171717;
}

.color-slider-value {
  font-size: 0.82rem;
  text-align: right;
  color: var(--text);
}

.color-adjust-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.color-adjust-apply,
.color-adjust-close {
  min-height: 36px;
  padding: 8px 12px;
  text-align: center;
}

.color-preview {
  min-height: 54px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
  outline: none;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%),
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
  transition: filter 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.color-preview:hover,
.color-preview.is-open {
  filter: brightness(0.98);
  border-color: var(--border-strong);
}

.color-preview:focus-visible {
  outline: 2px solid var(--selection);
  outline-offset: 2px;
}

.color-preview-label {
  position: relative;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: none;
  opacity: 1;
  pointer-events: none;
}

.color-meta {
  display: grid;
  gap: 2px;
}

.color-meta-hex {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}

.color-meta-rgba {
  font-size: 0.78rem;
  color: var(--muted);
}

.tone-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.tone-button {
  min-width: 0;
  height: auto;
  min-height: 0;
  padding: 6px;
  cursor: pointer;
  display: grid;
  grid-template-rows: auto 18px;
  align-items: start;
  gap: 6px;
  background: var(--surface-soft);
}

.tone-swatch {
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background:
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%),
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
}

.tone-label {
  display: grid;
  align-items: center;
  justify-items: center;
  min-height: 18px;
  height: 18px;
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.custom-slot-grid {
  display: grid;
  grid-template-columns: repeat(6, var(--swatch-size));
  gap: 8px;
  justify-content: start;
}

.custom-slot-button {
  width: var(--swatch-size);
  height: var(--swatch-size);
  min-height: var(--swatch-size);
  border-radius: 10px;
  background:
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%),
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
}

.custom-slot-button.is-empty {
  background: var(--surface);
  border-style: solid;
  border-color: #e5e5e5;
}

.canvas-stage {
  overflow: auto;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px;
  background: #f8f8f8;
}

#skin-canvas {
  display: block;
  max-width: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%),
    linear-gradient(45deg, #ececec 25%, transparent 25%, transparent 75%, #ececec 75%);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
  image-rendering: pixelated;
  cursor: crosshair;
}

body[data-active-tool="eyedropper"] #skin-canvas,
body[data-alt-eyedropper="true"] #skin-canvas {
  cursor: copy;
}

body[data-active-tool="area-copy"] #skin-canvas {
  cursor: cell;
}

@media (max-width: 1300px) {
  .workspace {
    grid-template-columns: 272px minmax(0, 1fr) 292px;
  }

  :root {
    --swatch-size: 38px;
  }

  .editor-topbar-grid {
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr);
  }

  .editor-info-block--status {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .app-header,
  .panel-head {
    flex-direction: column;
    align-items: start;
  }

  .editor-topbar-grid,
  .editor-info-row--double {
    grid-template-columns: 1fr;
  }

  .editor-info-block {
    width: 100%;
    min-width: 0;
  }

  .editor-panel-head {
    align-items: stretch;
  }

  .editor-head-controls {
    width: 100%;
    justify-content: stretch;
  }

  .editor-model-switch {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .toolbar-grid--tools,
  .toolbar-grid--compact,
  .custom-control-row,
  .tone-grid,
  .recent-colors,
  .palette--compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-slot-grid {
    grid-template-columns: repeat(6, var(--swatch-size));
  }

  .color-adjust-head,
  .color-adjust-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .palette--compact .palette-swatch {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .header-note {
    white-space: normal;
  }
}




