:root {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #111;
  background: #dedede;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { min-height: 100vh; overflow: hidden; }
button, input, select { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(350px, 420px) 1fr; }
.panel { z-index: 2; padding: 24px 26px; overflow-y: auto; background: rgba(250,250,247,.98); border-right: 1px solid #d1d1cc; }
.brand { margin-bottom: 24px; }
.eyebrow { font-size: 10px; letter-spacing: .14em; font-weight: 750; }
h1 { margin: 7px 0 6px; font-size: 28px; letter-spacing: -.035em; }
.brand p { margin: 0; color: #696964; font-size: 13px; }

.control-group { padding: 15px 0; border-top: 1px solid #deded9; }
.control-group > label, .part-card > label { display: block; margin: 10px 0 7px; font-size: 12px; font-weight: 650; }
.section-title { margin-bottom: 12px; font-size: 11px; letter-spacing: .13em; font-weight: 800; }
input[type="text"], input[type="url"], input[type="number"], select {
  width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #c8c8c3; border-radius: 7px; background: #fff; color: #111;
}
input:disabled, select:disabled { opacity: .55; background: #f2f2ee; cursor: not-allowed; }
.url-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
button, .file-button { border: 1px solid #bdbdb7; border-radius: 7px; background: #fff; padding: 9px 11px; cursor: pointer; color: #111; }
button:hover, .file-button:hover { background: #f0f0ec; }
.file-button { display: inline-block !important; margin: 9px 0 0 !important; font-weight: 500 !important; }
input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.catalogue-import-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; }
.catalogue-import-row .file-button { margin: 0 !important; }
#catalogue-status { color: #62625d; font-size: 11px; line-height: 1.3; }
.mini-note { margin: 10px 0 0; color: #777; font-size: 10px; line-height: 1.42; }

.setting-row { display: grid; grid-template-columns: minmax(135px, 1fr) 165px; align-items: center; gap: 14px; min-height: 46px; border-top: 1px solid #ecece7; font-size: 12px; }
.setting-row label { margin: 0; font-weight: 600; }
.setting-row input[type="color"] { justify-self: stretch; width: 100%; height: 32px; padding: 2px; border: 1px solid #c8c8c3; border-radius: 6px; background: #fff; cursor: pointer; }
.setting-row select { justify-self: end; width: 165px; }
.label-row { grid-template-columns: 1fr; gap: 5px; padding: 9px 0; }
.label-row input { width: 100%; }
.compact-setting { min-height: 42px; }
.unit-control { display: grid; grid-template-columns: 88px auto; gap: 7px; align-items: center; justify-content: end; color: #62625d; font-size: 11px; }
.unit-control input { width: 88px; }

.assembly-controls, .geometry-controls, .view-controls, .light-controls, .frame-controls, .graphic-controls { display: grid; gap: 9px; }
.fixed-row { display: grid; grid-template-columns: 1fr auto; align-items: center; min-height: 34px; font-size: 12px; }
.fixed-row span { color: #666; }
.fixed-row strong { font-weight: 600; }
.toggle { display: flex !important; align-items: center; gap: 8px; margin: 0 !important; font-weight: 500 !important; }
.background-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 4px; }
.background-controls button[aria-pressed="true"] { background: #111; color: #fff; border-color: #111; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions button:last-child { grid-column: 1 / -1; }
.status-panel { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 12px 0; border-top: 1px solid #deded9; font-size: 12px; }
.status-panel span { color: #777; }
.assembly-info { margin-bottom: 8px; padding: 10px 11px; background: #efefea; border-radius: 7px; font-size: 10.5px; line-height: 1.45; color: #4f4f4a; }
.note { margin: 0; color: #777; font-size: 10.5px; line-height: 1.45; }

.viewer { position: relative; min-width: 0; min-height: 100vh; background: #dedede; overflow: hidden; }
#viewport { position: absolute; inset: 0; overflow: hidden; }
#viewport.fixed-frame { box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
#viewport canvas { display: block; width: 100%; height: 100%; }
.dev-overlay { position: absolute; top: 18px; left: 20px; z-index: 3; display: grid; gap: 3px; pointer-events: none; color: #111; }
.dev-overlay strong { font-size: 10px; letter-spacing: .12em; }
.dev-overlay span { font-size: 13px; font-weight: 700; }
.viewport-hint { position: absolute; right: 18px; top: 16px; z-index: 3; padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.72); color: #60605b; font-size: 10px; pointer-events: none; }
body[data-bg="black"] .dev-overlay { color: #f4f4f1; }
body[data-bg="black"] .viewport-hint { background: rgba(30,30,30,.72); color: #efefec; }

.graphic-preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  color: #050505;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.graphic-preview-overlay[hidden] { display: none; }
.graphic-title-block { position: absolute; top: 5.5%; left: 5.2%; display: grid; gap: .15em; }
.graphic-brand-name { font-size: clamp(15px, 1.55vw, 28px); font-weight: 500; letter-spacing: .075em; }
.graphic-model { font-size: clamp(17px, 1.7vw, 32px); font-weight: 750; letter-spacing: .02em; }
.graphic-logo { position: absolute; display: none; object-fit: contain; }
.graphic-logo-black { top: 5.2%; right: 5.2%; width: clamp(28px, 3.2vw, 56px); height: clamp(62px, 7vw, 124px); }
.graphic-logo-bags { top: 5.2%; right: 5.2%; width: clamp(170px, 20vw, 360px); height: auto; }
.graphic-materials { position: absolute; left: 5.2%; bottom: 6.2%; display: grid; gap: .15em; max-width: 48%; font-size: clamp(12px, 1.12vw, 22px); font-weight: 500; letter-spacing: .045em; text-transform: uppercase; }
.graphic-material { display: grid; grid-template-columns: 1.2em 1fr; align-items: baseline; }
.graphic-bullet { font-size: .8em; transform: translateY(-.05em); }

.graphic-preview-overlay[data-logo="simple"] .graphic-logo-black { display: block; }
.graphic-preview-overlay[data-logo="large"] .graphic-logo-bags { display: block; }
.graphic-preview-overlay[data-logo="mix"] .graphic-logo-bags,
.graphic-preview-overlay[data-logo="mix"] .graphic-logo-black { display: block; }
.graphic-preview-overlay[data-logo="mix"] .graphic-logo-black { top: auto; bottom: 5.2%; }

body[data-graphic-preview="on"] .dev-overlay { display: none; }
body[data-bg="black"] .graphic-preview-overlay { color: #f4f4f1; }
body[data-bg="black"] .graphic-logo { filter: invert(1); }
body[data-embed-frame="portrait"] .graphic-title-block { top: 5.2%; left: 7%; }
body[data-embed-frame="portrait"] .graphic-logo-black { top: 5%; right: 7%; width: 6.5%; height: 12%; }
body[data-embed-frame="portrait"] .graphic-logo-bags { top: 5%; right: 7%; width: 28%; }
body[data-embed-frame="portrait"] .graphic-preview-overlay[data-logo="mix"] .graphic-logo-black { top: auto; right: 7%; bottom: 5%; width: 6.5%; height: 12%; }
body[data-embed-frame="portrait"] .graphic-materials { left: 7%; bottom: 6%; max-width: 68%; font-size: clamp(12px, 1.45vw, 20px); }
body[data-embed-frame="landscape"] .graphic-materials { max-width: 42%; }

#loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: rgba(222,222,222,.92);
  pointer-events: none;
}
#loading-overlay[hidden] { display: none; }
.yoyo-loader-logo {
  width: 58px;
  height: 132px;
  object-fit: contain;
  transform-origin: 50% 50%;
  animation: yoyo-loader-turn 2.2s ease-in-out infinite;
}
.loading-label { font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
@keyframes yoyo-loader-turn {
  0%, 36% { transform: rotate(0deg); }
  64%, 100% { transform: rotate(180deg); }
}
body[data-bg="black"] #loading-overlay { background: rgba(0,0,0,.92); color: #f4f4f1; }
body[data-bg="black"] .yoyo-loader-logo { filter: invert(1); }

body.embed .panel { display: none; }
body.embed .app-shell { grid-template-columns: 1fr; }
body.embed .viewport-hint { display: none; }
body.embed #viewport.fixed-frame { box-shadow: none; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 66vh; }
  .panel { border-right: 0; border-bottom: 1px solid #d1d1cc; }
  .viewer { min-height: 66vh; }
  .setting-row { grid-template-columns: 1fr 150px; }
  .setting-row select { width: 150px; }
  .unit-control { grid-template-columns: 76px auto; }
  .unit-control input { width: 76px; }
  .graphic-materials { max-width: 68%; }
}
