/* SPDX-License-Identifier: Apache-2.0 */
/* ModelCraft — toolbar | outliner · 3D view · entity info, style, scenes | status with the value box.
 * Tokens only (paper/model aware); hierarchy by line weight; no shadows. */

.mc {
  display: grid;
  grid-template-columns: 14.5rem minmax(0, 1fr) 17.5rem;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "tools tools tools"
    "left stage right"
    "status status status";
  height: 100%;
  min-height: 0;
}

/* ---- Toolbar ---- */
.mc-tools { grid-area: tools; display: flex; flex-wrap: wrap; background: var(--sheet-2); border-bottom: var(--pen-2) solid var(--ink); scrollbar-width: thin; }
.mc-tool-group { display: flex; flex-direction: column; padding: .25rem .35rem .3rem; border-right: var(--pen-1) solid var(--line); flex: 0 0 auto; }
.mc-tool-group:last-of-type { border-right: 0; }
.mc-tool-label { font-size: .75rem; font-weight: 600; color: var(--ink-2); padding: 0 .2rem .15rem; }
.mc-tool-row { display: flex; gap: .1rem; align-items: stretch; }
.mc-tool {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  min-width: 2.6rem; padding: .25rem .2rem .2rem;
  font: inherit; font-size: .71875rem; font-weight: 600; color: var(--ink);
  background: transparent; border: var(--pen-1) solid transparent; border-radius: var(--radius);
  cursor: pointer; white-space: nowrap; list-style: none;
}
.mc-tool::-webkit-details-marker { display: none; }
.mc-tool .bi { font-size: 1.15rem; line-height: 1; color: var(--layer); }
.mc-tool:hover { border-color: var(--line); background: var(--sheet); }
.mc-tool:focus-visible { outline: var(--pen-3) solid var(--action); outline-offset: 1px; }
.mc-tool[aria-pressed="true"] { border-color: var(--ink); background: var(--sheet); }
.mc-tool:disabled { opacity: .45; cursor: default; }
.mc-menu { position: relative; }
.mc-menu[open] > summary { border-color: var(--ink); background: var(--sheet); }
.mc-menu-list {
  position: absolute; z-index: 30; top: calc(100% + .25rem); left: 0; min-width: 14rem;
  display: flex; flex-direction: column; padding: .25rem 0;
  background: var(--sheet-2); border: var(--pen-2) solid var(--ink); border-radius: var(--radius);
}
.mc-menu-list button { font: inherit; font-size: .875rem; font-weight: 500; text-align: left; color: var(--ink); background: none; border: 0; padding: .35rem .8rem; cursor: pointer; }
.mc-menu-list button:hover, .mc-menu-list button:focus-visible { background: var(--sheet); text-decoration: underline; outline: none; }
.mc-menu-list button kbd { margin-left: 1.25rem; float: right; font: inherit; font-size: .75rem; color: var(--ink-2); background: none; border: 0; padding: 0; }
.mc-menu-list hr { margin: .25rem 0; border: 0; border-top: var(--pen-1) solid var(--line); }
.mc-menu-list [aria-checked="true"]::before { content: "✓ "; }
.mc-menu-list [aria-checked="false"]::before { content: "   "; white-space: pre; }

body.app-shell .sp-tab { bottom: 3.25rem; }

