/* MecchaPalette — dark, mobile-first, colors-are-the-interface. */

:root {
  color-scheme: dark;
  --bg: #14161a;
  --bg-2: #1b1e24;
  --bg-3: #23262c;
  --line: #2c3038;
  --text: #e6e8ea;
  --muted: #8b9098;
  --accent: #57c9a7;
  --radius: 12px;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { scroll-behavior: smooth; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* ---------- header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(20, 22, 26, .9);
  backdrop-filter: blur(8px);
  z-index: 20;
}
.brand { font-size: 18px; margin: 0; letter-spacing: .3px; font-weight: 700; }
.brand span { color: var(--accent); }
.base-echo {
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .18);
}

/* ---------- ad slots (empty placeholders until approved) ----------
   Hidden by default. When AdSense is live, add class="ads-on" to <body>
   in index.html and the slots (and the desktop sidebar column) appear. */
body:not(.ads-on) .ad-slot { display: none; }
/* make the hidden attribute win over .ad-slot's display:flex
   (used by the mobile sticky's dismiss button) */
.ad-slot[hidden] { display: none; }

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a5058;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  border: 1px dashed #2c3038;
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, #16181d, #16181d 10px, #181b21 10px, #181b21 20px);
}
.ad-slot::after { content: "ad"; }
.ad-top { min-height: 66px; margin: 12px 18px; }
.ad-rect { min-height: 200px; margin: 18px 0; }
.ad-side { display: none; }
.ad-sticky {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  min-height: 56px;
  border-radius: 0;
  z-index: 30;
}
.ad-sticky-close {
  position: absolute;
  top: 4px; right: 6px;
  background: none; border: none; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}

/* ---------- layout ---------- */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px 96px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
.tool { min-width: 0; }
.section-title { font-size: 16px; margin: 26px 0 12px; }
.section-title small { color: var(--muted); font-weight: 400; }
.section-sub { color: var(--muted); margin: -6px 0 14px; font-size: 13px; }

.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.panel-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 0 0 auto;
  background: var(--bg-3);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
.tab.active { color: var(--text); border-color: var(--accent); background: #1f2a28; }

/* ---------- dropper ---------- */
.dropper { display: grid; grid-template-columns: 1fr; gap: 18px; }
.dropper-square-wrap { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.sb-square {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
  outline: none;
  background:
    linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
    linear-gradient(to right, #fff, rgba(255, 255, 255, 0)),
    hsl(var(--hue, 0) 100% 50%);
}
.sb-square:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.sb-thumb {
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .55), var(--shadow);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.hue-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; max-width: 320px; height: 16px;
  border-radius: 999px;
  background: linear-gradient(to right,
    #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
  cursor: pointer; outline: none;
}
.hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid #222; box-shadow: var(--shadow); cursor: grab;
}
.hue-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid #222; box-shadow: var(--shadow); cursor: grab;
}

.dropper-side { display: flex; flex-direction: column; gap: 12px; }
.preview-chip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.preview-hex { font: 700 18px/1 ui-monospace, Menlo, monospace; letter-spacing: .5px; }
.preview-copy { font-size: 12px; opacity: .85; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.field-hex { grid-column: 1 / -1; }
.field span { text-transform: uppercase; letter-spacing: .08em; }
.field input {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 10px;
  font: 600 14px/1 ui-monospace, Menlo, monospace;
  width: 100%;
}
.field input:focus { outline: none; border-color: var(--accent); }
.dropper-hint { color: var(--muted); font-size: 12px; margin: 0; }

/* ---------- screenshot sampler ---------- */
.shot-drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px 18px;
  text-align: center;
  cursor: pointer;
}
.shot-drop.drag { border-color: var(--accent); background: #1a211f; }
.shot-drop-text { margin: 0 0 6px; }
.shot-browse { color: var(--accent); text-decoration: underline; }
.shot-drop-sub { margin: 0; color: var(--muted); font-size: 12px; }
.shot-stage { position: relative; }
.shot-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
}
.shot-loupe {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: var(--shadow);
  image-rendering: pixelated;
  z-index: 5;
}
.shot-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 10px;
}
.shot-readout { font: 600 13px/1 ui-monospace, Menlo, monospace; }
.shot-clear {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 13px;
}

/* ---------- swatch strips ---------- */
.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.sw {
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .08);
  flex: 0 0 auto;
}

/* ---------- palette cards ---------- */
.palettes { display: grid; gap: 12px; }
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.card.open { border-color: #3a4a46; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; width: 100%;
  background: none; border: none; color: inherit;
  cursor: pointer; text-align: left; padding: 0 0 10px;
}
.card-titles h3 { margin: 0; font-size: 15px; }
.card-titles p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.caret { color: var(--muted); transition: transform .15s ease; }
.card.open .caret { transform: rotate(90deg); }

