/* Color Palette from Image - neutral chrome so the image's colors are the only colors on screen. */
:root, :root[data-theme="light"] {
  --bg: #f4f3f1; --panel: #ffffff; --panel-2: #f7f6f4; --line: #e2dfda; --line-2: #cfcac3;
  --text: #1f1d1b; --muted: #66625c; --faint: #9a958d;
  --accent: #2b59c3; --accent-ink: #ffffff; --accent-soft: rgba(43, 89, 195, 0.1);
  --ok: #2f7d4f; --warn: #9a6512; --bad: #b2412b;
  --check-a: #e9e6e1; --check-b: #ffffff;
  --shadow: 0 6px 20px rgba(30, 25, 20, 0.08);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141316; --panel: #1d1c20; --panel-2: #242328; --line: #2f2d33; --line-2: #403d45;
  --text: #ecebee; --muted: #a6a3ab; --faint: #75727b;
  --accent: #7ea2ff; --accent-ink: #0d1430; --accent-soft: rgba(126, 162, 255, 0.14);
  --ok: #7cc79a; --warn: #e3b25f; --bad: #ec8a78;
  --check-a: #2a292e; --check-b: #1d1c20;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
.mono, code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--accent); }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 10px; line-height: 1.3; }
h3 { font-size: 15px; margin: 16px 0 6px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; height: 52px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo svg { display: block; }
.backlink { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.backlink:hover { color: var(--text); }
.topactions { display: flex; align-items: center; gap: 10px; }
.badge-free { font-size: 12px; color: var(--ok); border: 1px solid currentColor; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; }
.intro { margin: 6px 0 18px; }
.intro p { margin: 0; max-width: 760px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.grid .panel { margin-bottom: 0; }
.grid { margin-bottom: 16px; }

.btn { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; font-weight: 600; }
.btn:hover { filter: brightness(1.06); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.ghostbtn { background: transparent; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 12px; }
.ghostbtn:hover { border-color: var(--muted); }
.iconbtn { padding: 6px 8px; display: inline-flex; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* drop zone and stage */
.drop { position: relative; border: 2px dashed var(--line-2); border-radius: 10px; min-height: 320px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 20px 20px; cursor: pointer; overflow: hidden; }
.drop.has { border-style: solid; border-color: var(--line); cursor: crosshair; background: var(--panel-2); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.dropempty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 30px 16px; color: var(--muted); background: var(--panel); border-radius: 10px; margin: 20px; }
.dropempty strong { color: var(--text); font-size: 17px; }
.stagewrap { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
#stage { display: block; max-width: 100%; max-height: 62vh; height: auto; width: auto; }
.markers { position: absolute; inset: 0; pointer-events: none; }
.marker { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.4); font: 600 10px/16px system-ui, sans-serif; text-align: center; }
.stagebar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.segbtn { background: transparent; border: 0; padding: 6px 12px; font-size: 13px; }
.segbtn.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.filename { margin-left: auto; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.chip { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line-2); display: inline-block; }
.tip { margin: 8px 0 0; }
.samples { margin-top: 14px; }
.samplelist { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.sample { border: 1px solid var(--line-2); border-radius: 8px; padding: 0; background: none; overflow: hidden; width: 120px; text-align: left; }
.sample canvas { display: block; width: 120px; height: 80px; }
.sample span { display: block; padding: 4px 8px; font-size: 12px; color: var(--muted); }
.sample:hover, .sample.on { border-color: var(--accent); }

/* controls */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.lbl { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.lbl output { font-weight: 400; color: var(--muted); }
select, input[type="text"] { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; max-width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* result */
.resulthead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.resulthead h2 { margin: 0; }
.strip { display: flex; height: 110px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.stripcell { flex: 1 1 0; border: 0; padding: 8px; display: flex; align-items: flex-end; justify-content: center; font: 600 12px ui-monospace, Menlo, monospace; min-width: 0; }
.stripcell:hover { filter: brightness(1.05); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 14px 0 10px; }
.card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel-2); display: flex; flex-direction: column; }
.cardswatch { height: 74px; border: 0; width: 100%; display: flex; align-items: flex-start; justify-content: space-between; padding: 6px 8px; font-size: 12px; font-weight: 600; }
.cardbody { padding: 8px 10px 10px; font-size: 13px; }
.cardbody .hex { font: 600 15px ui-monospace, Menlo, monospace; display: flex; justify-content: space-between; align-items: center; }
.cardbody .kv { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); }
.cardbody .kv b { color: var(--text); font-weight: 500; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.copybit { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: right; }
.copybit:hover { color: var(--accent); }
.cardtools { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.cardtools input[type="color"] { width: 32px; height: 26px; padding: 0; border: 1px solid var(--line-2); border-radius: 6px; background: none; }
.cardtools .rm { margin-left: auto; background: none; border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--muted); }
.share { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.share i { display: block; height: 100%; background: var(--muted); }

/* contrast */
.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.pair { border-radius: 10px; padding: 12px; border: 1px solid var(--line); }
.pair .big { font-size: 20px; font-weight: 700; line-height: 1.2; }
.pair .meta { display: flex; justify-content: space-between; font-size: 12px; margin-top: 6px; font-family: ui-monospace, Menlo, monospace; }
.gradepill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: rgba(0,0,0,.25); color: #fff; }
.matrixbox { margin-top: 14px; }
.matrixbox summary { cursor: pointer; font-weight: 600; }
.matrixwrap { overflow-x: auto; margin-top: 10px; }
.matrix { border-collapse: collapse; font: 12px ui-monospace, Menlo, monospace; }
.matrix th, .matrix td { padding: 6px 8px; border: 1px solid var(--line); text-align: center; white-space: nowrap; }
.matrix .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; margin-right: 4px; border: 1px solid var(--line-2); }
.g-AAA { color: var(--ok); font-weight: 700; } .g-AA { color: var(--ok); } .g-AALarge { color: var(--warn); } .g-Fail { color: var(--faint); }
.empty { color: var(--muted); font-style: italic; }

/* export */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.exportopts { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 13px; line-height: 1.5; overflow: auto; max-height: 340px; white-space: pre; margin: 0 0 10px; }

/* previews */
.previews { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.chartbox svg { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 10px; }
.uicard { border-radius: 12px; padding: 20px; border: 1px solid var(--line); }
.uicard h4 { margin: 0 0 6px; font-size: 20px; }
.uicard p { margin: 0 0 14px; }
.uicard .cta { border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; }
.uicard .tag { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; margin-right: 6px; }

.faq p, .faq li { max-width: 820px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 0 16px 30px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .previews { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 23px; }
}
@media (max-width: 520px) {
  .badge-free { display: none; }
  .brand strong { font-size: 14px; }
  .drop { min-height: 220px; }
  .strip { height: 80px; }
  .stripcell { font-size: 0; }
  .swatches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sample { width: calc(50% - 5px); }
  .sample canvas { width: 100%; height: auto; aspect-ratio: 3 / 2; }
  .filename { margin-left: 0; }
}
