:root {
  color-scheme: light dark;
  --bg: #eef3f6;
  --surface: #fff;
  --text: #172b3a;
  --muted: #475d6e;
  --border: #b4c5d0;
  --accent: #125789;
  --on-accent: #fff;
  --focus: #0967a4;
  --tint: #e7f2fb;
  --grid: #d3e3ef;
  --success: #17674f;
  --error: #a22035;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101921;
    --surface: #17242f;
    --text: #e9f1f7;
    --muted: #b3c5d4;
    --border: #516a7b;
    --accent: #8ccaff;
    --on-accent: #11273a;
    --focus: #a6d6ff;
    --tint: #1e3445;
    --grid: #2b495f;
    --success: #80d8b9;
    --error: #ff9aa9;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button, summary { cursor: pointer; }
a { color: var(--accent); text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, p, figure { margin: 0; }
.wrap { width: min(100% - 2rem, 72rem); margin-inline: auto; }
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.masthead, .brand, .preview-head, .range-head {
  display: flex; align-items: center; gap: .75rem;
}
.masthead { justify-content: space-between; min-height: 4rem; padding-block: .5rem; flex-wrap: wrap; }
.brand { font-weight: 680; }
.brand img { border-radius: .65rem; }
.intro { padding-block: 2rem 1.5rem; }
h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -.035em; }
.intro p { margin-top: .5rem; color: var(--muted); max-width: 48ch; }
.workspace { display: grid; grid-template-columns: minmax(15rem, 1fr) minmax(0, 2.3fr); gap: 1rem; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; padding: 1rem; min-width: 0; }
h2 { font-size: 1.25rem; line-height: 1.2; letter-spacing: -.015em; }
.drop { display: grid; justify-items: center; gap: .5rem; text-align: center; padding: 1rem .75rem; margin-top: .75rem; border: 1px dashed var(--accent); background: var(--tint); border-radius: .75rem; }
.drop.over { outline: 3px solid var(--focus); outline-offset: 2px; }
.upload-icon { width: 1.5rem; height: 1.5rem; color: var(--accent); }
.button { min-height: 44px; padding: .5rem .875rem; font-weight: 650; border: 1px solid var(--border); border-radius: .625rem; background: var(--surface); color: var(--accent); }
.button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: .16em; }
.button:active:not(:disabled) { box-shadow: inset 0 0 0 2px currentColor; }
.button[aria-pressed=true] { background: var(--tint); border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.button:disabled { color: var(--muted); opacity: .66; cursor: default; }
.button.destructive:not(:disabled) { color: var(--error); }
.meta { font-size: .8125rem; color: var(--muted); }
.formats { margin-top: .75rem; }
.selected-image { display: flex; align-items: center; gap: .375rem; margin-top: .5rem; }
.remove-image {
  flex: 0 0 44px; min-height: 44px; padding: 0; border: 0; border-radius: .5rem;
  background: transparent; color: var(--muted); font-size: 1.25rem;
}
.remove-image:hover, .remove-image:active { background: var(--tint); color: var(--error); }
.filename { font-size: .875rem; font-weight: 620; overflow-wrap: anywhere; }
.controls { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: .5rem; }
.range-head { justify-content: space-between; margin-top: .75rem; }
label, figcaption { font-size: .9375rem; font-weight: 620; }
output, .tag { color: var(--accent); font-size: .8125rem; font-variant-numeric: tabular-nums; }
input[type=range] { display: block; width: 100%; margin: 0; height: 44px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: .65rem; min-height: 44px; margin-top: .5rem; }
.check input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--accent); }
.preview-head { justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; }
.tag { padding: .2rem .55rem; background: var(--tint); border-radius: .4rem; }
.views { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
figcaption { margin-bottom: .5rem; }
.board { height: clamp(10rem, 27vw, 21rem); display: grid; place-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: .625rem; padding: .75rem; }
.input-board { background: var(--bg); }
.output-board {
  background-color: var(--tint);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 1rem 1rem;
}
.placeholder { max-width: 18ch; text-align: center; color: var(--muted); font-size: .875rem; background: var(--surface); padding: .35rem .5rem; border-radius: .375rem; }
canvas { display: block; max-width: 100%; max-height: 100%; object-fit: contain; min-width: 0; min-height: 0; }
#outline { width: 100%; height: 100%; min-height: 0; min-width: 0; }
#original[data-tool=crop], #original[data-tool=brush] { cursor: crosshair; touch-action: none; }
#outline { touch-action: none; cursor: crosshair; }
#outline[data-tool=pan] { cursor: grab; }
#outline[data-tool=pan]:active { cursor: grabbing; }
#outline-path, #selected-path { fill: none; stroke: var(--accent); stroke-width: 1.35px; stroke-linejoin: round; }
#selected-path { stroke-width: 2.5px; }
#point-handles, #selected-point { fill: none; stroke: var(--accent); stroke-width: 5px; stroke-linecap: round; }
#selected-point { stroke: var(--error); stroke-width: 9px; }
.edit-tools { display: grid; gap: .5rem; margin-top: .75rem; }
.tool-row, .editor-fields { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.tool-row .button, .editor-fields .button { padding-inline: .625rem; font-size: .875rem; }
#zoom-in, #zoom-out { min-width: 44px; }
#zoom-value { min-width: 3.4rem; text-align: center; font-variant-numeric: tabular-nums; }
.editor-fields { align-items: end; }
.editor-fields label { display: grid; gap: .25rem; min-width: 0; }
.editor-fields input {
  width: min(100%, 6rem); min-height: 44px; font-size: 1rem;
  padding-inline: .5rem; border-radius: .5rem; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.point-editor { display: grid; gap: .75rem; padding: .75rem; border: 1px solid var(--border); border-radius: .625rem; }
.edit-lock { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; background: var(--tint); padding: .75rem; margin-top: 1rem; border-radius: .625rem; }
.edit-lock p { flex: 1 1 18rem; font-size: .875rem; }
#contour-message:empty { display: none; }
.message { margin-top: .75rem; font-size: .875rem; color: var(--muted); }
.error { color: var(--error); }
.success { color: var(--success); }
.export { display: flex; justify-content: space-between; align-items: start; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.measure { flex: 1 1 12rem; min-width: 0; }
.unit { display: flex; align-items: center; gap: .5rem; margin-block: .35rem; color: var(--muted); }
.unit input { font-size: 1rem; color: var(--text); width: min(8rem, 100%); min-width: 0; min-height: 44px; padding-inline: .625rem; border-radius: .5rem; border: 1px solid var(--border); background: var(--bg); }
.unit input[aria-invalid=true] { border-color: var(--error); }
.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.primary:disabled { background: var(--tint); border-color: var(--border); color: var(--muted); cursor: default; }
.save { flex: 1 1 14rem; min-width: 0; }
.filename-input input { width: 100%; }
.filename-input { margin-bottom: .5rem; }
.save p:not(:empty) { margin-top: .35rem; }
.output-size { margin-top: .25rem; font-variant-numeric: tabular-nums; }
footer { padding-block: 1rem 2rem; color: var(--muted); font-size: .875rem; }
@media (max-width: 53rem) {
  .workspace { grid-template-columns: 1fr; }
}
@media (max-width: 28rem) {
  .views { grid-template-columns: 1fr; }
  .save, .save .button { width: 100%; }
}
@media (prefers-contrast: more) {
  :root { --border: var(--muted); }
  .button, .panel { border-width: 2px; }
}
.board { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
/* Keep light motifs visible on light systems and dark motifs visible on dark systems. */
.input-board {
  background-color: #d0dae1;
  background-image: conic-gradient(#e4ebf0 25%, transparent 0 50%, #e4ebf0 0 75%, transparent 0);
  background-size: 16px 16px;
}
