:root {
  color-scheme: light;
  --base: #f8f7f3;
  --panel: #fcfbf8;
  --paper: #f9f8f4;
  --line: #e8e5de;
  --ink: #25241f;
  --muted: #6f6b62;
  --faint: #817c71;
  --orange: #f58239;
  --orange-ink: #9f4819;
  --orange-wash: #fbede1;
  --green: #347855;
  --red: #ae4434;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--base);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: grid; grid-template-rows: 72px minmax(0, 1fr) 34px; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .40; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, .canvas:focus-visible { outline: 2px solid #b95e2b; outline-offset: 2px; }
button, input, select { -webkit-tap-highlight-color: transparent; }
button svg, [data-icon] svg { display: block; flex: none; width: 17px; height: 17px; }
[data-icon] { display: inline-flex; align-items: center; }
button { border: 1px solid transparent; background: transparent; border-radius: 6px; }
button:not(:disabled):hover { background: #f1eee7; }
[hidden] { display: none !important; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1; }
.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand img { display: block; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 19px; font-weight: 720; letter-spacing: .035em; line-height: 1.25; }
.brand p { color: var(--muted); font-size: 11px; margin-top: 5px; letter-spacing: .085em; }
nav, .actions { display: flex; align-items: center; gap: 7px; }
nav button, .actions button, .quiet, .outline, .primary { display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; min-height: 34px; padding: 0 9px; }
nav button { color: #535048; font-size: 13px; }
.actions { gap: 4px; }
.actions button { font-size: 13px; }
.actions .history { padding: 0 8px; }
.actions .history svg { width: 16px; height: 16px; }
.separator { width: 1px; height: 21px; background: var(--line); margin: 0 5px; flex: none; }
button.primary { background: var(--orange); color: #2d1c0e; font-weight: 700; padding: 0 14px; min-height: 37px; border: 1px solid #e87831; }
button.primary:not(:disabled):hover { background: #ff944e; }
.workspace { display: grid; grid-template-columns: 88px minmax(0, 1fr) 300px; min-height: 0; }
.tools { background: var(--panel); border-right: 1px solid var(--line); min-height: 0; overflow: auto; scrollbar-width: thin; padding: 0 9px 10px; }
.tools h2 { display: grid; place-items: center; height: 47px; color: var(--faint); font-size: 12px; font-weight: 550; }
.tools button { display: flex; width: 100%; min-height: 56px; flex-direction: column; align-items: center; justify-content: center; gap: 7px; font-size: 11px; color: #57534b; margin-bottom: 4px; white-space: nowrap; }
.tools button svg { width: 19px; height: 19px; }
.tools button.is-active { background: var(--orange-wash); color: var(--orange-ink); border-color: #efd9c7; font-weight: 650; }
.tools button.accent { color: var(--orange-ink); }
.tools .tool-divider { width: calc(100% - 14px); height: 1px; margin: 9px auto; background: var(--line); }
.studio { min-width: 0; min-height: 0; display: grid; grid-template-rows: 54px minmax(0, 1fr) 38px; padding: 0 18px; }
.studio-title, .studio-title > div, .canvas-foot, .inspector-title, .inspector-foot { display: flex; align-items: center; }
.studio-title, .canvas-foot { justify-content: space-between; }
.studio-title > div { gap: 9px; overflow: hidden; }
h2 { font-size: 15px; font-weight: 700; white-space: nowrap; }
.studio-title > div > [data-icon], .inspector-title > [data-icon] { color: #5b574d; }
.title-divider { width: 1px; height: 15px; background: #ddd8cd; margin: 0 3px; flex: none; }
.document { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiet { font-size: 12px; color: #5e594e; }
.grid-toggle[aria-pressed="true"] { background: #f1eee7; border-color: #e9e4da; }
.canvas { position: relative; overflow: hidden; min-height: 0; background: var(--paper); isolation: isolate; border: 1px solid #e3dfd5; border-radius: 8px; touch-action: none; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; }
.canvas.is-dragging, .canvas[data-tool="pan"] { cursor: grab; }
.canvas.is-dragging { cursor: grabbing; }
.canvas-top { pointer-events: none; position: absolute; inset: 14px 14px auto; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.modes, .sample-tag, .zoom { pointer-events: auto; border: 1px solid #e6e1d8; border-radius: 7px; background: #fcfbf8; }
.modes { display: flex; padding: 3px; gap: 2px; flex-wrap: wrap; }
.modes button { display: flex; align-items: center; justify-content: center; min-height: 31px; padding: 0 10px; gap: 6px; font-size: 12px; color: #625c51; white-space: nowrap; }
.modes button svg { width: 15px; height: 15px; }
.modes button.is-active { color: var(--orange-ink); background: var(--orange-wash); font-weight: 700; }
.sample-tag { font-size: 11px; padding: 8px 9px; display: inline-flex; align-items: center; gap: 6px; color: #716244; white-space: nowrap; }
.sample-tag i { width: 6px; height: 6px; border-radius: 100%; background: var(--orange); }
.axis { color: #8a8070; position: absolute; bottom: 20px; left: 19px; width: 47px; height: 40px; pointer-events: none; font: 10px var(--mono); }
.axis svg { position: absolute; width: 34px; top: 8px; left: 0; }
.axis span { position: absolute; top: 0; left: 3px; }
.axis span:last-child { top: 27px; left: 36px; }
.scale { position: absolute; bottom: 23px; right: 18px; color: #776f60; text-align: center; display: grid; justify-items: center; gap: 4px; font: 10px var(--mono); pointer-events: none; }
.scale i { width: 60px; height: 6px; border: solid #9e9482; border-width: 0 1px 1px; }
.zoom { position: absolute; bottom: 17px; left: 50%; transform: translateX(-50%); height: 39px; display: flex; align-items: center; gap: 1px; padding: 3px 5px; }
.zoom button { display: grid; place-items: center; min-width: 31px; height: 30px; padding: 0 6px; color: #575147; }
.zoom .zoom-value { min-width: 53px; color: var(--ink); font: 12px var(--mono); }
.zoom .separator { margin: 0 4px; height: 18px; }
.canvas-foot { color: var(--muted); font-size: 11px; gap: 7px; white-space: nowrap; }
.canvas-foot > span { display: flex; align-items: center; gap: 7px; }
.canvas-foot svg { width: 14px; height: 14px; }
.canvas-foot b { color: #b7ab97; }
.empty { position: absolute; inset: 72px 15px 62px; display: grid; justify-items: center; align-content: center; gap: 12px; color: var(--muted); text-align: center; }
.empty > span { background: var(--orange-wash); color: var(--orange-ink); padding: 12px; border-radius: 13px; }
.empty > span svg { width: 25px; height: 25px; }
.empty strong { font-size: 18px; color: var(--ink); }
.empty p { line-height: 1.6; }
.inspector { background: var(--panel); border-left: 1px solid var(--line); display: grid; grid-template-rows: 54px minmax(0, 1fr) 38px; min-height: 0; min-width: 0; }
.inspector-title { border-bottom: 1px solid var(--line); padding: 0 16px; gap: 8px; }
.unit { margin-left: auto; font: 11px var(--mono); padding: 3px 6px; color: #706858; background: #f2efe9; border: 1px solid #eae5da; border-radius: 4px; }
.inspector-scroll { min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #ddd5c6 transparent; }
.panel { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel h3 { display: flex; align-items: center; gap: 8px; font-size: 13px; height: 19px; font-weight: 700; margin-bottom: 10px; }
.panel h3 svg { width: 15px; height: 15px; color: #766e60; }
.pattern { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pattern > div:last-child { min-width: 0; }
.thumb { display: grid; place-items: center; width: 47px; height: 42px; flex: none; border-radius: 6px; background: #f4eee3; border: 1px solid #ede5d6; }
.thumb img { display: block; width: 33px; height: 31px; object-fit: contain; }
.pattern strong, .pattern small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pattern strong { font-size: 13px; font-weight: 650; }
.pattern small { margin-top: 4px; font-size: 11px; color: var(--muted); }
.lock { display: flex; align-items: center; gap: 4px; color: var(--muted); margin-left: auto; font-size: 11px; font-weight: 500; }
.lock svg { width: 12px !important; height: 12px !important; }
.dimensions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dimensions > div { display: flex; min-width: 0; align-items: baseline; gap: 5px; border: 1px solid #e9e5dc; border-radius: 5px; padding: 7px; background: #f7f5ef; white-space: nowrap; }
.dimensions span, .dimensions small { font-size: 11px; color: var(--muted); }
.dimensions strong { margin-left: auto; font: 600 15px var(--mono); }
.panel-note { margin-top: 8px; font-size: 11px; color: var(--muted); line-height: 1.45; }
.panel-note.warn { color: var(--orange-ink); }
.stroke-controls { display: flex; align-items: center; gap: 12px; }
input[type="range"] { width: 100%; min-width: 0; margin: 0; height: 16px; appearance: none; background: transparent; cursor: pointer; --value: 50%; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 5px; background: linear-gradient(to right, var(--orange) 0 var(--value), #e9e3d9 var(--value) 100%); }
input[type="range"]::-webkit-slider-thumb { appearance: none; background: var(--orange); border: 2px solid #fff8ef; border-radius: 50%; width: 14px; height: 14px; margin-top: -5px; box-shadow: 0 0 0 1px #e58245; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 5px; background: linear-gradient(to right, var(--orange) 0 var(--value), #e9e3d9 var(--value) 100%); }
input[type="range"]::-moz-range-thumb { background: var(--orange); border: 2px solid #fff8ef; border-radius: 50%; width: 10px; height: 10px; box-shadow: 0 0 0 1px #e58245; }
.number { display: flex; align-items: center; flex: none; gap: 1px; padding: 5px 7px; border: 1px solid #e7e2d8; border-radius: 5px; background: white; }
.number input { width: 42px; background: none; border: 0; font: 13px var(--mono); padding: 0; appearance: textfield; }
.number input::-webkit-inner-spin-button { appearance: none; }
.number span, .presets button { font: 11px var(--mono); color: var(--muted); }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 8px; }
.presets button { padding: 5px 2px; border: 1px solid #e8e3d9; background: #faf8f3; }
.presets button.is-active { color: var(--orange-ink); background: var(--orange-wash); border-color: #f0d3bc; font-weight: 700; }
.range-label { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #625c51; margin-bottom: 2px; }
.range-label output { font: 11px var(--mono); color: var(--orange-ink); }
.refine input + label { margin-top: 7px; }
.sym-label { display: block; color: #625c51; font-size: 12px; margin-bottom: 5px; }
select, .form-control { width: 100%; border: 1px solid #e7e2d8; border-radius: 5px; background: #faf8f3; padding: 6px 9px; font-size: 12px; min-height: 31px; }
select { appearance: none; background: #faf8f3 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' viewBox='0 0 14 14'%3E%3Cpath d='m4 5 3 3 3-3' stroke='%236f6b62' stroke-width='1.3'/%3E%3C/svg%3E") no-repeat right 8px center; padding-right: 27px; }
.check-tag { margin-left: auto; font-size: 10px; font-weight: 650; color: var(--green); background: #eaf3e9; border-radius: 4px; padding: 3px 5px; white-space: nowrap; }
.check-tag.warn { color: var(--orange-ink); background: var(--orange-wash); }
.check-tag.fail { color: var(--red); background: #f8e8e3; }
.check-row { display: flex; align-items: center; gap: 6px; text-align: left; min-height: 23px; font-size: 11px; color: #5f5a51; padding: 2px 3px; width: 100%; }
.check-row[aria-disabled="true"] { cursor: default; }
.check-row:not(:disabled)[aria-disabled="true"]:hover { background: none; }
.check-row svg { width: 13px; height: 13px; color: var(--green); }
.check-row.warn svg { color: var(--orange-ink); }
.check-row.fail svg { color: var(--red); }
.check-row small { margin-left: auto; font-size: 10px; white-space: nowrap; }
.outline { background: #faf8f3; border-color: #e5dfd3; }
.repair { width: 100%; font-size: 12px; margin-top: 9px; }
.inspector-foot { gap: 7px; padding: 0 12px 0 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; min-width: 0; }
.inspector-foot button { margin-left: auto; min-height: 24px; }
.inspector-foot svg { width: 14px; height: 14px; }
.statusbar { background: var(--panel); border-top: 1px solid var(--line); padding: 0 17px; display: flex; align-items: center; justify-content: space-between; gap: 9px; color: #665f52; font-size: 11px; }
.statusbar > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.statusbar .separator { height: 12px; margin: 0 3px; }
#status { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4c9a6a; flex: none; }
.status-dot.fail { background: var(--red); }
.status-dot.warn { background: var(--orange); }
#status-right { font: 11px var(--mono); white-space: nowrap; }
dialog { max-width: min(500px, calc(100vw - 30px)); width: 100%; max-height: calc(100dvh - 36px); border: 1px solid #ded8cb; border-radius: 11px; background: var(--panel); padding: 0; color: var(--ink); }
dialog::backdrop { background: #30291e55; }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.dialog-head button { padding: 6px; }
.dialog-body { padding: 16px 17px; display: grid; gap: 12px; }
.dialog-body p, .dialog-body li { color: #5b5549; line-height: 1.6; }
.dialog-body ul { margin: 0; padding-left: 20px; }
.dialog-body label { display: grid; gap: 6px; }
.dialog-body small { color: var(--muted); line-height: 1.6; }
.dialog-body .option { display: flex; align-items: center; gap: 8px; }
.dialog-body input[type="radio"] { accent-color: var(--orange); }
.dialog-foot { border-bottom: 0; border-top: 1px solid var(--line); justify-content: flex-end; gap: 8px; }
.library { display: flex; align-items: center; width: 100%; text-align: left; gap: 16px; padding: 12px; background: #f8f4ea; border-color: #ede4d4; }
.library img { width: 70px; height: 58px; object-fit: contain; }
.library small { display: block; margin-top: 5px; }
.repair-preview { width: 100%; height: 150px; background: #f5f1e7; border-radius: 6px; }
#toast { position: fixed; bottom: 52px; left: 50%; transform: translateX(-50%); z-index: 8; max-width: calc(100% - 30px); padding: 10px 15px; border-radius: 7px; color: #fffaf1; background: #373128; font-size: 13px; pointer-events: none; }
@media(max-width: 1120px) {
  .topbar { padding: 0 13px; gap: 8px; }
  .actions .history span { display: none; }
  .workspace { grid-template-columns: 75px minmax(0, 1fr) 270px; }
  .studio { padding: 0 12px; }
  .panel { padding-inline: 12px; }
}
@media(max-width: 860px) {
  nav { gap: 1px; }
  nav button span { display: none; }
  nav button { font-size: 12px; padding-inline: 5px; }
  .actions .reset span, .actions .clear span { display: none; }
  .workspace { grid-template-columns: 62px minmax(0, 1fr) 233px; }
  .tools { padding-inline: 5px; }
  .studio { padding-inline: 8px; }
  .sample-tag { display: none; }
  .canvas-top { inset: 8px 8px auto; }
  .modes button { padding: 0 6px; }
  .modes button svg { display: none; }
}
@media(max-width: 680px) {
  body { height: auto; min-height: 100dvh; overflow: auto; grid-template-rows: auto 1fr 31px; }
  .topbar { flex-wrap: wrap; padding: 9px; min-height: 95px; }
  nav { order: 3; width: 100%; justify-content: center; }
  nav button { min-height: 26px; padding-inline: 10px; }
  nav button span { display: inline; }
  .actions button { padding-inline: 5px; gap: 4px; }
  .actions .separator { display: none; }
  .actions .primary { padding-inline: 6px; font-size: 11px; min-height: 31px; }
  .brand img { width: 31px; height: 31px; }
  .brand { gap: 6px; }
  h1 { font-size: 15px; }
  .brand p { font-size: 9px; }
  .workspace { grid-template-columns: 54px minmax(0, 1fr); grid-template-rows: minmax(470px, 74dvh) auto; }
  .inspector { grid-column: 1/-1; grid-template-rows: 44px auto 36px; border: 0; border-top: 1px solid var(--line); }
  .inspector-scroll { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .panel:nth-child(odd) { border-right: 1px solid var(--line); }
  .dimensions { grid-template-columns: minmax(0,1fr); gap: 4px; }
  .dimensions > div { padding-block: 4px; }
  .refine { grid-column: 1/-1; }
  .checks { grid-column: 1/-1; }
  .canvas-foot { font-size: 9px; }
  .canvas-foot > span { gap: 4px; }
  .scale, .axis { display: none; }
  #status-right { font-size: 9px; }
}
