.cr-rail, .cr-dialog { --cr-ink:#26251f; --cr-paper:#f1eee7; --cr-line:#cbc5b7; --cr-muted:#625e51; }
/* Keep the room in the same column as the perspective controls, under the canvas.
   The dock has its own grid row so it never covers a small screen's 3D viewport. */
#studio :is(#maStudio,#thStudio,#hyStudio,#nuStudio,#standardEditor).cr-editor-docked:not([hidden]) {
  display:grid; grid-template-areas:"scene inspector" "dock inspector";
  grid-template-rows:minmax(0,1fr) auto;
}
.cr-editor-docked > :is(#maStage,#thStage,#hyStage,#nuStageBox,#stage) { grid-area:scene; }
.cr-editor-docked > :is(#maInspector,#thInspector,#hyInspector,.hy-inspector,.nuSide,#editorPanel) { grid-area:inspector; }
#studio .cr-rail {
  grid-area:dock; min-width:0; display:flex; align-items:center; gap:8px;
  padding:6px clamp(8px,1vw,17px); box-sizing:border-box; color:var(--cr-ink); background:#eee9df;
  border-block-start:1px solid #c6bdad; border-inline-end:1px solid #c6bdad;
}
#studio .cr-rail button,.cr-dialog button { font:inherit; line-height:1.28; cursor:pointer; touch-action:manipulation; }
#studio .cr-rail button {
  min-height:44px; margin:0; padding:6px 12px; border:1px solid #b5ab9b; border-radius:3px;
  display:inline-flex; align-items:center; justify-content:center; gap:7px; color:var(--cr-ink); background:transparent;
  font:500 .875rem/1.16 var(--sans,Arial,sans-serif); text-align:start;
}
#studio .cr-rail button strong { font-weight:550; }
#studio .cr-room-view { border-color:#766e60; }
#studio .cr-room-view[aria-pressed=true] { border-color:#322c24; background:#322c24; color:#fff9ed; }
.cr-room-caption { display:grid; gap:2px; }
#crRoomMeasure { font-size:.75rem; font-variant-numeric:tabular-nums; white-space:nowrap; }
.cr-house { font:1.45rem/1 Georgia,serif; }
#studio .cr-rail .cr-open { margin-inline-start:auto; }
#studio .cr-rail .cr-open:hover,#studio .cr-rail .cr-quick-add:hover { background:#e2dbce; }
.cr-quick-add>span { font-size:1.1rem; line-height:1; }
.cr-scale-readout { display:grid; gap:2px; font-size:.75rem; line-height:1.2; color:#5f5548; }
.cr-scale-readout strong { font-size:.8125rem; font-weight:500; color:#332a21; font-variant-numeric:tabular-nums; }
.cr-scale-readout[hidden],#studio #roomViewBtn,#studio #nuVroom { display:none!important; }
@media(max-width:780px) and (orientation:portrait) {
  #studio :is(#maStudio,#thStudio,#hyStudio,#nuStudio,#standardEditor).cr-editor-docked:not([hidden]) {
    grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,43%) auto minmax(0,1fr);
    grid-template-areas:"scene" "dock" "inspector";
  }
  #studio .cr-editor-docked>:is(#maStage,#thStage,#hyStage,#nuStageBox,#stage) { height:100%; min-height:0; }
}
@media(max-width:570px),(max-width:1020px) and (orientation:landscape) {
  #studio .cr-rail { gap:5px; padding:4px 7px; }
  #studio .cr-rail button { padding:5px 8px; }
  #studio .cr-rail .cr-quick-add { width:44px; flex:none; }
  .cr-quick-add strong { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
}
@media(max-width:425px) {
  #studio .cr-rail { flex-wrap:wrap; }
  .cr-scale-readout { order:4; flex:1 0 100%; display:flex; justify-content:space-between; align-items:center; }
}
.cr-dialog:not([open]) { display:none; }
dialog.cr-dialog { position:fixed; inset:0; width:min(1600px,96vw); height:min(960px,94vh); height:min(960px,94dvh); max-width:none; max-height:none; margin:auto; padding:0; overflow:hidden; border:1px solid #9f988b; border-radius:5px; color:var(--cr-ink); background:var(--cr-paper); box-shadow:0 30px 110px #0a090950; font-family:inherit; }
.cr-dialog::backdrop { background:rgba(26,24,20,.63); }
.cr-shell { height:100%; display:flex; flex-direction:column; }
.cr-head { flex:none; padding:12px clamp(15px,2vw,34px); display:flex; justify-content:space-between; align-items:center; gap:14px; border-bottom:1px solid var(--cr-line); background:#f5f2eb; }
.cr-head>div,.cr-actions { display:flex; align-items:center; gap:clamp(12px,2.1vw,34px); }
.cr-head img { width:96px; max-height:23px; object-fit:contain; }
.cr-head h2, .cr-panel h3 { margin:0; font-family:Georgia,'Times New Roman',serif; font-weight:400; }
.cr-head h2 { font-size:clamp(25px,2.5vw,36px); line-height:1; letter-spacing:-.045em; }
.cr-dialog button { background:transparent; color:inherit; border:1px solid var(--cr-line); border-radius:2px; padding:10px 13px; min-height:40px; }
.cr-dialog button:focus-visible, #studio .cr-rail button:focus-visible, .cr-dialog input:focus-visible { outline:2px solid #876031; outline-offset:2px; }
.cr-dialog .cr-primary { background:var(--cr-ink); border-color:var(--cr-ink); color:#faf6ed; }
.cr-dialog .cr-close { min-width:42px; padding:2px 8px; border:0; font-size:26px; }
.cr-body { flex:1; min-height:0; display:grid; grid-template-columns:minmax(0,1fr) clamp(300px,30vw,415px); }
.cr-stage { position:relative; min-width:0; min-height:0; isolation:isolate; background:#dcd9cf; overflow:hidden; }
.cr-stage.cr-night { background:#242326; }
#crCanvas { width:100%; height:100%; display:block; touch-action:none; }
#crStageStatus { position:absolute; z-index:2; top:14px; left:14px; max-width:calc(100% - 28px); box-sizing:border-box; color:var(--cr-ink); background:#f5f1e6ed; padding:7px 11px; border-radius:2px; font-size:12px; pointer-events:none; }
#crStageStatus:empty, #crFeedback:empty { display:none; }
.cr-views { position:absolute; z-index:2; bottom:max(15px,env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); display:flex; max-width:calc(100% - 14px); padding:3px; border:1px solid #aea798; border-radius:4px; background:#f5f1e8ee; backdrop-filter:blur(10px); color:var(--cr-ink); }
.cr-views button { min-height:36px; padding:6px 12px; white-space:nowrap; border:0; font-size:12px; }
.cr-views button[aria-pressed=true] { background:var(--cr-ink); color:var(--cr-paper); }
.cr-panel { background-color:var(--cr-paper); color:var(--cr-ink); color-scheme:light; box-sizing:border-box; min-height:0; overflow-y:auto; overscroll-behavior:contain; border-left:1px solid var(--cr-line); padding:clamp(16px,2.1vw,34px); }
#crFeedback { padding:10px 0 15px; font-size:13px; }
.cr-section-title { display:flex; align-items:baseline; justify-content:space-between; margin-bottom:15px; }
.cr-panel h3 { font-size:clamp(26px,2vw,34px); line-height:1.1; letter-spacing:-.035em; }
.cr-section-title>span { font-size:13px; }
.cr-entries { display:grid; gap:5px; }
.cr-entries .cr-entry { display:grid; grid-template-columns:27px 1fr auto; align-items:center; text-align:start; padding:10px 9px; min-height:44px; gap:4px; }
.cr-entry[aria-pressed=true] { border-color:#524c3f; background:#e4ded1; }
.cr-entry i,.cr-index { color:var(--cr-muted); font-style:normal; font-size:11px; }
.cr-section { display:grid; margin:23px 0; gap:12px; }
.cr-section h4 { margin:0 0 2px; font-size:14px; font-weight:600; }
.cr-range { display:grid; gap:3px; font-size:13px; }
.cr-range span { display:flex; justify-content:space-between; align-items:center; }
.cr-range output { font-size:12px; color:var(--cr-muted); font-variant-numeric:tabular-nums; }
.cr-range input { width:100%; padding:0; height:25px; margin:0; accent-color:#5f5140; touch-action:pan-y; }
.cr-dialog .cr-link { border:0; padding:2px; text-align:start; font-size:12px; text-decoration:underline; text-underline-offset:3px; }
.cr-footer-actions { border-top:1px solid var(--cr-line); padding-top:16px; display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.cr-footer-actions button { font-size:12px; min-height:44px; padding:8px 5px; }
.cr-dialog button:disabled { opacity:.43; cursor:default; }
.cr-cards { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:16px 0; }
.cr-dialog .cr-card { text-align:start; padding:0; overflow:hidden; }
.cr-card img { display:block; width:100%; height:auto; aspect-ratio:1.45; object-fit:cover; background:#dad4c7; }
.cr-card span { display:flex; padding:9px; min-height:23px; align-items:center; }
.cr-family-cover { grid-column:1 / -1; width:100%; max-height:165px; object-fit:cover; background:#dad4c7; }
.cr-dialog .cr-layout-choice { min-height:44px; text-align:start; }
.cr-cards .cr-family-label { grid-column:1 / -1; margin:10px 0 0; padding-block-start:12px; border-top:1px solid var(--cr-line); font-size:.94rem; font-weight:550; }
.cr-wall-choice { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; margin:6px 0 12px; border:0; padding:0; min-width:0; }
.cr-wall-choice legend { margin-bottom:7px; padding:0; }
.cr-wall-choice button { font-size:.875rem; min-height:44px; }
.cr-wall-choice button[aria-pressed=true] { color:var(--cr-paper); background:var(--cr-ink); border-color:var(--cr-ink); }
.hy-choice { display:flex; flex-wrap:wrap; gap:5px; margin:6px 0 12px; }
.hy-choice button { flex:1; min-height:38px; border:1px solid #bcb4a3; padding:6px; color:#2e2a24; background:#eeebe3; font-size:12px; }
#hyStudio .hy-choice button[aria-pressed=true] {
  background:#e8e0d3; color:#29231e; border-color:#514439; box-shadow:inset 0 0 0 1px #514439;
}
.hy-tier-status { font-variant-numeric:tabular-nums; font-size:12px; color:#575145; margin:5px 0 10px; }
@media (max-width:760px) and (orientation:portrait) {
  dialog.cr-dialog { width:100%; height:100vh; height:100dvh; border:0; border-radius:0; }
  .cr-head { padding:max(9px,env(safe-area-inset-top)) 13px 8px; }
  .cr-head img { width:67px; }
  .cr-head h2 { font-size:26px; }
  .cr-head>div { gap:11px; }
  .cr-head .cr-primary { padding:8px 12px; }
  .cr-body { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(170px,42%) minmax(0,1fr); }
  .cr-panel { border-left:none; border-top:1px solid var(--cr-line); padding:16px 15px max(17px,env(safe-area-inset-bottom)); }
  .cr-views { bottom:7px; }
  .cr-stage #crStageStatus { top:7px; left:7px; font-size:10px; }
  .cr-dialog button,.cr-views button { min-height:44px; }
  .cr-cards { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-height:560px) and (orientation:landscape) {
  dialog.cr-dialog { width:100vw; height:100dvh; }
  .cr-head { padding:4px 15px; }
  .cr-body { grid-template-columns:minmax(0,1fr) minmax(235px,36%); }
  .cr-panel { padding:12px; }
  #studio .cr-rail { padding-block:2px; }
}
@media (max-width:760px) {
  .cr-views { width:max-content; }
  .cr-views button { padding-inline:7px; font-size:11px; white-space:normal; }
}
.hy-tier-status { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.hy-inline-action { padding:5px 8px; min-height:34px; border:1px solid #bcb4a3; background:transparent; color:inherit; font:inherit; }
.hy-inline-action:disabled { opacity:.50; }

#crDialog .cr-mode-switch {
  display:flex;
  align-items:stretch;
  min-width:0;
  padding:2px;
  border:1px solid #b5ac9c;
  border-radius:4px;
  background:#e9e4da;
}
#crDialog[data-phase="furnishing"] .cr-mode-switch { display:none; }
#crDialog .cr-mode-switch button {
  flex:1 1 auto;
  min-width:0;
  min-height:44px;
  padding:7px clamp(8px,1.3vw,19px);
  border:0;
  border-radius:2px;
  font:500 .9rem/1.2 var(--sans,Arial,sans-serif);
  overflow-wrap:anywhere;
  color:#524a3e;
}
#crDialog .cr-mode-switch button[aria-pressed=true] {
  background:var(--cr-ink);
  color:#fffaf0;
}
.cr-composition-actions {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,8.6rem),1fr));
  gap:6px;
  margin-block:14px;
}
.cr-dialog .cr-composition-actions button {
  min-height:44px;
  font-size:.9rem;
  overflow-wrap:anywhere;
}
.cr-panel .cr-structure-title {
  margin:16px 0 7px;
  color:var(--cr-ink);
  font:550 .98rem/1.3 var(--sans,Arial,sans-serif);
}
.cr-edit-collection { display:grid; gap:5px; font-size:.9rem; }
#crEditCollection {
  min-width:0;
  width:100%;
  min-height:44px;
  padding:7px 10px;
  border:1px solid #a69b8a;
  border-radius:2px;
  color:var(--cr-ink);
  background-color:#f8f5ee;
  font:400 1rem/1.25 var(--sans,Arial,sans-serif);
}
#crEditCollection:focus-visible { outline:2px solid #876031; outline-offset:2px; }
#crEditPresets { grid-template-columns:repeat(2,minmax(0,1fr)); margin-block-start:5px; }
#crEditPresets button {
  position:relative;
  min-width:0;
  min-height:44px;
  overflow-wrap:anywhere;
}
#crEditPresets button[aria-pressed=true] {
  border-color:var(--cr-ink);
  background:var(--cr-ink);
  color:#fffaf0;
}
#crEditPresets button[aria-pressed=true]::after {
  content:"✓";
  content:"✓" / "";
  display:grid;
  place-items:center;
  position:absolute;
  inline-size:14px;
  block-size:14px;
  inset-block-start:8px;
  inset-inline-end:8px;
  border-radius:50%;
  border:1px solid #f6f1e7;
  background:var(--cr-ink);
  color:#fffaf0;
  font:700 11px/1 var(--sans,Arial,sans-serif);
  pointer-events:none;
}
#crEditPresets .cr-layout-choice[aria-pressed=true] { padding-inline-end:30px; }
#crEditPresets .cr-layout-choice[aria-pressed=true]::after {
  inset-block-start:50%;
  translate:0 -50%;
}
@media (hover:hover) {
  #crDialog .cr-mode-switch button:not([aria-pressed=true]):hover,
  #crEditPresets button:not([aria-pressed=true]):hover { background:#e0d9ca; color:var(--cr-ink); }
}
@media (max-width:640px) and (orientation:portrait) {
  #crDialog[data-phase="compositions"] .cr-head {
    display:grid;
    grid-template-columns:minmax(0,1fr) auto 44px;
    grid-template-areas:"brand add close" "mode mode mode";
    gap:4px 8px;
  }
  #crDialog[data-phase="compositions"] .cr-head>div:first-child { grid-area:brand; }
  #crDialog[data-phase="compositions"] .cr-head .cr-actions { display:contents; }
  #crDialog[data-phase="compositions"] .cr-mode-switch { grid-area:mode; }
  #crDialog[data-phase="compositions"] .cr-mode-switch button { flex:1 1 0; }
  #crDialog[data-phase="compositions"] #crClose { grid-area:close; }
  #crDialog[data-phase="compositions"] #crAdd { grid-area:add; max-width:42vw; }
}
