/* ============================================================
   Canass — styles
   Colors sampled directly from the Figma export.
   ============================================================ */
:root {
  --bg:            #0c1118;   /* page + sidebar base            */
  --bg-canvas:     #12161f;   /* left workspace                 */
  --surface:       #0e141c;   /* recipe / mixing card           */
  --surface-2:     #161c26;   /* nested rows                    */
  --pill:          rgba(38, 44, 54, .82); /* floating toolbar pills */
  --pill-border:   rgba(255, 255, 255, .07);

  --gold:          #c9a96a;
  --gold-bright:   #e0c489;
  --gold-deep:     #b2955e;
  --gold-soft:     rgba(201, 169, 106, .14);

  --text:          #e6e7ea;   /* titles / near-white            */
  --text-strong:   #dcdde0;
  --muted:         #8790a0;   /* section labels                 */
  --body:          #747c8c;   /* body copy                      */
  --dim:           #545b69;

  --line:          rgba(255, 255, 255, .065);
  --line-strong:   rgba(255, 255, 255, .10);
  --green:         #46d36b;

  --sidebar-w:     440px;
  --radius:        16px;
  --radius-lg:     22px;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;

  /* 4-point sparkle used for tips bullets */
  --spark: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2c.4 4.6 1.9 6.1 6.5 6.5C13.9 8.9 12.4 10.4 12 15c-.4-4.6-1.9-6.1-6.5-6.5C10.1 8.1 11.6 6.6 12 2Z" fill="black"/></svg>');
}

* { box-sizing: border-box; }
/* Author display rules (e.g. .dropzone{display:flex}) would otherwise
   beat the UA [hidden]{display:none}; force hidden to always win. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }
svg.i--sm { width: 14px; height: 14px; }
svg.i--gold { stroke: var(--gold); }

/* ============================================================
   Layout shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
}

/* ---------- Workspace ---------- */
.workspace {
  position: relative;
  /* Schackrutigt transparens-mönster — mörkaste rutan = sidopanelens färg (#0c1118),
     ljusa rutan en subtil variant av samma ton. */
  background-color: #12161f;
  background-image:
    linear-gradient(45deg, #0c1118 25%, transparent 25%),
    linear-gradient(-45deg, #0c1118 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0c1118 75%),
    linear-gradient(-45deg, transparent 75%, #0c1118 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
/* Inner shadow (från Figma: X -200, Y 0, Blur 100, Spread -100, #0C1118)
   — fadar arbetsytans högerkant mjukt in i sidopanelen. Eget lager med
   pointer-events:none så pipetten fortfarande fungerar. */
.workspace::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  box-shadow: inset -200px 0 100px -100px #0C1118;
}

/* ---------- Floating toolbar ---------- */
.toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
}
.toolbar__group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  background: var(--pill);
  border: 1px solid var(--pill-border);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.tool {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #c7ccd6;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.tool:hover { background: rgba(255,255,255,.07); color: #fff; }
.tool:disabled {
  color: var(--dim);
  cursor: not-allowed;
}
.tool:disabled:hover { background: transparent; color: var(--dim); }
.tool.is-active { background: var(--gold); color: #1a1305; }
.tool.is-active svg { stroke: #1a1305; }
.tool.is-puffed {
  color: #9fe7b3;
  animation: iconPuff .58s ease;
}
.tool.is-puffed::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 999px;
  border: 1px solid rgba(70, 211, 107, .65);
  animation: iconPuffRing .58s ease;
  pointer-events: none;
}
.tool--text { gap: 3px; }
.zoom-menu {
  position: relative;
  display: inline-flex;
}
.zoom-menu__list {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 99;
  min-width: 112px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(18, 22, 31, .96);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .42);
  transform: translateX(-50%);
}
.zoom-menu--up .zoom-menu__list {
  top: auto;
  bottom: calc(100% + 8px);
}
.zoom-menu__list button {
  width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #c7ccd6;
  font-size: 13px;
  text-align: left;
}
.zoom-menu__list button:hover {
  background: rgba(255, 255, 255, .07);
  color: #fff;
}
.zoom-menu__list button.is-selected {
  background: var(--gold-soft);
  color: var(--gold-bright);
}
.zoom-menu__list button.is-selected::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

/* cm-fält för rutnätet */
.tool-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 38px;
  padding: 0 8px 0 6px;
}
.tool-field input {
  width: 42px;
  height: 28px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--pill-border);
  border-radius: 7px;
  color: #fff;
  font-family: var(--sans);
  font-size: 13px;
  text-align: center;
  padding: 0 2px;
  -moz-appearance: textfield;
}
.tool-field input:focus { outline: none; border-color: rgba(201, 169, 106, .55); }
.tool-field input::-webkit-outer-spin-button,
.tool-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tool-field span { color: #8790a0; font-size: 12px; }

#changeImage{
  white-space: nowrap;
}

.btn-gold {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  color: #1c1606;
  font-weight: 600;
  font-size: 14px;
  padding: 0 16px;
  height: 44px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.25);
  transition: filter .15s, transform .05s;
}
.btn-gold:hover { filter: brightness(1.06); }
.btn-gold:active { transform: translateY(1px); }
.btn-gold .i { stroke: #1c1606; width: 18px; height: 18px; stroke-width: 2; }
.btn-gold--sm { height: 48px; border-radius: 12px; }

/* ---------- Dropzone ---------- */
.dropzone {
  width: 100%;
  max-width: 880px;
  aspect-ratio: 16 / 11;
  max-height: 100%;
  border: 1.5px dashed rgba(255,255,255,.18);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .18s, background .18s;
}
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.dropzone__inner { text-align: center; pointer-events: none; padding: 20px; }
.dropzone__icon {
  width: 56px; height: 56px; fill: none; stroke: #6b7280;
  stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
  margin-bottom: 18px;
}
.dropzone__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  color: var(--text);
  margin: 0 0 10px;
}
.dropzone__sub { margin: 2px 0; font-size: 14px; color: var(--body); }
.dropzone__sub--dim { color: var(--dim); }

