@font-face {
  font-family: Nunito;
  src: url("fonts/nunito-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("fonts/nunito-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("fonts/nunito-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("fonts/nunito-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Fraunces;
  src: url("fonts/fraunces-600-italic.woff2") format("woff2");
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}

:root {
  --sans: Nunito, "Trebuchet MS", "Segoe UI", sans-serif;
  --serif: Fraunces, Georgia, "Palatino Linotype", serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #ecece8;
  --card: #f7f7f4;
  --solid: #ffffff;
  --ink: #1c1c19;
  --muted: #6d6d66;
  --faint: #8d8d85;
  --line: #e1e1da;
  --line-strong: #cfcfc6;
  --accent: #2a2a26;
  --accent-ink: #f6f6f3;
  --soft: #e7e7e2;
  --soft-2: #f1f1ed;
  --danger: #8d3a3a;
  --shadow: 0 16px 40px rgba(24, 24, 20, 0.07);
  --empty-a: #f4f4f1;
  --empty-b: #e4e4de;
  --mark: #1c1c19;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --card: #1b1b19;
  --solid: #232321;
  --ink: #f3f3ee;
  --muted: #a8a89f;
  --faint: #8c8c84;
  --line: #32322e;
  --line-strong: #454540;
  --accent: #f3f3ee;
  --accent-ink: #171715;
  --soft: #2a2a26;
  --soft-2: #222220;
  --danger: #e3a3a3;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  --empty-a: #2a2a26;
  --empty-b: #1a1a18;
  --mark: #f3f3ee;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--ink) 4%, transparent), transparent 220px),
    var(--bg);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.42; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--ink) 16%, transparent); }

.boot {
  max-width: 36rem;
  margin: 18vh auto;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}
.shell { width: min(1440px, calc(100% - 32px)); margin: 20px auto 48px; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 16px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 105px; height: 105px; object-fit: contain; flex: none; }
.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
h1, h2, h3 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: 28px; line-height: 1; }
.version {
  margin: 5px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--faint);
}
.palette-name, .name-input, .hex, .hint-input, .add-field input {
  border: 1px solid var(--line);
  background: var(--solid);
  border-radius: 10px;
  padding: 8px 10px;
}
.tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }

button.ghost, button.primary, button.danger, button.tiny {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--solid);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 800;
}
button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
button.danger { color: var(--danger); background: transparent; }
button.tiny { padding: 4px 10px; font-size: 12px; background: transparent; }
button.tiny.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.on { background: var(--soft); color: var(--ink); }
.icon-btn:hover { background: var(--soft); }

.theme-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  gap: 2px;
  background: var(--soft);
  border-radius: 999px;
}
.theme-switch button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}
.theme-switch button.on {
  background: var(--solid);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.species-menu {
  position: absolute;
  z-index: 25;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.species-option:hover { background: var(--soft); }

.species-wrap { position: relative; margin-bottom: 16px; }
.species-picker { position: relative; }
.species-trigger {
  width: min(420px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 8px 10px 8px 8px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}
.species-trigger strong { display: block; font-size: 15px; }
.species-trigger small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; }
.species-trigger .grow { flex: 1; min-width: 0; }
.chevron {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
}
.species-menu {
  top: calc(100% + 8px);
  left: 0;
  width: min(760px, calc(100vw - 48px));
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.species-option {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
}
.species-option.active {
  background: var(--soft-2);
  border-color: var(--line);
}
.species-option strong { display: block; font-size: 14px; }
.species-option small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 650;
  font-size: 12px;
  line-height: 1.35;
}
.species-icon, .species-option .species-icon, .species-trigger .species-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--ink);
}
.species-icon svg { width: 22px; height: 22px; }
.species-icon img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: brightness(0);
}
html[data-theme="dark"] .species-icon img {
  filter: brightness(0) invert(1);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.workspace.compare-open {
  grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
}
.sidebar, .editor {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.sidebar {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 14px;
}
.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.side-head h2 { font-size: 16px; }
.palette-stage { margin-top: 10px; }

.strip.selected {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.strip-open {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.strip-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
}
.strip-delete:hover { color: var(--danger); background: var(--soft); }
.strip strong { display: block; font-size: 13px; }
.strip em {
  color: var(--faint);
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}
.quiet {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.bar-wrap { display: grid; gap: 3px; min-width: 0; width: 100%; }
.bar-nums { display: flex; }
.bar-nums b {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  color: var(--faint);
  font-style: normal;
}
.bar i {
  display: block;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.empty-chip, .swatch.empty, .bar i.empty {
  background: repeating-linear-gradient(135deg, var(--empty-a), var(--empty-a) 4px, var(--empty-b) 4px, var(--empty-b) 8px);
}

.strips { display: flex; flex-direction: column; gap: 8px; }
.strip {
  position: relative;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--soft-2);
  border-radius: 14px;
  padding: 10px;
}
.strip-name { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding-right: 36px; }
.bar { display: flex; height: 36px; border-radius: 8px; overflow: hidden; }
.bar i { flex: 1; min-width: 0; }
.editor-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.active-strip .bar { height: 40px; }
.compare-toggle.on {
  background: var(--soft);
  color: var(--ink);
}

.editor { padding: 16px; }
.editor-head { display: grid; gap: 10px; }
.callout {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--soft);
  text-align: left;
}
button.callout:hover { background: color-mix(in srgb, var(--ink) 6%, var(--soft)); }
.callout p, .lock-note, .note-card { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 650; }
.switcher { display: flex; align-items: center; gap: 8px; }
.switcher button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--solid);
  font-size: 18px;
}
.switcher-count { font-size: 12px; font-weight: 800; color: var(--muted); }
.palette-name {
  width: 100%;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  padding: 4px 8px;
  border-color: transparent;
  background: transparent;
}
.palette-name:hover, .palette-name:focus { border-color: var(--line); background: var(--solid); }
.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.block-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.recolor-picker { position: relative; z-index: 6; }
.recolor-trigger { width: 100%; }
.recolor-menu {
  width: 100%;
  max-height: 320px;
  overflow: auto;
}
.recolor-option { grid-template-columns: 1fr; }
.note-card {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--soft);
}

