* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0f1115;
  color: #e8eaed;
}

.app {
  display: grid;
  grid-template-columns: 420px 1fr;
  min-height: 100vh;
}

header {
  grid-column: 1 / -1;
  padding: 16px 20px;
  border-bottom: 1px solid #2a2f3a;
  background: #151922;
}

header h1 {
  margin: 0;
  font-size: 20px;
}

.subtitle {
  margin: 6px 0 0;
  color: #9aa3b2;
  font-size: 13px;
}

.sidebar {
  padding: 16px;
  border-right: 1px solid #2a2f3a;
  overflow: auto;
  background: #12161d;
}

.configurator-sidebar {
  padding: 14px;
}

.config-intro,
.config-step,
.selection-card,
.advanced-config {
  margin-bottom: 12px;
  border: 1px solid #2a2f3a;
  border-radius: 12px;
  background: #171c24;
}

.config-intro {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 13px;
}

.config-intro h2 {
  margin: 2px 0 0;
  font-size: 17px;
}

.step-kicker {
  color: #60a5fa;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}

.compact-load {
  width: auto !important;
  padding: 8px 12px !important;
}

.compact-file {
  grid-column: 1 / -1;
  margin: 0 !important;
  font-size: 11px;
}

.config-step {
  padding: 13px;
}

.step-title {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 11px;
}

.step-title > span {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  place-items: center;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.step-title strong,
.step-title small {
  display: block;
}

.step-title strong {
  font-size: 13px;
}

.step-title small {
  margin-top: 2px;
  color: #8f99aa;
  font-size: 10px;
}

.config-select,
.line-color-picker select {
  width: 100%;
  padding: 10px;
  border: 1px solid #3a4558;
  border-radius: 8px;
  background: #202733;
  color: #f1f5f9;
}

.segmented,
.material-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background: #10151d;
}

.segmented button,
.material-tabs button {
  padding: 8px 5px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #929daf;
  cursor: pointer;
  font-size: 11px;
}

.segmented button.active,
.material-tabs button.active {
  background: #2b3545;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.config-item-list {
  display: grid;
  gap: 7px;
  max-height: 235px;
  margin-top: 9px;
  overflow: auto;
}

.config-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 9px;
  border: 1px solid #30394a;
  border-radius: 9px;
  background: #202733;
  color: #e7ebf2;
  cursor: pointer;
  text-align: left;
}

.config-item:hover,
.config-item.active {
  border-color: #3b82f6;
  background: #23324a;
}

.config-item.locked {
  opacity: .58;
  cursor: not-allowed;
}

.config-item-index {
  display: grid;
  min-width: 28px;
  height: 28px;
  padding: 0 5px;
  place-items: center;
  border-radius: 7px;
  background: #111720;
  color: #9ba7b8;
  font-size: 10px;
}

.config-item-copy strong,
.config-item-copy small {
  display: block;
}

