/* Minimal theme: full-bleed stage with paper feel.
   touch-action on html/body is pan-x/pan-y (no pinch-zoom) so children can
   still opt into vertical scroll. Do NOT set none here — it would lock
   sliders and the settings column too. */

/* .mat-row uses display:grid — without !important, [hidden] loses and rows stay visible. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
  font: 12px/1.35 "IBM Plex Sans", "Segoe UI", sans-serif;
  color: #2a2a28;
  background: #fffef8;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
}

input,
textarea,
select {
  user-select: text;
  -webkit-user-select: text;
}

#stage {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 250, 235, 0.9), transparent 55%),
    linear-gradient(#fffef8, #fff8ec);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.03);
}

#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#gl {
  z-index: 0;
  pointer-events: none;
}

#wet-host {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  display: none;
}

#wet-host canvas {
  position: absolute;
  inset: auto;
  width: auto;
  height: auto;
  display: block;
}

#chrome {
  z-index: 2;
  touch-action: none;
}

.perf-hud {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  padding: 8px 10px 10px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  border-radius: 10px;
  background: rgba(28, 26, 22, 0.82);
  color: #f2efe6;
  font: 11px/1.35 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
}
.perf-hud-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff8e8;
}
.perf-hud-hint {
  font-weight: 400;
  opacity: 0.55;
  font-size: 10px;
}
.perf-hud-grid {
  display: grid;
  grid-template-columns: max-content minmax(8rem, 1fr);
  gap: 1px 12px;
  font-variant-numeric: tabular-nums;
}
.perf-k {
  opacity: 0.62;
  white-space: nowrap;
}
.perf-v {
  text-align: right;
  color: #c8e6ff;
  overflow-wrap: anywhere;
}

#layer-root {
  position: fixed;
  left: max(8px, env(safe-area-inset-left, 0px));
  top: max(8px, env(safe-area-inset-top, 0px));
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: min(260px, calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  pointer-events: none;
  transform: translateZ(0);
}
#layer-root.is-perf {
  width: min(420px, calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
}
.left-chrome-toggle {
  pointer-events: auto;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #2a2a28;
  background: rgba(255, 252, 245, 0.94);
  border: 1px solid rgba(40, 36, 28, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(40, 36, 28, 0.08);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.left-chrome-toggle[aria-pressed='true'] {
  color: #1e5ab4;
}
.left-chrome-toggle:active {
  background: #fff;
}
.layer-shell {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  max-height: calc(100dvh - 66px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  background: rgba(255, 252, 245, 0.94);
  border: 1px solid rgba(40, 36, 28, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(40, 36, 28, 0.08);
  overflow: hidden;
}
@media (max-width: 720px) {
  #layer-root {
    width: min(220px, calc(42vw));
  }
}

#ui-root {
  position: fixed;
  right: max(8px, env(safe-area-inset-right, 0px));
  top: max(8px, env(safe-area-inset-top, 0px));
  z-index: 20;
  width: min(274px, calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  pointer-events: auto;
  transform: translateZ(0);
}

.boot-block {
  pointer-events: auto;
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: #fffef8;
  color: #2a2a28;
}

.boot-block h1 {
  margin: 0;
  font: 600 22px/1.3 "IBM Plex Sans", "Segoe UI", sans-serif;
}

.boot-block p {
  margin: 0;
  max-width: 36rem;
  font: 14px/1.45 "IBM Plex Sans", "Segoe UI", sans-serif;
  color: rgba(42, 42, 40, 0.8);
}

.ui-shell {
  pointer-events: auto;
  touch-action: pan-x pan-y;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* Shared card chrome — Tools, Tool options, Colour, and accordion drawers. */
.ui-block,
.mat-section {
  border: 1px solid rgba(40, 36, 28, 0.14);
  border-radius: 4px;
  background: rgba(255, 254, 248, 0.94);
  box-shadow: 0 1px 2px rgba(40, 36, 28, 0.04);
  box-sizing: border-box;
  min-width: 0;
}

.ui-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 6px 5px;
}

.ui-block-title {
  display: flex;
  align-items: center;
  min-height: 22px;
  margin: 0 -6px;
  padding: 3px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(40, 36, 28, 0.78);
  border-bottom: 1px solid rgba(40, 36, 28, 0.1);
  background: rgba(40, 36, 28, 0.04);
  border-radius: 4px 4px 0 0;
  user-select: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.toolbar-block .c4d-attr-row {
  margin: 6px 0 2px;
  padding: 0;
}

.ui-drawers {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.brush-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: none;
}

.brush-fit-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 6px;
  align-items: center;
}

.brush-fit-btns {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 3px;
}

.brush-fit-btns button {
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  min-height: 20px;
  flex: 1 1 0;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #fff;
  border-radius: 3px;
  color: inherit;
  cursor: pointer;
}

.brush-fit-btns button.is-on {
  border-color: rgba(40, 36, 28, 0.55);
  background: rgba(40, 36, 28, 0.08);
}

.brush-select-btns {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 3px;
}

.brush-select-btns .mat-btn {
  flex: 1 1 0;
}

.toolbar button,
.mat-btn {
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  min-height: 22px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #fff;
  border-radius: 3px;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.toolbar button:hover,
.mat-btn:hover {
  border-color: rgba(40, 36, 28, 0.35);
  background: #fbfaf4;
}

.toolbar button.is-active {
  border-color: #1e5ab4;
  background: rgba(30, 90, 180, 0.1);
  color: #1e5ab4;
}

.draw-confirm-bar {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateZ(0);
  z-index: 21;
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255, 254, 248, 0.94);
  border: 1px solid rgba(40, 36, 28, 0.14);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(40, 36, 28, 0.1);
  pointer-events: auto;
  touch-action: manipulation;
}

