@font-face { font-family: "Unbounded"; src: url("fonts/unbounded-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("fonts/instrument-sans-latin-wght-normal.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Readex Pro"; src: url("fonts/readex-pro-arabic-wght-normal.woff2") format("woff2"); font-weight: 160 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --ground-base: #f2f3f5;
  --surface: #ffffff;
  --ink: #14151a;
  --muted: #62666f;
  --line: #dadce2;
  --tint-amount: 9%;
  --display: "Unbounded", "Instrument Sans", "Readex Pro", system-ui, sans-serif;
  --ui: "Instrument Sans", "Readex Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Readex Pro", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground-base: #111216;
    --surface: #1a1c22;
    --ink: #f0f1f4;
    --muted: #9ea3ae;
    --line: #2b2e37;
    --tint-amount: 14%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --ground-base: #111216;
    --surface: #1a1c22;
    --ink: #f0f1f4;
    --muted: #9ea3ae;
    --line: #2b2e37;
    --tint-amount: 14%;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: color-mix(in srgb, var(--tint, transparent) var(--tint-amount), var(--ground-base));
  color: var(--ink);
  font: 400 14.5px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.6s ease;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }

.bar { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; padding: 16px 20px 12px; }
.brand { margin: 0; font: 700 19px/1 var(--display); letter-spacing: -0.04em; }
.brand i { font-style: normal; color: var(--tint, var(--muted)); }
.bar-meta { color: var(--muted); font-size: 12.5px; }
.purpose { flex: 1; margin: 0; font-size: 15px; font-weight: 500; }

.split { display: grid; gap: 16px; padding: 0 20px 20px; }
.right { display: flex; flex-direction: column; gap: 16px; min-height: 0; min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font: 600 16px/1 var(--display); letter-spacing: -0.03em; }
.actions { display: flex; gap: 14px; }

.link { font: 600 12.5px/1 var(--ui); background: none; border: 0; padding: 6px 2px; color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; cursor: pointer; }
.link:hover { color: var(--ink); text-decoration-color: currentColor; }

.left { display: flex; flex-direction: column; min-height: 0; }
.left .panel-head { margin-bottom: 12px; }

/* Drop zone */
.drop {
  position: relative; display: grid; place-items: center; flex: 1; min-height: 220px; overflow: hidden;
  border: 2px dashed var(--line); border-radius: 16px; cursor: pointer; text-align: center;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  transition: border-color 0.2s, background-color 0.2s;
}
.drop:hover, .drop.over { border-color: var(--ink); }
.drop.over { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.drop:focus-within { outline: 2px solid var(--ink); outline-offset: 3px; }
.drop.has-image { border-style: solid; border-color: transparent; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.drop-text { display: grid; gap: 4px; padding: 24px; color: var(--muted); }
.drop-text strong { font: 600 18px/1.2 var(--display); letter-spacing: -0.03em; color: var(--ink); }

.count-row { display: grid; grid-template-columns: auto 1fr 2ch; align-items: center; gap: 12px; margin-top: 16px; }
.count-row label { font-weight: 600; font-size: 13px; }
.count-row output { font: 600 14px var(--mono); text-align: end; }
input[type="range"] { width: 100%; accent-color: var(--ink); }
.status { margin: 8px 0 0; min-height: 20px; color: var(--muted); font-size: 12.5px; }
.error { margin: 8px 0 0; color: #c8261d; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .error { color: #ff6b5e; } }
:root[data-theme="dark"] .error { color: #ff6b5e; }

/* Swatches: paint-chip cards */
.swatches { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: 10px; flex: 1; min-height: 240px; }
.swatch, .ghost-swatch {
  display: flex; flex-direction: column; min-width: 0; padding: 0; overflow: hidden;
  border-radius: 20px; text-align: start; font: inherit; color: inherit;
}
.ghost-swatch { border: 2px dashed var(--line); background: transparent; align-items: center; justify-content: center; color: var(--muted); font: 600 22px var(--display); opacity: 0.6; }
.swatch {
  --c: #888; --on: #fff;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.swatch:hover { transform: translateY(-4px); box-shadow: 0 18px 28px -18px color-mix(in srgb, var(--c) 80%, black); }
.chip { flex: 1; min-height: 120px; padding: 14px; background: var(--c); color: var(--on); display: flex; align-items: flex-start; }
.share { font: 700 clamp(18px, 2.2vw, 28px)/1 var(--display); letter-spacing: -0.05em; direction: ltr; unicode-bidi: isolate; }
.share small { font-size: 0.5em; margin-inline-start: 1px; opacity: 0.85; }
.info { padding: 12px 10px 14px; display: grid; gap: 8px; min-width: 0; }
.hex { font: 700 14px var(--mono); letter-spacing: -0.02em; text-transform: uppercase; direction: ltr; unicode-bidi: isolate; }
.rgb { font: 400 11px var(--mono); color: var(--muted); margin-top: -4px; direction: ltr; unicode-bidi: isolate; }
.ratios { display: grid; gap: 4px; }
.ratio { display: flex; align-items: center; gap: 5px; font: 500 11px var(--mono); color: var(--muted); white-space: nowrap; }
.ratio i { display: inline-grid; place-items: center; width: 24px; height: 18px; border-radius: 5px; font: 700 10px var(--ui); font-style: normal; background: var(--c); }
.ratio b { color: var(--ink); font-weight: 600; }

@media (prefers-reduced-motion: no-preference) {
  .swatch { animation: drop-in 0.55s cubic-bezier(0.2, 0.9, 0.25, 1) backwards; animation-delay: calc(var(--i, 0) * 70ms); }
  @keyframes drop-in { from { transform: translateY(-18px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Export */
.export { padding: 14px 18px 16px; }
.export .panel-head { margin-bottom: 8px; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tabs button { font: 600 12.5px/1 var(--ui); padding: 8px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--surface); }
.code { margin: 0; padding: 12px 14px; max-height: 168px; overflow: auto; border-radius: 12px; background: color-mix(in srgb, var(--ink) 5%, transparent); font: 400 12.5px/1.6 var(--mono); }

.toast {
  position: fixed; left: 50%; bottom: 24px; margin: 0; padding: 10px 16px; border-radius: 999px;
  background: var(--ink); color: var(--surface); font: 600 13px var(--ui);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* One screen on desktop-sized windows */
@media (min-width: 900px) and (min-height: 620px) {
  .app { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
  .split { grid-template-columns: minmax(300px, 4fr) 8fr; min-height: 0; }
}
@media (max-width: 899px), (max-height: 619px) {
  .drop { min-height: 240px; }
}
@media (max-width: 640px) {
  .bar, .split { padding-inline: 14px; }
  .purpose { flex-basis: 100%; order: 3; }
  .panel { padding: 14px; }
}

/* Questions under the tool: for people who scroll, and for search engines */
.faq { max-width: 920px; margin: 0 auto; padding: 56px 20px 64px; }
.faq h2 { margin: 0 0 20px; font: 700 22px/1.2 var(--display); letter-spacing: -0.02em; }
.faq-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px 32px; }
.faq h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.faq p { margin: 0; color: var(--muted); line-height: 1.6; }

/* Arabic page: letter spacing breaks the joins between Arabic letters. Code stays left to right. */
:lang(ar) :is(.panel-head h2, .drop-text strong, .faq h2) { letter-spacing: 0; }
.code { direction: ltr; text-align: left; }
/* The "choose an image" line is words, not code: page font and page direction, so Arabic joins up */
.code:has(.empty) { direction: inherit; text-align: start; }
.code code { font: inherit; }
.code .empty { font-family: var(--ui); }
.lang { margin-inline-start: 10px; font-weight: 600; color: var(--ink); unicode-bidi: isolate; }

/* Light/dark button (theme.js): follows the device until the visitor picks */
.theme { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-inline-start: 8px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; vertical-align: middle; }
.theme:hover { background: var(--line); }
.theme svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme .sun, .theme[data-dark="true"] .moon { display: none; }
.theme[data-dark="true"] .sun { display: block; }
