.mondrian-customizer-page {
  --md-bg: #ecebe7;
  --md-panel: #f7f6f2;
  --md-ink: #111111;
  --md-muted: #65645f;
  --md-line: rgba(17, 17, 17, 0.14);
  --md-soft: rgba(17, 17, 17, 0.055);
  --md-red: #bf1c0d;
  --md-yellow: #e2bd18;
  --md-blue: #1b438d;
  --md-shadow: 0 28px 80px rgba(23, 22, 19, 0.12);
  --frame-gap: clamp(8rem, 16vh, 16rem);
  --frame-mobile-gap: 2rem;
  --frame-width: 1200;
  --frame-height: 1800;
  --frame-max-width: 800px;   /* 与地图定制器一致：设计稿显示上限 */
  --active-drawer-width: 0px;
}

.mondrian-customizer-page .footer {
  display: none;
}

body:not(.dark-theme).mondrian-customizer-page {
  --bg-primary: #e7e7e7;
  --bg-card: #f2f2f2;
  --border-card: rgba(17, 17, 17, 0.12);
  --text-primary: #111111;
  --text-secondary: rgba(17, 17, 17, 0.72);
  --text-muted: rgba(17, 17, 17, 0.56);
  --input-bg: color-mix(in srgb, #ffffff, #e7e7e7 18%);
  --input-border: rgba(17, 17, 17, 0.12);
  --input-focus-border: rgba(17, 17, 17, 0.28);
  --btn-primary-bg: #000000;
  --btn-primary-text: #ffffff;
  --btn-outline-border: rgba(17, 17, 17, 0.12);
  --btn-outline-text: #111111;
  --btn-outline-hover: #f0f0f0;
  --shadow-sm: 0 22px 60px rgba(17, 17, 17, 0.06);
  --shadow-md: 0 30px 80px rgba(17, 17, 17, 0.1);
  --badge-bg: #f0f0f0;
  --badge-text: rgba(17, 17, 17, 0.72);
  --hr-color: rgba(17, 17, 17, 0.08);
  --tab-bg: #f2f2f2;
  --tab-hover: #e6e6e6;
  --tab-active: #ededed;
  --drawer-bg: rgba(242, 242, 242, 0.95);
  --drawer-border: rgba(17, 17, 17, 0.12);
}

.mondrian-customizer-page main {
  min-height: calc(100vh - 76px);
}

.mondrian-app {
  position: relative;
  min-height: calc(100vh - 76px);
  color: var(--md-ink);
  background:
    linear-gradient(90deg, rgba(191, 28, 13, 0.06), transparent 26%),
    linear-gradient(180deg, rgba(27, 67, 141, 0.07), transparent 34%),
    var(--md-bg);
  --tab-width: 80px;
  --drawer-width: 380px;
}

.mondrian-app .main-content-container {
  min-height: calc(100vh - 76px);
  transition: margin-right 0.28s ease;
}

.mondrian-app .main-content-container.drawer-open {
  margin-right: calc(var(--drawer-width) + var(--tab-width));
  --active-drawer-width: var(--drawer-width);
}

.mondrian-workspace {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: calc(100vh - 76px);
  min-width: 0;
}

.mondrian-stage-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  min-height: 84px;
  padding: 1.1rem clamp(1rem, 2.5vw, 2rem);
  border-bottom: 1px solid var(--md-line);
  background: rgba(247, 246, 242, 0.72);
  backdrop-filter: blur(18px);
}