.draw-confirm-bar[hidden] {
  display: none;
}

.draw-confirm-btn {
  font: 16px/1 inherit;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(40, 36, 28, 0.18);
  border-radius: 6px;
  background: #fff;
  color: #2a2a28;
  cursor: pointer;
  touch-action: manipulation;
}

.draw-confirm-btn:hover {
  border-color: rgba(40, 36, 28, 0.4);
}

.draw-confirm-ok {
  color: #1a6b3c;
}

.draw-confirm-cancel {
  color: #a03030;
}

.materials-panel {
  display: contents;
}

.scene-settings {
  display: contents;
  pointer-events: auto;
  touch-action: pan-x pan-y;
}


.mat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center;
  gap: 2px 6px;
  margin: 0;
  min-width: 0;
}

.mat-row:has(> input[type='checkbox']),
.mat-row:has(> input[type='color']) {
  grid-template-columns: minmax(0, 1fr) auto;
}

.mat-label {
  color: rgba(40, 36, 28, 0.7);
  font-size: 11px;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: break-word;
  min-width: 0;
}

.mat-row > :not(.mat-label) {
  min-width: 0;
  max-width: 100%;
}

.mat-row select,
.mat-row input[type='range'],
.mat-row input[type='number'],
.mat-row textarea {
  width: 100%;
  box-sizing: border-box;
}

.mat-row input[type='checkbox'],
.mat-row input[type='color'] {
  justify-self: end;
  width: auto;
}

.mat-btn {
  width: auto;
}

.zoom-bar {
  pointer-events: auto;
  position: fixed;
  left: max(12px, env(safe-area-inset-left, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  padding: 8px 10px;
  background: rgba(255, 254, 248, 0.88);
  border: 1px solid rgba(40, 36, 28, 0.1);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(40, 36, 28, 0.06);
  backdrop-filter: blur(6px);
  transform: translateZ(0);
  touch-action: manipulation;
}

.zoom-bar input[type='range'] {
  flex: 1;
  min-width: 100px;
}

.zoom-bar .zoom-label {
  font: inherit;
  min-width: 3.5em;
  min-height: 36px;
  padding: 4px 6px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #fff;
  border-radius: 4px;
  color: inherit;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
}

.zoom-bar .zoom-label:hover {
  border-color: rgba(40, 36, 28, 0.35);
}

.mat-inline-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.mat-section {
  padding: 0 6px 6px;
}
.mat-section + .mat-section {
  margin-top: 0;
}
.mat-section summary {
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(40, 36, 28, 0.78);
  margin: 0 -6px 3px;
  padding: 3px 6px;
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  user-select: none;
  touch-action: manipulation;
  border-bottom: 1px solid rgba(40, 36, 28, 0.1);
  background: rgba(40, 36, 28, 0.04);
  border-radius: 4px 4px 0 0;
}
.mat-section summary::-webkit-details-marker {
  display: none;
}
.mat-section summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  opacity: 0.65;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}
.mat-section .mat-row {
  padding: 1px 0;
}

.mat-sub-section {
  border: 1px solid rgba(40, 36, 28, 0.12);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.6);
  margin: 3px 0 4px;
  padding: 0 5px 4px;
  box-sizing: border-box;
}

.mat-sub-section summary {
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(40, 36, 28, 0.76);
  margin: 0 -5px 3px;
  padding: 3px 6px;
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  user-select: none;
  touch-action: manipulation;
  border-bottom: 1px solid rgba(40, 36, 28, 0.08);
  background: rgba(40, 36, 28, 0.03);
  border-radius: 3px 3px 0 0;
}
.mat-sub-section summary::-webkit-details-marker {
  display: none;
}
.mat-sub-section summary::before {
  content: '▸';
  display: inline-block;
  width: 0.9em;
  opacity: 0.6;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}
.mat-sub-section[open] > summary::before {
  content: '▾';
}
.mat-sub-section .mat-row {
  padding: 1px 0;
}

.vram-status-badge {
  margin: 4px 0 8px 0;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  line-height: 1.35;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: rgba(40, 36, 28, 0.05);
  color: #3b372e;
  border: 1px solid rgba(40, 36, 28, 0.12);
}
.vram-status-badge.vram-ok {
  background: rgba(38, 138, 70, 0.08);
  border-color: rgba(38, 138, 70, 0.25);
  color: #1b6332;
}
.vram-status-badge.vram-warning {
  background: rgba(214, 137, 16, 0.12);
  border-color: rgba(214, 137, 16, 0.35);
  color: #8c5300;
}
.vram-status-badge.vram-danger {
  background: rgba(214, 40, 40, 0.12);
  border-color: rgba(214, 40, 40, 0.35);
  color: #9e1414;
}
.vram-status-icon {
  font-size: 12px;
  flex-shrink: 0;
  margin-top: -1px;
}
.vram-status-text {
  flex: 1;
}