/* ---------- Image viewer ---------- */
/* Bakgrunden ligger på .workspace och syns igenom här. */
.viewer { position: absolute; inset: 0; overflow: hidden; }
.viewer__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  overscroll-behavior: contain;
}
#canvas {
  position: absolute;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  image-rendering: auto;
  z-index: 21;
}
.viewer.tool-eyedropper #canvas { cursor: crosshair; }
.viewer.tool-pan #canvas { cursor: grab; }
.viewer.tool-pan.is-panning #canvas { cursor: grabbing; }
.viewer.tool-grid #canvas { cursor: move; }

/* Rutnäts-overlay — ligger ovanpå bilden, följer pan/zoom via JS */
.grid-overlay {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  pointer-events: none;
  z-index: 22;
  background-repeat: repeat;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .55) 0 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .55) 0 1px, transparent 1px);
}
@keyframes iconPuff {
  0% { transform: scale(1); }
  38% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes iconPuffRing {
  0% { opacity: .75; transform: scale(.72); }
  100% { opacity: 0; transform: scale(1.75); }
}

.loupe {
  position: fixed;
  width: 108px; height: 108px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 6px 22px rgba(0,0,0,.5), 0 0 0 1px rgba(0,0,0,.4);
  pointer-events: none;
  z-index: 60;
  transform: translate(-50%, -50%);
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.loupe::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  transform: translate(-50%,-50%);
  border: 1.5px solid rgba(255,255,255,.9);
  box-shadow: 0 0 0 1px rgba(0,0,0,.5);
  border-radius: 2px;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: relative;
  background: var(--bg);
  padding: 22px 26px 30px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ---------- Brand header ---------- */
.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 60px;
}
.brand__logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand__mark { width: 26px; height: 26px; fill: none; stroke: var(--text); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; }
.brand__name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 23px;
  letter-spacing: .2px;
  color: var(--text);
}
.brand__nav { display: flex; align-items: center; gap: 14px; }
.brand__count { font-size: 13px; color: var(--body); }
.iconbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: none;
  background: transparent;
  border-radius: 9px;
  color: #aeb4c0;
  transition: background .15s;
}
.iconbtn:hover { background: rgba(255,255,255,.06); }
.badge-dot {
  position: absolute; top: 3px; right: 3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--bg);
}
.badge-dot.is-missing {
  background: #d6321f;
}

