:root {
  font-family: "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color: #253a30;
  background: #f7f6ef;
  font-synthesis: none;
  --ink: #253a30;
  --muted: #526459;
  --line: #d9ded2;
  --paper: #fffefa;
  --green: #315343;
  --soft: #edf3e9;
  --motion: cubic-bezier(.22, 1, .36, 1);
  --accent: #63836a;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .43; cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #6a916f; outline-offset: 3px; }
.topbar {
  height: 70px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 max(30px, calc((100vw - 1530px) / 2));
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.045em; }
.brand-icon { width: 34px; height: 34px; flex: none; background: var(--green); border-radius: 9px; display: grid; place-content: center; gap: 3px; }
.brand-icon i { display: block; width: 15px; height: 3px; border: solid #dcebdc; border-width: 0 0 1px 1px; }
.unit { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 6px 10px; text-align: center; }
.unit:empty { visibility: hidden; }
.workspace {
  width: min(100%, 1590px);
  margin: auto;
  padding: 26px 30px;
  display: grid;
  grid-template-columns: minmax(0, 2.25fr) minmax(310px, 1fr);
  gap: 20px;
  height: calc(100dvh - 70px);
  min-height: 560px;
}
.stage, .panel { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--paper); }
.stage { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.stage-top, .panel-top, .stage-bottom, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 22px; }
.stage-top h1 { font-size: clamp(25px, 2.8vw, 40px); margin: 0; letter-spacing: -.065em; line-height: 1.15; }
.stage-top p, .layer-toolbar p { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.view-actions, .toolbar-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.view-actions, .dialog-actions { justify-content: flex-end; }
#viewport {
  background: radial-gradient(ellipse at 46% 36%, #f9f8ed, #e9ece0 85%);
  position: relative;
  cursor: grab;
  touch-action: none;
  overflow: hidden;
  border-block: 1px solid #e0e4d7;
}
#viewport:focus-visible { outline-offset: -5px; }
#viewport.dragging { cursor: grabbing; }
#viewport canvas { display: block; width: 100%; height: 100%; }
.stage-bottom { padding-block: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.stage-bottom output { font-variant-numeric: tabular-nums; font-weight: 750; color: var(--ink); }
.primary, .subtle { white-space: nowrap; padding: 9px 12px; min-height: 37px; border-radius: 11px; font-size: 13px; font-weight: 750; }
.primary { color: white; background: var(--green); border: 1px solid var(--green); }
.primary:hover { background: #254336; }
.subtle { border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.subtle:hover:not(:disabled) { background: var(--soft); border-color: #b1c0ae; }
.danger { color: #833e31; }
.panel { display: flex; flex-direction: column; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.panel-top { background: var(--soft); border-bottom: 1px solid var(--line); }
.panel-top h2, .dialog-heading h2 { font-size: 21px; margin: 0; letter-spacing: -.045em; }
#layer-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.layer-toolbar { padding: 14px 17px; border-bottom: 1px solid var(--line); }
.layer-list { padding: 14px 16px; display: grid; align-content: start; gap: 9px; flex-shrink: 0; }
.layer { border: 1px solid var(--line); border-radius: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 3px; align-items: center; }
.layer-toggle { text-align: left; background: transparent; border: 0; color: var(--ink); display: flex; gap: 10px; align-items: center; padding: 9px 8px; border-radius: 7px; min-width: 0; }
.layer-toggle:hover { background: var(--soft); }
.layer-number { font-size: 13px; font-weight: 770; width: 34px; height: 34px; border-radius: 8px; background: #eef0e8; display: grid; place-items: center; flex: none; font-variant-numeric: tabular-nums; }
.layer-heading { display: grid; gap: 3px; flex: 1; min-width: 0; }
.layer-heading small { font-size: 12px; color: var(--muted); }
.chevron { width: 7px; height: 7px; border: solid var(--muted); border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); margin-right: 2px; flex: none; }
.height-handle {
  display: grid;
  place-items: center;
  background: var(--soft);
  border: 1px solid #b9c9b5;
  border-radius: 8px;
  color: var(--green);
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
  touch-action: none;
  user-select: none;
  cursor: ns-resize;
  width: 42px;
  height: 44px;
  margin: 0 3px;
}
.height-handle:hover, .height-handle.resizing { color: white; background: var(--green); border-color: var(--green); }
.scene-handles { position: absolute; z-index: 1; inset: 0; pointer-events: none; }
.scene-handle { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 32px; margin: 0; pointer-events: auto; box-shadow: 0 2px 7px #20352025; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

dialog { color: var(--ink); border: 1px solid var(--line); border-radius: 17px; background: var(--paper); padding: 0; width: min(780px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: 0 16px 54px #142b2060; }
dialog::backdrop { background: #1c302a76; }
.dialog-heading { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.edit-body { padding: 20px 22px 24px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 26px; }
.plan-section, .edit-controls { display: grid; gap: 16px; align-content: start; min-width: 0; }
.shapes { margin: 0; border: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.shapes legend { margin-bottom: 8px; font-size: 14px; font-weight: 760; }
.shapes label { position: relative; min-width: 0; }
.shapes input { position: absolute; opacity: 0; }
.shapes label span { border: 1px solid var(--line); border-radius: 7px; padding: 7px 4px; display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 40px; cursor: pointer; font-size: 12px; color: var(--muted); }
.shapes input:checked + span { border-color: #819d82; background: var(--soft); font-weight: 750; color: var(--ink); }
.shapes input:focus-visible + span { outline: 3px solid #6a916f; outline-offset: 2px; }
.shape { width: 11px; height: 9px; flex: none; border: solid var(--accent); border-width: 2px 0 0; }
.shape.left, .shape.wrap { border-left-width: 2px; }
.shape.right, .shape.wrap { border-right-width: 2px; }
.plan-guide { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-size: 14px; }
.plan-guide span { font-size: 12px; color: var(--muted); }
.plan-frame { display: grid; place-items: center; background: #f6f5ed; border: 1px solid var(--line); border-radius: 12px; height: 195px; min-width: 0; }
.plan { position: relative; }
.plan button { position: absolute; display: grid; place-items: center; overflow: hidden; padding: 0; background: #e8d5b9; border: 1px solid #947750; color: #3d352d; font-size: 12px; font-weight: 720; white-space: nowrap; }
.plan button[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: white; }
.plan button:focus-visible { z-index: 1; }
.panel-shortcuts { display: flex; flex-wrap: wrap; gap: 7px; }
.panel-shortcuts button[aria-pressed="true"] { background: var(--soft); border-color: var(--accent); }
.edit-controls h3 { font-size: 15px; margin: 0 0 10px; }
.dimensions, .extra-fields { display: grid; gap: 10px; }
.dimension-label, .partition-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 720; }
.number { display: flex; align-items: center; gap: 5px; padding-right: 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 12px; }
.number input { width: 76px; padding: 7px; border: 0; background: transparent; color: var(--ink); border-radius: 7px; font-variant-numeric: tabular-nums; font-weight: 750; font-size: 16px; }
.dimension-slider { appearance: none; width: 100%; height: 28px; margin: 3px 0 0; background: linear-gradient(to right, var(--accent) var(--progress), #e2e8de var(--progress)) center / 100% 5px no-repeat; cursor: ew-resize; touch-action: pan-y; }
.dimension-slider::-webkit-slider-thumb { appearance: none; width: 22px; height: 22px; border: 2px solid white; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 1px var(--accent); }
.dimension-slider::-moz-range-thumb { width: 18px; height: 18px; border: 2px solid white; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 1px var(--accent); }
#height-control, #extra-settings { border-top: 1px solid var(--line); padding-top: 12px; }
#extra-settings summary { font-size: 13px; font-weight: 750; cursor: pointer; }
.extra-fields { margin-top: 12px; }
.group-control { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.group-control input, .partition-control input { accent-color: var(--green); }
.partition-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: center; margin-top: 7px; font-size: 12px; }
.partition-control input { display: block; width: 100%; }
#partition-widths { color: var(--muted); font-size: 12px; margin: 0; }
.small-dialog { width: min(440px, calc(100% - 32px)); }
.small-dialog p { padding: 0 22px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.dialog-actions { padding: 2px 22px 20px; }

@media (max-width: 850px) {
  .workspace { height: auto; grid-template-columns: 1fr; padding: 14px; gap: 14px; }
  .topbar { height: 58px; padding: 0 14px; }
  .stage { grid-template-rows: auto minmax(330px, 52dvh) auto; }
}
@media (max-width: 600px) {
  .brand { font-size: 16px; }
  .unit { font-size: 11px; }
  .stage-top, .stage-bottom, .panel-top, .dialog-heading { padding: 14px; }
  .stage-top { flex-wrap: wrap; }
  .stage-top p, .layer-toolbar p { font-size: 12px; }
  .view-actions { justify-content: flex-start; }
  .edit-body { grid-template-columns: 1fr; padding: 13px 14px 20px; gap: 17px; }
  .plan-section { gap: 11px; }
  .plan-frame { height: 154px; }
  .small-dialog p, .dialog-actions { padding-inline: 14px; }
}

.floor-gap-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 4px 0 0 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.floor-gap-row output { margin-left: 5px; color: var(--ink); font-weight: 750; }
.gap-handle { background: #edf2f5; border-color: #b8c9d1; color: #325864; }
.gap-handle:hover, .gap-handle.resizing { background: #325864; border-color: #325864; }
#floor-gap-control { border-top: 1px solid var(--line); padding-top: 12px; }
#floor-gap-control small, #height-control small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.module-plus {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 16px;
  translate: -50% 0;
  width: max-content;
  max-width: calc(100% - 16px);
  min-height: 38px;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 15px;
  background: var(--green);
  border: 1px solid #fff;
  border-radius: 24px;
  box-shadow: 0 2px 10px #20352037;
  color: white;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  pointer-events: auto;
}
.module-plus:hover { background: #254336; }
.module-destination { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.module-destination select { width: 100%; min-height: 38px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; font-size: 14px; }
.dialog-module-fields { padding: 12px 22px; margin: 0; border-bottom: 1px solid var(--line); }
.module-options { padding: 4px 22px 16px; display: grid; gap: 12px; }
.module-options p { padding: 0; margin: 8px 0 0; }
.module-options fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 6px; }
.module-options legend { margin-bottom: 6px; font-size: 13px; font-weight: 750; }
.module-options fieldset label { display: flex; align-items: flex-start; gap: 8px; border: 1px solid var(--line); padding: 9px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.module-options fieldset label:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.module-options input { accent-color: var(--green); }
.module-options small { display: block; margin-top: 3px; color: var(--muted); }

.module-plus span { font-size: 18px; line-height: 1; }
#selected-controls { display: grid; gap: 10px; margin-top: 10px; }
#side-offset small { color: var(--muted); font-size: 12px; }
.side-tools {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 3px 14px #20352032;
  white-space: nowrap;
}
.side-tools button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 3px 6px;
  background: var(--soft);
  color: var(--green);
  font-weight: 750;
  font-size: 12px;
  touch-action: none;
  user-select: none;
}
.side-tools button span { font-size: 15px; }
.side-tools button:hover, .side-tools button.resizing { background: var(--green); color: white; }
#side-shift { cursor: ew-resize; }
#side-lift { cursor: ns-resize; }
@media (max-width: 540px) {
  .module-plus { padding: 6px 7px; font-size: 11px; }
}

.layer-toggle[aria-pressed="true"] {
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.stage, .panel { box-shadow: 0 8px 28px #2942330b; }
.panel > * { flex-shrink: 0; }
#layer-editor, #delete-module { scroll-margin-block: 12px; }
.layer-list:not([hidden]) { animation: list-in 180ms ease-out both; }
@keyframes list-in { from { opacity: .45; transform: translateY(4px); } }
.editor-heading { padding: 14px 16px; display: grid; gap: 9px; background: #f4f7f0; border-bottom: 1px solid var(--line); }
.editor-heading h2 { font-size: 17px; margin: 0; letter-spacing: -.035em; }
#layer-editor .dialog-module-fields { padding: 12px 16px; }
#layer-editor .edit-body { padding: 15px 16px 20px; grid-template-columns: minmax(0, 1fr); gap: 20px; }
#layer-editor .plan-frame { height: 145px; }
#delete-module { background: #fbefea; border-color: #ebd3cb; }
#delete-module:hover { background: #f5dfd7; border-color: #d9a89b; }
button, .shapes label span, .module-options fieldset label {
  transition: background-color 170ms ease, border-color 170ms ease, color 160ms ease,
    box-shadow 190ms var(--motion), scale 190ms var(--motion);
}
@media (hover: hover) and (pointer: fine) {
  :is(.primary, .subtle, .module-plus):hover:not(:disabled) { scale: 1.025; box-shadow: 0 4px 12px #29423324; }
}
:is(.primary, .subtle, .module-plus):active:not(:disabled) { scale: .98; }
dialog[open] { animation: modal-in 240ms var(--motion) both; }
dialog[open]::backdrop { animation: backdrop-in 220ms ease both; backdrop-filter: blur(3px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(9px) scale(.985); } }
@keyframes backdrop-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::backdrop { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  :is(.primary, .subtle, .module-plus):is(:hover, :active) { scale: 1; }
}

.installation-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 750;
}
#front-position { padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.wall-margins {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 4px 0 0;
}
.wall-margins div {
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f7f7ef;
  transition: background-color 180ms ease, border-color 180ms ease;
}
.wall-margins .wall-touch { border-color: #adc7af; background: #e6f1e5; }
.wall-margins dt { font-size: 11px; color: var(--muted); }
.wall-margins dd { margin: 3px 0 0; font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums; }
#wall-contact { margin: 5px 0 0; font-size: 12px; color: var(--green); min-height: 1.35em; }

/* Virtual product library: independent of the cabinet viewer */
.vl-root{grid-column:1/-1;min-width:0}.virtual-library{background:#fff;border:1px solid #e5e7eb;border-radius:16px;padding:20px}.virtual-library h2{font-size:20px;margin:0 0 8px}.virtual-library h2 small{font-size:12px;color:#6b7280}.virtual-library p{color:#6b7280;font-size:13px}.vl-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px;margin:16px 0}.vl-card{display:flex;flex-direction:column;align-items:center;gap:7px;min-width:0;padding:14px 5px;border:1px solid #e5e7eb;border-radius:12px;background:#fafaf9;color:#374151;cursor:pointer}.vl-card[aria-pressed=true]{border:2px solid #426d5a;background:#eef5f0}.vl-card b{font-size:12px}.vl-card small{font-size:11px;color:#6b7280}.vl-glyph{font-size:32px;color:#8a9da1}.vl-editor{border-top:1px solid #e5e7eb;padding-top:12px}.vl-editor h3{margin:0 0 12px;font-size:16px}.vl-dims{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.vl-editor label{font-size:12px;display:block}.vl-editor input,.vl-editor select{width:100%;padding:9px;border:1px solid #cbd5d1;border-radius:8px;background:#fff;color:#1f2937}.vl-preview{display:flex;align-items:center;gap:14px;margin-top:14px;padding:12px;background:#f8faf9;border-radius:10px}.vl-swatch{width:56px;height:56px;flex-shrink:0;border:1px solid #a5a5a5;border-radius:8px}.vl-preview p{margin:3px 0}.vl-disclaimer{margin-bottom:0}@media(max-width:800px){.vl-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.vl-dims{grid-template-columns:repeat(2,minmax(0,1fr))}}
.vl-actions{display:flex;flex-wrap:wrap;align-items:end;gap:10px;margin-top:14px}.vl-actions label{flex:1;min-width:145px}.vl-actions button{padding:10px 14px;border-radius:9px;cursor:pointer}.vl-actions button:disabled{opacity:.45;cursor:not-allowed}

/* Styling studio */
.style-studio{padding:18px;border:1px solid var(--line,#deded8);border-radius:16px;margin:16px 0;background:var(--panel,#fff)}
.style-studio h2{font-size:20px;margin:0 0 8px}.style-studio h2 small{font-size:12px;font-weight:400;color:#777}.style-studio>p{font-size:13px;color:#666;line-height:1.6}.style-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin:14px 0}.style-card{display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:13px;text-align:left;background:#fafaf8;color:#262626;border:1px solid #ddd;border-radius:12px;cursor:pointer}.style-card[aria-pressed="true"]{border:2px solid #547d70;background:#eef4ef}.style-card strong{font-size:13px}.style-card small{font-size:11px;color:#666}.style-swatches{display:flex;gap:4px}.style-swatches i{display:block;width:25px;height:25px;border:1px solid #ccc;border-radius:6px}.style-studio-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.style-studio-actions span{font-size:12px;color:#456d61}

/* v3.1: keep the cabinet editor visible after adding styling panels. */
.workspace {
  height: auto;
  min-height: calc(100dvh - 70px);
  grid-template-rows: minmax(600px, auto) auto auto;
  align-items: stretch;
}
.workspace > .stage, .workspace > .panel { min-height: 600px; }
.workspace > .stage { height: 700px; }
.workspace > .panel { height: 700px; }
#viewport { min-height: 380px; }
#style-templates-root, #virtual-library-root {grid-column:1 / -1;}
@media (max-width: 850px) {
  .workspace { grid-template-rows: auto; min-height:0; }
  .workspace > .stage {min-height:490px;height:auto;}
  .workspace > .panel {min-height:480px;height:auto;max-height:780px;}
  #viewport {min-height:330px;}
}