/* --- Cinema 4D / DCC Scrubbable Numeric Inputs --- */
body.is-scrub-dragging,
body.is-scrub-dragging * {
  cursor: ew-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.scrub-wrap {
  position: relative;
  display: flex;
  align-items: center;
  height: 22px;
  background: #f4f2ea;
  border: 1px solid rgba(40, 36, 28, 0.2);
  border-radius: 3px;
  overflow: hidden;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-sizing: border-box;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.scrub-wrap:hover {
  border-color: rgba(30, 90, 180, 0.6);
  background: #f8f7f0;
}

.scrub-wrap.is-scrubbing {
  border-color: #1e5ab4;
  box-shadow: 0 0 0 1px #1e5ab4;
  background: #eef3fa;
  cursor: ew-resize;
}

.scrub-wrap.is-focused {
  background: #ffffff;
  border-color: #1e5ab4;
  box-shadow: 0 0 0 1px #1e5ab4;
  cursor: text;
}

.scrub-wrap.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.scrub-track {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(30, 90, 180, 0.22);
  border-right: 1.5px solid rgba(30, 90, 180, 0.45);
  pointer-events: none;
}

.scrub-wrap.is-focused .scrub-track {
  opacity: 0.12;
}

.scrub-value-display {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1a1a18;
  padding: 0 16px 0 6px;
  text-align: left;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: ew-resize;
  box-sizing: border-box;
}

.scrub-input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1a1a18;
  padding: 0 16px 0 6px;
  text-align: left;
  outline: none;
  cursor: text;
  box-sizing: border-box;
  user-select: text;
  -webkit-user-select: text;
}

.scrub-steppers {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  display: flex;
  flex-direction: column;
  z-index: 2;
  border-left: 1px solid rgba(40, 36, 28, 0.12);
  background: rgba(255, 255, 255, 0.8);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.scrub-wrap:hover .scrub-steppers,
.scrub-wrap.is-scrubbing .scrub-steppers,
.scrub-wrap.is-touch .scrub-steppers {
  opacity: 1;
}

.scrub-step-btn {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 6.5px;
  line-height: 1;
  padding: 0;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.scrub-step-btn:hover {
  background: rgba(30, 90, 180, 0.2);
  color: #1e5ab4;
}

/* --- Cinema 4D Attributes Panel & Controls --- */
.c4d-attributes-panel {
  display: flex;
  flex-direction: column;
}

.c4d-attr-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 2px 6px;
  min-height: 22px;
  padding: 1px 0;
  box-sizing: border-box;
}

.c4d-attr-row:has(> input[type='checkbox']),
.c4d-attr-row:has(> input[type='color']) {
  grid-template-columns: minmax(0, 1fr) auto;
}

.c4d-attr-row.is-stacked {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2.5px;
  min-height: 0;
  padding: 3px 0 4px;
}

.c4d-attr-row.is-stacked .c4d-attr-label {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  font-size: 10px;
  font-weight: 600;
  color: rgba(40, 36, 28, 0.76);
  line-height: 1.2;
}

.c4d-attr-row.is-stacked .scrub-wrap,
.c4d-attr-row.is-stacked select {
  width: 100%;
}

.c4d-attr-label {
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(40, 36, 28, 0.75);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.c4d-attr-select {
  height: 20px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 16px 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #f8f7f2;
  color: #222;
  box-sizing: border-box;
  outline: none;
}

.fill-preset-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.fill-preset-block .c4d-attr-select,
.fill-preset-block .c4d-btn {
  width: 100%;
}

.fill-swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  --fill-swatch-color: #8fd0c9;
}

.fill-swatch {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 3px;
  border: 1px solid rgba(40, 36, 28, 0.22);
  background-color: var(--fill-swatch-color);
  cursor: pointer;
  flex: 0 0 auto;
}

.fill-swatch.has-mask {
  -webkit-mask-image: var(--swatch-url);
  mask-image: var(--swatch-url);
  -webkit-mask-size: cover;
  mask-size: cover;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  mask-mode: luminance;
  -webkit-mask-source-type: luminance;
}

.fill-swatch:hover {
  border-color: rgba(30, 90, 180, 0.5);
}

.fill-swatch.is-on {
  outline: 2px solid #1e5ab4;
  outline-offset: 1px;
}

.fill-preset-hint {
  font-size: 10px;
  line-height: 1.3;
  color: rgba(40, 36, 28, 0.55);
}

.c4d-attr-select:focus {
  border-color: #1e5ab4;
}

.c4d-attr-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #1e5ab4;
  cursor: pointer;
}

.c4d-attr-number {
  height: 20px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #fff;
  color: #222;
  box-sizing: border-box;
  outline: none;
}

.c4d-attr-number:focus {
  border-color: #1e5ab4;
}

.c4d-attr-color {
  width: 22px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(40, 36, 28, 0.2);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
}

.c4d-attr-pair {
  display: flex;
  gap: 4px;
}

.c4d-attr-pair .c4d-attr-number {
  flex: 1;
  min-width: 0;
}

.c4d-attr-textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 10.5px;
  padding: 3px 5px;
  border-radius: 3px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #fff;
}

.c4d-toggle-group {
  display: flex;
  gap: 1px;
  background: rgba(40, 36, 28, 0.1);
  padding: 1px;
  border-radius: 3px;
}

.c4d-group-btn {
  flex: 1;
  height: 18px;
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #555;
  cursor: pointer;
  border-radius: 2px;
  padding: 0 4px;
  transition: all 0.1s ease;
}

.c4d-group-btn.is-on {
  background: #fff;
  color: #1e5ab4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.c4d-presets-wrap {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 2px 0 4px;
}

.c4d-preset-btn {
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(40, 36, 28, 0.16);
  background: #f8f7f2;
  color: #333;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.c4d-preset-btn:hover {
  background: #fff;
  border-color: rgba(30, 90, 180, 0.4);
  color: #1e5ab4;
}

