:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: #eaeae4; }
[hidden] { display: none !important; }
h1, h2, p, figure { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid #508fff; outline-offset: 3px; }
svg { width: 18px; height: 18px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.app {
  --paper: #f8f9f6; --ink: #20241e; --muted: #5d665a; --line: #dce1d8;
  --control: #edf0ea; --accent: #294b35; --on-accent: #fff; --selected: #dceadd;
  background: var(--paper); color: var(--ink); min-height: 100svh;
}
.app-head {
  height: 84px; padding: 0 clamp(24px, 4vw, 64px); display: flex; align-items: center;
  justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 11px; color: var(--on-accent); background: var(--accent); flex: none; }
.mark svg { width: 23px; height: 23px; }
.brand h1 { font-size: 23px; font-weight: 760; letter-spacing: -.06em; white-space: nowrap; }
.head-actions, .actions, .seg { display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px;
  padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper);
  color: var(--ink); white-space: nowrap; font-size: 13px; font-weight: 610; transition: transform 150ms ease-out;
}
.btn:active, .choice:active { transform: scale(.97); }
.btn:hover { background: var(--control); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { opacity: .88; }
.btn[aria-pressed=true] { background: var(--selected); border-color: transparent; }
.btn.icon-only { width: 40px; padding: 0; }
.btn.text { padding-inline: 5px; color: var(--muted); border-color: transparent; background: transparent; }
.btn.text:hover { color: var(--ink); }
.seg { gap: 3px; padding: 3px; border-radius: 9px; background: var(--control); width: fit-content; }
.choice {
  flex: 1; min-height: 33px; padding: 0 12px; color: var(--muted); border: 1px solid transparent;
  background: transparent; border-radius: 6px; white-space: nowrap; font-weight: 640; font-size: 13px;
  transition: transform 150ms ease-out;
}
.choice:hover { color: var(--ink); }
.choice[aria-pressed=true] { color: var(--ink); border-color: var(--line); background: var(--paper); }
.field { display: grid; gap: 10px; min-width: 0; }
.field label, .control-label { font-size: 13px; font-weight: 650; }
.range-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.range-label output, .numbers { font-variant-numeric: tabular-nums; }
.range-label output { font-size: 12px; color: var(--muted); }
input[type=range] { appearance: none; width: 100%; margin: 0; background: transparent; cursor: pointer; height: 22px; }
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px; background: linear-gradient(to right,var(--accent) var(--fill),var(--line) var(--fill));
}
input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; margin-top: -5px;
  border: 1px solid var(--accent); border-radius: 50%; background: var(--accent);
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: var(--accent); }
.btn:disabled { opacity: .43; cursor: default; }
.image-wrap { position: relative; width: 100%; min-width: 0; }
canvas { display: block; width: 100%; background: #e5e8e3; }
canvas[data-edit=true] { cursor: crosshair; touch-action: none; }
.brush-bar {
  position: absolute; z-index: 1; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px; padding: 4px; border-radius: 10px;
  background: var(--paper); box-shadow: 0 5px 25px #0003; white-space: nowrap;
}
.brush-bar .btn { min-height: 34px; padding-inline: 9px; }
.filename { display: flex; align-items: center; gap: 7px; min-width: 0; }
.filename [data-filename] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 38vw; }
.filename svg, .btn svg { width: 16px; height: 16px; }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #598466; }
.subtle { font-size: 12px; line-height: 1.6; color: var(--muted); }
.status {
  position: fixed; z-index: 5; top: 93px; left: 50%; translate: -50% 0;
  width: max-content; max-width: calc(100% - 32px); background: #171a18; color: #fff;
  border: 1px solid #ffffff24; border-radius: 10px; padding: 12px 16px; font-size: 13px;
}
.workbody { min-height: calc(100svh - 84px); display: grid; grid-template-columns: minmax(0,1fr) 335px; }
.workstage {
  display: flex; flex-direction: column; gap: 16px; padding: 24px 30px;
  background-color: #e9ede7; background-image: radial-gradient(#a8b2a5 1px, transparent 1px);
  background-size: 18px 18px;
}
.worktop, .workfoot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.worktop .filename { padding: 7px 10px; border-radius: 7px; background: #f8f9f6; font-size: 12px; }
.workstage .main-image { display: grid; align-items: center; justify-items: center; flex: 1; }
.workstage .image-wrap {
  max-width: 100%;
  box-shadow: 0 14px 44px #15201828, 0 0 0 1px #2832251c;
}
.workfoot span { padding: 3px 7px; background: #eeF1eb; border-radius: 4px; }
.inspector { display: flex; flex-direction: column; padding: 27px 24px; border-left: 1px solid var(--line); }
.inspector-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.inspector h2 { font-size: 20px; letter-spacing: -.035em; }
.inspector section { padding: 24px 0; border-bottom: 1px solid var(--line); display: grid; gap: 18px; }
.inspector .seg { width: 100%; }
.subject-card { display: grid; grid-template-columns: 42px minmax(0,1fr); align-items: center; column-gap: 11px; }
.subject-card .subject-icon { grid-row: span 2; display: grid; place-items: center; height: 42px; background: var(--selected); color: var(--accent); border-radius: 8px; }
.subject-card strong { font-size: 14px; }
.inspector .refine { width: 100%; }
.editor-footer { display: flex; gap: 11px; align-items: center; flex-wrap: wrap; }
.editor-footer > span:first-child { display: flex; align-items: center; gap: 7px; margin-right: auto; }
.editor-footer a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.inspector .editor-footer { margin-top: auto; padding-top: 22px; }
.mobile .editor-footer { margin-top: 9px; font-size: 11px; }


dialog {
  width: min(440px, calc(100vw - 32px)); padding: 24px; border-radius: 16px; border: 1px solid #e5e6e1;
  background: #fbfcf9; color: #222823; box-shadow: 0 18px 70px #0003;
  --paper: #fbfcf9; --ink: #222823; --control: #edf0ec; --muted: #535c53; --line: #dce0da;
  --accent: #294b35; --on-accent: #fff; --selected: #dceadd;
}
dialog::backdrop { background: #17202280; }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
dialog h2 { font-size: 21px; letter-spacing: -.04em; }
dialog p { margin: 12px 0 20px; }
.dialog-actions .btn { flex: 1; }

.layout-controls { display: grid; gap: 12px; }
.layout-row { display: grid; grid-template-columns: 48px minmax(0,1fr); align-items: center; gap: 6px; }
.layout-row .seg { width: 100%; }
.layout-row .choice { padding-inline: 6px; }
.stepper {
  display: grid; grid-template-columns: 38px minmax(0,1fr) 38px; padding: 3px;
  background: var(--control); border-radius: 9px; align-items: stretch;
}
.stepper button {
  min-height: 33px; font-size: 19px; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); background: var(--paper);
}
.stepper button:active { transform: scale(.96); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper output { display: grid; place-items: center; font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 650; }
.workstage .image-wrap { width: min(100%, 720px, max(150px, calc((100svh - 220px) * var(--photo-ratio, 1)))); }

.mobile {
  --paper: #f8f9f6; --ink: #20271f; --line: #d9e1d6; --control: #eaf0e8;
  --accent: #294b35; --on-accent: #fff; --selected: #deeadf;
  display: flex; flex-direction: column;
  min-height: 100svh;
}
.mobile .app-head {
  height: auto; min-height: 66px; padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  gap: 10px;
}
.mobile .brand { gap: 8px; }
.mobile .brand .mark { width: 34px; height: 34px; border-radius: 9px; }
.mobile .brand .mark svg { width: 20px; height: 20px; }
.mobile .brand h1 { font-size: 21px; }
.mobile .head-actions { gap: 6px; }
.mobile .head-actions .btn { min-height: 42px; padding-inline: 10px; font-size: 12px; }
.mobile .head-actions .btn svg { width: 14px; height: 14px; }
.mobile .workbody { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #e9ede7; }
.mobile .workstage {
  flex: 1; min-height: 240px; padding: 10px 16px 18px; gap: 10px;
  background-image: radial-gradient(#abb5a9 .8px, transparent .8px); background-size: 16px 16px;
}
.mobile .worktop .filename { padding: 6px 8px; background: #f8f9f6; }
.mobile .worktop .btn { min-height: 40px; padding-inline: 11px; }
.mobile .workstage .image-wrap {
  width: min(100%, 500px, max(170px, calc((100svh - 397px) * var(--photo-ratio, 1))));
  box-shadow: 0 10px 38px #2438262a, 0 0 0 1px #17221724;
}
.mobile-tools {
  position: relative; background: var(--paper); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 6px 16px max(16px, env(safe-area-inset-bottom)); box-shadow: 0 -4px 18px #253e2410;
}
.tool-head { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.tool-switch { display: flex; gap: 17px; }
.tool-switch button {
  min-height: 44px; padding: 0 4px; border: 0; border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 650;
}
.tool-switch button[aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
.tool-switch svg { width: 16px; height: 16px; }
.tool-head .btn { min-height: 44px; }
.tool-panel { display: grid; align-content: start; min-height: 177px; gap: 12px; padding-top: 12px; }
.mobile .layout-controls { gap: 8px; }
.mobile .layout-row { grid-template-columns: 48px minmax(0,1fr); gap: 8px; }
.mobile .layout-row .choice { min-height: 40px; }
.mobile .stepper { grid-template-columns: 44px minmax(0,1fr) 44px; }
.mobile .stepper button { min-height: 40px; }
.tool-sliders { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 19px; }
.tool-sliders .field { gap: 0; }
.tool-sliders input { height: 33px; }
.tool-sliders input::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -7px; }
.mobile-brush { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.mobile-brush .btn { min-height: 44px; flex: 1; }
.mobile-brush .icon-only { min-width: 44px; }
.mask-instruction { margin-top: -4px; }
@media (max-width: 950px) {
  .app:not(.mobile) .workbody { grid-template-columns: minmax(0,1fr) 285px; }
  .app:not(.mobile) .workstage { padding: 18px; }
  .inspector { padding-inline: 18px; }
}
@media (max-width: 375px) {
  .mobile .head-actions .btn svg { display: none; }
  .mobile .app-head { padding-inline: 12px; }
  .mobile .workstage, .mobile-tools { padding-inline: 12px; }
}
@media (max-width: 700px) {
  .status { top: 76px; bottom: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .choice { transition: none; }
}
