:root {
  --ink: #172018;
  --muted: #697268;
  --paper: #f7f3e8;
  --panel: #fffdf6;
  --line: #d9d5c6;
  --green: #507b42;
  --green-dark: #2e4e2b;
  --green-light: #d9e7c7;
  --soil: #a76b3f;
  --soil-dark: #6e4129;
  --gold: #f0c758;
  --sky: #d9eef0;
  --danger: #b84e3a;
  --shadow: 0 5px 0 #bfb8a5, 0 18px 45px rgba(52, 58, 43, .09);
  --pixel-border: polygon(6px 0, calc(100% - 6px) 0, calc(100% - 6px) 3px, 100% 3px, 100% calc(100% - 6px), calc(100% - 3px) calc(100% - 6px), calc(100% - 3px) 100%, 6px 100%, 6px calc(100% - 3px), 0 calc(100% - 3px), 0 6px, 3px 6px, 3px 3px, 6px 3px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(65, 95, 65, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(65, 95, 65, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font: 14px/1.5 "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}
button, input, select { font: inherit; }
button { color: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid rgba(80, 123, 66, .28); outline-offset: 2px; }

.sky-decor { position: absolute; inset: 74px 0 auto; height: 310px; overflow: hidden; pointer-events: none; opacity: .6; }
.sky-decor::before, .sky-decor::after, .sky-decor i { content: ""; position: absolute; background: #fff; box-shadow: 12px 0 #fff, 24px 0 #fff, 6px -6px #fff, 18px -6px #fff; width: 12px; height: 12px; }
.sky-decor::before { left: 7%; top: 72px; transform: scale(1.8); }
.sky-decor::after { right: 13%; top: 34px; transform: scale(1.2); }
.sky-decor i:nth-child(1) { left: 44%; top: 118px; transform: scale(.8); }
.sky-decor i:nth-child(2) { right: 4%; top: 196px; transform: scale(.65); }
.sky-decor i:nth-child(3) { left: 22%; top: 220px; transform: scale(.55); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 11px max(22px, calc((100vw - 1520px) / 2));
  background: rgba(247, 243, 232, .92);
  border-bottom: 1px solid rgba(96, 94, 79, .18);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 18px; font-weight: 900; letter-spacing: .08em; }
.brand small { color: var(--muted); font: 8px "Chivo Mono", monospace; letter-spacing: .16em; }
.brand-cube, .empty-cube { position: relative; display: inline-block; width: 35px; height: 35px; transform: rotate(30deg) skewY(-10deg); }
.brand-cube i, .brand-cube b, .brand-cube em, .empty-cube i, .empty-cube b, .empty-cube em { position: absolute; display: block; width: 24px; height: 24px; box-shadow: inset -4px -4px rgba(0,0,0,.08); }
.brand-cube i, .empty-cube i { left: 6px; top: 0; background: #7fa65f; transform: skewY(0deg); }
.brand-cube b, .empty-cube b { left: -6px; top: 18px; height: 17px; background: var(--soil); transform: skewY(30deg); }
.brand-cube em, .empty-cube em { left: 18px; top: 18px; height: 17px; background: #805034; transform: skewY(-30deg); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.local-badge { display: inline-flex; align-items: center; gap: 7px; margin-right: 8px; color: var(--green-dark); font-size: 11px; font-weight: 600; }
.local-badge i { width: 7px; height: 7px; background: #67a54e; box-shadow: 0 0 0 4px rgba(103,165,78,.12); animation: pulse 2s infinite; }

main { position: relative; z-index: 1; max-width: 1520px; margin: auto; padding: 0 22px; }
.intro { display: grid; grid-template-columns: 1.1fr .9fr; align-items: end; gap: 60px; padding: 66px 12px 38px; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--green); font: 700 10px "Chivo Mono", monospace; letter-spacing: .13em; }
.eyebrow::before { content: ""; width: 35px; height: 5px; background: repeating-linear-gradient(90deg, var(--green) 0 6px, transparent 6px 9px); }
h1 { margin: 13px 0 15px; font-size: clamp(39px, 4.2vw, 66px); line-height: 1.07; letter-spacing: -.055em; font-weight: 900; }
h1 em { color: var(--green); font-style: normal; }
.intro p { max-width: 660px; margin: 0; color: var(--muted); font-size: 15px; }
.intro-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding-bottom: 5px; }
.step-pill { display: flex; align-items: center; gap: 10px; min-height: 70px; padding: 12px; border: 1px solid var(--line); background: rgba(255,253,246,.7); cursor: pointer; text-align: left; transition: .2s ease; clip-path: var(--pixel-border); }
.step-pill:hover, .step-pill.is-active { border-color: var(--green); background: #fffdf6; transform: translateY(-3px); box-shadow: 0 4px 0 #b7b29f; }
.step-pill b { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; color: #fff; background: var(--green); font: 700 11px "Chivo Mono"; }
.step-pill span { font-weight: 800; font-size: 12px; }
.step-pill small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; white-space: nowrap; }

.workbench { display: grid; grid-template-columns: 280px minmax(500px, 1fr) 284px; align-items: start; gap: 14px; padding-bottom: 52px; }
.panel { min-width: 0; background: rgba(255,253,246,.95); border: 1px solid var(--line); box-shadow: var(--shadow); clip-path: var(--pixel-border); }
.control-panel, .palette-panel { padding: 18px; }
.canvas-panel { overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; min-height: 34px; margin-bottom: 17px; }
.panel-heading > div { display: flex; align-items: center; gap: 8px; }
.panel-heading h2 { margin: 0; font-size: 15px; font-weight: 900; }
.panel-no { display: grid; place-items: center; width: 25px; height: 25px; color: #fff; background: var(--green-dark); font: 700 9px "Chivo Mono"; }
.panel-chip { padding: 4px 7px; color: var(--muted); background: #efebdf; font: 600 8px "Chivo Mono"; letter-spacing: .08em; }

.upload-zone { display: flex; align-items: center; flex-direction: column; min-height: 188px; padding: 24px 15px 15px; border: 1px dashed #aaa796; background: #f4f0e3; cursor: pointer; text-align: center; transition: .2s ease; }
.upload-zone:hover, .upload-zone.is-dragging { border-color: var(--green); background: #eef2e2; transform: translateY(-2px); }
.upload-zone.has-image { border-style: solid; background: #edf2e5; }
.upload-icon { position: relative; display: grid; place-items: center; width: 45px; height: 45px; margin-bottom: 12px; background: var(--green-light); box-shadow: 5px 5px 0 #b9c9a8; }
.upload-icon i::before, .upload-icon i::after { content: ""; position: absolute; background: var(--green); }
.upload-icon i::before { width: 18px; height: 3px; left: 9px; bottom: 10px; }
.upload-icon i::after { width: 3px; height: 13px; left: 16px; bottom: 10px; }
.upload-icon b { position: absolute; right: -8px; top: -9px; display: grid; place-items: center; width: 21px; height: 21px; color: #fff; background: var(--soil); font-size: 16px; }
.upload-zone strong { font-size: 13px; }
.upload-zone small { margin: 4px 0 14px; color: var(--muted); font-size: 9px; }
.upload-button { width: 100%; padding: 8px; border: 1px solid #cec8b8; background: #fffdf8; font-size: 11px; font-weight: 700; }

.setting-block { padding: 17px 0; border-bottom: 1px dashed #d3cebf; }
.setting-title, .range-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; font-size: 11px; font-weight: 800; }
.tip { display: grid; place-items: center; width: 17px; height: 17px; padding: 0; color: var(--muted); border: 1px solid var(--line); border-radius: 50%; background: none; font: 700 9px serif; cursor: help; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mode-card { display: flex; align-items: center; gap: 7px; min-height: 48px; padding: 7px; border: 1px solid #d7d1c1; background: #fbf8ef; cursor: pointer; text-align: left; transition: .15s; }
.mode-card:hover { border-color: #8da47d; }
.mode-card.is-active { border-color: var(--green); background: var(--green-light); box-shadow: inset 0 -3px rgba(80,123,66,.12); }
.mode-card b { display: grid; place-items: center; width: 28px; height: 28px; color: var(--green-dark); background: rgba(255,255,255,.55); font-size: 16px; }
.mode-card span { font-size: 10px; font-weight: 800; }
.mode-card small { display: block; color: var(--muted); font-size: 8px; font-weight: 400; }
.dimension-row { display: grid; grid-template-columns: 1fr 26px 1fr; align-items: end; gap: 6px; }
.dimension-row label { color: var(--muted); font-size: 9px; }
.dimension-row input { width: 100%; height: 36px; margin-top: 4px; padding: 0 10px; color: var(--ink); border: 1px solid var(--line); background: #fffdf8; font: 700 12px "Chivo Mono"; }
.ratio-lock { width: 26px; height: 34px; padding: 0; color: #aaa394; border: 0; background: transparent; cursor: pointer; }
.ratio-lock.is-active { color: var(--green); }
.live-size { color: var(--green); font: 700 10px "Chivo Mono"; }
.preset-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; margin-top: 7px; }
.preset-row button { padding: 6px 2px; color: var(--muted); border: 1px solid var(--line); background: #f8f5ed; font-size: 8px; cursor: pointer; }
.preset-row button:hover { color: var(--green-dark); border-color: #8fa683; }
.select-box { width: 100%; height: 38px; padding: 0 10px; color: var(--ink); border: 1px solid var(--line); background: #fffdf8; font-size: 11px; }
.text-button { padding: 0; color: var(--green); border: 0; background: none; font-size: 9px; font-weight: 700; cursor: pointer; }
.range-label { margin-top: 13px; margin-bottom: 7px; color: var(--muted); font-size: 9px; font-weight: 600; }
.range-label output { color: var(--green-dark); font-weight: 800; }
.range { width: 100%; height: 5px; margin: 5px 0; accent-color: var(--green); cursor: pointer; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 13px; border: 1px solid transparent; background: none; cursor: pointer; font-size: 10px; font-weight: 800; transition: transform .16s, box-shadow .16s, background .16s; }
.button:hover { transform: translateY(-2px); }
.button-primary { color: #fff; border-color: var(--green-dark); background: var(--green); box-shadow: 0 4px 0 var(--green-dark); }
.button-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }
.button-dark { color: #fff; background: var(--ink); box-shadow: 0 3px 0 #000; }
.button-ghost { border-color: var(--line); background: rgba(255,255,255,.38); }
.button-light { border-color: #c8c2b2; background: #fffdf6; box-shadow: 0 3px 0 #c8c2b2; }
.generate-button { justify-content: space-between; width: 100%; height: 46px; margin-top: 16px; padding: 0 16px; font-size: 12px; }
.generate-button b { font-size: 18px; }
.generate-button.is-loading { pointer-events: none; filter: saturate(.6); }
.generate-button.is-loading b { animation: bob 1s infinite; }
.privacy-note { margin: 12px 0 0; color: var(--muted); font-size: 8px; text-align: center; }
.privacy-note i { color: var(--green); font-style: normal; }

.canvas-heading { min-height: 67px; margin: 0; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.save-state { margin-left: 5px; color: var(--muted); font-size: 8px; font-weight: 500; }
.save-state::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 4px; background: #79a963; }
.view-switch { display: flex!important; gap: 0!important; padding: 3px; background: #efebdf; }
.view-switch button { min-width: 52px; padding: 6px 8px; color: var(--muted); border: 0; background: transparent; cursor: pointer; font-size: 9px; font-weight: 700; }
.view-switch button.is-active { color: var(--green-dark); background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.toolbar { display: flex; align-items: center; min-height: 60px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #f5f1e6; }
.tool-group { display: flex; gap: 4px; }
.tool { display: flex; align-items: center; flex-direction: column; justify-content: center; width: 46px; height: 43px; padding: 2px; color: var(--muted); border: 1px solid transparent; background: transparent; cursor: pointer; }
.tool span { height: 20px; font-size: 15px; }
.tool small { font-size: 8px; }
.tool:hover, .tool.is-active { color: var(--green-dark); border-color: #bdc9b2; background: var(--green-light); }
.toolbar-divider { width: 1px; height: 29px; margin: 0 9px; background: var(--line); }
.icon-button, .zoom-button { display: grid; place-items: center; width: 31px; height: 31px; padding: 0; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 17px; }
.icon-button:hover, .zoom-button:hover { border-color: var(--line); background: #fff; }
.toolbar-spacer { flex: 1; }
.toolbar output { min-width: 42px; color: var(--muted); font: 600 9px "Chivo Mono"; text-align: center; }
.button-build { min-height: 34px; margin-left: 9px; color: #fff; background: var(--soil); box-shadow: 0 3px 0 var(--soil-dark); }

.canvas-stage { position: relative; min-height: 640px; background: #dce8e5; overflow: hidden; }
.canvas-stage::before { content: ""; position: absolute; inset: 0; opacity: .32; background: linear-gradient(45deg, rgba(68,104,96,.12) 25%, transparent 25%, transparent 75%, rgba(68,104,96,.12) 75%), linear-gradient(45deg, rgba(68,104,96,.12) 25%, transparent 25%, transparent 75%, rgba(68,104,96,.12) 75%); background-size: 24px 24px; background-position: 0 0, 12px 12px; }
.canvas-scroll { position: absolute; inset: 0; display: grid; place-items: center; padding: 74px 46px 48px; overflow: auto; }
#patternCanvas { display: none; max-width: none; background: #fff; box-shadow: 0 0 0 6px #fffdf5, 0 0 0 8px rgba(50,70,56,.18), 0 18px 45px rgba(50,70,56,.18); image-rendering: pixelated; touch-action: none; cursor: crosshair; }
.canvas-stage.has-pattern #patternCanvas { display: block; }
.board-label { position: absolute; z-index: 2; left: 16px; top: 14px; display: none; align-items: center; gap: 8px; padding: 7px 9px; background: rgba(255,253,246,.92); box-shadow: 3px 3px 0 rgba(65,82,64,.15); }
.canvas-stage.has-pattern .board-label { display: flex; }
.board-label span { font-size: 10px; font-weight: 800; }
.board-label small { color: var(--muted); font: 8px "Chivo Mono"; }
.empty-hint { position: absolute; inset: 0; display: flex; align-items: center; flex-direction: column; justify-content: center; padding: 30px; text-align: center; }
.canvas-stage.has-pattern .empty-hint { display: none; }
.empty-cube { width: 72px; height: 72px; margin: 0 0 28px; transform: rotate(30deg) skewY(-10deg) scale(1.6); }
.empty-cube i { background: #92b673; }
.empty-cube b { background: #b97d4e; }
.empty-cube em { background: #8f5c38; }
.empty-hint strong { font-size: 15px; }
.empty-hint small { margin: 5px 0 14px; color: var(--muted); font-size: 10px; }
.board-strip { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 10px 17px; border-top: 1px solid var(--line); background: #fbf8ef; }
.board-strip > div:first-child { display: grid; }
.board-strip strong { font-size: 10px; }
.board-strip small { color: var(--muted); font-size: 8px; }
.board-tabs { display: flex; gap: 5px; max-width: 70%; overflow-x: auto; padding: 3px; }
.board-tabs button, .build-board-tabs button { flex: none; min-width: 35px; height: 30px; border: 1px solid var(--line); background: #fffdf7; cursor: pointer; font: 700 9px "Chivo Mono"; }
.board-tabs button.is-active, .build-board-tabs button.is-active { color: #fff; border-color: var(--green-dark); background: var(--green); }

.stats-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; }
.stats-grid > div { min-width: 0; padding: 10px 7px; border: 1px solid var(--line); background: #f7f4eb; }
.stats-grid small, .stats-grid span { display: block; overflow: hidden; color: var(--muted); font-size: 7px; white-space: nowrap; }
.stats-grid strong { display: block; margin: 2px 0; font: 700 18px "Chivo Mono"; }
.stats-grid span { color: #aaa495; font: 7px "Chivo Mono"; }
.selected-color { display: grid; grid-template-columns: 42px 1fr 28px; align-items: center; gap: 10px; margin: 14px 0; padding: 10px; color: #fff; background: var(--green-dark); box-shadow: 0 4px 0 #1c351e; }
.color-well { width: 42px; height: 42px; border: 3px solid rgba(255,255,255,.7); background: #f4ead5; }
.selected-color div { display: grid; }
.selected-color small { color: rgba(255,255,255,.6); font-size: 7px; }
.selected-color strong { font: 700 13px "Chivo Mono"; }
.selected-color span:not(.color-well) { color: rgba(255,255,255,.78); font-size: 8px; }
.selected-color kbd { display: grid; place-items: center; width: 26px; height: 26px; color: var(--green-dark); border: 0; background: #fff; font-size: 12px; }
.palette-list-heading { display: flex; justify-content: space-between; margin: 15px 0 8px; font-size: 9px; font-weight: 800; }
.palette-list { height: 308px; overflow: auto; border-top: 1px solid var(--line); }
.palette-item { display: grid; grid-template-columns: 27px 36px 1fr auto; align-items: center; gap: 7px; min-height: 43px; padding: 5px 4px; border-bottom: 1px solid #e9e4d7; cursor: pointer; transition: background .12s; }
.palette-item:hover, .palette-item.is-active { background: #edf2e5; }
.palette-swatch { display: grid; place-items: center; width: 27px; height: 27px; color: rgba(0,0,0,.7); border: 1px solid rgba(0,0,0,.12); font-size: 9px; text-shadow: 0 1px rgba(255,255,255,.3); }
.palette-code { font: 700 9px "Chivo Mono"; }
.palette-name { overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.palette-count { color: var(--muted); font: 600 8px "Chivo Mono"; }
.export-card { margin-top: 15px; padding: 13px; border: 1px solid #d0c8b3; background: #eee7d5; }
.export-card > div:first-child { display: grid; margin-bottom: 9px; }
.export-card > div span { font-size: 10px; font-weight: 900; }
.export-card > div small { color: var(--muted); font-size: 8px; }
.export-main { display: flex; justify-content: space-between; width: 100%; height: 38px; padding: 0 10px; color: #fff; border: 0; background: var(--green); box-shadow: 0 3px 0 var(--green-dark); cursor: pointer; font-size: 10px; font-weight: 800; }
.export-row { display: grid!important; grid-template-columns: repeat(3,1fr); gap: 4px; margin-top: 8px; }
.export-row button { padding: 6px 2px; border: 1px solid #c9c1af; background: #fffdf8; cursor: pointer; font-size: 8px; }

footer { display: flex; align-items: center; justify-content: space-between; min-height: 115px; padding: 25px max(25px, calc((100vw - 1480px)/2)); color: #eae7dc; background: var(--green-dark); border-top: 8px solid #75a15b; }
footer div { display: grid; }
footer strong { font-size: 16px; }
footer span { color: rgba(255,255,255,.55); font-size: 9px; }
footer p { color: rgba(255,255,255,.4); font: 9px "Chivo Mono"; letter-spacing: .12em; }

.modal { width: min(680px, calc(100vw - 28px)); padding: 0; color: var(--ink); border: 0; background: transparent; overflow: visible; }
.modal::backdrop, .build-dialog::backdrop { background: rgba(21,31,22,.72); backdrop-filter: blur(5px); }
.modal-card { padding: 22px; border: 1px solid #a8a392; background: var(--panel); box-shadow: 0 8px 0 rgba(25,31,24,.45); clip-path: var(--pixel-border); }
.modal-head { display: flex; align-items: start; justify-content: space-between; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.modal-head span { color: var(--green); font: 700 9px "Chivo Mono"; letter-spacing: .1em; }
.modal-head h2 { margin: 3px 0 0; font-size: 20px; }
.modal-head > button { width: 32px; height: 32px; color: var(--muted); border: 1px solid var(--line); background: none; cursor: pointer; font-size: 19px; }
.modal-card > p { color: var(--muted); font-size: 11px; }
.custom-color-row { display: grid; grid-template-columns: 1fr 1.5fr 65px; gap: 10px; margin: 20px 0; }
.custom-color-row label { color: var(--muted); font-size: 9px; }
.custom-color-row input { width: 100%; height: 38px; margin-top: 5px; padding: 0 9px; border: 1px solid var(--line); background: #fff; }
.custom-color-row input[type=color] { padding: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.file-button { cursor: pointer; }
.preview-modal { width: min(920px, calc(100vw - 28px)); }
.preview-layout { display: grid; grid-template-columns: minmax(0,1fr) 210px; gap: 20px; padding-top: 20px; }
.preview-art { display: grid; place-items: center; min-height: 450px; padding: 24px; background: #dce8e5; }
#previewCanvas { width: min(100%, 520px); height: auto; background: #fff; box-shadow: 0 8px 22px rgba(0,0,0,.15); }
.preview-layout aside { padding: 15px 0; }
.preview-logo { color: var(--green); font-weight: 900; }
.preview-layout h3 { margin: 8px 0 25px; font-size: 24px; }
.preview-layout dl { margin-bottom: 25px; }
.preview-layout dl div { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 10px; }
.preview-layout dt { color: var(--muted); }
.preview-layout dd { margin: 0; font: 700 10px "Chivo Mono"; }

.build-dialog { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; color: var(--ink); border: 0; background: var(--paper); }
.build-shell { display: flex; flex-direction: column; height: 100%; }
.build-shell > header { display: grid; grid-template-columns: 1fr minmax(230px, 360px) 1fr; align-items: center; gap: 20px; min-height: 90px; padding: 13px 24px; color: #fff; background: var(--green-dark); border-bottom: 7px solid #79a65c; }
.build-shell header > div:first-child span { color: rgba(255,255,255,.5); font: 8px "Chivo Mono"; letter-spacing: .12em; }
.build-shell header h2 { display: inline; margin: 0 10px 0 0; font-size: 20px; }
.build-shell header p { display: inline; color: rgba(255,255,255,.55); font-size: 9px; }
.build-shell header > button { justify-self: end; padding: 9px 13px; color: #fff; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.14); cursor: pointer; }
.build-progress { text-align: center; }
.build-progress strong { display: block; font: 700 17px "Chivo Mono"; }
.build-progress > span { display: block; height: 7px; margin: 5px 0; background: rgba(255,255,255,.16); }
.build-progress i { display: block; width: 0; height: 100%; background: var(--gold); transition: width .25s; }
.build-progress small { color: rgba(255,255,255,.55); font-size: 8px; }
.build-shell > main { display: grid; grid-template-columns: minmax(0,1fr) 230px; flex: 1; width: 100%; max-width: none; min-height: 0; padding: 0; }
.build-canvas-wrap { display: grid; place-items: center; min-height: 0; padding: 30px; overflow: auto; background: #dce8e5; }
#buildCanvas { max-width: min(80vh, 100%); max-height: calc(100vh - 150px); background: #fff; box-shadow: 0 0 0 6px #fff, 0 0 0 8px rgba(0,0,0,.15), 0 15px 35px rgba(0,0,0,.15); touch-action: none; cursor: pointer; }
.build-shell main > aside { padding: 22px 15px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--panel); }
.build-shell aside h3 { margin: 5px 0 9px; font-size: 10px; }
.build-board-tabs { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; margin-bottom: 22px; }
.build-shell select { width: 100%; height: 36px; padding: 0 8px; border: 1px solid var(--line); background: #fff; font-size: 9px; }
.build-actions { display: grid; gap: 6px; margin-top: 22px; }
.build-actions button { padding: 9px; border: 1px solid var(--line); background: #f5f1e7; cursor: pointer; font-size: 9px; }
.build-actions button:first-child, .build-actions button:nth-child(2) { color: #fff; border-color: var(--green-dark); background: var(--green); }
.build-shell aside p { margin-top: 18px; color: var(--muted); font-size: 8px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 25px; padding: 10px 16px; color: #fff; background: var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.35); opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .22s; font-size: 10px; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes pulse { 50% { opacity: .45; } }
@keyframes bob { 50% { transform: translateX(5px); } }

@media (max-width: 1180px) {
  .workbench { grid-template-columns: 250px minmax(480px,1fr); }
  .palette-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 240px 1fr 280px; gap: 16px; }
  .palette-panel .panel-heading { grid-column: 1 / -1; margin-bottom: 0; }
  .palette-panel .stats-grid, .palette-panel .selected-color { grid-column: 1; }
  .palette-panel .selected-color { margin: -12px 0 0; align-self: end; }
  .palette-list-heading { grid-column: 2; margin: 0; }
  .palette-list { grid-column: 2; grid-row: 3 / span 2; height: 165px; }
  .export-card { grid-column: 3; grid-row: 2 / span 3; margin: 0; align-self: stretch; }
}

@media (max-width: 820px) {
  .local-badge, .button-ghost { display: none; }
  .topbar { padding: 10px 14px; }
  main { padding: 0 12px; }
  .intro { grid-template-columns: 1fr; gap: 26px; padding: 40px 4px 25px; }
  .intro-steps { overflow-x: auto; }
  .step-pill { min-width: 145px; }
  .workbench { grid-template-columns: 1fr; }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
  .control-panel .panel-heading, .control-panel .generate-button, .control-panel .privacy-note { grid-column: 1 / -1; }
  .upload-zone { grid-row: span 2; }
  .canvas-stage { min-height: 580px; }
  .palette-panel { grid-template-columns: 1fr 1fr; }
  .palette-list-heading, .palette-list { grid-column: 2; }
  .export-card { grid-column: 1 / -1; grid-row: auto; }
  .build-shell > header { grid-template-columns: 1fr auto; }
  .build-progress { grid-column: 1 / -1; grid-row: 2; }
  .build-shell > main { grid-template-columns: 1fr; }
  .build-shell main > aside { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 15px; border-left: 0; border-top: 1px solid var(--line); }
  .build-shell aside h3, .build-shell aside p { display: none; }
  .build-board-tabs, .build-actions { margin: 0; }
  .build-canvas-wrap { min-height: 50vh; padding: 18px; }
}

@media (max-width: 560px) {
  h1 { font-size: 37px; }
  .intro p { font-size: 12px; }
  .control-panel { display: block; }
  .upload-zone { min-height: 160px; }
  .canvas-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .view-switch { align-self: stretch; }
  .view-switch button { flex: 1; }
  .toolbar { overflow-x: auto; }
  .tool { width: 41px; }
  .toolbar output, .zoom-button { display: none; }
  .canvas-stage { min-height: 470px; }
  .canvas-scroll { padding: 70px 28px 40px; }
  .button-build { flex: none; }
  .board-strip { align-items: flex-start; flex-direction: column; gap: 8px; }
  .board-tabs { max-width: 100%; width: 100%; }
  .palette-panel { display: block; }
  .palette-panel .selected-color { margin: 12px 0; }
  .palette-list { height: 220px; }
  .preview-layout { grid-template-columns: 1fr; }
  .preview-art { min-height: 280px; }
  .custom-color-row { grid-template-columns: 1fr 1fr; }
  .custom-color-row label:last-child { grid-column: 1 / -1; }
  .top-actions .button-dark { font-size: 0; }
  .top-actions .button-dark::after { content: "保存"; font-size: 10px; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media print {
  body { background: #fff; }
  .topbar, .intro, .control-panel, .palette-panel, .toolbar, .board-strip, footer, .board-label { display: none!important; }
  main, .workbench, .canvas-panel, .canvas-stage, .canvas-scroll { display: block; width: 100%; max-width: none; min-height: 0; margin: 0; padding: 0; border: 0; box-shadow: none; background: #fff; }
  #patternCanvas { display: block!important; width: 100%!important; height: auto!important; margin: auto; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto!important; animation-duration: .01ms!important; animation-iteration-count: 1!important; transition-duration: .01ms!important; }
}