.c4d-btn {
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  min-height: 22px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  border-radius: 3px;
  background: #fff;
  color: #2a2a28;
  cursor: pointer;
}

.c4d-btn:hover {
  background: #f7f6f0;
  border-color: rgba(40, 36, 28, 0.3);
}

.c4d-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.c4d-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(40, 36, 28, 0.55);
  margin: 6px 0 2px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(40, 36, 28, 0.08);
}

/* --- Cinema 4D & Illustrator Layer Panel Overhaul --- */
.layer-panel.c4d-system-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #fffefb;
}

.layer-panel-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px 5px;
  border-bottom: 1px solid rgba(40, 36, 28, 0.1);
  background: rgba(40, 36, 28, 0.03);
}

.layer-panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layer-title-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.layer-title-icon {
  display: flex;
  align-items: center;
  color: #1e5ab4;
}

.layer-panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #1a1a18;
  text-transform: uppercase;
}

.layer-header-toggles {
  display: flex;
  align-items: center;
  gap: 3px;
}

.layer-mode-toggle {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #f5f4ee;
  color: #555;
  cursor: pointer;
  transition: all 0.12s ease;
}

.layer-mode-toggle.is-active-toggle {
  background: #1e5ab4;
  color: #fff;
  border-color: #1e5ab4;
}

.layer-panel-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.layer-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 5px;
  min-height: 22px;
  border: 1px solid rgba(40, 36, 28, 0.16);
  border-radius: 3px;
  background: #fff;
  color: #2a2a28;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.layer-action-btn:hover {
  background: #f7f6f0;
  border-color: rgba(40, 36, 28, 0.28);
}

.layer-delete-btn {
  flex: 0 0 22px;
  color: #888;
}

.layer-delete-btn:hover {
  color: #d32f2f;
  background: #ffebee;
  border-color: rgba(211, 47, 47, 0.3);
}

.c4d-tree-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 100px;
  padding: 2px 0;
}

/* Tree Rows */
.c4d-tree-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px 0 2px;
  height: 22px;
  min-height: 22px;
  cursor: grab;
  font-size: 11px;
  touch-action: none;
  border-radius: 2px;
  margin: 1px 2px;
  transition: background 0.08s;
  user-select: none;
  box-sizing: border-box;
}

.c4d-tree-row:hover {
  background: rgba(40, 36, 28, 0.05);
}

.c4d-tree-row.is-active {
  background: rgba(30, 90, 180, 0.12);
  font-weight: 600;
  box-shadow: inset 2px 0 0 #1e5ab4;
}

.c4d-tree-row.is-selected {
  background: rgba(30, 90, 180, 0.16);
}

.c4d-tree-row.is-drop-into {
  outline: 1.5px dashed #1e5ab4;
  background: rgba(30, 90, 180, 0.1);
}

.c4d-tree-row.is-hidden {
  opacity: 0.45;
}

.c4d-tree-row.is-locked .layer-name {
  color: #888;
}

/* Tree Connector Guides */
.tree-guide-wrap {
  display: flex;
  height: 100%;
  flex-shrink: 0;
}

.tree-guide-line {
  width: 14px;
  height: 100%;
  position: relative;
  flex-shrink: 0;
}

.tree-guide-vertical::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(40, 36, 28, 0.22);
}

.tree-guide-tee::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(40, 36, 28, 0.22);
}

.tree-guide-tee::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: rgba(40, 36, 28, 0.22);
}

.tree-guide-corner::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  height: 50%;
  width: 1px;
  background: rgba(40, 36, 28, 0.22);
}

.tree-guide-corner::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: rgba(40, 36, 28, 0.22);
}

/* Illustrator Hierarchy Color Stripe */
.layer-color-stripe {
  width: 3px;
  height: 14px;
  border-radius: 1px;
  flex-shrink: 0;
  margin-right: 2px;
}

.shape-color-pip {
  width: 2px;
  height: 12px;
  border-radius: 1px;
  flex-shrink: 0;
  margin-right: 2px;
  opacity: 0.8;
}

.layer-chevron {
  flex: none;
  width: 14px;
  height: 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 9px;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.layer-chevron.is-leaf {
  visibility: hidden;
}

.layer-type-icon {
  flex: none;
  font-size: 11px;
  width: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1px;
}

.layer-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10.5px;
  cursor: default;
}

.layer-rename-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid #1e5ab4;
  border-radius: 2px;
  padding: 1px 4px;
  background: #fff;
  height: 18px;
  box-sizing: border-box;
  outline: none;
}

/* Right-Aligned C4D Tag Strip */
.c4d-tag-zone {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}

.c4d-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 15px;
  padding: 0 4px;
  font-size: 8.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 0.1s ease;
}

.c4d-shape-tag {
  color: #555;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.c4d-shape-tag:hover,
.c4d-shape-tag.is-open {
  background: rgba(30, 90, 180, 0.15);
  color: #1e5ab4;
  border-color: rgba(30, 90, 180, 0.3);
}

.c4d-depth-tag {
  color: #1e5ab4;
  background: rgba(30, 90, 180, 0.08);
  border: 1px solid rgba(30, 90, 180, 0.15);
}

.c4d-depth-tag:hover {
  background: rgba(30, 90, 180, 0.18);
  border-color: rgba(30, 90, 180, 0.4);
}

.c4d-boil-tag {
  color: #b05c08;
  background: rgba(220, 120, 20, 0.12);
  border: 1px solid rgba(220, 120, 20, 0.28);
}

.c4d-boil-tag:hover {
  background: rgba(220, 120, 20, 0.22);
}

.c4d-tag-btn {
  width: 17px;
  height: 17px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  padding: 0;
  color: #444;
  transition: background 0.1s, color 0.1s;
}

.c4d-tag-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #111;
}

