* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; min-height: 100svh; padding: 24px; display: grid; place-items: center }
main { width: min(1160px,100%); aspect-ratio: 16/9; border: 1px solid #ddd; display: flex; flex-direction: column; overflow: hidden; position: relative }
header { display: flex; justify-content: space-between; align-items: center; padding: 15px 28px; border-bottom: 1px solid #e6e6e6 }
a { text-decoration: none }
header a:hover { text-decoration: underline }
.layout { display: grid; flex: 1; grid-template-columns: minmax(0,1.8fr) minmax(286px,1fr); padding: clamp(18px,3vw,38px); gap: clamp(22px,3.5vw,48px) }
.example { position: relative; border-radius: 10px; background: #e8e2d6 url(avatar-portrait.jpg) center/cover; overflow: hidden; container-type: size }
.outline { position: absolute; width: min(66cqh,66cqw); aspect-ratio: 1; top: 50%; left: 50%; transform: translate(-50%,-50%); border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 100vmax #15212c42 }
.inset { position: absolute; right: 5%; bottom: 5%; height: 20%; aspect-ratio: 1; background: url(avatar-portrait.jpg) center/auto max(100%,152%) no-repeat; border: 4px solid white; border-radius: 50%; box-shadow: 0 3px 12px #0003 }
.intro,.panel { align-self: center; min-width: 0 }
h1 { line-height: 1.04; margin: 0 0 16px }
.intro p { font-size: 20px; line-height: 1.4; margin: 0 0 28px }
button { font: inherit; font-weight: 600; background: white; color: #27425b; cursor: pointer; border: 1px solid #c4cbd1; border-radius: 7px; padding: 9px 14px; min-height: 42px }
button:hover { filter: brightness(.955) }
button:has(svg) { display: inline-flex; align-items: center; justify-content: center; gap: 8px }
button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none }
#shapes button,#reset { min-width: 44px; min-height: 44px }
#shapes button[aria-pressed=true] svg { fill: currentColor }
.primary { width: 100%; min-height: 46px }
#welcome .upload-zone { grid-column:1/-1; display:grid; justify-items:center; align-content:center; gap:10px; min-height:220px; padding:20px; text-align:center; border:1px dashed #9dbbb9; border-radius:12px; background:radial-gradient(#d5e5e2 1px, transparent 1px) center/14px 14px,#f6faf9; }
.upload-zone #choose { width:auto; padding-inline:22px; }
#welcome .upload-zone .example { width:min(100%,320px); aspect-ratio:16/10; height:auto; }
main.over .upload-zone { background:#deeee8; border-color:#276358; }
small { display: block; font-size: 14px; color: #566473 }
.intro small { margin-top: 18px }
.workspace { min-width: 0; display: grid; grid-template-rows: minmax(220px,1fr) auto auto; align-content: start; gap: 8px }
canvas { width: 100%; height: 100%; min-height: 0; background: #e8edf1; border-radius: 8px; touch-action: none }
.zoom,.source { display: flex; align-items: center; gap: 12px }
.zoom input { flex: 1; min-width: 48px }
.zoom output { min-width: 38px; font-variant-numeric: tabular-nums }
.source { justify-content: space-between; border-bottom: 1px solid #e0e5ea; padding-bottom: 14px }
#filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
#replace,#reset { white-space: nowrap; color: var(--accent); border: 0; padding-inline: 6px }
fieldset { padding: 0; margin: 16px 0; border: 0 }
legend { padding: 0; font-weight: 650; margin-bottom: 6px }
.options { display: flex; flex-wrap: wrap; gap: 6px }
.options button { font-size: 15px; padding: 7px 11px }
.options button[aria-pressed=true] { background: #eaf4ff; border-color: var(--accent); color: #00549f; box-shadow: inset 0 0 0 1px var(--accent) }
.export { border-top: 1px solid #e0e5ea; padding-top: 15px }
.export small { margin-bottom: 8px }
#error:not(:empty) { background: #fff1ea; color: #853317; margin: 0; padding: 10px 24px }
#error:empty { display: none }
#ratio-select { display:none; }
#editor.layout:not([hidden]) { background:#f6faf9; border:1px solid #9dbbb9; border-radius:12px; }
#editor .panel { min-width:0; }
#editor :is(#preview,#dimensions) { grid-area:1 / 1; }
#editor #dimensions {
  align-self:start;
  justify-self:end;
  z-index:1;
  margin:8px;
  padding:3px 7px;
  border-radius:5px;
  background:#25383ddd;
  color:white;
  font-size:12px;
  line-height:1.4;
  pointer-events:none;
}
#editor .export { display:flex; align-items:center; justify-content:space-between; gap:8px; }
main:has(.upload-zone) :is(#choose,#save) { background:#21665e; border-color:#21665e; color:white; }
#editor .options button[aria-pressed=true] { background:#e3f2ed; color:#20594f; border-color:#427e70; box-shadow:none; }
main.over { outline: 3px dashed var(--accent) }
@media(min-width:681px) {
  main:has(#editor:not([hidden])) { min-height: 580px }
}
@media(max-width:800px) {
  body { padding: 10px }
  .layout { gap: 18px; padding: 18px }
}
@media(max-width:680px) {
  body { align-items: start; padding: 0 }
  main { aspect-ratio: auto; border: 0; border-radius: 0 }
  header { padding: 12px 18px }
  .layout { grid-template-columns: 1fr }
  .example { height: clamp(170px,48vw,260px); grid-row: 2 }
  .intro p { margin-bottom: 16px; font-size: 17px }
  .workspace { grid-template-rows: clamp(160px,27svh,225px) auto auto; position: sticky; top: 0; background: white; padding-block: 5px; z-index: 1 }
  .panel h1 { font-size: 26px; margin-bottom: 4px }
  #editor { overflow: visible }
  main { overflow: visible }
  fieldset { margin: 12px 0 }
}