.fields { display: grid; gap: 10px; margin-top: 14px; overflow-anchor: none; }
.card {
  border: 1px solid var(--line);
  background: var(--solid);
  border-radius: 16px;
  padding: 12px;
}
.card.main-empty { border-style: dashed; }
.card.is-locked { background: var(--soft-2); }
.card-top { display: flex; align-items: center; gap: 6px; }
.field-index {
  color: var(--faint);
  font-size: 13px;
  font-weight: 800;
  min-width: 1.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.handle { border: 0; background: transparent; color: var(--faint); padding: 0; display: grid; cursor: grab; touch-action: none; }
.handle svg { width: 18px; height: 18px; }
.handle:active { cursor: grabbing; }
html.is-reordering, html.is-reordering * { cursor: grabbing; }
.card.is-lifted {
  position: fixed;
  z-index: 30;
  margin: 0;
  pointer-events: none;
  box-shadow: var(--shadow);
  transform: rotate(-0.5deg) scale(1.015);
}
.drag-slot {
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--soft);
}
.name-input {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  font-size: 16px;
  border-color: transparent;
  background: transparent;
  padding: 4px 6px;
}
.name-input:hover, .name-input:focus { border-color: var(--line); background: var(--card); }
.hint-btn, .hint-input {
  display: block;
  width: 100%;
  margin: 2px 0 8px;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}
.hint-btn {
  border: 1px dashed transparent;
  background: transparent;
  border-radius: 8px;
  padding: 4px 6px;
}
.hint-btn:hover { border-color: var(--line); background: var(--soft-2); }
.hint-btn.is-empty { color: var(--faint); font-style: italic; }
.color-row { display: flex; gap: 10px; align-items: center; }
.swatch {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  overflow: hidden;
  flex: none;
  position: relative;
}
.swatch input {
  position: absolute;
  inset: -20%;
  width: 140%;
  height: 140%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
}
.hex-line { display: flex; align-items: center; gap: 4px; }
.hex {
  width: 108px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  font-weight: 800;
}
.hex::placeholder { color: var(--faint); font-weight: 700; }
.shade-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.ramp-wrap { margin-top: 8px; }
.ramp { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; }
.ramp button {
  height: 28px;
  border: 0;
  border-radius: 6px;
  padding: 0;
}
.ramp button.is-current { outline: 2px solid var(--ink); outline-offset: 1px; }
.ramp-label, .footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
}
.ramp-label { margin-top: 4px; }
.undo-shade {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0;
}
.add-field { display: flex; gap: 8px; }
.add-field input { flex: 1; }

.footer { margin-top: 18px; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 16, 14, 0.46);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}
.modal-card {
  width: min(520px, 100%);
  background: var(--card);
  color: var(--ink);
  border-radius: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.modal-card p { color: var(--muted); line-height: 1.45; }
.modal-hero { display: flex; gap: 14px; align-items: center; }
.swatch-lg { width: 64px; height: 64px; border-radius: 18px; border: 1px solid var(--line); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 8px; list-style: none; }
.chips li {
  background: var(--soft);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}
.help-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.help-list li { margin: 6px 0; }
kbd {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0 5px;
  background: var(--solid);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 50;
}
.toast {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 750;
  max-width: 280px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .top, .workspace, .workspace.compare-open { display: flex; flex-direction: column; }
  .editor-bar { grid-template-columns: auto auto; }
  .active-strip { grid-column: 1 / -1; }
  .tools { align-items: stretch; }
  .sidebar { position: static; max-height: none; }
  .species-menu { grid-template-columns: 1fr; width: min(440px, calc(100vw - 40px)); }
  .recolor-menu { width: 100%; }
  .shell { width: min(100% - 20px, 1440px); }
  .footer { flex-direction: column; }
}

@media print {
  .tools, .species-wrap, .sidebar, .editor-actions, .recolor-picker, .add-field, .footer, .shade-row, .handle, .icon-btn { display: none !important; }
  body { background: white; color: black; }
  .editor, .card { box-shadow: none; }
}