.c4d-tag-btn.is-unlocked {
  opacity: 0.2;
}

.c4d-tag-btn.is-hidden {
  opacity: 0.3;
}

.c4d-add-sub-btn {
  font-size: 13px;
  font-weight: 700;
  color: #777;
  opacity: 0.3;
}

.c4d-tree-row:hover .c4d-add-sub-btn {
  opacity: 0.85;
}

.c4d-add-sub-btn:hover {
  color: #1e5ab4 !important;
  opacity: 1 !important;
}

/* Shape Sub-Rows */
.c4d-shape-row {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
  min-height: 20px;
  font-size: 10px;
  color: #555;
  margin: 1px 2px;
  padding: 0 4px 0 2px;
  border-radius: 2px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: background 0.08s;
  box-sizing: border-box;
}

.c4d-shape-row:hover {
  background: rgba(40, 36, 28, 0.04);
}

.c4d-shape-row.is-selected,
.c4d-shape-row.is-active {
  background: rgba(30, 90, 180, 0.14);
  color: #1a1a18;
  font-weight: 600;
}

.c4d-shape-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  margin-right: 2px;
}

/* A light row carries a lamp colour, not a fill/stroke pair — the halo is
   what tells the two kinds of row apart at this size. */
.c4d-shape-swatch.is-light {
  border-color: rgba(107, 78, 18, 0.7);
  box-shadow: 0 0 0 2px rgba(243, 210, 122, 0.4);
  margin-right: 4px;
}

.layer-shape-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.layer-drop-guide {
  position: absolute;
  height: 2px;
  background: #1e5ab4;
  border-radius: 1px;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 0 3px rgba(30, 90, 180, 0.6);
}

/* Layer Inspector in C4D Style */
.layer-inspector.c4d-attributes-panel {
  border-top: 1px solid rgba(40, 36, 28, 0.1);
  padding: 6px 8px 8px;
  font-size: 10.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fdfdf9;
}

.c4d-attr-header {
  font-weight: 700;
  font-size: 10.5px;
  color: #222;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}

.c4d-attr-info-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #f4f3ec;
  border-radius: 4px;
  padding: 4px 6px;
  border: 1px solid rgba(40, 36, 28, 0.08);
  margin-bottom: 2px;
}

.c4d-attr-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.5px;
  color: #666;
}

.c4d-pos-tag {
  font-weight: 600;
  color: #444;
}

.c4d-attr-divider {
  font-size: 9.5px;
  font-weight: 700;
  color: #1e5ab4;
  border-top: 1px solid rgba(30, 90, 180, 0.15);
  padding-top: 4px;
  margin-top: 4px;
  text-transform: uppercase;
}

.c4d-checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  cursor: pointer;
  margin-top: 2px;
}

/* --- Floating 2.5D Parallax Motion Widget --- */
.parallax-widget {
  border-top: 1px solid rgba(40, 36, 28, 0.1);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #fff;
}

.parallax-widget-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.parallax-widget-title {
  font-size: 11px;
  font-weight: 700;
  color: #222;
}

.parallax-btn-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
}

.parallax-mini-btn {
  font: inherit;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #f8f8f4;
  color: #555;
  cursor: pointer;
}

.parallax-mini-btn.is-active {
  background: #1e5ab4;
  color: #fff;
  border-color: #1e5ab4;
}