.config-item-copy strong { font-size: 12px; }
.config-item-copy small { margin-top: 2px; color: #8f99aa; font-size: 10px; }
.config-item-status { color: #93c5fd; font-size: 10px; }
.empty-copy { margin: 10px 0; color: #768195; font-size: 11px; text-align: center; }

.selected-material-bar {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  padding: 8px;
  border-radius: 9px;
  background: #10151d;
}

.selected-material-bar .skin-preview { height: 48px; }
.selected-material-bar small,
.selected-material-bar strong { display: block; }
.selected-material-bar small { color: #778296; font-size: 9px; }
.selected-material-bar strong { margin-top: 3px; font-size: 11px; }

.line-legend {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.line-legend > div {
  display: grid;
  grid-template-columns: 10px 1fr 48px auto;
  gap: 7px;
  align-items: center;
  font-size: 11px;
}

.line-legend span strong,
.line-legend span small { display: block; }
.line-legend small { color: #7e899b; font-size: 9px; }
.line-legend i { width: 8px; height: 8px; border-radius: 50%; }
.line-legend input { width: 100%; height: 28px; border: 0; background: transparent; }
.line-legend button { padding: 6px 7px; border: 0; border-radius: 6px; background: #334155; color: white; cursor: pointer; font-size: 9px; }
.wrap-dot { background: #64748b; }
.inside-dot { background: #facc15; }
.bolster-dot { background: #22d3ee; }
.subsection-label { margin: 12px 0 4px; color: #7f8a9b; font-size: 9px; }

.line-color-picker {
  display: grid;
  grid-template-columns: 75px 1fr;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  font-size: 11px;
}

.line-color-picker input[type="color"] { width: 100%; height: 34px; border: 0; background: transparent; }
.piping-compact { margin-top: 10px; padding-top: 8px; border-top: 1px solid #2c3442; }
.piping-compact label { display: grid; grid-template-columns: 1fr 60px auto; gap: 6px; align-items: center; margin-top: 6px; font-size: 10px; }
.piping-compact input { width: 100%; height: 28px; border: 0; background: transparent; }

.selection-card { padding: 12px; }
.selection-card-title { margin-bottom: 7px; color: #cbd5e1; font-size: 11px; font-weight: 700; }
.advanced-config summary { padding: 12px; color: #c4ccd8; cursor: pointer; font-size: 11px; }
.advanced-body { padding: 0 12px 12px; }
.advanced-body h3 { margin: 12px 0 7px; font-size: 11px; }
.config-actions { grid-template-columns: 1fr 1fr; }
.config-actions .btn { margin: 0 !important; }

.panel {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #2a2f3a;
  border-radius: 10px;
  background: #171c24;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 14px;
}

.hint,
.tip {
  color: #9aa3b2;
  font-size: 12px;
}

input[type="file"] {
  width: 100%;
  margin-bottom: 8px;
  color: #cbd2dc;
}

.btn {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.btn.primary {
  background: #3b82f6;
  color: white;
}

.btn.secondary {
  background: #2a3140;
  color: #e8eaed;
}

.btn + .btn {
  margin-top: 8px;
}

.actions {
  display: grid;
  gap: 8px;
}

.category-defaults {
  display: grid;
  gap: 8px;
}

.category-default {
  display: grid;
  grid-template-columns: 66px 1fr auto;
  gap: 7px;
  align-items: center;
  padding: 8px;
  border: 1px solid #303849;
  border-radius: 8px;
  background: #202733;
}

.category-default .category-name {
  font-weight: 700;
  font-size: 12px;
}

.category-default .category-value {
  min-width: 0;
  color: #b8c0ce;
  font-size: 11px;
  line-height: 1.35;
}

.category-default .btn,
.btn.compact {
  width: auto;
  padding: 7px 9px;
  font-size: 12px;
}

.selection-details {
  padding: 9px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #10151d;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.selection-details strong {
  color: #e8eaed;
}

.piping-row {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
}

.piping-row input[type="color"] {
  width: 100%;
  height: 32px;
  border: 0;
  background: transparent;
}

.order-summary {
  max-height: 320px;
  overflow: auto;
  line-height: 1.55;
}

.order-summary h3 {
  margin: 10px 0 4px;
  color: #e8eaed;
  font-size: 12px;
}

.order-summary ul {
  margin: 0;
  padding-left: 18px;
}

.order-empty {
  color: #778195;
}

.color-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}

.color-row input[type="color"] {
  width: 100%;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.color-row select {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #3a4254;
  background: #202733;
  color: #e8eaed;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid #3a4254;
  cursor: pointer;
}

.swatch.active {
  border-color: #fff;
}

.part-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow: auto;
}

.part-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: #202733;
  cursor: pointer;
  font-size: 13px;
}

.part-item:hover {
  background: #283041;
}

.part-item.locked {
  opacity: 0.62;
  cursor: not-allowed;
}

.locked-note {
  color: #fca5a5;
  font-weight: 700;
}

.layer-tag.inside {
  background: #413b14;
  color: #fde68a;
}

.layer-tag.bolster {
  background: #103b46;
  color: #67e8f9;
}

.part-item .code {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.part-item .layer-tag {
  font-weight: 500;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #1e3a2f;
  color: #86efac;
}

.part-item .layer-tag.stitch-tag {
  background: #3b2430;
  color: #fda4af;
}

.part-item .layer-tag.stitch-tag:first-letter {
  text-transform: uppercase;
}

.parts-panel .hint {
  margin: -4px 0 10px;
}

.part-item .desc {
  color: #9aa3b2;
  font-size: 11px;
}

.part-item .mini {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid #555;
  background: #fff;
}

.status {
  font-size: 12px;
  color: #9aa3b2;
  line-height: 1.5;
}

.canvas-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #2a2f3a;
  background: #151922;
  font-size: 13px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  background: #1c2230;
  border: 1px solid #2a2f3a;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #3a4455;
  border-radius: 6px;
  background: #252b36;
  color: #e8eaed;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.btn-icon.text {
  width: auto;
  padding: 0 8px;
  font-size: 12px;
}

.btn-icon:hover {
  background: #323a48;
}

#zoomLevel {
  min-width: 42px;
  text-align: center;
  font-size: 12px;
  color: #9aa3b2;
}

.viewport {
  flex: 1;
  overflow: auto;
  padding: 16px;
  background: #0b0d11;
}

.stage-wrap {
  transform-origin: 0 0;
  display: inline-block;
  min-width: min-content;
}

.viewport.pan-ready {
  cursor: default;
}

.viewport.pan-ready canvas {
  cursor: crosshair;
}

.viewport.pan-ready .svg-stage {
  cursor: default;
}

.viewport.panning,
.viewport.panning canvas,
.viewport.panning .svg-stage {
  cursor: grabbing !important;
  user-select: none;
}

.stage-wrap.layered-stage {
  position: relative;
}

.stage-wrap.layered-stage .svg-stage.doc-underlay {
  position: relative;
  z-index: 0;
}

.stage-wrap.layered-stage canvas.fill-overlay {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  background: transparent;
}

.svg-stage {
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  line-height: 0;
}

.svg-stage svg {
  display: block;
  height: auto;
}

.svg-part:hover {
  filter: brightness(0.95);
  outline: 1px dashed rgba(59, 130, 246, 0.6);
}

#modeBadge {
  padding: 2px 8px;
  border-radius: 999px;
  background: #2a3140;
  font-size: 12px;
}

#modeBadge.vector {
  background: #14532d;
  color: #bbf7d0;
}

.sidebar .btn.primary {
  margin-bottom: 4px;
}

#modeBadge.pdf {
  background: #713f12;
  color: #fde68a;
}

.skin-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.skin-controls input[type="file"] {
  margin: 0;
  font-size: 12px;
}

.skin-preview {
  width: 100%;
  height: 56px;
  border-radius: 8px;
  border: 1px dashed #3a4458;
  background: #0f131a center / cover no-repeat;
}

.skin-preview.has-skin {
  border-style: solid;
  border-color: #3b82f6;
}

.skin-library-title {
  color: #cbd2dc;
  font-size: 11px;
  font-weight: 600;
}

.skin-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: 300px;
  overflow: auto;
  padding-right: 2px;
}

.material-step .skin-library,
.overall-material-panel .skin-library {
  max-height: 360px;
  margin-bottom: 10px;
}

.material-step .skin-card-image,
.overall-material-panel .skin-card-image { height: 82px; }

.overall-material-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #334155;
}

.progress-connector {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-bottom: 10px;
  color: #bfdbfe;
  font-size: 11px;
  line-height: 1.4;
}

.progress-connector span {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  place-items: center;
  border-radius: 50%;
  background: #2563eb;
  color: white;
}

.diy-step > .btn {
  width: 100%;
}

.ventilation-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.ventilation-card .skin-card-image {
  height: 78px;
}

.ventilation-none {
  background:
    linear-gradient(135deg, rgba(255,255,255,.06), transparent 45%),
    #252b35 !important;
}

.skin-card-badge.perforated {
  background: #173b35;
  color: #6ee7b7;
}

.quilt-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  padding: 9px 10px;
  border: 1px solid #30394a;
  border-radius: 8px;
  background: #111720;
}

.quilt-color-row span {
  display: grid;
  gap: 2px;
  font-size: 11px;
}

.quilt-color-row small {
  color: #8490a3;
  font-size: 9px;
}

.quilt-color-row input[type="color"] {
  width: 58px;
  height: 32px;
  padding: 2px;
  border: 1px solid #465166;
  border-radius: 6px;
  background: #202733;
}

.quilt-color-row.disabled {
  opacity: .48;
}

.region-mode-tabs {
  margin-bottom: 10px;
}

.fixed-color-panel {
  margin-bottom: 10px;
  padding: 9px;
  border: 1px solid #30394a;
  border-radius: 9px;
  background: #111720;
}

.fixed-color-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #d8dee9;
  font-size: 11px;
}

.fixed-color-panel input[type="color"] {
  width: 54px;
  height: 30px;
  padding: 2px;
  border: 1px solid #465166;
  border-radius: 6px;
  background: #202733;
}

.fixed-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}

.fixed-swatches button {
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 5px;
  cursor: pointer;
}

.diy-hint {
  margin: 8px 0 10px;
  padding: 9px 10px;
  border: 1px solid #2563eb;
  border-radius: 8px;
  background: rgba(37, 99, 235, .12);
  color: #bfdbfe;
  font-size: 11px;
  line-height: 1.55;
}

body.region-diy-active .svg-stage svg {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M8 5l11 11-7 7L1 12z' fill='%23f8fafc' stroke='%230f172a' stroke-width='2'/%3E%3Cpath d='M18 19c3 3 4 5 2 7-2 2-5 1-5-2 0-1 1-3 3-5z' fill='%233b82f6' stroke='%230f172a'/%3E%3C/svg%3E") 3 27, crosshair !important;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; }
  .canvas-wrap { min-height: 70vh; }
}

.skin-card {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #3a4458;
  border-radius: 8px;
  background: #111720;
  color: #e8eaed;
  cursor: pointer;
  text-align: left;
}

.skin-card:hover,
.skin-card.active {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px #60a5fa inset;
}

.skin-card-image {
  display: block;
  width: 100%;
  height: 62px;
  background: #0f131a center / cover no-repeat;
}

.skin-card-label {
  display: block;
  padding: 5px 6px 3px;
  overflow: hidden;
  color: #dbe3ee;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skin-card-badge {
  display: inline-block;
  margin: 0 6px 6px;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 9px;
}

.skin-card-badge.suede {
  background: #3b2f1d;
  color: #fcd34d;
}

.skin-card-badge.smooth {
  background: #1d3540;
  color: #7dd3fc;
}

.skin-card-badge.textured {
  background: #2f2344;
  color: #d8b4fe;
}

.material-tabs small {
  color: #758095;
  font-size: 8px;
}

.color-row .skin-controls {
  align-items: stretch;
}

.svg-only.hidden,
.pdf-only.hidden,
.hidden {
  display: none !important;
}

.help-panel .steps {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.7;
}

.hint.warn {
  color: #fbbf24;
  font-size: 11px;
}

.svg-part.svg-hover {
  filter: brightness(0.92);
}

.svg-part.svg-highlight {
  filter: drop-shadow(0 0 4px #3b82f6);
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
}

.svg-bucket {
  stroke: #999;
  stroke-width: 0.5;
}

#canvas {
  display: block;
  background: #fff;
  cursor: crosshair;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

#canvas.fill-overlay {
  background: transparent;
  box-shadow: none;
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }
}