/* ---------- close-shade grid ---------- */
.grid-panel { padding-top: 12px; border-top: 1px solid var(--line); margin-top: 4px; }
.grid-controls {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 14px 20px; margin-bottom: 12px;
}
.closeness { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; font-size: 12px; color: var(--muted); }
.closeness b { color: var(--text); }
.close-slider { width: 100%; accent-color: var(--accent); cursor: pointer; }
.fmt { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.fmt-select {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit;
}
.grid-count { font-size: 12px; color: var(--muted); margin-left: auto; }
.shade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 4px;
}
.shade {
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  padding: 0;
  font: 700 13px/1 system-ui;
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s ease;
}
.shade:hover { transform: scale(1.14); z-index: 2; box-shadow: var(--shadow); }
.shade.copied { outline: 2px solid #fff; }
.shade.copyfail { outline: 2px solid #ff5b5b; }

/* ---------- swatch tooltip ---------- */
.swatch-tip {
  position: fixed;
  display: none;
  z-index: 50;
  pointer-events: none;
  background: #0d0f12;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
  font: 500 12px/1.5 ui-monospace, Menlo, monospace;
}
.swatch-tip b { display: block; font-size: 13px; }
.swatch-tip span { display: block; color: var(--muted); }
.swatch-tip .tip-de { color: var(--accent); margin-top: 2px; }

/* ---------- presets ---------- */
.presets { display: grid; gap: 8px; }
.preset-group {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.preset-group > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex; align-items: baseline; gap: 10px;
}
.preset-group > summary::-webkit-details-marker { display: none; }
.preset-group > summary::before {
  content: "▸"; color: var(--muted); transition: transform .15s ease;
}
.preset-group[open] > summary::before { transform: rotate(90deg); }
.preset-group summary em { color: var(--muted); font-style: normal; font-size: 12px; }
.preset-surfaces { padding: 0 14px 12px; display: grid; gap: 10px; }
.surface { border-top: 1px solid var(--line); padding-top: 10px; }
.surface-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; background: none; border: none; color: inherit;
  cursor: pointer; text-align: left; padding: 0;
}
.surface-name { font-size: 13px; }
.surface.open { }

/* ---------- visual preview (compare) ---------- */
.compare {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: start;
}
.cmp-half { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cmp-chip {
  height: 84px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  cursor: pointer;
  font: 700 15px/1 ui-monospace, Menlo, monospace;
  letter-spacing: .4px;
}
.cmp-chip:disabled { cursor: default; border-style: dashed; }
.cmp-empty { color: var(--muted); font: 400 12px/1 system-ui; }
.cmp-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.cmp-vals { font: 500 11px/1.4 ui-monospace, Menlo, monospace; color: var(--muted); overflow-wrap: anywhere; }
.cmp-mid {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding-top: 16px; text-align: center; min-width: 96px;
}
/* narrow screens: chips side by side, ΔE strip full-width beneath */
@media (max-width: 560px) {
  .compare { grid-template-columns: 1fr 1fr; }
  .cmp-mid {
    grid-column: 1 / -1;
    order: 3;
    padding-top: 4px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }
  .cmp-verdict { max-width: none; }
}
.cmp-de { font: 700 18px/1 ui-monospace, Menlo, monospace; color: var(--accent); }
.cmp-verdict { font-size: 12px; color: var(--muted); max-width: 140px; }
.cmp-adopt {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.cmp-adopt:hover { border-color: var(--accent); }

/* ---------- recent / pinned shelf ---------- */
.swatch-shelf {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 14px;
  display: grid;
  gap: 8px;
}
.shelf-row { display: flex; align-items: center; gap: 10px; }
.shelf-label {
  flex: 0 0 52px;
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
}
.shelf-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch-chip {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.chip-color {
  border: none; cursor: pointer;
  padding: 7px 10px;
  font: 600 12px/1 ui-monospace, Menlo, monospace;
}
.chip-pin {
  border: none; border-left: 1px solid var(--line);
  background: var(--bg-3); color: var(--muted);
  cursor: pointer; padding: 0 8px; font-size: 13px;
}
.chip-pin.pinned, .chip-pin:hover { color: #f5c542; }

/* ---------- consent notice ---------- */
.consent {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  z-index: 60;
  display: flex; align-items: center; gap: 14px;
  background: #0d0f12;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  max-width: 640px;
  margin: 0 auto;
}
.consent p { margin: 0; font-size: 12.5px; color: #cdd2d7; }
.consent a { color: var(--accent); }
.consent-ok {
  flex: 0 0 auto;
  background: var(--accent); color: #08120f;
  border: none; border-radius: 8px;
  padding: 8px 16px; font: 600 13px/1 system-ui; cursor: pointer;
}

/* ---------- static pages (privacy etc.) ---------- */
.page { max-width: 720px; padding-top: 8px; }
.page h3 { margin: 26px 0 8px; font-size: 15px; }
.page p, .page li { color: #cdd2d7; }
.page a { color: var(--accent); }
.page-updated { color: var(--muted); font-size: 12px; margin-top: -6px; }

/* ---------- guide + footer ---------- */
.guide { margin-top: 34px; color: #cdd2d7; }
.guide h3 { margin: 26px 0 8px; font-size: 15px; color: var(--text); }
.guide ul { padding-left: 20px; }
.guide p, .guide li { max-width: 68ch; }
.guide ol { padding-left: 20px; }
.guide li { margin-bottom: 8px; }
.mono { font-family: ui-monospace, Menlo, monospace; background: var(--bg-3); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.site-footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.foot-links a { color: var(--muted); }

/* ---------- desktop ---------- */
@media (min-width: 720px) {
  .dropper { grid-template-columns: 320px 1fr; align-items: start; }
  .dropper-square-wrap { align-items: flex-start; }
}
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
  /* no ads yet → give the sidebar column back to the tool */
  body:not(.ads-on) .layout { grid-template-columns: minmax(0, 1fr); }
  .ad-side {
    display: flex;
    align-self: start;
    position: sticky;
    top: 78px;
    min-height: 600px;
  }
  .ad-sticky { display: none; }
}
