:root {
  color-scheme: dark;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #f5f6f6;
  background: #272b2d;
  --panel: #202427;
  --surface: #303537;
  --hover: #3b4245;
  --muted: #b1b8bc;
  --text: #f5f6f6;
  --line: rgb(255 255 255 / 14%);
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 14px; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-library { position: absolute; width: 0; height: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: clamp(28px, 5.5vw, 88px);
  height: 76px;
  padding-inline: clamp(20px, 4.2vw, 68px);
  background: var(--panel);
}
.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  color: var(--text);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: .06em;
  white-space: nowrap;
}
.brand-mark { position: relative; flex: none; width: 26px; height: 28px; border: 1.5px solid currentColor; border-radius: 4px; }
.brand-mark::before { content: ""; position: absolute; inset: 0 auto 0 50%; border-left: 1px solid currentColor; }
.brand-mark::after { content: ""; position: absolute; top: calc(50% - 2px); left: calc(50% - 5px); width: 2px; height: 4px; border-radius: 1px; background: currentColor; box-shadow: 8px 0 currentColor; }
.topbar-title { min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.language-control { position: relative; flex: none; margin-inline-start: auto; }
.language-control::after { content: ""; position: absolute; top: calc(50% - 4px); inset-inline-end: 9px; width: 5px; height: 5px; border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
.language-select { appearance: none; display: block; padding: 6px 23px 6px 8px; border: 0; border-radius: 5px; color: var(--text); background: transparent; font: inherit; cursor: pointer; }
.language-select:hover { background: rgb(255 255 255 / 7%); }
.language-select:focus-visible { outline: 1px solid rgb(255 255 255 / 45%); outline-offset: 1px; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(360px, 35.4vw, 680px);
  gap: 16px;
  padding: 16px;
  height: calc(100svh - 76px);
  min-height: 570px;
}
.stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: radial-gradient(ellipse at 48% 42%, #444c50, #353b3e 58%, #2d3336);
}
.stage-heading { position: absolute; top: 26px; left: 24px; z-index: 1; pointer-events: none; }
.stage-heading p { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 0; }
.stage-heading .eyebrow { font-size: 12px; }
.stage-heading h1, h2 { margin: 0; font-weight: 550; }
.stage-heading h1 { margin-block: 12px 14px; font-size: clamp(23px, 2vw, 30px); line-height: 1.37; }
.stage-tools { position: absolute; z-index: 2; top: 24px; right: 24px; display: grid; gap: 8px; }
.stage-tools button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(32 36 39 / 20%);
  font-size: 13px;
}
.stage-tools button:hover:enabled, .stage-tools button[aria-pressed="true"] { background: var(--hover); }
.viewport { position: absolute; inset: 0 0 59px; }
.viewport :is(#wardrobe-canvas, .ruler-labels) { opacity: 0; transition: opacity 240ms ease-out; }
.viewport[data-ready="true"] :is(#wardrobe-canvas, .ruler-labels) { opacity: 1; }
.viewport:not([data-ready="true"]) #wardrobe-canvas { pointer-events: none; }
#wardrobe-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#wardrobe-canvas:active { cursor: grabbing; }
.ruler-labels { position: absolute; inset: 0; pointer-events: none; }
.ruler-labels span {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 6px;
  background: rgb(32 36 39 / 92%);
  color: var(--text);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.stage-status, .texture-status {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 40px);
  padding: 12px 15px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  margin: 0;
  width: max-content;
}
.texture-status { top: auto; bottom: 8px; transform: translateX(-50%); font-size: 12px; }
.stage-status p { margin: 0; }
.stage-status progress { display: block; width: min(160px, 50vw); height: 6px; margin: 12px auto 0; accent-color: var(--text); }
.scene-load-steps { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; font-size: 12px; }
.scene-load-steps li { display: flex; justify-content: space-between; gap: 16px; }
.scene-load-steps li[data-status="ready"] span:last-child { color: var(--text); }
.stage-footer {
  position: absolute;
  z-index: 1;
  inset: auto 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 55px;
  gap: 10px;
  border-top: 1px solid var(--line);
}
.stage-spec { display: flex; flex-wrap: wrap; gap: 5px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.stage-spec span:first-child { color: var(--muted); }
.zoom-tools { display: flex; gap: 4px; }
.zoom-tools button, .dialog-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 8px;
}
.zoom-tools button:hover:enabled, .dialog-close:hover { background: var(--hover); }

.panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; border-radius: var(--radius); background: var(--panel); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); padding-inline: 12px; }
.tabs button { position: relative; height: 62px; border: 0; background: transparent; color: var(--muted); }
.tabs button:hover, .tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; inset: auto calc(50% - 14px) 0; height: 2px; background: var(--text); }
.tabs button:focus-visible { outline-offset: -4px; border-radius: 8px; }
.panel-content { padding: 24px; overflow: auto; scrollbar-width: thin; }
h2 { font-size: clamp(21px, 1.8vw, 28px); line-height: 1.3; }
.section-copy { margin: 9px 0 0; color: var(--muted); line-height: 1.65; font-size: 13px; }
.dimension-fields { display: grid; gap: 27px; margin-top: 32px; }
.dimension-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.number-field {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  width: 116px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}
.number-field:focus-within { border-color: var(--text); }
.number-field input { min-width: 0; width: 100%; color: var(--text); background: transparent; border: 0; outline: none; padding: 0; appearance: textfield; }
.number-field input::-webkit-inner-spin-button { appearance: none; }
.number-field span, .dimension-ends { color: var(--muted); font-size: 12px; }
.dimension-field input[type="range"] { appearance: none; display: block; width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer; }
.dimension-field input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 5px; background: linear-gradient(to right, var(--text) var(--fill, 0%), #666d70 var(--fill, 0%)); }
.dimension-field input[type="range"]::-moz-range-track { height: 5px; border-radius: 5px; background: linear-gradient(to right, var(--text) var(--fill, 0%), #666d70 var(--fill, 0%)); }
.dimension-field input[type="range"]::-webkit-slider-thumb { appearance: none; width: 15px; height: 15px; margin-top: -5px; border: 0; border-radius: 50%; background: var(--text); }
.dimension-field input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border: 0; border-radius: 50%; background: var(--text); }
.dimension-ends { display: flex; justify-content: space-between; margin-top: 5px; font-variant-numeric: tabular-nums; }

.door-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
#panel-finishes { display: flex; flex-direction: column; }
#panel-finishes h2 { font-size: clamp(24px, 1.667vw, 32px); font-weight: 500; }
.finish-target { margin: 22px 0 0; color: var(--muted); font-size: 13px; }
.finish-scopes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 24px; padding: 4px; gap: 2px; border-radius: 8px; background: var(--surface); }
.finish-scopes button { min-width: 0; padding: 9px 4px; background: transparent; color: var(--muted); border: 0; border-radius: 6px; }
.finish-scopes button[aria-pressed="true"] { background: var(--text); color: var(--panel); }
.finish-summary { display: flex; align-items: center; justify-content: center; gap: 5px; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.finish-scopes button[aria-pressed="true"] .finish-summary { color: #555d61; }
.finish-summary img { flex: none; width: 14px; height: 14px; border: 1px solid var(--line); border-radius: 2px; object-fit: cover; }
.finish-summary-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 68px), 1fr)); gap: 18px 12px; margin-top: 24px; }
.finish-tile { position: relative; display: block; width: 100%; aspect-ratio: 1; min-width: 0; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 4px; background-clip: padding-box; }
.finish-tile[aria-pressed="true"] { border-color: var(--text); }
.finish-tile:focus-visible { outline-offset: 2px; }
.finish-tile img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border-radius: 2px; object-fit: cover; }
.finish-tile strong { position: absolute; inset: auto 0 0; padding: 4px; overflow-wrap: anywhere; background: rgb(36 32 34 / 75%); color: var(--text); font-size: 12px; font-weight: 400; line-height: 1.4; text-align: center; opacity: 0; pointer-events: none; }
:lang(en) .finish-tile strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.finish-tile:is([aria-pressed="true"], [aria-busy="true"], :active, :focus-visible) strong { opacity: 1; }
.finish-tile[aria-busy="true"]::before { content: ""; position: absolute; inset: 0; background: rgb(32 36 39 / 50%); z-index: 1; }
.finish-tile[aria-busy="true"]::after { content: ""; position: absolute; inset: 0; width: 22px; height: 22px; margin: auto; border: 2px solid rgb(255 255 255 / 30%); border-top-color: var(--text); border-radius: 50%; animation: finish-loading 650ms linear infinite; z-index: 2; }
.finish-tile[aria-busy="true"] strong { z-index: 2; }
@keyframes finish-loading { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .viewport :is(#wardrobe-canvas, .ruler-labels) { transition: none; }
  .finish-tile[aria-busy="true"]::after { animation: none; }
}
@media (hover: hover) {
  .finish-tile:hover strong { opacity: 1; }
}
.option { display: grid; gap: 5px; align-content: start; min-width: 0; padding: 5px 5px 9px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.option:hover { background: var(--hover); }
.option[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.option img { display: block; width: 100%; height: auto; border-radius: 5px; }
.option strong, .option small { padding-inline: 3px; overflow-wrap: anywhere; }
.option strong { font-size: 13px; font-weight: 500; }
.option small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.door-grid img { aspect-ratio: 4 / 5; object-fit: contain; background: #e4e5e3; }

.panel-footer { border-top: 1px solid var(--line); padding: 16px 24px 22px; }
.config-summary { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 12px; }
.config-summary strong { font-size: 17px; font-weight: 500; }
.config-summary p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.price { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price strong { font-size: 22px; }
.footer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.button { min-height: 42px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.button:hover { background: var(--hover); }
.primary { background: var(--text); color: var(--panel); font-weight: 600; border-color: transparent; }
.primary:hover { background: #dce0e1; }

dialog { width: min(440px, calc(100% - 36px)); padding: 26px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 60px rgb(0 0 0 / 35%); }
dialog::backdrop { background: rgb(0 0 0 / 65%); }
.dialog-close { position: absolute; inset: 10px 10px auto auto; }
.budget-lines { display: grid; grid-template-columns: 1fr auto; margin: 18px 0 0; }
.budget-lines :is(dt, dd) { margin: 0; padding-block: 9px; border-bottom: 1px solid var(--line); }
.budget-lines dd { text-align: right; font-variant-numeric: tabular-nums; }
.budget-lines :nth-last-child(-n + 2) { font-weight: 650; border-bottom: 0; }
.contact-qr { display: block; max-width: 100%; height: auto; margin: 20px auto 0; background: #fff; border: 8px solid #fff; border-radius: 8px; }

@media (max-width: 780px) {
  .topbar { height: 58px; padding-inline: 16px; gap: 12px; }
  .brand { min-width: 0; gap: 8px; font-size: 17px; letter-spacing: .03em; }
  .language-select { padding: 5px 21px 5px 6px; font-size: 12px; }
  .brand-mark { width: 22px; height: 24px; }
  .workspace { grid-template-columns: minmax(0, 1fr); height: auto; gap: 10px; padding: 10px; }
  .stage { min-height: clamp(370px, 62svh, 540px); }
  .stage-heading { inset: 16px auto auto 16px; }
  .stage-heading h1 { margin-block: 4px 0; font-size: 21px; }
  .stage-heading p:not(.eyebrow) { display: none; }
  .stage-heading .eyebrow { font-size: 8px; }
  .stage-tools { inset: 13px 12px auto auto; gap: 5px; }
  .stage-tools button { min-height: 31px; padding: 4px 6px; font-size: 11px; }
  .stage-tools svg { width: 14px; height: 14px; }
  .viewport { inset: 92px 0 48px; }
  .stage-footer { inset-inline: 14px; min-height: 47px; }
  .panel { grid-template-rows: auto minmax(0, 1fr) auto; min-height: 470px; }
  .panel-content, .panel-footer { padding: 16px; }
  .tabs button { height: 49px; }
  .dimension-fields { gap: 19px; margin-top: 22px; }
  .dimension-header { margin-bottom: 10px; }
  .number-field { height: 35px; }
  .finish-scopes { margin-top: 12px; }
  .finish-target { order: 1; margin-top: 8px; font-size: 12px; }
  .finish-grid { order: 2; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; margin-top: 12px; }
}