.parallax-track {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: radial-gradient(circle at center, #ffffff 0%, #f4f3ea 100%);
  position: relative;
  touch-action: none;
  cursor: grab;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.parallax-crosshair {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, transparent 44px, rgba(0, 0, 0, 0.08) 44px, rgba(0, 0, 0, 0.08) 46px, transparent 46px),
    linear-gradient(to bottom, transparent 44px, rgba(0, 0, 0, 0.08) 44px, rgba(0, 0, 0, 0.08) 46px, transparent 46px);
}

.parallax-puck {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3d3d3a, #1a1a18);
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  position: absolute;
  pointer-events: none;
  transition: transform 0.04s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.parallax-wsad-hint {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(26, 26, 24, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: #fff;
  font-size: 8px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  z-index: 2;
  user-select: none;
}

.parallax-wsad-hint .wsad-row {
  display: flex;
  gap: 2px;
  justify-content: center;
  margin: 1px 0;
}

.parallax-wsad-hint .wsad-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 14px;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 3px;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.parallax-wsad-hint .wsad-key.is-held {
  background: #3b82f6;
  border-color: #60a5fa;
  box-shadow: 0 0 4px #3b82f6;
}

.parallax-wsad-hint .wsad-sub {
  font-size: 7px;
  opacity: 0.85;
  margin-top: 2px;
  letter-spacing: 0.2px;
}

.layer-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex: none;
}
.layer-collapse {
  flex: none;
  width: 1.4em;
  min-height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  opacity: 0.7;
  touch-action: manipulation;
}
.layer-group-name,
.layer-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-group-delete {
  opacity: 0.5;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  padding: 0 2px;
}
.layer-plane-badge {
  flex: none;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  opacity: 0.55;
  padding: 1px 5px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}
.layer-add-menu {
  position: relative;
  flex: none;
}
.layer-add-menu > summary {
  list-style: none;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.65;
  font-weight: 600;
}
.layer-add-menu > summary::-webkit-details-marker {
  display: none;
}
.layer-add-menu[open] > summary {
  opacity: 1;
}
.layer-add-menu-panel {
  display: none;
  position: absolute;
  right: 0;
  left: auto;
  top: auto;
  bottom: calc(100% + 2px);
  z-index: 8;
  min-width: 104px;
  max-width: calc(100vw - 24px);
  padding: 2px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.layer-add-menu[open] > .layer-add-menu-panel {
  display: block;
}
.layer-add-menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 11px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 2px;
}
.layer-add-menu-panel button:hover {
  background: rgba(40, 36, 28, 0.08);
}

.scene-settings-title {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
  padding-top: 2px;
}
.scene-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.scene-presets button {
  font: inherit;
  font-size: 10px;
  padding: 3px 6px;
  min-height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  touch-action: manipulation;
}
.scene-presets button:hover {
  background: rgba(40, 36, 28, 0.08);
}
.scene-reset {
  font: inherit;
  font-size: 11px;
  padding: 4px 6px;
  min-height: 24px;
  margin-top: 2px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  touch-action: manipulation;
}
.scene-reset:hover {
  background: rgba(40, 36, 28, 0.08);
}
.scene-settings .look-stack .mat-label {
  opacity: 0.9;
}
.scene-settings .look-pair {
  display: flex;
  gap: 4px;
  min-width: 0;
  width: 100%;
}
.scene-settings .look-pair input {
  max-width: none;
  flex: 1;
  min-width: 0;
}
.scene-settings textarea {
  font: inherit;
  font-size: 11px;
  min-height: 32px;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}
.scene-settings .pixel-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 6px;
}
.scene-settings .pixel-preset-btn {
  flex: 1 1 calc(33.33% - 4px);
  font: inherit;
  font-size: 10.5px;
  padding: 4px 5px;
  min-height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  touch-action: manipulation;
  text-align: center;
  white-space: nowrap;
}
.scene-settings .pixel-preset-btn:hover {
  background: rgba(40, 36, 28, 0.08);
}

/* —— Colour panel + sheets —— */
.color-panel.ui-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 6px 6px;
}

.color-targets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.color-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 4px;
  border: 1px solid rgba(40, 36, 28, 0.16);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 11px;
  color: inherit;
  cursor: pointer;
  min-height: 0;
}

.color-target.is-active {
  border-color: rgba(40, 36, 28, 0.5);
  background: rgba(40, 36, 28, 0.06);
  box-shadow: inset 0 0 0 1px rgba(40, 36, 28, 0.12);
}

.color-target.is-off .color-target-swatch {
  opacity: 0.35;
}

.color-target-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.color-target-on {
  margin: 0;
  flex: none;
}

.color-target-swatch {
  width: 100%;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #888;
}

/* --- Light drawers: notes and per-lamp "inherit from scene" dials --- */
.light-note {
  margin: 4px 0 6px;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  line-height: 1.35;
  background: rgba(214, 137, 16, 0.12);
  border: 1px solid rgba(214, 137, 16, 0.35);
  color: #8c5300;
}

.light-note.light-note-quiet {
  background: rgba(40, 36, 28, 0.05);
  border-color: rgba(40, 36, 28, 0.12);
  color: rgba(40, 36, 28, 0.7);
}

.fill-vary-group {
  margin: 6px 0 4px;
  padding: 2px 6px 6px;
  border: 1px solid rgba(40, 36, 28, 0.12);
  border-radius: 4px;
  min-inline-size: 0;
}

.fill-vary-group legend {
  padding-inline: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(40, 36, 28, 0.76);
}

.light-note.light-note-warn {
  background: rgba(214, 40, 40, 0.12);
  border-color: rgba(214, 40, 40, 0.35);
  color: #9e1414;
}

.light-inherit {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.light-inherit .scrub-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.light-inherit-btn {
  flex: 0 0 auto;
  height: 22px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(40, 36, 28, 0.55);
  background: #f4f2ea;
  border: 1px solid rgba(40, 36, 28, 0.2);
  border-radius: 3px;
  cursor: pointer;
}

.light-inherit-btn:hover {
  border-color: rgba(30, 90, 180, 0.6);
}

.light-inherit-btn.is-on {
  color: #ffffff;
  background: #1e5ab4;
  border-color: #1e5ab4;
}

.mat-group-label {
  margin: 8px 0 2px;
  padding: 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(40, 36, 28, 0.55);
  text-transform: uppercase;
}

.color-palette-strip-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.color-palette-strip-label {
  font-size: 11px;
  color: rgba(40, 36, 28, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.color-palette-strip-wrap.is-empty .color-palette-strip {
  display: none;
}

.color-palette-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.color-chip {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  padding: 0;
  cursor: pointer;
  background: #ccc;
  touch-action: manipulation;
}

.color-chip-sm {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  pointer-events: none;
}

.color-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.color-panel-actions .mat-btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 6px;
  font-size: 11px;
}

.color-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  background: rgba(20, 18, 14, 0.35);
  backdrop-filter: blur(2px);
  pointer-events: auto;
  transform: translateZ(0);
  touch-action: pan-x pan-y;
}

.color-sheet-backdrop[hidden] {
  display: none;
}

.color-sheet {
  width: min(440px, 100%);
  max-height: min(88dvh, 720px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  background: #fffef8;
  border: 1px solid rgba(40, 36, 28, 0.14);
  border-radius: 12px 12px 8px 8px;
  box-shadow: 0 12px 40px rgba(20, 18, 14, 0.22);
  display: flex;
  flex-direction: column;
}

@media (min-width: 720px) {
  .color-sheet-backdrop {
    align-items: center;
  }
  .color-sheet {
    border-radius: 12px;
  }
}

.color-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(40, 36, 28, 0.08);
  position: sticky;
  top: 0;
  background: #fffef8;
  z-index: 1;
}

.color-sheet-header h2 {
  margin: 0;
  font: 600 16px/1.2 inherit;
}

.color-sheet-close {
  font: inherit;
  padding: 8px 14px;
  min-height: 36px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.color-sheet-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Compact notice after demo / import open */
.load-time-backdrop {
  z-index: 50;
}
.load-time-sheet {
  width: min(360px, 100%);
  max-height: none;
}
.load-time-message {
  margin: 0;
  font: 500 15px/1.35 inherit;
}
.load-time-detail {
  margin: 0;
  font: 400 12px/1.35 inherit;
  opacity: 0.6;
}

.gen-fill-heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.55;
  margin-top: 4px;
}

.gen-fill-heading:first-child {
  margin-top: 0;
}

.gen-fill-backdrop {
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
}

.gen-fill-backdrop .generative-fill-sheet {
  pointer-events: auto;
}

.gen-close-btn {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  border-radius: 6px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #fff;
  cursor: pointer;
  color: rgba(40, 36, 28, 0.75);
}

.gen-close-btn:hover {
  background: #f0eee6;
  color: #1a1a18;
}

.generative-fill-sheet {
  width: min(500px, calc(100vw - 20px));
  max-height: min(94dvh, 520px);
}

.generative-fill-sheet .color-sheet-body {
  padding: 10px 14px 12px;
  gap: 8px;
}

.gen-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  align-items: center;
}