/* ---------- Target color ---------- */
.target { margin-bottom: 60px; }
.target__head {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
}
.target__swatch {
  width: 160px;
  height: auto;
  flex: 0 0 auto;
  display: block;
  /* Lyft över färgväljarens backdrop (z 90) så swatchen inte mörknar
     när väljaren är öppen; ligger fortfarande under själva väljaren (z 100). */
  position: relative;
  z-index: 95;
  transition: transform .12s;
}
.target__head:hover .target__swatch { transform: translateY(-1px); }
#targetSwatchFill { transition: fill .15s ease; }
.target__meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.target__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  color: var(--text);
  line-height: 1.1;
}
.target__title.is-hex { letter-spacing: .5px; }
.target__rgb { font-size: 12.5px; color: var(--body); }
.target__hint { margin: 16px 0 0; font-size: 13.5px; color: var(--body); }

/* ---------- Analyze button ---------- */
.btn-analyze {
  position: relative;
  width: 100%;
  height: 64px;
  min-height: 64px;
  margin-bottom: 18px;
  border: 1px solid rgba(201, 169, 106, .32);
  border-radius: var(--radius);
  background: transparent;             /* active/vilande: ingen bakgrundsfärg */
  color: var(--gold);
  font-size: 17px;
  font-weight: 500;
  overflow: hidden;
  isolation: isolate;
  transition: border-color .2s, box-shadow .25s, color .2s, background .2s;
}

/* Shimmer-svep (tech/magi) — ligger utanför knappen tills hover/loading */
.btn-analyze::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(224, 196, 137, .14) 45%,
    rgba(255, 244, 214, .40) 50%,
    rgba(224, 196, 137, .14) 55%,
    transparent 70%
  );
  transform: translateX(-130%);
}

/* Indeterminat "AI körs"-stapel längst ned — syns bara vid loading */
.btn-analyze::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
  transform: translateX(-100%);
  opacity: 0;
}

.btn-analyze__content {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.btn-analyze__icon { display: inline-flex; }
.btn-analyze__icon svg { stroke: var(--gold); width: 22px; height: 22px; }

/* ---- Disabled: mörk och tydligt inaktiv ---- */
.btn-analyze:disabled {
  border-color: rgba(255, 255, 255, .06);
  background: rgba(0, 0, 0, .22);
  color: #444b58;
  cursor: not-allowed;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
}
.btn-analyze:disabled .btn-analyze__icon svg { stroke: #3c424e; }

/* ---- Hover (aktiverad): tech-shimmer, glöd och tindrande gnistor ---- */
@media (hover: hover) and (pointer: fine) {
  .btn-analyze:not(:disabled):not(.is-loading):hover {
    border-color: rgba(201, 169, 106, .6);
    color: var(--gold-bright);
    box-shadow: 0 0 28px rgba(201, 169, 106, .16), inset 0 0 18px rgba(201, 169, 106, .06);
  }
  .btn-analyze:not(:disabled):not(.is-loading):hover::before { animation: sheen 1.5s linear infinite; }
  .btn-analyze:not(:disabled):not(.is-loading):hover .btn-analyze__icon { animation: twinkle 1.1s ease-in-out infinite; }
}

/* ---- Loading: AI-analys körs (magi) — överrider disabled-stilen ---- */
.btn-analyze.is-loading {
  color: var(--gold);
  border-color: rgba(201, 169, 106, .55);
  background: transparent;
  cursor: progress;
  animation: glowPulse 1.5s ease-in-out infinite;
}
.btn-analyze.is-loading::before { animation: sheen 1.15s linear infinite; }
.btn-analyze.is-loading::after  { opacity: 1; animation: progressBar 1.25s ease-in-out infinite; }
.btn-analyze.is-loading .btn-analyze__icon { animation: twinkle .8s ease-in-out infinite; }
.btn-analyze.is-loading .btn-analyze__icon svg { stroke: var(--gold-bright); }

.analyze-wait {
  margin: -8px 0 18px;
  text-align: center;
  font-style: italic;
  font-size: 13.5px;
  color: var(--body);
}

.analyze-warn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: -6px 0 18px;
  padding: 11px 13px;
  border: 1px solid rgba(224, 170, 90, .28);
  border-radius: 12px;
  background: rgba(224, 170, 90, .07);
  font-size: 12.5px;
  line-height: 1.45;
  color: #c9b48f;
}
.analyze-warn svg {
  width: 17px; height: 17px;
  flex: 0 0 auto;
  margin-top: 1px;
  fill: none;
  stroke: #e0aa5a;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--gold-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.linklike:hover { color: #fff; }

@keyframes sheen {
  0%   { transform: translateX(-130%); }
  100% { transform: translateX(130%); }
}
@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50%      { transform: scale(1.22) rotate(10deg); opacity: .82;
             filter: drop-shadow(0 0 4px rgba(224, 196, 137, .7)); }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(201, 169, 106, 0), inset 0 0 16px rgba(201, 169, 106, .05); }
  50%      { box-shadow: 0 0 30px rgba(201, 169, 106, .26), inset 0 0 26px rgba(201, 169, 106, .12); }
}
@keyframes progressBar {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ---------- Recipe ---------- */
.recipe { margin-bottom: 4px; }
.recipe__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 2px 14px;
}
.recipe__label {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 1.4px;
  color: var(--muted);
}
.recipe__label .i { width: 17px; height: 17px; }
.recipe__conf { font-size: 12.5px; color: var(--body); letter-spacing: .3px; }
.recipe__conf b { color: var(--text-strong); letter-spacing: 1px; }

