:root {
  color-scheme: dark;
  --paper: #141917;
  --panel: #1b221e;
  --well: #101512;
  --line: #39463e;
  --ink: #f1f6ef;
  --muted: #b2bfb5;
  --lime: #d0f588;
  --soft-lime: #293824;
  --error: #ffb6aa;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  accent-color: var(--lime);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.symbols { position: absolute; width: 0; height: 0; }
button, input, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0 13px;
  min-height: 44px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: .875rem;
  font-weight: 650;
  cursor: pointer;
}
button:enabled:hover { background: #303e33; }
button:disabled { color: #9aa79d; cursor: default; }
button[aria-pressed="true"] { color: var(--lime); border-color: #657b4c; background: var(--soft-lime); }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
::selection { background: var(--lime); color: var(--well); }
.topbar { padding: 14px max(20px, calc((100% - 1192px) / 2)); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.identity, .header-actions { display: flex; align-items: center; gap: 12px; }
.mark svg { width: 25px; height: 25px; }
.identity h1 { margin: 0; font-size: 1.44rem; line-height: 1; letter-spacing: -.03em; }
.mark { display: grid; place-items: center; color: var(--lime); }
.product { color: var(--muted); padding-left: 11px; border-left: 1px solid var(--line); font-size: .875rem; }
main { width: min(1192px, calc(100% - 40px)); margin: 30px auto; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.workspace, .inspector { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); min-width: 0; }
.workspace-head { padding: 11px 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.workspace-head p { margin: 0; color: var(--muted); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.views { display: flex; gap: 4px; }
.views button { border-color: transparent; padding-inline: 10px; }
.stage { min-height: 240px; padding: 12px; background: var(--well); display: grid; place-items: center; }
.stage p { color: var(--muted); padding: 12px; text-align: center; }
#frame { position: relative; max-width: 100%; line-height: 0; }
#photo { display: block; width: 100%; height: 100%; }
#mask { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#cursor { position: absolute; pointer-events: none; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 1px 3px #0b110dd0; transform: translate(-50%, -50%); }
.tools { display: flex; gap: 7px; padding: 12px 14px 0; flex-wrap: wrap; }
.size { display: flex; align-items: center; gap: 12px; padding: 6px 14px 10px; color: var(--muted); font-size: .875rem; }
.size input { width: min(100%, 220px); height: 38px; margin: 0; }
.size output { min-width: 3ch; font-variant-numeric: tabular-nums; }
.inspector { padding: 20px; }
h2 { margin: 0; font-size: 1.55rem; letter-spacing: -.03em; }
p { line-height: 1.48; }
.intro { color: var(--muted); margin: 8px 0 19px; }
form { display: grid; gap: 10px; }
form label, summary { font-size: .875rem; font-weight: 650; }
textarea, input[type="password"] { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--well); color: var(--ink); padding: 11px; line-height: 1.4; caret-color: var(--lime); }
textarea { resize: vertical; min-height: 94px; }
textarea::placeholder, input::placeholder { color: #adbaaf; }
details { border-bottom: 1px solid var(--line); padding-bottom: 5px; }
summary { cursor: pointer; min-height: 44px; line-height: 44px; }
details label { display: block; margin-bottom: 6px; }
details input { margin-bottom: 7px; }
.primary { background: var(--lime); color: #192612; border-color: var(--lime); }
.primary:enabled:hover { background: #e1ffa8; }
.primary:disabled { background: #2e392b; border-color: #465647; color: #b4c1b6; }
.subtle, #status { color: var(--muted); font-size: .875rem; margin: 14px 0 0; }
#status:empty { display: none; }
#status[data-error="true"] { color: var(--error); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 820px) { main { grid-template-columns: minmax(0, 1fr) 282px; gap: 12px; } .inspector { padding: 16px; } }
@media (max-width: 690px) {
  main { width: calc(100% - 24px); grid-template-columns: minmax(0, 1fr); margin: 12px auto 24px; }
  .topbar { padding: 9px 12px; }
  .product { display: none; }
  .workspace-head { padding: 6px 9px; }
  .stage { min-height: 170px; padding: 6px; }
  .tools { padding: 8px 9px 0; gap: 5px; }
  .tools button { padding-inline: 8px; }
  .size { padding-inline: 10px; }
}
select {
  width: 100%;
  min-height: 44px;
  font: inherit;
  color: var(--ink);
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding-inline: 10px;
}

.modebar { width: min(1192px, calc(100% - 40px)); margin: 14px auto 0; display: flex; gap: 6px; }
.modebar button { border-color: transparent; background: transparent; }
.modebar button[aria-pressed="true"] { border-color: #657b4c; background: var(--soft-lime); }
main { margin-top: 14px; }
.template-head span, .template-actions label span, #template-status { color: var(--muted); font-size: .875rem; }
.template-stage { border-radius: 0 0 13px 13px; }
#template-canvas { display: block; width: min(100%, 490px, 50dvh); height: auto; }
.template-actions { display: grid; gap: 10px; }
.template-actions label { display: flex; justify-content: space-between; gap: 10px; font-size: .875rem; font-weight: 650; }
.template-actions label span { font-weight: 400; }
.template-actions input { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--well); color: var(--ink); min-height: 44px; padding: 10px; }
#template-status:empty { display: none; }
@media (max-width: 690px) {
  .modebar { width: calc(100% - 24px); margin-top: 8px; }
  .modebar button { padding-inline: 10px; }
  #template-canvas { width: min(100%, 43dvh); }
}
@media (max-width: 360px) { .header-actions { gap: 4px; } .identity { gap: 5px; } .identity h1 { font-size: 1.15rem; } }

#template-canvas { width: auto; height: auto; max-width: 100%; max-height: 63dvh; }
.grade-note { color: var(--muted); font-size: .875rem; margin: 0 0 9px; }
.template-actions input[type="range"] { padding: 0; margin: 0; }
@media (max-width: 690px) { #template-canvas { max-height: 52dvh; } }

@media (max-width: 690px) and (min-height: 540px) {
  .workspace { position: sticky; top: 0; z-index: 1; }
  .template-stage { min-height: 0; }
  #template-canvas { max-height: 29dvh; }
}