.mondrian-stage-bar p,
.section-title,
.panel-head span,
.panel-row label,
.slider-row label,
.print-grid span {
  margin: 0;
  color: var(--md-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-row label {
  flex: 0 0 72px;
}

.mondrian-stage-bar h1 {
  margin: 0.2rem 0 0;
  font-size: clamp(1.25rem, 2vw, 1.95rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: 0;
}

.mondrian-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 320px;
  min-height: 34px;
  padding: 0.45rem 0.7rem;
  overflow: hidden;
  color: var(--md-muted);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--md-line);
  border-radius: 8px;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mondrian-status span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mondrian-status strong {
  display: inline-grid;
  min-width: 30px;
  height: 26px;
  place-items: center;
  color: #ffffff;
  background: var(--md-ink);
  border-radius: 8px;
  font-size: 0.75rem;
}

.mondrian-stage-wrap {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: calc(var(--frame-gap) / 2);
  background-image:
    linear-gradient(rgba(17, 17, 17, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 17, 0.055) 1px, transparent 1px);
  background-size: 42px 42px;
}

.mondrian-stage {
  width: min(
    calc(100vw - var(--tab-width) - var(--active-drawer-width) - var(--frame-gap)),
    calc((100vh - var(--customizer-header-height) - var(--frame-gap)) * var(--frame-width) / var(--frame-height)),
    var(--frame-max-width)
  );
  max-width: 100%;
  aspect-ratio: calc(var(--frame-width) / var(--frame-height));
  background: #ffffff;
  box-shadow: var(--md-shadow);
}

.mondrian-svg {
  display: block;
  width: 100%;
  height: 100%;
  background: #f9f8f3;
  cursor: default;
}

.mondrian-block {
  cursor: pointer;
  transition: filter 0.12s ease, opacity 0.12s ease;
}

.mondrian-block:hover {
  filter: brightness(0.96);
}

.mondrian-lock-mark {
  pointer-events: none;
}

.split-handle {
  fill: transparent;
  cursor: col-resize;
  pointer-events: all;
}

.split-handle.horizontal {
  cursor: row-resize;
}

.split-handle:hover,
.split-handle.dragging {
  fill: rgba(27, 67, 141, 0.12);
}

.vertical-tab-bar {
  position: fixed;
  right: 0;
  z-index: 950;
  display: flex;
  flex-direction: column;
  width: var(--tab-width);
  height: calc(100vh - var(--customizer-header-height));
  align-items: center;
  justify-content: flex-start;
  background: var(--tab-bg);
  border-left: 1px solid var(--border-card);
  backdrop-filter: blur(12px);
}

.tab-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 62px;
  padding: 10px 0;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
}

.tab-item:hover,
.tab-item.active {
  color: var(--text-primary);
  background: var(--tab-active);
}

.tab-item.active {
  border-color: color-mix(in srgb, var(--text-primary), transparent 88%);
  border-left-color: var(--text-primary);
}

.tab-icon {
  position: relative;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-icon::before,
.tab-icon::after {
  position: absolute;
  content: "";
}

.tab-icon-size::before {
  inset: 4px;
  border: 2px solid currentColor;
}

.tab-icon-size::after {
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.tab-icon-generate::before {
  inset: 3px;
  border: 2px solid currentColor;
  transform: rotate(45deg);
}

.tab-icon-generate::after {
  inset: 9px;
  background: currentColor;
  border-radius: 999px;
}

.tab-icon-colors::before {
  inset: 2px 12px 12px 2px;
  background: var(--md-red);
  box-shadow: 10px 0 0 var(--md-yellow), 5px 10px 0 var(--md-blue);
}

.tab-icon-block::before {
  inset: 3px;
  border: 2px solid currentColor;
}

.tab-icon-block::after {
  top: 3px;
  bottom: 3px;
  left: 11px;
  width: 2px;
  background: currentColor;
}

.tab-icon-export::before {
  left: 10px;
  top: 3px;
  width: 2px;
  height: 13px;
  background: currentColor;
}

.tab-icon-export::after {
  left: 6px;
  top: 10px;
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.tab-item span:last-child {
  max-width: 100%;
  font-size: 0.68rem;
  line-height: 1.1;
  text-align: center;
}

.drawer-panel {
  position: fixed;
  right: var(--tab-width);
  z-index: 940;
  width: var(--drawer-width);
  padding: 1.8rem 1.5rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: var(--drawer-bg);
  border-left: 1px solid var(--drawer-border);
  box-shadow: -28px 0 60px rgba(0, 0, 0, 0.08);
  transform: translateX(calc(100% + var(--tab-width)));
  transition: transform 0.3s ease;
  backdrop-filter: blur(18px);
}

.drawer-panel.open {
  transform: translateX(0);
}

.drawer-header {
  position: sticky;
  top: -1.8rem;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: -1.8rem -1.5rem 0;
  padding: 1.15rem 1.5rem 0.95rem;
  background: var(--drawer-bg);
  border-bottom: 2px solid var(--hr-color);
  backdrop-filter: blur(18px);
}

.drawer-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0;
}

.close-drawer {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 1.35rem;
}

.drawer-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 1.4rem;
}

.panel-section {
  display: grid;
  gap: 0.75rem;
  padding: 0.95rem;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--md-line);
  border-radius: 8px;
}

.panel-tip {
  margin: 0;
  color: var(--md-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.generate-actions {
  gap: 0.45rem;
}

.generate-control-group {
  display: grid;
  gap: 0;
}

.generate-control-group > .panel-section {
  border-radius: 0;
}

.generate-control-group > .panel-section + .panel-section {
  border-top: 0;
}

.generate-control-group > .panel-section:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.generate-control-group > .panel-section:last-child {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.generate-settings {
  gap: 0.42rem;
}

.generate-settings .setting-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 30px;
  gap: 0.55rem;
  align-items: center;
}

.generate-settings .setting-row label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generate-settings .setting-row input[type="range"] {
  width: 100%;
}

.generate-settings .setting-row output {
  min-width: 30px;
  text-align: right;
}

.panel-row,
.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.slider-row output {
  min-width: 36px;
  color: var(--md-ink);
  font-size: 0.8rem;
  text-align: right;
}

.panel-section input[type="text"],
.panel-section input[type="number"],
.panel-section select {
  width: 100%;
  min-height: 42px;
  padding: 0 0.72rem;
  color: var(--md-ink);
  background: #ffffff;
  border: 1px solid var(--md-line);
  border-radius: 8px;
  outline: none;
}

.panel-section input[type="text"]:focus,
.panel-section input[type="number"]:focus,
.panel-section select:focus {
  border-color: rgba(27, 67, 141, 0.45);
}

.panel-section input[type="range"] {
  width: 100%;
  accent-color: var(--md-ink);
}

.button-grid {
  display: grid;
  gap: 0.5rem;
}

.button-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.chip {
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.chip:hover {
  border-color: color-mix(in srgb, var(--text-primary), transparent 72%);
  transform: translateY(-1px);
}

.chip.active-chip {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

.orientation-card {
  display: flex;
  min-height: 104px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.55rem;
  border-radius: 12px;
  padding: 0.7rem;
}

.orientation-card .preview-svg {
  width: 62px;
  height: 46px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
}

.orientation-card span {
  font-size: 0.78rem;
  font-weight: 800;
}

.panel-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0.68rem 0.72rem;
  color: var(--md-ink);
  background: #ffffff;
  border: 1px solid var(--md-line);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.panel-button:hover {
  border-color: rgba(17, 17, 17, 0.3);
  transform: translateY(-1px);
}

.panel-button.primary {
  color: #ffffff;
  background: var(--md-ink);
  border-color: var(--md-ink);
}

.panel-button.full {
  width: 100%;
}

.style-preset-list,
.color-control-list {
  display: grid;
  gap: 0.65rem;
}

.style-preset-list {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.color-control-list {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.28rem;
  background: rgba(17, 17, 17, 0.06);
  border: 1px solid var(--md-line);
  border-radius: 8px;
}

.segmented-control button {
  min-height: 38px;
  color: var(--md-muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control button.active {
  color: #ffffff;
  background: var(--md-ink);
}

.size-list {
  display: grid;
  gap: 0.5rem;
}

.size-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  min-height: 48px;
  padding: 0.62rem 0.72rem;
  color: var(--md-ink);
  background: #ffffff;
  border: 1px solid var(--md-line);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.size-option.active {
  color: #ffffff;
  background: var(--md-ink);
  border-color: var(--md-ink);
}

.size-option strong,
.size-option span {
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.2;
}

.size-option span {
  color: var(--md-muted);
  font-weight: 800;
}

.size-option.active span {
  color: rgba(255, 255, 255, 0.72);
}

.color-control {
  display: grid;
  grid-template-columns: 42px 64px minmax(0, 1fr);
  gap: 0.55rem;
  min-width: 0;
  align-items: center;
}

.color-control-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  color: var(--md-ink);
  font-size: 0.72rem;
  font-weight: 700;
}

.color-dot {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(17, 17, 17, 0.24);
  border-radius: 999px;
}

.color-control-picker {
  width: 42px;
  height: 32px;
  padding: 2px;
  background: #ffffff;
  border: 1px solid var(--md-line);
  border-radius: 8px;
  cursor: pointer;
}

.color-control-ratio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 0.45rem;
  align-items: center;
}

.color-control-ratio input[type="range"] {
  width: 100%;
  accent-color: var(--md-ink);
}

.color-control-ratio output {
  color: var(--md-muted);
  font-size: 0.75rem;
  text-align: right;
}

.style-preset {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  width: 100%;
  min-width: 0;
  min-height: 78px;
  padding: 0.5rem;
  overflow: hidden;
  color: var(--md-ink);
  background: #ffffff;
  border: 1px solid var(--md-line);
  border-radius: 6px !important;
  cursor: pointer;
}

.style-preset:hover {
  border-color: #999999;
}

.style-preset.active {
  border-color: var(--md-ink);
  box-shadow: inset 0 0 0 1px var(--md-ink);
}

.style-swatches {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(17, 17, 17, 0.18);
  border-radius: 5px;
}

.style-swatch {
  min-width: 0;
  min-height: 0;
}

.lock-toggle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 38px;
  color: var(--md-ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.lock-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--md-ink);
}

.print-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.print-grid label {
  display: grid;
  gap: 0.35rem;
}

.price-box {
  display: grid;
  align-content: center;
  min-height: 42px;
  padding: 0.62rem 0.72rem;
  background: #ffffff;
  border: 1px solid var(--md-line);
  border-radius: 8px;
}

.price-box span {
  color: var(--md-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.price-box strong {
  color: var(--md-ink);
  font-size: 1.05rem;
  line-height: 1.15;
}

.purchase-section {
  position: sticky;
  bottom: 0.75rem;
  z-index: 2;
  box-shadow: 0 18px 42px rgba(23, 22, 19, 0.1);
}

.cart-message {
  min-height: 1.2rem;
  margin: 0;
  color: var(--md-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

body.dark-theme .mondrian-customizer-page,
body.dark-theme.mondrian-customizer-page {
  --md-bg: #10100f;
  --md-panel: #171716;
  --md-ink: #f4f1e8;
  --md-muted: #a7a39b;
  --md-line: rgba(244, 241, 232, 0.15);
  --md-soft: rgba(244, 241, 232, 0.07);
  --md-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

body.dark-theme .mondrian-app {
  background:
    linear-gradient(90deg, rgba(191, 28, 13, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(27, 67, 141, 0.18), transparent 34%),
    var(--md-bg);
}

body.dark-theme .mondrian-stage-bar,
body.dark-theme .panel-section {
  background: rgba(24, 24, 22, 0.72);
}

body.dark-theme .mondrian-status,
body.dark-theme .panel-section input[type="text"],
body.dark-theme .panel-section input[type="number"],
body.dark-theme .panel-section select,
body.dark-theme .panel-button,
body.dark-theme .size-option,
body.dark-theme .style-preset,
body.dark-theme .price-box,
body.dark-theme .color-control-picker {
  color: var(--md-ink);
  background: #10100f;
}

body.dark-theme .panel-button.primary,
body.dark-theme .segmented-control button.active,
body.dark-theme .size-option.active,
body.dark-theme .style-preset.active,
body.dark-theme .panel-head strong {
  color: #111111;
  background: #f4f1e8;
  border-color: #f4f1e8;
}

@media (max-width: 1120px) {
  .mondrian-customizer-page main {
    min-height: calc(100vh - 58px);
  }

  .mondrian-app {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 58px);
  }

  .mondrian-workspace {
    border-right: 0;
  }

  .mondrian-panel {
    max-height: none;
    border-top: 1px solid var(--md-line);
  }

  .mondrian-stage {
    width: min(72vw, 620px);
  }
}

@media (max-width: 680px) {
  .mondrian-stage-bar {
    align-items: start;
    flex-direction: column;
    min-height: 0;
  }

  .mondrian-status {
    width: 100%;
    max-width: none;
  }

  .mondrian-stage-wrap {
    padding: 1rem;
  }

  .mondrian-stage {
    width: min(calc(100vw - var(--frame-mobile-gap)), 460px);
  }

  .button-grid.two,
  .button-grid.three,
  .print-grid {
    grid-template-columns: 1fr;
  }

  .color-control-list {
    gap: 0.42rem;
  }

  .color-control {
    grid-template-columns: 38px 54px minmax(0, 1fr);
    gap: 0.42rem;
  }

  .color-control-picker {
    width: 38px;
  }
}