.gen-control-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.gen-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.gen-label {
  font-size: 11px;
  font-weight: 500;
  color: rgba(40, 36, 28, 0.7);
  line-height: 1.1;
  white-space: nowrap;
}

.gen-badge {
  font-size: 11px;
  font-weight: 600;
  color: #1e5ab4;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.gen-num-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  background: #fff;
  border: 1px solid rgba(40, 36, 28, 0.18);
  border-radius: 4px;
  padding: 1px 4px;
  height: 20px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gen-num-wrap:focus-within {
  border-color: #1e5ab4;
  box-shadow: 0 0 0 1px #1e5ab4;
}

.gen-num-input {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: #1e5ab4;
  font-variant-numeric: tabular-nums;
  text-align: right;
  width: 38px;
  outline: none;
  font-family: inherit;
  -moz-appearance: textfield;
}

.gen-num-input::-webkit-outer-spin-button,
.gen-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.gen-num-unit {
  font-size: 10px;
  font-weight: 600;
  color: rgba(30, 90, 180, 0.7);
  margin-left: 1px;
  user-select: none;
}

.gen-layer-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gen-layer-hint {
  font-size: 11px;
  font-weight: 500;
  color: rgba(40, 36, 28, 0.55);
}

.gen-select,
.gen-range,
.gen-seed-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
}

.gen-select {
  height: 28px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #fff;
  color: inherit;
}

.gen-range {
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.gen-inline-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}

.gen-check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(40, 36, 28, 0.85);
  cursor: pointer;
  user-select: none;
}

.gen-check-label input[type='checkbox'] {
  margin: 0;
  cursor: pointer;
}

.gen-seed-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.gen-seed-input {
  width: 72px;
  height: 26px;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  font-size: 11px;
  text-align: right;
}

.gen-seed-btn {
  height: 26px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gen-layer-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gen-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(40, 36, 28, 0.08);
}

.gen-fill-estimate {
  font-size: 11.5px;
  opacity: 0.75;
  line-height: 1.2;
  flex: 1;
}

.gen-fill-estimate.is-warning {
  color: #a03030;
  opacity: 1;
}

.gen-fill-populate {
  flex-shrink: 0;
  font: 600 13px/1 inherit;
  padding: 8px 16px;
  min-height: 34px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  border-radius: 6px;
  background: #2a2a28;
  color: #fffef8;
  cursor: pointer;
}

.gen-fill-populate:hover {
  background: #1a1a18;
}

