/* Small, dependency-free stylesheet. Page weight is a feature here —
   these tools compete on being instant. */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --ink: #15181c;
  --ink-2: #5b646e;
  --rule: #e2e6ea;
  --accent: #1c6b5a;
  --accent-soft: #e3f0ec;
  --error: #9b2c3a;
  --ok: #1c6b5a;
  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101315;
    --surface: #171b1e;
    --ink: #e9edf0;
    --ink-2: #9aa5ae;
    --rule: #262c31;
    --accent: #5cc0a8;
    --accent-soft: #16302a;
    --error: #e88f9c;
    --ok: #5cc0a8;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

header.site {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule); background: var(--surface);
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
header.site nav { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .92rem; }
header.site nav a { color: var(--ink-2); text-decoration: none; }
header.site nav a:hover { color: var(--accent); }

main { max-width: 880px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

h1 { font-size: clamp(1.6rem, 4vw, 2.15rem); line-height: 1.15; margin: .2rem 0 .5rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 2rem 0 .6rem; letter-spacing: -.01em; }
h2 a { text-decoration: none; }
.lede { color: var(--ink-2); margin: 0 0 1.5rem; max-width: 62ch; }
.muted { color: var(--ink-2); }

.crumbs { font-size: .85rem; color: var(--ink-2); margin-bottom: .75rem; }
.crumbs a { color: var(--ink-2); }

/* ---- tool shell ---- */
.tool {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

textarea.io {
  width: 100%; min-height: 190px; resize: vertical;
  font-family: var(--mono); font-size: .85rem; line-height: 1.5;
  padding: .75rem; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--bg); color: var(--ink);
}
textarea.io.tall { min-height: 260px; }
textarea.io[readonly] { background: var(--accent-soft); }

pre.out {
  margin: 0; padding: .75rem; overflow-x: auto;
  font-family: var(--mono); font-size: .82rem;
  background: var(--accent-soft); border-radius: 8px; min-height: 3rem;
}

.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.controls { padding-top: .25rem; }

.btn {
  font: inherit; font-size: .9rem; font-weight: 550;
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }

.lbl { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--ink-2); }
.lbl.inline { gap: .35rem; }
.field {
  font: inherit; font-size: .88rem; padding: .35rem .5rem; width: 6.5rem;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--bg); color: var(--ink);
}
.range { width: 9rem; }
.range-val { font-family: var(--mono); font-size: .8rem; color: var(--ink-2); min-width: 3ch; }

.status { margin: 0; font-size: .85rem; color: var(--ink-2); }
.status.ok { color: var(--ok); }
.status.error { color: var(--error); }

.hidden { display: none !important; }

/* ---- image drop zone ---- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .3rem; padding: 2.25rem 1rem; cursor: pointer; text-align: center;
  border: 2px dashed var(--rule); border-radius: var(--radius);
  background: var(--bg); color: var(--ink-2); font-size: .9rem;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { color: var(--ink); font-size: 1rem; }

.preview:empty { display: none; }
.preview img {
  max-width: 100%; max-height: 460px; border-radius: 8px;
  border: 1px solid var(--rule); display: block; margin: 0 auto;
  /* Checkerboard so transparency is visible rather than guessed at. */
  background-image:
    linear-gradient(45deg, var(--rule) 25%, transparent 25%),
    linear-gradient(-45deg, var(--rule) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--rule) 75%),
    linear-gradient(-45deg, transparent 75%, var(--rule) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ---- cards ---- */
.cards {
  display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  display: flex; flex-direction: column; gap: .2rem;
  padding: .85rem 1rem; text-decoration: none;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-title { font-weight: 600; color: var(--ink); font-size: .95rem; }
.card-blurb { font-size: .82rem; color: var(--ink-2); line-height: 1.45; }

.explain { margin-top: 2.25rem; }
.explain p { color: var(--ink-2); max-width: 68ch; font-size: .95rem; }

.faq { margin-top: 2rem; }
.faq details {
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface); margin-bottom: .5rem;
}
.faq summary {
  cursor: pointer; padding: .7rem .9rem;
  font-weight: 550; font-size: .93rem; list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "＋"; margin-right: .5rem; color: var(--accent); }
.faq details[open] summary::before { content: "－"; }
.faq details p {
  margin: 0; padding: 0 .9rem .85rem 2rem;
  color: var(--ink-2); font-size: .92rem; max-width: 68ch;
}

.swatch {
  width: 2.2rem; height: 1.9rem; padding: 2px; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--bg);
}
.hint { font-size: .78rem; color: var(--ink-2); }

footer.site {
  border-top: 1px solid var(--rule); background: var(--surface);
  padding: 1.75rem 1.25rem; font-size: .88rem;
}
footer.site p { max-width: 70ch; margin: 0 auto .5rem; color: var(--ink-2); }
footer.site strong { color: var(--ink); }
