:root {
  color-scheme: light;
  font: 16px/1.35 system-ui, -apple-system, sans-serif;
  --ink: #172d38;
  --quiet: #52686e;
  --cream: #fff8ea;
  --line: #dfded2;
  --green: #20564c;
  --mint: #e3f1e9;
  --gold: #ffce76;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--cream); color: var(--ink); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; font-weight: 700; min-height: 44px; touch-action: manipulation; }
button:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 3px solid #b84545; outline-offset: 3px; }
h1, h2, p { margin: 0; }
.masthead, main { max-width: 900px; margin: 0 auto; padding: 0 16px; }
.masthead { display: flex; align-items: center; justify-content: space-between; min-height: 65px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 1.27rem; font-weight: 850; }
.mark { display: grid; place-items: center; background: var(--green); color: var(--gold); border-radius: 12px; width: 40px; height: 40px; font-size: 1.22rem; }
.quiet, .tools button { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 8px 12px; }
.primary { background: var(--green); color: #fff; padding: 10px 15px; border-radius: 13px; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 12px; padding: 16px; margin: 6px 0 21px; background: var(--mint); border: 1px solid #c8ddd0; border-radius: 19px; }
.intro h1 { font-size: clamp(1.55rem, 5.4vw, 2.4rem); line-height: 1.08; }
.intro p { color: var(--quiet); margin-top: 7px; }
.intro button { flex: none; }
h2 { font-size: 1.2rem; margin: 0 0 9px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 7px 5px 9px; overflow: hidden; }
.card svg { display: block; width: 100%; height: auto; aspect-ratio: 1.2; margin: 0 auto 4px; background: #fff; }
.card span { display: block; font-size: .88rem; }
.pack { margin-top: 23px; }
.byline { color: var(--quiet); margin: -5px 0 9px; font-size: .9rem; }
#library { padding-bottom: 25px; }
.studio-heading { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin: 2px 0 9px; }
.studio-heading h1 { font-size: 1.12rem; line-height: 1.1; text-align: center; overflow-wrap: anywhere; }
.studio-heading button { padding-inline: 9px; font-size: .87rem; }
.paper { max-width: min(100%, 540px, 100vh - 285px); min-width: min(100%, 215px); margin: 0 auto; background: white; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.colours, .tools { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin: 9px auto 0; }
.colours { max-width: 430px; }
.swatch { border-radius: 50%; width: 44px; height: 44px; border: 1px solid #a29a8e; box-shadow: inset 0 0 0 3px white; padding: 0; position: relative; }
.swatch[aria-pressed="true"] { border: 3px solid var(--ink); }
.swatch[aria-pressed="true"]::after { content: '✓'; color: white; text-shadow: 0 1px 3px #111, 0 0 3px #111; }
.tools button { padding: 6px 11px; }
.tools button[aria-pressed="true"] { background: var(--mint); border-color: var(--green); color: var(--green); }
.hint { margin: 8px 0 12px; text-align: center; color: var(--quiet); font-size: .88rem; }
dialog { width: min(420px, calc(100% - 36px)); max-height: calc(100% - 28px); border: 1px solid var(--line); border-radius: 20px; padding: 20px; color: var(--ink); }
dialog::backdrop { background: #182b38a8; }
dialog p { margin-bottom: 12px; }
dialog .small { color: var(--quiet); font-size: .92rem; }
dialog label { display: block; font-weight: 650; }
dialog input:not([type="file"]) { min-height: 44px; width: 100%; padding: 6px 12px; border: 1px solid #747e7d; border-radius: 10px; }
#gate-error { color: #a13531; margin: 7px 0 0; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#notice { position: fixed; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 5; width: max-content; max-width: calc(100% - 32px); border-radius: 12px; background: var(--ink); color: #fff; padding: 10px 14px; font-weight: 650; }
@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .intro { align-items: start; flex-direction: column; }
}
@media (max-width: 355px) {
  .masthead, main { padding-inline: 10px; }
  .tools button { padding-inline: 8px; }
}