.color-picker-preview {
  height: 40px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.color-picker-sv {
  position: relative;
  width: 100%;
  aspect-ratio: 1.35 / 1;
  max-height: 220px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  touch-action: none;
  cursor: crosshair;
  overflow: hidden;
}

.color-picker-sv-cursor {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.color-picker-hue {
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: #2a2a28;
  border-radius: 4px;
}

.color-picker-hex-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker-hex {
  flex: 1;
  font: 14px/1.2 ui-monospace, Menlo, Consolas, monospace;
  padding: 8px 10px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  border-radius: 6px;
  background: #fff;
  min-height: 36px;
  box-sizing: border-box;
}

.color-picker-recent {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.palette-tools-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
}

.palette-tools-tabs button {
  flex: 1;
  font: inherit;
  padding: 8px 6px;
  min-height: 36px;
  border: 1px solid rgba(40, 36, 28, 0.14);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.palette-tools-tabs button.is-active {
  background: rgba(40, 36, 28, 0.1);
  border-color: rgba(40, 36, 28, 0.4);
  font-weight: 600;
}

.palette-tools-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.palette-tools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.palette-tools-actions button,
.palette-tools-pane > button,
.palette-lib-actions button {
  font: inherit;
  padding: 7px 10px;
  min-height: 34px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.palette-lib-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
}

.palette-lib-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(40, 36, 28, 0.12);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.palette-lib-row.is-active {
  border-color: rgba(40, 36, 28, 0.45);
  background: rgba(40, 36, 28, 0.05);
}

.palette-lib-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.palette-lib-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.palette-lib-badge {
  font-size: 11px;
  color: rgba(40, 36, 28, 0.55);
}

.palette-lib-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.palette-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  padding: 16px;
  border: 2px dashed rgba(40, 36, 28, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  text-align: center;
  cursor: pointer;
  color: rgba(40, 36, 28, 0.7);
}

.palette-dropzone.is-drag {
  border-color: rgba(40, 36, 28, 0.55);
  background: rgba(40, 36, 28, 0.06);
}

.palette-dropzone p {
  margin: 0;
  line-height: 1.4;
}

.palette-dropzone span {
  font-size: 11px;
  opacity: 0.7;
}

.palette-image-preview {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.palette-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: rgba(40, 36, 28, 0.7);
}

.palette-field input[type='range'],
.palette-field select {
  width: 100%;
  min-height: 44px;
}

.palette-field input,
.palette-field select {
  font-size: 16px;
}

.palette-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
}

.palette-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.palette-name-input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid rgba(40, 36, 28, 0.18);
  border-radius: 6px;
  min-height: 36px;
  box-sizing: border-box;
}

.palette-seed-row {
  display: flex;
  gap: 10px;
}

.palette-seed-swatch {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: #ccc;
  font: 600 18px/1 inherit;
  color: rgba(40, 36, 28, 0.45);
  cursor: pointer;
  padding: 0;
}

/* Bigger thumbs + touch-action so horizontal drags aren't stolen by a
   parent’s vertical scroll (same lesson as the pigment labs). */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  touch-action: none;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(40, 36, 28, 0.22);
  border-radius: 2px;
}

input[type='range']::-moz-range-track {
  height: 4px;
  background: rgba(40, 36, 28, 0.22);
  border-radius: 2px;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -12px;
  border-radius: 50%;
  background: #2a2a28;
  border: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

input[type='range']::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #2a2a28;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.color-picker-hue::-webkit-slider-runnable-track {
  height: 12px;
  background: linear-gradient(
    to right,
    #f00,
    #ff0,
    #0f0,
    #0ff,
    #00f,
    #f0f,
    #f00
  );
  border-radius: 4px;
}

.color-picker-hue::-moz-range-track {
  height: 12px;
  background: linear-gradient(
    to right,
    #f00,
    #ff0,
    #0f0,
    #0ff,
    #00f,
    #f0f,
    #f00
  );
  border-radius: 4px;
}

.materials-panel input[type='number'],
.scene-settings input[type='number'] {
  min-height: 22px;
  font-size: 12px;
  max-width: none;
  box-sizing: border-box;
}

.mat-row:has(> select),
.mat-row:has(> textarea) {
  grid-template-columns: 1fr;
}

.ui-shell select {
  font: inherit;
  font-size: 11px;
  max-width: 100%;
  min-width: 0;
}

.ui-shell input[type='color'] {
  height: 22px;
  min-height: 22px;
  padding: 0;
  min-width: 36px;
}

/* Sidebar sliders stay short; colour sheets keep the big thumbs above. */
.ui-shell input[type='range'] {
  height: 18px;
}

.ui-shell input[type='range']::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
}

.ui-shell input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
}



/* Contextual path overlay (labs v5 port) */
.vt-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 9; }
.vt-vertex-toggle {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  opacity: 0.55;
  transition: opacity 0.12s ease;
  z-index: 3;
}
.vt-vertex-toggle:hover { opacity: 1; }
.vt-vertex-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink, #1a1a1a);
  background: var(--panel, #f4f1ea);
  border: 1px solid var(--line, #c8c2b4);
  border-radius: 6px;
  cursor: pointer;
}
.vt-vertex-box svg { display: block; width: 18px; height: 18px; }
.vt-vertex-dots { display: flex; gap: 4px; }
.vt-vertex-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--muted, #888); opacity: 0.4;
}
.vt-vertex-dot.is-on { background: var(--accent, #2a5cad); opacity: 1; }
.vt-vertex-toggle.is-hidden,
.vt-icon-btn.is-hidden,
.vt-shape-row.is-hidden { opacity: 0; pointer-events: none; }
.vt-icon-btn {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink, #1a1a1a);
  background: var(--panel, #f4f1ea);
  border: 1px solid var(--line, #c8c2b4);
  border-radius: 6px;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}
.vt-icon-btn svg { display: block; width: 16px; height: 16px; }
.vt-shape-row {
  position: absolute;
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-wrap: wrap;
  max-width: 220px;
  pointer-events: auto;
  transform: translate(0, 0);
}
.vt-shape-row .vt-icon-btn {
  position: relative;
  transform: none;
}
.vt-shape-row .vt-bool-toggle {
  position: relative;
  transform: none;
  opacity: 1;
}
.vt-shape-row .vt-bool-toggle .vt-vertex-box {
  width: 32px;
  height: 32px;
}
@keyframes vt-gap-flash {
  0%, 42% { opacity: 1; }
  58%, 100% { opacity: 0.12; }
}
.vt-gap-edge {
  animation: vt-gap-flash 1.05s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .vt-gap-edge { animation: none; opacity: 1; }
}

/* --- Compact Cinema 4D / DCC Scrollbars --- */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(40, 36, 28, 0.16);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(40, 36, 28, 0.32);
}

.perf-flags-panel { display: flex; flex-direction: column; gap: 6px; }
.perf-flags-report {
  white-space: pre-line;
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: 0.75;
  padding: 6px 0;
}
