:root {
  --ink: #1d2730;
  --muted: #72808a;
  --paper: #f8f7f2;
  --panel: #ffffff;
  --line: #dfe5e2;
  --tomato: #ef5b4d;
  --tomato-dark: #d94639;
  --lemon: #f9c846;
  --mint: #c5e2d3;
  --aqua: #45b6b0;
  --shadow: 0 12px 34px rgba(35, 49, 52, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(34, 48, 56, 0.025) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(34, 48, 56, 0.025) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--paper);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, label:focus-within { outline: 3px solid rgba(69, 182, 176, 0.38); outline-offset: 2px; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 34px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-mark { display: grid; grid-template-columns: repeat(2, 10px); gap: 3px; transform: rotate(-6deg); }
.brand-mark i { display: block; width: 10px; aspect-ratio: 1; border: 1px solid rgba(29, 39, 48, 0.22); border-radius: 3px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.brand-mark i:nth-child(1) { background: var(--tomato); }.brand-mark i:nth-child(2) { background: var(--lemon); }.brand-mark i:nth-child(3) { background: var(--aqua); }.brand-mark i:nth-child(4) { background: var(--mint); }

.project-name { flex: 1; display: flex; align-items: center; min-width: 0; gap: 9px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #57b884; box-shadow: 0 0 0 3px #e3f5eb; flex: none; }
.project-name input { width: min(230px, 32vw); border: 0; background: transparent; padding: 4px 0; color: var(--ink); font-weight: 700; }
.autosave { color: var(--muted); font-size: 12px; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.icon-button {
  width: 39px;
  height: 39px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.icon-button:hover { background: #f6faf8; border-color: #b8cbc3; transform: translateY(-1px); }
.icon-button.small { width: 31px; height: 31px; font-size: 18px; }

.primary-button, .secondary-button {
  min-height: 39px;
  border-radius: 5px;
  padding: 0 15px;
  border: 1px solid transparent;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.primary-button { color: #fff; background: var(--tomato); box-shadow: 0 4px 0 var(--tomato-dark); }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--tomato-dark); }
.primary-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tomato-dark); }
.secondary-button { color: var(--ink); border-color: #cdd8d3; background: #fff; }
.secondary-button:hover { background: #eff7f2; }
.text-button { padding: 0; border: 0; background: none; color: #718b81; font-size: 12px; text-decoration: underline; }

.workspace { min-height: calc(100vh - 72px); display: grid; grid-template-columns: 286px minmax(440px, 1fr) 284px; }
.control-panel, .materials-panel { background: rgba(255,255,255,.85); }
.control-panel { border-right: 1px solid var(--line); padding: 23px 22px; }
.materials-panel { border-left: 1px solid var(--line); padding: 25px 21px 21px; display: flex; flex-direction: column; }

.panel-section { padding: 0 0 22px; margin: 0 0 22px; border-bottom: 1px solid var(--line); }
.section-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; font-weight: 800; font-size: 13px; }
.section-label .unit, .section-label output { color: var(--muted); font-size: 12px; font-weight: 600; }

.upload-dropzone { display: grid; place-items: center; height: 142px; overflow: hidden; border: 1.5px dashed #a8beb4; border-radius: 6px; background: #f5faf7; color: #547268; cursor: pointer; position: relative; }
.upload-dropzone:hover, .upload-dropzone.is-dragging { border-color: var(--aqua); background: #eff9f6; }
.upload-dropzone.is-dragging { box-shadow: inset 0 0 0 2px rgba(69, 182, 176, 0.18); }
#sourceThumbnail { display: none; height: 100%; width: 100%; object-fit: cover; }
.upload-placeholder { display: grid; gap: 5px; justify-items: center; text-align: center; padding: 15px; }
.upload-placeholder b { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--mint); color: #297d73; font-size: 23px; line-height: 1; }
.upload-placeholder strong { color: var(--ink); font-size: 13px; }.upload-placeholder small { color: var(--muted); font-size: 11px; }
.upload-trigger { width: 100%; margin-top: 9px; min-height: 36px; font-size: 13px; }

.size-fields { display: grid; grid-template-columns: 1fr 17px 1fr; align-items: end; gap: 7px; }
.size-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }.size-fields input { width: 100%; height: 37px; border: 1px solid #cfd9d4; border-radius: 4px; padding: 0 8px; color: var(--ink); font-weight: 800; background: #fff; }.size-fields input:disabled { color: #7a8781; background: #f0f4f1; cursor: not-allowed; }.multiply { padding-bottom: 9px; color: #96a29e; text-align: center; }
.size-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 9px; }.size-presets button { height: 31px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: #fff; font-size: 10px; }.size-presets button:hover, .size-presets button.is-selected { color: var(--ink); border-color: #79b6a0; background: #e9f5ee; font-weight: 800; }.board-hint { margin: 7px 0 0; color: var(--muted); font-size: 10px; }

.range-input { width: 100%; appearance: none; height: 4px; margin: 4px 0 7px; border-radius: 10px; background: linear-gradient(to right, var(--aqua) 0%, var(--aqua) 50%, #d8e3de 50%, #d8e3de 100%); }.range-input::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; border: 3px solid #fff; border-radius: 50%; background: var(--aqua); box-shadow: 0 1px 4px rgba(29,39,48,.35); }.range-input::-moz-range-thumb { width: 12px; height: 12px; border: 3px solid #fff; border-radius: 50%; background: var(--aqua); box-shadow: 0 1px 4px rgba(29,39,48,.35); }.range-ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }

.segmented-control { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #f5f7f5; }.segmented-control button { min-height: 32px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; }.segmented-control button.is-selected { background: #fff; color: var(--ink); font-weight: 800; box-shadow: 0 1px 4px rgba(31,47,43,.12); }

.fit-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }.fit-option { min-height: 70px; display: grid; justify-items: center; align-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--muted); font-size: 10px; text-align: center; }.fit-option.is-selected { color: var(--ink); border-color: #79b6a0; background: #f1f8f4; font-weight: 800; }.fit-icon { width: 23px; height: 20px; position: relative; border: 1.5px solid currentColor; }.crop-icon::before, .crop-icon::after { content: ""; position: absolute; border-color: currentColor; }.crop-icon::before { width: 7px; height: 7px; right: -4px; top: -4px; border-top: 1.5px solid; border-right: 1.5px solid; }.crop-icon::after { width: 7px; height: 7px; left: -4px; bottom: -4px; border-bottom: 1.5px solid; border-left: 1.5px solid; }.contain-icon { transform: scale(.72); outline: 1.5px solid currentColor; outline-offset: 4px; }.split-icon { background: linear-gradient(90deg, transparent 46%, currentColor 46%, currentColor 54%, transparent 54%), linear-gradient(transparent 43%, currentColor 43%, currentColor 57%, transparent 57%); }
.crop-controls, .split-settings { margin-top: 12px; padding-top: 10px; border-top: 1px solid #e4e9e6; }.crop-control-label { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 11px; }.crop-control-label span:first-child { color: var(--ink); font-weight: 800; }.crop-axis { display: grid; grid-template-columns: 25px 1fr; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 10px; }.crop-axis input { width: 100%; accent-color: var(--aqua); }.layout-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }.layout-presets button { min-height: 28px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); font-size: 10px; }.layout-presets button.is-selected { border-color: #79b6a0; background: #e9f5ee; color: var(--ink); font-weight: 800; }.split-hint { margin: 8px 0 0; color: #52766a; font-size: 10px; line-height: 1.45; }
.tip-card { display: grid; grid-template-columns: 20px 1fr; gap: 8px; border-left: 3px solid var(--lemon); padding: 10px 9px; background: #fff8e8; color: #79652c; }.tip-card p { margin: 0; font-size: 11px; line-height: 1.55; }.tip-symbol { color: #d39b17; }

.canvas-stage { min-width: 0; padding: 28px clamp(24px, 4vw, 62px) 22px; display: flex; flex-direction: column; }
.stage-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 23px; }.eyebrow { margin: 0 0 6px; color: #81918c; font-size: 10px; font-weight: 900; letter-spacing: .14em; }.stage-heading h1 { margin: 0; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 29px; line-height: 1; letter-spacing: 0; }.stage-meta { display: flex; align-items: center; gap: 9px; padding-bottom: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; }.meta-divider { height: 12px; border-left: 1px solid #bdc9c4; }
.canvas-tools { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 17px; }.view-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 5px; background: #eaeeeb; }.view-tabs button { border: 0; border-radius: 3px; padding: 6px 11px; background: transparent; color: var(--muted); font-size: 12px; }.view-tabs button.is-selected { background: #fff; color: var(--ink); font-weight: 800; box-shadow: 0 1px 3px rgba(30,45,40,.1); }.zoom-control { display: flex; align-items: center; gap: 7px; }.zoom-control output { width: 37px; color: var(--muted); font-size: 11px; text-align: center; }.zoom-control input { width: 80px; accent-color: var(--aqua); }

.board-viewport { flex: 1; min-height: 400px; display: grid; place-items: center; overflow: auto; padding: 25px; border: 1px solid #d4ddd8; background-color: #eaf0ed; background-image: linear-gradient(45deg, rgba(255,255,255,.48) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.48) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.48) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.48) 75%); background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0; }.board-viewport.is-code-view { flex: 0 0 min(62vh, 620px); height: min(62vh, 620px); min-height: 0; place-items: start; }
.board-wrap { --board-size: min(62vh, 590px); --board-aspect: 1; position: relative; width: min(var(--board-size), calc(var(--board-size) * var(--board-aspect))); aspect-ratio: var(--board-aspect); height: auto; transform: scale(1); transform-origin: center; transition: transform 180ms ease; box-shadow: 11px 11px 0 rgba(29,39,48,.12), 0 2px 0 rgba(29,39,48,.12); }.board-wrap.is-code-view { width: var(--code-board-width); max-width: none; }.board-wrap::before { content: ""; position: absolute; inset: -10px; border: 1px solid rgba(29,39,48,.22); pointer-events: none; }.board-wrap canvas { width: 100%; height: 100%; display: block; cursor: crosshair; background: #fff; image-rendering: pixelated; }
.board-label { position: absolute; color: #62736d; font: 700 10px "Noto Sans SC", sans-serif; }.top-label { top: -25px; left: 0; }.bottom-label { right: -25px; bottom: 0; writing-mode: vertical-rl; }
.selected-cell { min-height: 41px; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 17px; color: var(--muted); font-size: 12px; text-align: center; }.selection-swatch { width: 15px; height: 15px; border-radius: 3px; background: transparent; }

.materials-heading { padding-bottom: 16px; border-bottom: 1px solid var(--line); }.materials-title-row { display: flex; justify-content: space-between; align-items: center; }.materials-heading h2 { margin: 0; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 21px; }.materials-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.palette-list { margin: 11px 0; padding: 0; list-style: none; overflow: auto; flex: 1; }.palette-item { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 9px; min-height: 44px; border-bottom: 1px solid #edf0ee; }.palette-swatch { width: 26px; height: 26px; border: 1px solid rgba(29,39,48,.18); border-radius: 4px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }.palette-name { display: grid; gap: 1px; min-width: 0; }.palette-name strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.palette-name span { color: var(--muted); font-size: 10px; }.palette-count { color: #596761; font-size: 12px; font-weight: 800; white-space: nowrap; }
.estimate-card { padding: 13px; border: 1px solid #ccd9d2; border-radius: 6px; background: #f3f8f5; }.estimate-card > div { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }.estimate-card span { color: var(--muted); font-size: 11px; }.estimate-card strong { font-size: 13px; }.estimate-card button { width: 100%; min-height: 35px; margin-top: 5px; font-size: 12px; }.tile-plan { margin: -1px 0 10px; padding: 0 0 8px; border-bottom: 1px solid #d5e1da; }.tile-plan > div { margin-bottom: 6px; }.tile-plan ol { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0; padding: 0; list-style: none; }.tile-plan li { display: flex; justify-content: space-between; gap: 5px; padding: 4px 5px; border: 1px solid #dce7e1; border-radius: 3px; background: rgba(255,255,255,.55); color: #587068; font-size: 9px; }.tile-plan li b { color: var(--ink); }
.tile-plan[hidden] { display: none; }

dialog { width: min(420px, calc(100% - 34px)); padding: 28px; border: 1px solid #d3dcd7; border-radius: 7px; color: var(--ink); box-shadow: 0 22px 60px rgba(29,39,48,.28); }.dialog-close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 25px; color: var(--muted); }dialog h2 { margin: 0 0 13px; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 24px; }dialog p:not(.eyebrow) { margin: 0 0 19px; color: #56645e; line-height: 1.75; font-size: 14px; }dialog::backdrop { background: rgba(28, 43, 45, .38); }

@media (max-width: 1060px) { .workspace { grid-template-columns: 255px minmax(420px, 1fr); }.materials-panel { grid-column: 1 / -1; min-height: 0; border-top: 1px solid var(--line); border-left: 0; }.materials-panel .palette-list { flex: none; max-height: 300px; }.control-panel { padding-inline: 18px; }.board-wrap { --board-size: min(58vh, 530px); } }
@media (max-width: 760px) { .topbar { height: auto; min-height: 62px; padding: 11px 14px; gap: 12px; flex-wrap: wrap; }.brand { font-size: 20px; }.project-name { order: 3; flex-basis: 100%; }.project-name input { width: calc(100% - 88px); }.autosave { font-size: 10px; }.top-actions { margin-left: auto; }.top-actions .icon-button { display: none; }.primary-button { min-height: 35px; padding-inline: 11px; font-size: 12px; }.workspace { min-height: 0; display: flex; flex-direction: column; }.control-panel { border: 0; border-bottom: 1px solid var(--line); padding: 17px 15px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }.panel-section { padding-bottom: 13px; margin-bottom: 13px; }.upload-section { grid-row: span 2; }.upload-dropzone { height: 118px; }.fit-section { grid-column: 1 / -1; }.tip-card { display: none; }.canvas-stage { min-height: calc(100vh - 390px); padding: 22px 15px 14px; }.stage-heading { margin-bottom: 15px; }.stage-heading h1 { font-size: 25px; }.stage-meta { align-items: end; flex-direction: column; gap: 2px; font-size: 11px; }.meta-divider { display: none; }.canvas-tools { margin-bottom: 12px; }.board-viewport { min-height: 330px; padding: 19px; }.board-viewport.is-code-view { flex-basis: min(64vh, 520px); height: min(64vh, 520px); min-height: 330px; }.board-wrap { --board-size: min(74vw, 470px); }.selected-cell { margin-top: 13px; }.zoom-control input { display: none; }.materials-panel { padding: 21px 15px; }.materials-panel .palette-list { max-height: 330px; } }
@media (max-width: 470px) { .control-panel { display: block; }.upload-section { display: grid; grid-template-columns: 105px 1fr; gap: 8px 10px; align-items: center; }.upload-section .section-label { grid-column: 1 / -1; margin: 0; }.upload-dropzone { height: 82px; }.upload-placeholder strong { font-size: 11px; }.upload-placeholder small, .upload-placeholder b { display: none; }.upload-trigger { margin: 0; }.canvas-stage { padding-inline: 11px; }.stage-meta { display: none; }.view-tabs button { padding-inline: 8px; }.board-viewport { min-height: 290px; padding: 13px; }.board-wrap { --board-size: min(78vw, 350px); } }