/* ---- Panels ---- */
.mc-panel { overflow-y: auto; min-height: 0; background: var(--sheet-2); }
.mc-left { grid-area: left; border-right: var(--pen-2) solid var(--ink); }
.mc-right { grid-area: right; border-left: var(--pen-2) solid var(--ink); }
.mc-sec { padding: .9rem 1rem; border-bottom: var(--pen-1) solid var(--line); }
.mc-sec:last-child { border-bottom: 0; }
.mc-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.mc-h { font-size: var(--fs-sm); font-weight: 700; font-stretch: 112%; margin: 0 0 .5rem; }
.mc-sec-head .mc-h { margin: 0; }
.mc-note { color: var(--ink-2); font-size: .875rem; margin: .5rem 0 0; }
.mc-linkbtn { font: inherit; font-size: .875rem; font-weight: 600; color: var(--action); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.mc-linkbtn:hover { text-decoration-thickness: 2px; }
.mc-linkbtn:disabled { color: var(--ink-2); cursor: default; text-decoration: none; }
.mc kbd { font-family: inherit; font-size: .8125rem; font-weight: 700; padding: 0 .3rem; color: var(--ink); background: var(--sheet); border: var(--pen-1) solid var(--line); border-radius: var(--radius); }

.mc-input, .mc-select {
  width: 100%; min-width: 0; font: inherit; font-size: .875rem; font-weight: 500; color: var(--ink);
  background: var(--sheet); border: var(--pen-1) solid var(--line); border-radius: var(--radius);
  padding: .2rem .4rem; font-variant-numeric: tabular-nums;
}
.mc-input:focus, .mc-select:focus { outline: var(--pen-2) solid var(--action); outline-offset: 0; border-color: var(--action); }
.mc-num { width: 4.5rem; flex: 0 0 auto; }
.mc-props { display: grid; grid-template-columns: fit-content(45%) minmax(0, 1fr); gap: .4rem .6rem; align-items: center; font-size: .875rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.mc-props > label, .mc-props .k { color: var(--ink-2); font-weight: 500; }
.mc-props .v { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mc-props .span { grid-column: 1 / -1; }
.mc-props + .mc-props { margin-top: .75rem; padding-top: .75rem; border-top: var(--pen-1) solid var(--grid); }
.mc-props:disabled { opacity: .55; }
.mc-check { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.mc-check input, .mc-props input[type="range"] { accent-color: var(--action); }
.mc-row { display: flex; gap: .4rem; align-items: center; min-width: 0; }
.mc-row input[type="range"] { flex: 1 1 auto; min-width: 0; }
.mc-out { font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: right; }
.mc-actions { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .6rem; }

/* outliner + components */
.mc-crumbs { margin: 0 0 .4rem; font-size: .8125rem; color: var(--ink-2); }
.mc-crumbs:empty { display: none; }
.mc-tree, .mc-list { list-style: none; margin: 0; padding: 0; font-size: .875rem; }
.mc-tree ul { list-style: none; margin: 0; padding-left: 1rem; }
.mc-tree li, .mc-list li { border-top: var(--pen-1) solid var(--grid); }
.mc-tree > li:first-child, .mc-list > li:first-child { border-top: 0; }
.mc-node { display: flex; align-items: center; gap: .4rem; width: 100%; padding: .22rem .2rem; font: inherit; color: var(--ink); background: none; border: 0; border-left: var(--pen-3) solid transparent; text-align: left; cursor: pointer; }
.mc-node:hover { background: var(--sheet); }
.mc-node.is-sel { border-left-color: var(--action); font-weight: 700; }
.mc-node.is-open { border-left-color: var(--layer); }
.mc-node .bi { color: var(--layer); flex: 0 0 auto; }
.mc-node .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .5rem; align-items: baseline; padding: .25rem 0; }
.mc-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-list .n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* an input with its buttons on one line (Soften up to, 0.4 M18) */
.mc-inline { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.mc-inline .mc-input { width: 4.5rem; }
/* Outliner rows (0.4 M22): the row button, then its eye; search; where a dragged row would go */
.mc-node-row { display: flex; align-items: center; min-width: 0; }
.mc-node-row .mc-node { flex: 1 1 auto; min-width: 0; }
.mc-tree .mc-eye { border: 0; background: none; padding: .125rem .375rem; color: var(--ink-2); cursor: pointer; line-height: 1; opacity: .55; }
.mc-node-row:hover .mc-eye, .mc-tree .mc-eye:focus-visible, .mc-tree .mc-eye[aria-pressed="false"] { opacity: 1; }
.mc-tree .mc-eye:focus-visible { outline: var(--pen-2, 2px) solid var(--layer-blue); outline-offset: 1px; }
.mc-tree-search { width: 100%; margin: .25rem 0 .375rem; }
.mc-node.is-match .nm { font-weight: 600; }
.mc-node.is-drop, [data-tree-top].is-drop { outline: 2px dashed var(--layer-blue); outline-offset: -2px; }
.mc-tree-name { min-width: 0; flex: 1 1 auto; padding-block: 0; }
.mc.is-touch .mc-tree .mc-eye { min-width: 2.25rem; min-height: 2.25rem; }
/* IFC storeys dialog (0.4 M12): name, elevation, remove */
.mc-storey { display: grid; grid-template-columns: minmax(0, 1fr) 7rem auto; gap: .375rem; align-items: center; margin-bottom: .25rem; }
.mc-storey-head span { font-size: .8125rem; color: var(--ink-2); }
/* the starter library (0.4 M25) */
.mc-dialog-wide { max-width: min(46rem, 94vw); }
.mc-starter + .mc-starter { margin-top: .5rem; }
.mc-starter-grid { display: flex; flex-wrap: wrap; gap: .375rem; }
/* the rules of a part inside a stretching component (0.4 M26) */
.mc-rules { margin-top: .5rem; }
.mc-rules-h { grid-column: 1 / -1; font-weight: 600; color: var(--ink); }
/* Tags (0.4 M6): eye, name (retype to rename), how many use it, delete */
.mc-tags li { grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; }
.mc-tags .mc-input { min-width: 0; padding-block: .125rem; }
.mc-tags .mc-eye, .mc-tags .mc-del { border: 0; background: none; padding: .25rem; color: var(--ink); cursor: pointer; line-height: 1; }
.mc-tags .mc-eye[aria-pressed="false"] { color: var(--ink-2); }
.mc-tags li.is-off .mc-input { color: var(--ink-2); font-style: italic; }
.mc-tags .mc-eye:focus-visible, .mc-tags .mc-del:focus-visible { outline: var(--pen-2, 2px) solid var(--layer-blue); outline-offset: 1px; }
.mc-tags .nm { padding-inline: .375rem; }
.mc.is-touch .mc-tags .mc-eye, .mc.is-touch .mc-tags .mc-del { min-width: 2.25rem; min-height: 2.25rem; }

/* scenes */
.mc-scenes { list-style: none; margin: 0; padding: 0; font-size: .875rem; counter-reset: sc; }
.mc-scenes li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; align-items: center; padding: .25rem 0; border-top: var(--pen-1) solid var(--grid); }
.mc-scenes li:first-child { border-top: 0; }
.mc-scenes li.is-cur .mc-scene-go { font-weight: 700; border-left-color: var(--action); }
.mc-scene-go { font: inherit; text-align: left; color: var(--ink); background: none; border: 0; border-left: var(--pen-3) solid transparent; padding: .1rem .4rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-scene-go:hover { text-decoration: underline; }
.mc-scene-acts { display: flex; gap: .15rem; }
.mc-icon { font: inherit; color: var(--ink-2); background: none; border: var(--pen-1) solid transparent; border-radius: var(--radius); padding: 0 .3rem; cursor: pointer; line-height: 1.5; }
.mc-icon:hover { color: var(--ink); border-color: var(--line); }
.mc-scene-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.mc-scene-nav .btn-sm-cc { min-height: 2rem; padding: .25rem .6rem; font-size: .8125rem; }

/* ---- Stage ---- */
.mc-stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--sheet); }
.mc-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mc-over { touch-action: none; cursor: crosshair; }
.mc-over:focus { outline: none; }
.mc-over:focus-visible { outline: var(--pen-2) solid var(--action); outline-offset: -3px; }
.mc-over.is-orbit { cursor: grab; }
.mc-over.is-select { cursor: default; }
.mc-hint {
  position: absolute; z-index: 2; top: 1rem; left: 1rem; max-width: min(31rem, calc(100% - 2rem));
  padding: .75rem 1rem; font-size: .875rem; background: var(--sheet-2);
  border: var(--pen-2) solid var(--ink); border-radius: var(--radius); pointer-events: none;
}
.mc-hint-h { margin: 0 0 .35rem; font-weight: 700; font-stretch: 112%; }
.mc-hint ul { margin: 0; padding-left: 1.1rem; }
.mc-hint li + li { margin-top: .2rem; }
.mc-drop {
  position: absolute; inset: .75rem; z-index: 3; display: grid; place-items: center; font-weight: 700;
  background: color-mix(in srgb, var(--sheet) 85%, transparent); border: var(--pen-3) dashed var(--action); border-radius: var(--radius);
}
.mc-scenebar { position: absolute; z-index: 2; left: 0; right: 0; top: 0; display: flex; gap: 0; overflow-x: auto; background: color-mix(in srgb, var(--sheet-2) 92%, transparent); border-bottom: var(--pen-1) solid var(--line); scrollbar-width: thin; }
.mc-scenebar button { font: inherit; font-size: .8125rem; font-weight: 600; color: var(--ink-2); background: none; border: 0; border-bottom: var(--pen-3) solid transparent; padding: .3rem .8rem .2rem; white-space: nowrap; cursor: pointer; }
.mc-scenebar button:hover { color: var(--ink); }
.mc-scenebar button[aria-current="true"] { color: var(--ink); border-bottom-color: var(--action); }

/* ask() dialog */
.mc-dialog { width: min(30rem, calc(100vw - 2rem)); padding: 0; color: var(--ink); background: var(--sheet-2); border: var(--pen-2) solid var(--ink); border-radius: var(--radius); }
.mc-dialog::backdrop { background: color-mix(in srgb, var(--ink) 35%, transparent); }
.mc-dialog-head, .mc-dialog-foot { display: flex; align-items: center; gap: .75rem; padding: .65rem 1rem; }
.mc-dialog-head { border-bottom: var(--pen-1) solid var(--line); }
.mc-dialog-head .mc-h { margin: 0; }
.mc-dialog-foot { justify-content: flex-end; flex-wrap: wrap; border-top: var(--pen-1) solid var(--line); }
.mc-dialog-text { margin: 0; padding: 1rem; }

/* ---- Status bar ---- */
.mc-status { grid-area: status; display: flex; align-items: center; gap: .9rem; padding: .3rem 1rem; font-size: .8125rem; background: var(--sheet-2); border-top: var(--pen-2) solid var(--ink); min-width: 0; }
.mc-tip { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; max-width: 45%; }
.mc-msg { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.mc-vcb { display: flex; align-items: center; gap: .4rem; margin-left: auto; flex: 0 0 auto; }
.mc-vcb-label { font-weight: 700; white-space: nowrap; }
.mc-vcb-input { width: 10rem; font: inherit; font-size: .9375rem; font-weight: 600; color: var(--ink); background: var(--sheet); border: var(--pen-1) solid var(--line); border-radius: var(--radius); padding: .1rem .4rem; font-variant-numeric: tabular-nums; }
.mc-vcb-input:focus { outline: var(--pen-2) solid var(--action); outline-offset: 0; border-color: var(--action); }
.mc-units { width: auto; flex: 0 0 auto; }
.mc-toggle { flex: 0 0 auto; padding: .1rem .5rem; font: inherit; color: var(--ink-2); background: transparent; border: var(--pen-1) solid var(--line); border-radius: var(--radius); text-decoration: line-through; }
.mc-toggle[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); text-decoration: none; font-weight: 600; }
.mc-toggle:hover { border-color: var(--ink); }
/* Settings › ModelCraft (settings.inc lives in the shell's dialog) */
.mc-set-seg2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .mc { grid-template-columns: 12.5rem minmax(0, 1fr) 15.5rem; }
}
@media (max-width: 760px) {
  body.app-shell .sp-tab { bottom: .75rem; }
  .mc-tools { flex-wrap: nowrap; overflow-x: auto; }
  .mc-menu-list { position: fixed; top: auto; left: 1rem; right: 1rem; min-width: 0; }
  .mc {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 60vh auto auto auto;
    grid-template-areas: "tools" "stage" "status" "right" "left";
    height: auto;
  }
  .mc-left, .mc-right { border: 0; border-top: var(--pen-2) solid var(--ink); }
  .mc-status { flex-wrap: wrap; gap: .4rem .75rem; }
  .mc-tip { max-width: 100%; flex-basis: 100%; }
  .mc-vcb { margin-left: 0; }
  .mc-vcb-input { width: 8rem; }
  .mc-hint { font-size: .8125rem; top: .5rem; left: .5rem; max-width: calc(100% - 1rem); padding: .5rem .75rem; }
  .mc-hint li:nth-child(n+3) { display: none; }
}
/* view cube (viewcube.js): clear of the scene tabs when they show */
.mc-scenebar:not([hidden]) ~ .cc-vc.at-top-right { top: 2.4rem; }

/* Colors (0.4 M8): swatches are the model's own colours (data), so they carry inline backgrounds; the ring is a token */
.mc-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(1.75rem, 1fr)); gap: .375rem; margin-bottom: .5rem; }
.mc-swatch { width: 100%; aspect-ratio: 1; border: var(--pen-1) solid var(--line); border-radius: var(--radius); padding: 0; cursor: pointer; position: relative; }
.mc-swatch[aria-checked="true"] { outline: var(--pen-3) solid var(--action); outline-offset: 2px; }
.mc-swatch:focus-visible { outline: var(--pen-3) solid var(--action); outline-offset: 2px; }
.mc-swatch { overflow: hidden; }
.mc-swatch.is-default { background: var(--sheet); }
.mc-swatch.is-default::after { content: ''; position: absolute; left: 50%; top: -20%; height: 140%; border-left: var(--pen-1) solid var(--ink-2); transform: rotate(45deg); }
.mc-swatch input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.mc-swatch.is-custom { background: var(--sheet); }
.mc-swatch.is-custom i { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); pointer-events: none; }

/* hidden placements in the outliner (0.4 M17) */
.mc-node.is-hidden .nm { color: var(--ink-2); font-style: italic; }
.mc-hidden-tag { margin-left: auto; color: var(--ink-2); }

/* touch (0.4 S.8): bigger targets; a small bar of Done / Cancel / Undo over the bottom of the view */
.mc.is-touch .mc-tool { min-height: 2.75rem; min-width: 2.75rem; }
.mc.is-touch .mc-swatch { min-height: 2.25rem; }
.mc-touchbar { position: absolute; left: 50%; bottom: .75rem; transform: translateX(-50%); display: flex; gap: .25rem; padding: .25rem; background: var(--sheet); border: var(--pen-1) solid var(--line); border-radius: var(--radius); z-index: 3; }
.mc-touchbar[hidden] { display: none; }
