:root {
  color: #243333;
  background: #f3f6f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  font-synthesis: none;
  --accent: #137b70;
  --muted: #71807f;
  --border: #e2e9e7;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: -.7px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
p { color: var(--muted); line-height: 1.7; }
button, input, select { font: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 13px;
  background: #fff; color: #344644; cursor: pointer; text-decoration: none;
  font-weight: 500; line-height: 1.4; transition: background .15s, border-color .15s;
}
button:hover, .button:hover { background: #f0f6f4; border-color: #b6cdc7; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #8bc7bc; outline-offset: 3px;
}
.primary { background: var(--accent); color: white; border-color: var(--accent); }
.primary:hover { background: #0e665d; color: white; border-color: #0e665d; }
.secondary { background: #f6faf9; border-color: #d5e4df; color: #245a50; }
.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.full { width: 100%; }
label { display: block; margin: 10px 0 6px; font-size: 13px; color: #536662; }
input:not([type=color]):not([type=file]), select {
  width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #dce5e1; border-radius: 7px;
  background: white; color: #344644; margin-top: 5px;
}
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.topbar { max-width: 1440px; margin: auto; padding: 22px 36px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 19px; font-weight: 700; color: #1b4b43; text-decoration: none; letter-spacing: -.5px; }
.brand span { vertical-align: middle; margin-left: 10px; font-size: 11px; font-weight: 500; color: #568277; background: #e4eeea; border-radius: 4px; padding: 3px 6px; }
.account { display: flex; gap: 15px; align-items: center; color: #60716d; font-size: 13px; }
.workspace { max-width: 1440px; margin: auto; padding: 10px 36px 48px; display: grid; gap: 20px; }
.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-heading { padding: 6px 0 8px; }
.page-heading p { margin-top: 8px; }
.section-heading p { margin-top: 5px; font-size: 12px; }
.quota { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: #60716d; }
.quota span { background: #e9efec; border-radius: 6px; padding: 7px 10px; white-space: nowrap; }
.quota b { color: #215c4e; font-weight: 650; }
.upload-actions { display: flex; gap: 9px; flex-shrink: 0; }
.upload-actions label { margin: 0; font-size: 14px; }
.file-hint { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; color: #899591; margin-top: 14px; }
.file-hint span { overflow-wrap: anywhere; }
.library { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 8px; margin-top: 12px; }
.empty-library { padding: 17px 0; font-size: 13px; }
.asset { width: 112px; flex: 0 0 112px; }
.asset button { width: 100%; padding: 0; border-radius: 8px; overflow: hidden; display: block; text-align: left; border: 2px solid transparent; background: #f4f7f6; }
.asset button.selected { border-color: var(--accent); background: #edf8f3; }
.asset img { display: block; width: 100%; height: 74px; object-fit: contain; background: #f5f7f6; }
.asset .asset-name { display: block; font-size: 11px; padding: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
.tools { padding: 20px; }
.tool-nav { display: grid; gap: 5px; margin: 15px -6px 0; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.tool-nav button { display: block; text-align: left; padding: 11px 13px; background: transparent; border-color: transparent; }
.tool-nav button span { display: block; font-size: 14px; font-weight: 600; }
.tool-nav button small { display: block; color: #83938e; font-size: 11px; margin-top: 4px; font-weight: 400; }
.tool-nav em, .full i { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; font-style: normal; }
.source-legend { display: grid; gap: 6px; margin-top: 8px; font-size: 11px; line-height: 1.5; }
.source-legend span { display: flex; align-items: center; gap: 6px; }
.own, .aidge { display: inline-flex; align-items: center; border-radius: 4px; padding: 1px 5px; font-size: 10px; font-weight: 650; line-height: 1.6; white-space: nowrap; }
.own { color: #1d6b57; background: #e7f5ef; }
.aidge { color: #8a5414; background: #fff1dc; }
button.full { flex-direction: column; align-items: flex-start; gap: 6px; white-space: normal; text-align: left; }
button.full em { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; font-style: normal; }
button.full i { margin: 0; }
.tool-nav button[aria-pressed=true] { background: #eaf5f0; border-color: #d1e9df; color: #116a58; }
.tool-nav button[aria-pressed=true] small { color: #628e7c; }
.tool-panel { padding-top: 20px; }
.tool-panel > p { font-size: 12px; margin: 9px 0 15px; }
.tool-panel .step-hint { font-size: 11px; margin: 9px 0 14px; color: #84918b; }
.size-fields { display: flex; align-items: center; gap: 8px; margin: 0 0 15px; }
.size-fields label { flex: 1; min-width: 0; font-size: 11px; }
.size-fields > span { color: #9aaba3; margin-top: 22px; }
.color-field { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 12px; }
input[type=color] { width: 42px; height: 36px; padding: 0; border: none; background: none; cursor: pointer; flex-shrink: 0; }
.swatches { display: flex; gap: 10px; margin: 13px 0 18px; }
.swatch { width: 25px; height: 25px; padding: 0; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 0 1px #dbe4df; }
.swatch:hover { box-shadow: 0 0 0 2px #719f8d; }
.swatch[aria-pressed=true] { box-shadow: 0 0 0 2px var(--accent); }
.green, .green:hover { background: #22b557; } .blue, .blue:hover { background: #3972db; }
.red, .red:hover { background: #d94a4a; } .yellow, .yellow:hover { background: #e9b844; }
.black, .black:hover { background: #252a32; } .white, .white:hover { background: #fff; }
.drawing-modes, .drawing-actions { display: flex; gap: 6px; }
.drawing-modes button, .drawing-actions button { padding: 7px 9px; font-size: 12px; }
.drawing-modes [aria-pressed=true] { background: #eaf5f0; border-color: #a2cbbb; color: #1b6951; }
.piece-preview { height: 120px; background: #f5f8f6; border-radius: 8px; margin: 12px 0 18px; display: grid; place-items: center; overflow: hidden; color: #89958f; font-size: 12px; }
.piece-preview img { width: 100%; height: 120px; object-fit: contain; }
.divider { display: flex; gap: 10px; align-items: center; font-size: 11px; color: #8b9890; margin: 22px 0 12px; }
.divider:before, .divider:after { content: ""; height: 1px; flex: 1; background: var(--border); }
#blocks { max-height: 340px; overflow-y: auto; }
#blocks label { font-size: 12px; line-height: 1.6; padding-bottom: 10px; }
#blocks small { display: block; color: #8a6a32; font-size: 11px; }
#translate-render { margin-top: 12px; }
.comparison { min-width: 0; padding: 22px; }
.compare-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 25px; }
.compare-column { min-width: 0; }
.preview-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 11px; }
.preview-heading span { color: #8a9791; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 65%; }
.image-stage { height: 390px; border: 1px solid var(--border); border-radius: 9px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: repeating-conic-gradient(#f1f4f2 0% 25%, #fafbfa 0% 50%) 50% / 18px 18px; }
.image-stage img, .image-stage canvas { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
#mask { cursor: crosshair; touch-action: manipulation; }
.image-empty { display: grid; gap: 8px; text-align: center; padding: 16px; }
.image-empty strong { color: #83928a; font-size: 13px; font-weight: 500; }
.image-empty span { font-size: 11px; color: #9ca8a1; }
.image-meta { display: inline-block; min-height: 37px; padding-top: 11px; font-size: 11px; color: #89968e; }
.output-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; min-height: 36px; }
.output-actions .button, .output-actions button { font-size: 12px; padding: 7px 10px; }
.status-badge { font-size: 11px; color: #6c8879; background: #edf5ef; border-radius: 20px; padding: 6px 10px; white-space: nowrap; }
.status-badge[data-state=error] { color: #a9433c; background: #fff0ee; }
.status-badge[data-state=busy] { color: #986e17; background: #fff6df; }
.result-message { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; color: #819087; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.result-message .error, .error { color: #b23f37; }
.notice { background: #fff3e7; color: #8a5b23; border: 1px solid #efdbc0; border-radius: 9px; padding: 12px 16px; font-size: 13px; overflow-wrap: anywhere; }
.notice[data-error=true] { background: #fff1ef; color: #a54740; border-color: #f0d1cc; }
.history { display: grid; gap: 0; margin: 15px 0 0; padding: 0; list-style: none; max-height: 300px; overflow-y: auto; }
.history button { display: flex; justify-content: space-between; width: 100%; text-align: left; border: none; border-top: 1px solid #edf1ee; border-radius: 0; padding: 13px 2px; font-size: 13px; }
.history small { color: #8b9890; font-size: 11px; }
.muted { color: #89968f; font-size: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.upload-actions:focus-within label { outline: 2px solid #8bc7bc; outline-offset: 2px; }
.narrow { max-width: 400px; margin: 12vh auto; padding: 32px; display: grid; gap: 20px; }
.narrow h1 { font-size: 24px; }
.narrow label { margin: 12px 0; }
.narrow button { width: 100%; margin-top: 12px; background: var(--accent); color: white; }
@media (min-width: 1500px) { .image-stage { height: 460px; } }
@media (max-width: 1000px) {
  .topbar { padding: 20px; } .workspace { padding: 6px 20px 32px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .editor-layout { grid-template-columns: 230px minmax(0, 1fr); gap: 14px; }
  .tools, .comparison { padding: 16px; } .compare-grid { gap: 10px; }
  .image-stage { height: 310px; }
}
@media (max-width: 760px) {
  h1 { font-size: 22px; } .topbar { padding: 16px; } .workspace { padding: 4px 12px 24px; gap: 14px; }
  .account { gap: 6px; font-size: 12px; } .brand { font-size: 17px; } .brand span { margin-left: 6px; }
  .editor-layout { grid-template-columns: minmax(0, 1fr); }
  .tool-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 10px; padding-bottom: 12px; }
  .tool-panel { padding-top: 16px; } .card { padding: 16px; }
  .materials .section-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .file-hint { flex-direction: column; gap: 4px; }
  .image-stage { height: 240px; } .comparison { padding: 14px; } .compare-grid { gap: 8px; margin-top: 20px; }
  .preview-heading { display: block; } .preview-heading span { display: block; max-width: 100%; margin-top: 4px; }
  .history-card .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .output-actions .button, .output-actions button { padding: 7px 8px; font-size: 11px; }
  .narrow { margin: 48px 16px; max-width: none; }
}