.recipe__card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.mix { list-style: none; margin: 0; padding: 0; }
.mix__row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}
.mix__blob { width: 42px; height: 24px; flex: 0 0 auto; }
.mix__name { font-size: 17px; color: var(--text); flex: 1; }
.mix__parts { font-size: 13px; color: var(--body); white-space: nowrap; }
.mix__glass { width: 22px; height: 28px; flex: 0 0 auto; }
.mix__water {
  margin-top: 12px;
  font-size: 16px;
  color: var(--body);
}
.mix__water b { color: var(--text); font-weight: 600; }

/* ---------- Tips ---------- */
.tips { margin-top: 30px; padding-top: 4px; }
.tips__label {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 1.4px;
  color: var(--muted);
}
.tips__list { list-style: none; margin: 14px 0 0; padding: 0; }
.tips__list li {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--body);
  line-height: 1.5;
}
.tips__list li::before {
  content: "";
  flex: 0 0 auto;
  width: 16px; height: 16px;
  margin-top: 2px;
  background: var(--gold);
  -webkit-mask: var(--spark) center/contain no-repeat;
  mask: var(--spark) center/contain no-repeat;
}
.ai-reasoning {
  margin-top: 30px;
  padding-top: 4px;
}
.ai-reasoning__tag {
  color: var(--gold);
  letter-spacing: 1.1px;
}
/* discreet "AI ej tillgänglig" pill — only shown on AI failure */
.ai-reasoning__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(224, 169, 109, .12);
  color: #e0a96d;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: none;
}
.ai-reasoning__status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.ai-reasoning__text {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--body);
}
.ai-reasoning__meta {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--dim);
}
.ai-reasoning__meta span {
  color: var(--body);
}
.ai-reasoning__sep {
  display: inline-block;
  margin: 0 8px;
  color: var(--dim);
}

.disclaimer {
  margin-top: auto;
  padding-top: 26px;
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--dim);
}

/* ============================================================
   Color picker popover
   ============================================================ */
.backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.35);
}
.picker {
  position: fixed;
  z-index: 100;
  width: 280px;
}
.picker__sheet {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0,0,0,.5);
  overflow: hidden;
}
.picker__sb {
  position: relative;
  height: 150px;
  cursor: crosshair;
  background: hsl(210, 100%, 50%);
}
.picker__sb-white {
  position: absolute; inset: 0;
  background: linear-gradient(to right, #fff, rgba(255,255,255,0));
}
.picker__sb-black {
  position: absolute; inset: 0;
  background: linear-gradient(to top, #000, rgba(0,0,0,0));
}
.picker__sb-thumb {
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.picker__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}
.picker__eyedrop {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex: 0 0 auto;
  border: none; background: none; color: #444;
}
.picker__eyedrop .i { stroke: #444; width: 18px; height: 18px; }
.picker__preview {
  width: 26px; height: 26px; flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.15);
  background: #6e7886;
}
.picker__hue {
  position: relative;
  flex: 1;
  height: 12px;
  border-radius: 6px;
  cursor: pointer;
  background: linear-gradient(to right,
    #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.picker__hue-thumb {
  position: absolute; top: 50%;
  width: 14px; height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.picker__rgb {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 12px 14px;
}
.picker__rgb label {
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #666;
}
.picker__rgb input {
  width: 100%;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 13px;
  font-family: var(--sans);
  text-align: center;
  color: #222;
  -moz-appearance: textfield;
}
.picker__rgb input::-webkit-outer-spin-button,
.picker__rgb input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.picker__spin { display: flex; flex-direction: column; gap: 2px; padding-bottom: 1px; }
.picker__spin button {
  border: 1px solid #d4d4d4;
  background: #f6f6f6;
  border-radius: 4px;
  width: 20px; height: 15px;
  font-size: 8px; line-height: 1;
  color: #555;
  display: flex; align-items: center; justify-content: center;
}
.picker__spin button:hover { background: #ececec; }

/* ============================================================
   Header-moduler (färgpalett + inställningar)
   ============================================================ */
.menu {
  position: fixed;
  z-index: 100;
  width: 320px;
  max-width: calc(100vw - 24px);
  background: #11161f;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  box-shadow: 0 22px 54px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .03);
  padding: 18px 20px 16px;
  transform-origin: top right;
  animation: menuIn .15s ease;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.menu__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.menu__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 19px;
  color: var(--text);
  margin: 0;
}
.menu__sub { font-size: 12.5px; color: var(--body); }
.menu__note {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  font-style: italic;
  color: var(--dim);
}

/* palett-lista */
.pal-scroll {
  position: relative;
}
.pal {
  list-style: none;
  margin: 0;
  padding: 0 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(48vh, 430px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.pal::-webkit-scrollbar {
  width: 0;
  height: 0;
}
.pal-scrollbar {
  position: absolute;
  top: 2px;
  right: 1px;
  bottom: 2px;
  width: 8px;
  background: rgba(255, 255, 255, .035);
  border-radius: 999px;
  opacity: 1;
  pointer-events: none;
  transition: background .15s, opacity .15s;
}
.pal-scrollbar[hidden] {
  display: none;
}
.pal-scrollbar__thumb {
  position: absolute;
  top: 0;
  right: 1px;
  width: 6px;
  min-height: 34px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(224, 196, 137, .78), rgba(201, 169, 106, .52));
  box-shadow: 0 0 0 1px rgba(201, 169, 106, .18), 0 2px 8px rgba(0, 0, 0, .28);
  transform: translateY(0);
  transition: background .15s;
}
.pal-scroll:hover .pal-scrollbar {
  background: rgba(255, 255, 255, .05);
}
.pal-scroll:hover .pal-scrollbar__thumb {
  background: linear-gradient(180deg, rgba(224, 196, 137, .94), rgba(201, 169, 106, .7));
}
.pal-shell {
  position: relative;
  overflow: hidden;
}
.pal-view {
  transition: transform .24s ease, opacity .18s ease;
}
/* secondary views (method / scan / photo / editor) start off to the right, hidden */
.pal-view--method,
.pal-view--scan,
.pal-view--photo,
.pal-view--editor {
  position: absolute;
  inset: 0;
  transform: translateX(104%);
  opacity: 0;
  pointer-events: none;
}
/* once we leave the list, push it slightly left and hide it */
.pal-shell:not([data-step="list"]) .pal-view--list {
  position: absolute;
  inset: 0;
  transform: translateX(-28%);
  opacity: 0;
  pointer-events: none;
}
/* the active secondary view takes the flow so the panel sizes to it */
.pal-shell[data-step="method"] .pal-view--method,
.pal-shell[data-step="scan"]   .pal-view--scan,
.pal-shell[data-step="photo"]  .pal-view--photo,
.pal-shell[data-step="editor"] .pal-view--editor {
  position: relative;
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
.pal li { min-width: 0; }
.pal__item {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, .035);
  text-align: left;
  transition: background .15s, border-color .15s;
}
.pal__item:hover {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .08);
}
.pal .sw {
  width: 30px; height: 19px;
  flex: 0 0 auto;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}
.pal .nm {
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pal .hx {
  font-size: 12px;
  color: var(--body);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}
.pal .chev {
  width: 18px;
  height: 18px;
  color: var(--dim);
}
.pal-add {
  width: 100%;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 10px;
  border: 1px solid rgba(201, 169, 106, .34);
  border-radius: 8px;
  background: var(--gold-soft);
  color: var(--gold-bright);
  font-size: 13px;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.pal-add:hover {
  background: rgba(201, 169, 106, .2);
  border-color: rgba(201, 169, 106, .5);
}
.pal-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  margin-bottom: 12px;
  padding: 0 8px 0 2px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--body);
  font-size: 12.5px;
  transition: background .15s, color .15s;
}
.pal-back:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.pal-form { display: flex; flex-direction: column; gap: 12px; }
.pal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--body);
}
.pal-field input[type="text"] {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}
.pal-field input:focus { outline: none; border-color: rgba(201, 169, 106, .55); }
.pal-color-row { display: grid; grid-template-columns: 46px 1fr; gap: 8px; }
.pal-color-row input[type="color"] {
  width: 46px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
}
.pal-readout {
  margin: 2px 0 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}
.pal-readout__row {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: baseline;
  gap: 10px;
}
.pal-readout__row dt {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--body);
}
.pal-readout__row dd {
  margin: 0;
  font-family: var(--mono, ui-monospace, "SF Mono", Menlo, monospace);
  font-size: 12.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}
.pal-delete {
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(214, 50, 31, .35);
  border-radius: 8px;
  background: rgba(214, 50, 31, .1);
  color: #ff9a8e;
  font-size: 13px;
}
.pal-delete:hover { background: rgba(214, 50, 31, .17); }

/* ---- proveniens-prick (lista + editor) ---- */
.pal__dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 1.5px var(--bg);
}
.pal .sw { position: relative; }
.pal .sw .pal__dot {
  position: absolute;
  top: -3px;
  right: -3px;
}
.pal__dot--high { background: var(--green); }
.pal__dot--mid  { background: var(--gold); }
.pal__dot--low  { background: #c97a5e; }

/* ---- metodväljare ---- */
.pal-method__lead {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--body);
}
.pal-method { display: flex; flex-direction: column; gap: 9px; }
.pal-method__opt {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, .035);
  text-align: left;
  transition: background .15s, border-color .15s;
}
.pal-method__opt:hover:not(:disabled) {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(201, 169, 106, .4);
}
.pal-method__opt.is-soon { opacity: .55; cursor: default; }
.pal-method__ic {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--gold-soft);
  color: var(--gold-bright);
}
.pal-method__ic .i { width: 19px; height: 19px; }
.pal-method__txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pal-method__title { font-size: 14px; color: var(--text); }
.pal-method__desc {
  font-size: 12px;
  color: var(--body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pal-method__opt .chev { width: 18px; height: 18px; color: var(--dim); }
.pal-soon {
  font-size: 10.5px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--gold-bright);
  border: 1px solid rgba(201, 169, 106, .4);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* ---- etikettscan ---- */
.pal-scan { display: flex; flex-direction: column; gap: 12px; }
.pal-scan__drop {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, background .15s;
}
.pal-scan__drop:hover { border-color: rgba(201, 169, 106, .45); background: rgba(255, 255, 255, .05); }
.pal-scan__preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.pal-scan__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px;
  text-align: center;
  color: var(--body);
  font-size: 12.5px;
}
.pal-scan__placeholder .i { width: 30px; height: 30px; color: var(--dim); }
.pal-scan__row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pal-scan__status {
  margin: 0;
  font-size: 12.5px;
  color: var(--body);
}
.pal-scan__status.is-loading { color: var(--gold-bright); }
.pal-scan__status.is-error { color: #ff9a8e; }
.pal-scan__note {
  margin: 0;
  font-size: 11.5px;
  font-style: italic;
  color: var(--dim);
  line-height: 1.5;
}
.pal-scan__note b { color: var(--body); font-style: normal; }

/* ---- proveniens i editorn ---- */
.pal-prov {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
}
.pal-prov__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.pal-prov__badge {
  font-size: 11px;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text);
}
.pal-prov__badge--etikett-estimat {
  color: var(--gold-bright);
  border-color: rgba(201, 169, 106, .4);
  background: var(--gold-soft);
}
.pal-prov__badge--foto {
  color: #9ec5ff;
  border-color: rgba(110, 160, 230, .35);
  background: rgba(110, 160, 230, .12);
}
.pal-prov__trust {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--body);
}
.pal-prov__pigs { display: flex; flex-wrap: wrap; gap: 6px; }
.pal-prov__pig {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
}
.pal-prov__note {
  margin: 0;
  font-size: 11.5px;
  font-style: italic;
  color: var(--dim);
  line-height: 1.5;
}

