:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111;
  background: #f3f3f0;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { min-height: 100vh; overflow: hidden; }
button, input { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(290px, 360px) 1fr;
}

.panel {
  z-index: 2;
  padding: 24px;
  overflow-y: auto;
  background: rgba(250,250,247,.97);
  border-right: 1px solid #d8d8d3;
}

.brand { margin-bottom: 28px; }
.eyebrow { font-size: 11px; letter-spacing: .14em; font-weight: 700; }
h1 { margin: 8px 0 8px; font-size: 27px; letter-spacing: -.03em; }
p { line-height: 1.45; }
.brand p { margin: 0; color: #666; font-size: 14px; }

.control-group {
  padding: 16px 0;
  border-top: 1px solid #deded9;
}
.control-group > label:first-child { display: block; margin-bottom: 8px; font-weight: 650; font-size: 13px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input[type="url"] {
  width: 100%; min-width: 0; padding: 10px 11px;
  border: 1px solid #c9c9c4; border-radius: 8px; background: white;
}
button, .file-button {
  border: 1px solid #bdbdb8; border-radius: 8px; background: #fff;
  padding: 9px 12px; 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; font-size: 13px !important; }
#local-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.render-controls { display: grid; gap: 0; }
.display-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: center;
  padding-bottom: 12px;
}
.toggle { display: flex !important; align-items: center; gap: 8px; margin: 0 !important; font-weight: 500 !important; }
.setting-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 156px;
  align-items: center;
  gap: 14px;
  min-height: 46px;
  margin: 0 !important;
  border-top: 1px solid #ecece7;
  font-weight: 500 !important;
}
.setting-row > span:first-child { min-width: 0; }
.setting-control {
  width: 156px;
  min-width: 156px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.checkbox-control input[type="checkbox"] { margin: 0; }
.number-with-unit {
  display: grid;
  grid-template-columns: 118px 26px;
  gap: 8px;
  align-items: center;
  color: #666;
  font-size: 12px;
}
input[type="number"] {
  width: 118px;
  padding: 7px 8px;
  border: 1px solid #c9c9c4;
  border-radius: 7px;
  background: #fff;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.color-slot { justify-content: flex-end; }
input[type="color"] { width: 118px; height: 34px; border: 1px solid #c9c9c4; border-radius: 6px; background: white; padding: 2px; cursor: pointer; }
.background-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.background-swatch {
  width: 48px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  position: relative;
}
.background-swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid #111;
  border-radius: 3px;
  mix-blend-mode: difference;
}
.swatch-white { background: #fff; }
.swatch-gray13 { background: #dedede; }
.swatch-black { background: #000; }
.render-note {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid #ecece7;
  color: #777;
  font-size: 11px;
  line-height: 1.35;
}

.orientation-controls > label { margin-bottom: 10px !important; }
.plane-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plane-buttons button[aria-pressed="true"] { background: #111; border-color: #111; color: #fff; }
.axis-legend { display: flex; align-items: center; gap: 10px; margin-top: 11px; font-size: 12px; }
.axis-legend span { font-weight: 750; }
.axis-legend small { margin-left: 2px; color: #777; }
.axis-x { color: #ff0000; }
.axis-y { color: #00a000; }
.axis-z { color: #0000ff; }
body[data-axes-visible="false"] .axis-legend { opacity: .38; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions button:last-child { grid-column: 1 / -1; }

.stats { border-top: 1px solid #deded9; margin-top: 4px; }
.stats div { display: grid; grid-template-columns: 88px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid #ecece7; }
.stats span { color: #70706b; font-size: 12px; }
.stats strong { font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.note { color: #777; font-size: 11px; margin: 10px 0 0; }

.viewer { position: relative; min-width: 0; min-height: 100vh; background: #dedede; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; }
.studio-mark {
  position: absolute; top: 16px; left: 18px; z-index: 1;
  font-size: 12px; font-weight: 800; letter-spacing: .14em;
  color: #111; pointer-events: none;
}
.model-meta {
  position: absolute; top: 14px; right: 16px; z-index: 1;
  max-width: min(520px, calc(100% - 32px));
  padding: 9px 11px; border-radius: 9px;
  background: rgba(255,255,255,.82); backdrop-filter: blur(6px);
  pointer-events: none;
}
.model-meta strong, .model-meta span { display: block; }
.model-meta strong { font-size: 13px; }
.model-meta span { margin-top: 2px; color: #666; font-size: 11px; }
.file-name {
  position: absolute; right: 16px; bottom: 14px; z-index: 1;
  max-width: min(560px, calc(100% - 32px));
  padding: 7px 10px; border-radius: 999px;
  background: rgba(255,255,255,.78); backdrop-filter: blur(6px);
  color: #30302d; font-size: 11px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.viewport-hint {
  position: absolute; left: 16px; bottom: 14px; padding: 7px 10px;
  border-radius: 999px; background: rgba(255,255,255,.78); backdrop-filter: blur(6px);
  color: #60605b; font-size: 11px; pointer-events: none;
}
body[data-viewer-bg="black"] .studio-mark { color: #fff; }
body[data-viewer-bg="black"] .model-meta,
body[data-viewer-bg="black"] .file-name,
body[data-viewer-bg="black"] .viewport-hint {
  background: rgba(20,20,20,.78);
  color: #f2f2f2;
}
body[data-viewer-bg="black"] .model-meta span,
body[data-viewer-bg="black"] .viewport-hint { color: #c8c8c8; }

body.embed .panel { display: none; }
body.embed .app-shell { grid-template-columns: 1fr; }
body.embed .viewer { min-height: 100vh; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 62vh; }
  .panel { border-right: 0; border-bottom: 1px solid #d8d8d3; }
  .viewer { min-height: 62vh; }
  .file-name { max-width: 52%; }
  .setting-row { grid-template-columns: minmax(0, 1fr) 144px; }
  .setting-control { width: 144px; min-width: 144px; }
  .number-with-unit { grid-template-columns: 106px 26px; }
  input[type="number"], input[type="color"] { width: 106px; }
  .background-swatch { width: 44px; }
}
