/* Layout: one narrow column, one thing at a time. Empty = a single upload target; done = the code
   itself on a white card, with download as the only strong action. Monochrome, like the code. */
:root {
  --bg: #f4f5f6;
  --card: #ffffff;
  --ink: #111315;
  --muted: #6b7177;
  --line: #e2e4e7;
  --hover: #eceef0;
  --ok: #1d7a46;
  --bad: #b3261e;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1011; --card: #1a1c1e; --ink: #eef0f2; --muted: #9298a0; --line: #2c2f33; --hover: #24272a;
    --ok: #6fd39c; --bad: #ff8a80; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1011; --card: #1a1c1e; --ink: #eef0f2; --muted: #9298a0; --line: #2c2f33; --hover: #24272a;
  --ok: #6fd39c; --bad: #ff8a80; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 48px 64px;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 440px; margin: 0 auto; display: grid; gap: 24px; }
h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: 0.01em; text-align: center; text-wrap: balance; }

/* Empty state: one upload target */
.drop {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  aspect-ratio: 1; max-width: 100%; display: grid; place-items: center; align-content: center; gap: 14px;
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.drop:hover { background: var(--hover); }
.drop.over { border-color: var(--ink); transform: scale(1.01); }
.drop:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.drop svg { width: 44px; height: 44px; color: var(--muted); }
.drop b { font-size: 16px; font-weight: 600; }
.drop span { color: var(--muted); font-size: 13.5px; }
.drop .err { color: var(--bad); max-width: 30ch; }

/* Done state: the code on a card */
.out { display: grid; gap: 16px; }
/* No padding or rounding of its own: the preview shows the SVG file exactly as downloaded.
   The SVG's rounded white background is the card, so the shadow is drawn around its shape. */
.code { aspect-ratio: 1; max-width: 100%; cursor: pointer; transition: opacity .15s; }
.code:hover { opacity: .85; }
.code:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.code svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.06)) drop-shadow(0 8px 20px rgba(0,0,0,.08)); }

/* One clear action (download), copy as a narrower companion, starting over as a quiet text link. */
.actions { display: flex; gap: 10px; }
.actions .primary { flex: 1; }
.actions #copy { padding: 0 20px; }
button {
  font: inherit; font-size: 15px; font-weight: 500; height: 44px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); transition: background .15s;
}
button:hover:not(:disabled) { background: var(--hover); }
#again {
  justify-self: center; display: inline-flex; align-items: center; gap: 6px;
  height: auto; padding: 4px 8px; border: 0; background: none; color: var(--muted); font-size: 14px;
}
#again:hover:not(:disabled) { background: none; color: var(--ink); }
#again svg { width: 15px; height: 15px; }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--card); }
button.primary:hover:not(:disabled) { background: var(--ink); opacity: .88; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.note { min-height: 1.4em; font-size: 13px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.note.bad { color: var(--bad); }

/* Several results: a two-column grid; each tile downloads its own file. */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tile { margin: 0; display: grid; gap: 6px; min-width: 0; }
.tile-code {
  display: block; width: 100%; height: auto; aspect-ratio: 1; padding: 0; border: 0; border-radius: 0;
  background: none; cursor: pointer;
}
.tile-code:hover:not(:disabled) { background: none; opacity: .85; }
.tile-code svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.06)) drop-shadow(0 4px 10px rgba(0,0,0,.07)); }
.tile.failed .tile-code { display: grid; place-items: center; background: var(--card); box-shadow: none; border: 1px dashed var(--line); color: var(--bad); font-size: 13px; cursor: default; }
.tile figcaption { font-size: 12.5px; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