/* ---- fotoreferens ---- */
.pal-photo { display: flex; flex-direction: column; gap: 12px; }
.pal-photo__modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, .03);
}
.pal-photo__mode {
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--body);
  font-size: 12.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.pal-photo__mode.is-active { background: var(--gold-soft); color: var(--gold-bright); }
.pal-photo__mode:disabled { opacity: .4; cursor: not-allowed; }
.pal-photo__refs { margin: 0; font-size: 12px; color: var(--body); line-height: 1.5; }
.pal-photo__refs b { color: var(--text); font-weight: 500; }

.pal-photo__stage {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #000;
  line-height: 0;
}
.pal-photo__stage canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
}
.pal-photo__markers { position: absolute; inset: 0; pointer-events: none; }
.pal-photo__marker {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .6), 0 1px 3px rgba(0, 0, 0, .5);
}
.pal-photo__marker--white  { background: #fff; }
.pal-photo__marker--black  { background: #111; }
.pal-photo__marker--swatch { background: var(--gold); border-color: #fff; }

.pal-photo__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 14px;
  text-align: center;
  color: var(--body);
  font-size: 12.5px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pal-photo__placeholder:hover { border-color: rgba(201, 169, 106, .45); background: rgba(255, 255, 255, .05); }
.pal-photo__placeholder .i { width: 30px; height: 30px; color: var(--dim); }

.pal-photo__steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pal-photo__step {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, .035);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pal-photo__step.is-active { border-color: rgba(201, 169, 106, .5); background: var(--gold-soft); }
.pal-photo__step.is-done .pal-photo__steplbl { color: var(--body); }
.pal-photo__num {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: var(--body);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.pal-photo__step.is-active .pal-photo__num { background: var(--gold); color: #1c1606; }
.pal-photo__chip {
  width: 22px; height: 22px;
  flex: 0 0 auto;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, .18);
}
.pal-photo__chip--empty {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .05);
  color: var(--dim);
  font-size: 12px;
}
.pal-photo__steplbl { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pal-photo__result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
}
.pal-photo__cmp { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pal-photo__cmp .pal-photo__chip { width: 40px; height: 40px; border-radius: 7px; }
.pal-photo__cmplbl { font-size: 11px; text-align: center; color: var(--body); line-height: 1.4; font-variant-numeric: tabular-nums; }
.pal-photo__arrow { width: 20px; height: 20px; color: var(--dim); flex: 0 0 auto; }

/* inställningsrad + switch */
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.setting:last-of-type { border-bottom: none; }
.setting__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting__label { font-size: 14px; color: var(--text); }
.setting__desc { font-size: 11.5px; color: var(--body); line-height: 1.35; }

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px; height: 24px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  transition: background .2s;
}
.switch[aria-checked="true"] { background: var(--gold); }
.switch__dot {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  transition: transform .2s;
}
.switch[aria-checked="true"] .switch__dot { transform: translateX(18px); }

.setting__field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.setting__field input {
  width: 46px; height: 30px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  text-align: center;
  -moz-appearance: textfield;
}
.setting__field input:focus { outline: none; border-color: rgba(201, 169, 106, .55); }
.setting__field input::-webkit-outer-spin-button,
.setting__field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.setting__field span { font-size: 12px; color: var(--body); }

/* staplad inställning (t.ex. API-nyckel) */
.setting--stack { flex-direction: column; align-items: stretch; gap: 9px; }
.key-field { position: relative; display: flex; align-items: center; }
.key-field input {
  width: 100%;
  height: 38px;
  padding: 0 38px 0 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: .3px;
}
.key-field input::placeholder { color: var(--dim); }
.key-field input:focus { outline: none; border-color: rgba(201, 169, 106, .55); }
.key-field__toggle {
  position: absolute;
  right: 6px;
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 7px;
  color: var(--body);
  transition: color .15s, background .15s;
}
.key-field__toggle:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.key-field__toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.key-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.setting-actions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}
.key-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--body); }
.key-status__dot {
  width: 8px; height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--dim);
  transition: background .2s, box-shadow .2s;
}
.key-status.is-saved { color: #9fe7b3; }
.key-status.is-saved .key-status__dot { background: var(--green); box-shadow: 0 0 8px rgba(70, 211, 107, .55); }
.key-status.is-dirty { color: var(--gold); }
.key-status.is-dirty .key-status__dot { background: var(--gold); box-shadow: 0 0 8px rgba(201, 169, 106, .5); }

.btn-mini {
  height: 30px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  color: #1c1606;
  font-size: 13px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: filter .15s, opacity .15s;
}
.btn-mini:hover:not(:disabled) { filter: brightness(1.06); }
.btn-mini:disabled {
  background: rgba(255, 255, 255, .07);
  color: var(--dim);
  box-shadow: none;
  cursor: not-allowed;
}
/* secondary (ghost) variant — must follow .btn-mini to win on source order */
.btn-mini--ghost {
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.btn-mini--ghost:hover:not(:disabled) { filter: none; background: rgba(255, 255, 255, .09); }
.btn-mini--ghost:disabled { background: rgba(255, 255, 255, .04); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  :root { --sidebar-w: 360px; }
  .sidebar { padding: 20px 20px 26px; }
  .target__swatch { width: 150px; }
}

/* Tablet / mobile: stack workspace over sidebar */
@media (max-width: 860px) {
  body { overflow: auto; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    min-height: 100dvh;
  }
  .brand {
    order: 0;
    margin: 0;
    padding: 20px 20px 18px;
    background: var(--bg);
  }
  .workspace {
    order: 1;
    min-height: 48vh;
    padding: 16px;
  }
  .workspace::after {
    box-shadow: none;
  }
  .dropzone { aspect-ratio: 4 / 3; }
  .sidebar {
    display: contents;
    border-left: none;
    box-shadow: none;
    overflow: visible;
  }
  .target,
  .btn-analyze,
  .analyze-warn,
  .analyze-wait,
  .recipe,
  .disclaimer {
    order: 2;
    margin-left: 20px;
    margin-right: 20px;
  }
  .target{
    margin-top:40px;
    margin-bottom: 40px;
  }
  .btn-analyze {
    width: auto;
  }
  .toolbar { gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 94%; }
  .workspace.has-image-tools {
    display: grid;
    grid-template-rows: minmax(300px, 48vh) auto;
    align-items: stretch;
    justify-items: stretch;
    gap: 18px;
    min-height: auto;
    background: var(--bg);
  }
  .workspace.has-image-tools .viewer {
    position: relative;
    inset: auto;
    grid-row: 1;
    min-height: 300px;
    width: 100%;
    overflow: hidden;
    background-color: #12161f;
    background-image:
      linear-gradient(45deg, #0c1118 25%, transparent 25%),
      linear-gradient(-45deg, #0c1118 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, #0c1118 75%),
      linear-gradient(-45deg, transparent 75%, #0c1118 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  }
  .workspace.has-image-tools .toolbar {
    position: relative;
    top: auto;
    left: auto;
    grid-row: 2;
    transform: none;
    width: 100%;
    max-width: none;
    align-self: end;
    justify-content: center;
    padding: 0;
  }
  .workspace.has-image-tools .btn-gold--sm {
    height: 42px;
  }
  .target__head { gap: 16px; }
  .target__swatch { width: 44%; max-width: 160px; }
  .disclaimer { margin-top: 28px; }
}

@media (max-width: 480px) {
  .brand { margin-bottom: 0; }
  .brand__count { display: none; }
  .target__title { font-size: 23px; }
  .btn-analyze { height: 58px; font-size: 16px; }
  .recipe__card { padding: 18px; }
  .toolbar__group { padding: 4px; }
  .tool { min-width: 34px; height: 34px; }
  .picker { width: calc(100vw - 32px); max-width: 320px; }
}

/* Floating picker becomes a centered sheet on small screens */
@media (max-width: 560px) {
  .picker {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
