/* Grid Maker styles. Colors are tokens at the top; change them there. */
:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --text: #17171c;
  --muted: #63636f;
  --line: #e2e2e9;
  --accent: #3563f0;
  --accent-ink: #ffffff;
  --soft: #edf1ff;
  --warn-bg: #fff6e0;
  --warn-ink: #7a5300;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11;
    --panel: #18181d;
    --text: #ececf1;
    --muted: #9b9ba8;
    --line: #2b2b34;
    --accent: #7090ff;
    --accent-ink: #0b0b10;
    --soft: #1d2340;
    --warn-bg: #33290f;
    --warn-ink: #f3cf7a;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e11;
  --panel: #18181d;
  --text: #ececf1;
  --muted: #9b9ba8;
  --line: #2b2b34;
  --accent: #7090ff;
  --accent-ink: #0b0b10;
  --soft: #1d2340;
  --warn-bg: #33290f;
  --warn-ink: #f3cf7a;
  --shadow: none;
  color-scheme: dark;
}
header, main, footer {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

header { max-width: 1180px; margin: 0 auto; padding-block: 28px 8px; }
header h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
header p { margin: 4px 0 0; color: var(--muted); }

main {
  max-width: 1180px; margin: 0 auto; padding-block: 16px;
  display: grid; gap: 16px; grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  main { grid-template-columns: 310px minmax(0, 1fr); align-items: start; }
  aside { position: sticky; top: 16px; }
}
/* On phones: the "choose image" box comes first, then settings, then the picture. */
@media (max-width: 899px) {
  main > .work { display: contents; }
  #drop-section { order: -1; }
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
aside.card { padding: 18px; display: grid; gap: 18px; }
.field > .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 15px; padding: 7px 6px; border-radius: 8px; cursor: pointer; line-height: 1.25;
}
.seg button small { display: block; font-size: 11px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 20px; cursor: pointer;
}
.stepper button:disabled { opacity: .4; cursor: default; }
.stepper output { min-width: 32px; text-align: center; font-size: 18px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

input[type=range] { width: 100%; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-size: 16px; font-weight: 600; padding: 10px 16px; border-radius: 10px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { font-size: 14px; padding: 6px 12px; font-weight: 500; }

.work { display: grid; gap: 16px; min-width: 0; }
section.card { padding: 18px; min-width: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-head h2 { margin: 0; font-size: 17px; }
#result-meta { margin: 0; }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 48px 20px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--soft); }
.drop strong { display: block; font-size: 18px; margin-bottom: 4px; }
.drop p { margin: 0 0 16px; color: var(--muted); }

.editor-wrap { display: grid; gap: 12px; }
#fit { margin: 12px 0 0; }
#editor { display: block; margin: 0 auto; max-width: 100%; touch-action: none; cursor: grab; border-radius: 6px; }
#editor.dragging { cursor: grabbing; }
.editor-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor-tools label { font-size: 14px; color: var(--muted); }
.editor-tools input[type=range] { flex: 1; min-width: 140px; }

.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 12px 0 0; }

.tiles { display: grid; gap: 3px; max-width: 560px; margin: 0 auto; }
.tiles.carousel { max-width: none; gap: 8px; }
.tiles > [role="listitem"] { min-width: 0; }
.tile {
  position: relative; padding: 0; border: 0; background: var(--line); cursor: pointer; display: block; width: 100%;
}
.tile canvas { display: block; width: 100%; height: auto; }
.tile .badge {
  position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.65); color: #fff;
  font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 999px; pointer-events: none;
}
.tile .dl {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); color: #fff; font-weight: 600; font-size: 14px; opacity: 0; transition: opacity .15s;
}
.tile:hover .dl, .tile:focus-visible .dl { opacity: 1; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.howto { margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.howto ol { margin: 6px 0 0; padding-left: 20px; }
.status { min-height: 1.5em; font-size: 14px; color: var(--muted); margin: 8px 0 0; }
footer { max-width: 1180px; margin: 0 auto; padding-block: 8px 32px; color: var(--muted); font-size: 13px; }
[hidden] { display: none !important; }
footer a { color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Privacy page */
main.page { display: block; max-width: 760px; }
.prose { padding: 20px 22px; }
.prose h2 { font-size: 18px; margin: 20px 0 6px; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin: 0 0 10px; max-width: 65ch; }
.prose a { color: var(--accent); }
