
  /* Global scene-only eye: a viewport action, never a mode-bar action. */
  .m3-scene-eye-dock {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
  }

  .viewport-wrap > .m3-scene-eye-dock-floating {
    position: absolute;
    top: max(8px, env(safe-area-inset-top, 0px));
    left: max(8px, env(safe-area-inset-left, 0px));
    z-index: 30;
  }

  #m3-scene-only-toggle {
    position: relative;
    top: auto;
    right: auto;
    z-index: auto;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 9px;
    background: rgba(16,16,16,.76);
    color: rgba(255,255,255,.86);
    box-shadow: 0 4px 14px rgba(0,0,0,.22);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #m3-scene-only-toggle:active {
    color: #fff;
    background: var(--accent-bg);
    border-color: var(--accent);
  }
  #m3-scene-only-toggle svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  #m3-scene-only-toggle .m3-scene-eye-off { display: none; }

  /* The eye no longer occupies the mobile mode-bar cutout, so use that space
     for the existing Redo action instead of hiding it beside Undo. */
  @media (max-width: 600px) {
    .modebar {
      grid-template-columns: minmax(0, 1fr) repeat(4, 48px) !important;
    }
    .modebar-cutout-spacer {
      display: none !important;
    }
    #btn-redo {
      display: flex !important;
    }
  }

  @media (orientation: landscape) and (max-height: 600px) and (max-width: 700px) {
    .modebar {
      grid-template-columns: minmax(86px, 1fr) repeat(4, 44px) !important;
    }
  }

  /* Move/Rotate/Scale temporarily owns the viewport header. The outliner is
     merely hidden, not collapsed or reset, so it returns exactly as it was. */
  body.m3-transform-interface-active #right-outliner,
  body.m3-transform-interface-active .right-outliner {
    display: none !important;
  }

  /* Outliner object actions reuse the established dark popover and bottom
     sheet language while keeping touch targets large enough for long-press use. */
  .outliner-object-action-title {
    min-width: 0;
    margin: 0 2px 5px;
    padding: 6px 8px 8px;
    overflow: hidden;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .outliner-object-actions button > span:first-child {
    width: 20px;
    flex: 0 0 20px;
    color: var(--accent);
    text-align: center;
  }
  .group-chooser .group-chooser-empty {
    margin: 2px 0 5px;
    padding: 13px 10px;
    border: 1px dashed rgba(255,255,255,.12);
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 11px;
    text-align: center;
  }
  .group-chooser button[data-group-choice] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .group-chooser button[data-group-choice].current {
    color: #fff;
    background: rgba(232,125,13,.18);
    box-shadow: inset 0 0 0 1px rgba(255,143,0,.55);
  }
  .group-choice-check { color: var(--accent); font-weight: 900; }
  .group-chooser .group-chooser-new {
    margin-top: 7px;
    border: 1px dashed rgba(255,143,0,.52);
    color: #ffad5c;
    background: rgba(232,125,13,.08);
  }

  .outline-rename-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 26px 26px;
    align-items: center;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
  }
  .outline-rename-editor .outline-rename-input {
    width: 100%;
    height: 28px;
    min-width: 0;
    padding: 3px 5px;
    user-select: text;
    -webkit-user-select: text;
  }
  .outline-rename-editor button {
    width: 26px;
    min-width: 26px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 5px;
    color: #fff;
    background: rgba(255,255,255,.06);
    font-size: 14px;
    font-weight: 900;
  }
  .outline-rename-editor .outline-rename-confirm {
    border-color: rgba(255,143,0,.58);
    color: #fff;
    background: var(--accent-bg);
  }

  /* Scene-only mode gives every available pixel to the active viewport canvas. */
  body.m3-scene-only #app {
    display: flex !important;
    flex-direction: column !important;
  }
  body.m3-scene-only #app > :not(.viewport-wrap):not(input[type="file"]) {
    display: none !important;
  }
  body.m3-scene-only .viewport-wrap {
    flex: 1 1 auto !important;
    grid-column: 1 / -1 !important;
    grid-row: 1 / -1 !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  body.m3-scene-only .viewport-wrap > :not(canvas):not(#m3-scene-only-toggle) {
    display: none !important;
  }
  body.m3-scene-only #m3-scene-only-toggle {
    position: absolute;
    top: max(10px, env(safe-area-inset-top, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    z-index: 1050;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    flex-basis: 38px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 10px;
    background: rgba(18,18,18,.70);
    box-shadow: 0 5px 16px rgba(0,0,0,.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  body.m3-scene-only #m3-scene-only-toggle .m3-scene-eye-on { display: none; }
  body.m3-scene-only #m3-scene-only-toggle .m3-scene-eye-off { display: block; }

  /* Render the Move / Rotate / Scale fan outside the scrollable tool rail. */
  #transform-fan.m3-viewport-transform-fan {
    position: fixed !important;
    right: auto !important;
    bottom: auto !important;
    z-index: 1000 !important;
  }

  /* Mobile transform context: Orientation and Pivot stay on independent rows,
     but the complete context bar is compressed and docked directly beneath
     the app bar so it does not waste viewport space. */
  .transform-context-bar {
    top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    gap: 0 !important;
    padding: 1px 3px !important;
    overflow: visible !important;
    border-top: 0 !important;
    border-right: 0 !important;
    border-left: 0 !important;
    border-radius: 0 0 8px 8px !important;
  }

  .transform-context-bar[hidden] {
    display: none !important;
  }

  .transform-context-bar .tcb-group {
    display: grid !important;
    grid-template-columns: 64px repeat(4, minmax(0, 1fr)) !important;
    align-items: center !important;
    gap: 2px !important;
    min-width: 0 !important;
  }

  .transform-context-bar .tcb-group[aria-label="Pivot"] {
    grid-template-columns: 64px repeat(3, minmax(0, 1fr)) !important;
  }

  .transform-context-bar .tcb-label {
    min-width: 0 !important;
    padding: 0 4px !important;
    overflow: hidden !important;
    color: rgba(255,255,255,.58) !important;
    font-size: 7px !important;
    line-height: 1.1 !important;
    letter-spacing: .25px !important;
    text-overflow: clip !important;
  }

  .transform-context-bar .tcb-option {
    width: 100% !important;
    min-width: 0 !important;
    height: 25px !important;
    min-height: 25px !important;
    padding: 2px 3px !important;
    overflow: hidden !important;
    border-radius: 5px !important;
    font-size: 9px !important;
    line-height: 1 !important;
    text-overflow: ellipsis !important;
  }

  .transform-context-bar .tcb-divider {
    width: 100% !important;
    height: 1px !important;
    margin: 0 !important;
    background: rgba(255,255,255,.09) !important;
  }

  /* Keep the same aligned two-row design on very narrow phones while giving
     the four Orientation choices as much width as possible. */
  @media (max-width: 380px) {
    .transform-context-bar .tcb-group {
      grid-template-columns: 56px repeat(4, minmax(0, 1fr)) !important;
      gap: 1px !important;
    }
    .transform-context-bar .tcb-group[aria-label="Pivot"] {
      grid-template-columns: 56px repeat(3, minmax(0, 1fr)) !important;
    }
    .transform-context-bar .tcb-label {
      padding-inline: 3px !important;
      font-size: 6.5px !important;
      letter-spacing: .15px !important;
    }
    .transform-context-bar .tcb-option {
      padding-inline: 1px !important;
      font-size: 8px !important;
    }
  }

  /* Wide screens have enough room for the original one-line arrangement. */
  @media (min-width: 760px) {
    .transform-context-bar {
      width: 100% !important;
      max-width: 100% !important;
      display: flex !important;
      align-items: stretch !important;
      justify-content: center !important;
      gap: 3px !important;
      padding: 1px 4px !important;
    }
    .transform-context-bar .tcb-group,
    .transform-context-bar .tcb-group[aria-label="Pivot"] {
      display: flex !important;
      gap: 2px !important;
    }
    .transform-context-bar .tcb-label {
      padding: 0 4px !important;
      font-size: 9px !important;
      letter-spacing: .45px !important;
    }
    .transform-context-bar .tcb-option {
      width: auto !important;
      height: 25px !important;
      min-height: 25px !important;
      padding: 2px 7px !important;
      overflow: visible !important;
      font-size: 9px !important;
      text-overflow: clip !important;
    }
    .transform-context-bar .tcb-divider {
      width: 1px !important;
      height: auto !important;
      margin: 2px 1px !important;
    }
  }

  /* In UV editing, keep Move and its on-demand transform fan on the left rail. */
  body.m3-uv-minimal-controls .left-tools > :not(#ltool-transform):not(#transform-fan) {
    display: none !important;
  }

  /* In UV editing, keep only Select on the right rail. */
  body.m3-uv-minimal-controls .right-actions > :not(#rb-select) {
    display: none !important;
  }

  /* Remove UV-side panels and companion viewport buttons only in UV editing. */
  body.m3-uv-minimal-controls .right-outliner,
  body.m3-uv-minimal-controls .vp-savepng,
  body.m3-uv-minimal-controls .studio-lighting-fab,
  body.m3-uv-minimal-controls #viewport-sun-gizmo {
    display: none !important;
  }

  /* Reduced UV rails should not reserve or clip any extra viewport space. */
  body.m3-uv-minimal-controls .left-tools,
  body.m3-uv-minimal-controls .right-actions {
    width: max-content !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body.m3-uv-minimal-controls #ltool-transform,
  body.m3-uv-minimal-controls #rb-select {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* Compact Edit Mode selection strip: keep it left-aligned immediately after Move. */
  body.mode-edit #submode-row {
    left: calc(max(8px, env(safe-area-inset-left, 0px)) + 52px) !important;
    right: auto !important;
    gap: 3px !important;
    justify-content: flex-start !important;
    transform: none !important;
    transition: opacity 0.14s ease, filter 0.14s ease !important;
  }

  body.mode-edit #submode-row .sub-btn {
    width: 42px !important;
    min-width: 42px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 3px 1px !important;
    border-radius: 8px !important;
    gap: 2px !important;
    font-size: 9px !important;
  }

  body.mode-edit #submode-row .sub-btn svg {
    width: 15px !important;
    height: 15px !important;
  }

  body.mode-edit #submode-row .sub-btn span {
    font-size: 9px !important;
  }

  /* Mode-aware workspace matrix. These rules only change presentation: the
     original controls and their state remain intact for the modes that use them. */
  body:not(.mode-edit) #rb-edit {
    display: none !important;
  }

  /* Object Mode owns the general Tools library. Mode-specific workspaces use
     their dedicated bottom panels instead of exposing unrelated object tools. */
  body:not(.mode-object) #rb-tools,
  body:not(.mode-object) #tools-menu,
  body:not(.mode-object) #tools-menu-backdrop {
    display: none !important;
  }

  /* Edit, Sculpt, Texture Paint, and Pose are focused workspaces. Remove the
     object/display chrome that cannot operate on their active component type. */
  body.mode-edit #vp-view-controls,
  body.mode-tpaint #vp-view-controls,
  body.mode-pose #vp-view-controls,
  body.mode-edit #axis-gizmo,
  body.mode-tpaint #axis-gizmo,
  body.mode-pose #axis-gizmo,
  body.mode-edit #right-outliner,
  body.mode-edit .right-outliner,
  body.mode-sculpt #right-outliner,
  body.mode-sculpt .right-outliner,
  body.mode-tpaint #right-outliner,
  body.mode-tpaint .right-outliner,
  body.mode-edit #rb-grid,
  body.mode-sculpt #rb-grid,
  body.mode-tpaint #rb-grid,
  body.mode-pose #rb-grid,
  body.mode-edit #rb-view,
  body.mode-sculpt #rb-view,
  body.mode-tpaint #rb-view,
  body.mode-pose #rb-view,
  body.mode-edit #tutorial-btn-wrap,
  body.mode-sculpt #tutorial-btn-wrap,
  body.mode-tpaint #tutorial-btn-wrap,
  body.mode-pose #tutorial-btn-wrap,
  body.mode-edit .vp-savepng,
  body.mode-sculpt .vp-savepng,
  body.mode-tpaint .vp-savepng,
  body.mode-pose .vp-savepng,
  body.mode-edit .studio-lighting-fab,
  body.mode-sculpt .studio-lighting-fab,
  body.mode-tpaint .studio-lighting-fab,
  body.mode-pose .studio-lighting-fab,
  body.mode-edit #viewport-sun-gizmo,
  body.mode-sculpt #viewport-sun-gizmo,
  body.mode-tpaint #viewport-sun-gizmo,
  body.mode-pose #viewport-sun-gizmo {
    display: none !important;
  }

  /* Sculpt keeps the gizmo top-left like Object Mode — just above sculpt's
     own viewport rails. The Lock/Eye stack's z-index lives with its own
     rule (#m3-view-lock-stack) since it no longer shares this container. */
  body.mode-sculpt #m3-top-left-controls {
    z-index: 28 !important;
  }

  body.mode-sculpt.m3-scene-only #m3-top-left-controls {
    display: none !important;
  }

  /* The scene-only exit must remain reachable across every mode transition. */
  body.mode-edit.m3-scene-only #m3-scene-only-toggle,
  body.mode-sculpt.m3-scene-only #m3-scene-only-toggle,
  body.mode-tpaint.m3-scene-only #m3-scene-only-toggle,
  body.mode-pose.m3-scene-only #m3-scene-only-toggle {
    display: flex !important;
  }

  /* Sculpt is already the active workspace, so a second Edit / Mat. layer adds
     no useful choice. Keep only Topology / Mesh Info plus the existing panel
     minimize and resize controls; brush settings remain in the viewport rail. */
  body.mode-sculpt #ltool-transform,
  body.mode-sculpt #transform-fan,
  body.mode-sculpt #ltool-actions,
  body.mode-sculpt #rb-select {
    display: none !important;
  }
  body.mode-sculpt #ltool-frame {
    display: flex !important;
  }

  /* Flatten Sculpt's primary and secondary inspector navigation into one row.
     The primary bar remains in the DOM so its established minimize and resize
     listeners stay intact, but it becomes a transparent overlay containing
     only those two controls. The secondary row reserves the left control slot. */
  body.mode-sculpt .properties-panel {
    position: relative;
  }

  body.mode-sculpt .properties-panel > .props-tab-bar {
    position: absolute !important;
    z-index: 35;
    inset: 0 0 auto 0;
    width: 100%;
    height: 46px !important;
    min-height: 46px !important;
    flex: none !important;
    border: 0 !important;
    background: transparent !important;
    pointer-events: none;
  }

  body.mode-sculpt .properties-panel > .props-tab-bar > .tab-btn,
  body.mode-sculpt .properties-panel > .props-tab-bar > #panel-drill-nav {
    display: none !important;
  }

  body.mode-sculpt .properties-panel > .props-tab-bar > .panel-min-btn {
    width: 44px !important;
    min-width: 44px !important;
    height: 46px !important;
    min-height: 46px !important;
    flex: 0 0 44px !important;
    border-right: 1px solid rgba(255,255,255,.07);
    pointer-events: auto;
  }

  body.mode-sculpt .properties-panel > .props-tab-bar > .props-resize-handle {
    pointer-events: auto;
  }

  body.mode-sculpt #subtab-bar-outer {
    display: block !important;
  }

  body.mode-sculpt #subtab-bar-outer .subtab-bar {
    min-height: 46px;
    padding-left: 44px;
  }

  /* A minimized Sculpt panel remains one useful row: the upward chevron can
     restore it, while Topology / Mesh Info keep the current destination clear. */
  body.mode-sculpt .properties-panel.panel-collapsed #subtab-bar-outer {
    display: block !important;
  }

  body.mode-sculpt .properties-panel.panel-collapsed .panel-min-btn {
    display: flex !important;
  }

  body.mode-sculpt .properties-panel.panel-collapsed .panel-min-btn svg {
    transform: rotate(180deg);
  }

  /* The default Topology view contains one compact stepped-density control
     beneath the single navigation row. User-resized and collapsed state win. */
  body.mode-sculpt .properties-panel.panel-sculpt-compact {
    height: calc(176px + env(safe-area-inset-bottom)) !important;
    max-height: calc(176px + env(safe-area-inset-bottom)) !important;
  }

  body.mode-sculpt .properties-panel.panel-sculpt-compact:not(.panel-collapsed):has(.sculpt-over-budget) {
    height: calc(224px + env(safe-area-inset-bottom)) !important;
    max-height: calc(224px + env(safe-area-inset-bottom)) !important;
  }

  body.mode-sculpt #props-inner:has(.sculpt-topology-panel),
  body.mode-sculpt #props-inner:has(.sculpt-mesh-info) {
    padding: 7px 10px 8px !important;
  }

  body.mode-sculpt .sculpt-topology-panel {
    display: grid;
    gap: 5px;
    width: 100%;
  }

  body.mode-sculpt .sculpt-subdivide-head {
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 3px;
    color: rgba(255,255,255,.56);
    font-size: 10px;
    line-height: 1;
  }

  body.mode-sculpt .sculpt-subdivide-level {
    color: #ffad43;
    font-size: 10px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
  }

  body.mode-sculpt .sculpt-device-budget {
    display: inline-flex;
    align-items: center;
    min-height: 16px;
    margin-left: 3px;
    padding: 1px 5px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 999px;
    color: rgba(255,255,255,.48);
    background: rgba(255,255,255,.035);
    font-size: 8px;
    font-weight: 650;
    line-height: 1;
    white-space: nowrap;
  }

  body.mode-sculpt .sculpt-subdivide-ladder {
    width: 100%;
    min-width: 0;
    padding: 0 3px;
  }

  body.mode-sculpt .sculpt-subdivide-range {
    width: 100%;
    height: 20px;
    margin: 0;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    touch-action: none;
  }

  body.mode-sculpt .sculpt-subdivide-range::-webkit-slider-runnable-track {
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent) 0 var(--subdivide-pct), rgba(255,255,255,.15) var(--subdivide-pct) 100%);
  }

  body.mode-sculpt .sculpt-subdivide-range::-moz-range-track {
    height: 3px;
    border: 0;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent) 0 var(--subdivide-pct), rgba(255,255,255,.15) var(--subdivide-pct) 100%);
  }

  body.mode-sculpt .sculpt-subdivide-range::-webkit-slider-thumb {
    width: 17px;
    height: 17px;
    margin-top: -7px;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 1px 6px rgba(0,0,0,.48);
  }

  body.mode-sculpt .sculpt-subdivide-range::-moz-range-thumb {
    width: 17px;
    height: 17px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 1px 6px rgba(0,0,0,.48);
  }

  body.mode-sculpt .sculpt-subdivide-range:disabled {
    opacity: .4;
  }

  body.mode-sculpt .sculpt-subdivide-ticks {
    display: grid;
    grid-template-columns: repeat(var(--tick-count), minmax(0, 1fr));
    align-items: start;
    width: 100%;
    margin-top: -2px;
  }

  body.mode-sculpt .sculpt-subdivide-tick {
    min-width: 0;
    min-height: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    padding: 0 1px;
    border: 0;
    color: rgba(255,255,255,.42);
    background: transparent;
    font: 650 8px/1 system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
  }

  body.mode-sculpt .sculpt-subdivide-tick > span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
  }

  body.mode-sculpt .sculpt-subdivide-tick > b {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font: inherit;
  }

  body.mode-sculpt .sculpt-subdivide-tick.current {
    color: rgba(255,255,255,.64);
  }

  body.mode-sculpt .sculpt-subdivide-tick.active {
    color: #ffad43;
  }

  body.mode-sculpt .sculpt-subdivide-tick.active > span {
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(255,143,0,.14);
  }

  body.mode-sculpt .sculpt-subdivide-tick.warning {
    color: #ff756f;
  }

  body.mode-sculpt .sculpt-subdivide-tick.warning > span {
    background: #d44848;
  }

  body.mode-sculpt .sculpt-subdivide-tick.warning.active {
    color: #ff8f89;
  }

  body.mode-sculpt .sculpt-subdivide-tick.warning.active > span {
    background: #ff5c55;
    box-shadow: 0 0 0 3px rgba(255,92,85,.16);
  }

  body.mode-sculpt .sculpt-subdivide-action-row {
    min-height: 34px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    padding-top: 5px;
    border-top: 1px solid rgba(255,255,255,.07);
  }

  body.mode-sculpt .sculpt-subdivide-result {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    color: rgba(255,255,255,.50);
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  body.mode-sculpt .sculpt-subdivide-result i {
    color: rgba(255,255,255,.28);
    font-style: normal;
  }

  body.mode-sculpt .sculpt-subdivide-result strong {
    color: rgba(255,255,255,.88);
    font-size: 10px;
  }

  body.mode-sculpt .sculpt-subdivide-result em {
    margin-left: 2px;
    padding-left: 5px;
    border-left: 1px solid rgba(255,255,255,.10);
    font-style: normal;
    font-weight: 750;
  }

  body.mode-sculpt .sculpt-subdivide-result em.normal { color: #6bd88b; }
  body.mode-sculpt .sculpt-subdivide-result em.warning,
  body.mode-sculpt .sculpt-subdivide-result em.blocked { color: #ff756f; }

  body.mode-sculpt .sculpt-subdivide-apply {
    min-width: 78px;
    height: 32px;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--accent);
    border-radius: 7px;
    color: #fff;
    background: var(--accent);
    font: 750 10px/1 system-ui, sans-serif;
  }

  body.mode-sculpt .sculpt-subdivide-apply.warning {
    border-color: #e2524c;
    background: #a8312d;
  }

  body.mode-sculpt .sculpt-subdivide-apply:disabled {
    border-color: rgba(255,255,255,.10);
    color: rgba(255,255,255,.38);
    background: rgba(255,255,255,.05);
  }

  body.mode-sculpt .sculpt-over-budget {
    min-height: 43px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 6px 3px 0;
    border-top: 1px solid rgba(255,92,85,.20);
  }

  body.mode-sculpt .sculpt-over-budget-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
    font-variant-numeric: tabular-nums;
  }

  body.mode-sculpt .sculpt-over-budget-copy strong {
    overflow: hidden;
    color: #ff756f;
    font: 750 10px/1 system-ui, sans-serif;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mode-sculpt .sculpt-over-budget-copy span {
    overflow: hidden;
    color: rgba(255,255,255,.48);
    font: 600 8px/1 system-ui, sans-serif;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mode-sculpt .sculpt-reduce-normal {
    height: 32px;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid rgba(255,117,111,.65);
    border-radius: 7px;
    color: #fff;
    background: rgba(168,49,45,.78);
    font: 750 9px/1 system-ui, sans-serif;
    white-space: nowrap;
  }

  body.mode-sculpt .sculpt-reduce-normal:disabled {
    opacity: .52;
  }

  .sculpt-extreme-warning {
    position: fixed;
    inset: 0;
    z-index: 4200;
    display: grid;
    place-items: center;
    padding: 18px;
    overflow: auto;
    color: #fff;
    background: rgba(0,0,0,.84);
    opacity: 0;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 140ms ease;
  }

  .sculpt-extreme-warning.visible {
    opacity: 1;
  }

  .sculpt-extreme-card {
    width: min(420px, calc(100vw - 28px));
    padding: 18px;
    border: 1px solid rgba(255,92,85,.72);
    border-radius: 14px;
    background: #171313;
    box-shadow: 0 22px 70px rgba(0,0,0,.66), inset 0 1px rgba(255,255,255,.035);
    transform: translateY(8px) scale(.985);
    transition: transform 160ms ease;
  }

  .sculpt-extreme-warning.visible .sculpt-extreme-card {
    transform: none;
  }

  .sculpt-extreme-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    border: 1px solid rgba(255,92,85,.58);
    border-radius: 50%;
    color: #ff756f;
    background: rgba(255,92,85,.10);
    font: 850 22px/1 system-ui, sans-serif;
  }

  .sculpt-extreme-card h2 {
    margin: 0 0 5px;
    color: #fff;
    font: 800 18px/1.15 system-ui, sans-serif;
  }

  .sculpt-extreme-target {
    margin: 0 0 12px;
    color: #ff8f89;
    font: 760 13px/1.25 system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
  }

  .sculpt-extreme-card > p:not(.sculpt-extreme-target) {
    margin: 0 0 9px;
    color: rgba(255,255,255,.70);
    font: 500 11px/1.45 system-ui, sans-serif;
  }

  .sculpt-extreme-card ul {
    display: grid;
    gap: 6px;
    margin: 10px 0 12px;
    padding-left: 18px;
    color: rgba(255,255,255,.78);
    font: 550 11px/1.35 system-ui, sans-serif;
  }

  .sculpt-extreme-device {
    margin: 0 0 14px;
    padding: 7px 9px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 7px;
    color: rgba(255,255,255,.54);
    background: rgba(255,255,255,.035);
    font: 600 9px/1.35 system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
  }

  .sculpt-extreme-actions {
    display: grid;
    grid-template-columns: minmax(82px, .7fr) minmax(150px, 1.3fr);
    gap: 8px;
  }

  .sculpt-extreme-cancel,
  .sculpt-extreme-hold,
  .sculpt-reduce-confirm {
    position: relative;
    min-width: 0;
    height: 42px;
    border-radius: 9px;
    color: #fff;
    font: 760 11px/1 system-ui, sans-serif;
  }

  .sculpt-extreme-cancel {
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.06);
  }

  .sculpt-extreme-hold {
    --hold-progress: 0;
    overflow: hidden;
    border: 1px solid #e2524c;
    background: #6e2422;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .sculpt-extreme-hold > span {
    position: absolute;
    inset: 0;
    background: #c43b36;
    transform: scaleX(var(--hold-progress));
    transform-origin: left center;
  }

  .sculpt-extreme-hold > b {
    position: relative;
    z-index: 1;
    pointer-events: none;
  }

  .sculpt-extreme-hold.holding {
    border-color: #ff7a74;
  }

  .sculpt-reduce-warning .sculpt-extreme-card {
    border-color: rgba(255,143,0,.68);
  }

  .sculpt-reduce-warning .sculpt-extreme-icon {
    border-color: rgba(255,143,0,.54);
    color: #ffad43;
    background: rgba(255,143,0,.10);
  }

  .sculpt-reduce-warning .sculpt-extreme-target {
    color: #ffad43;
  }

  .sculpt-reduce-confirm {
    border: 1px solid var(--accent);
    background: var(--accent);
  }

  @media (max-width: 370px) {
    .sculpt-extreme-actions {
      grid-template-columns: 1fr;
    }
  }

  body.mode-sculpt .sculpt-mesh-info {
    width: 100%;
    border-top: 1px solid rgba(255,255,255,.07);
  }

  body.mode-sculpt .sculpt-info-row {
    min-height: 30px;
    display: grid;
    grid-template-columns: minmax(76px, .8fr) minmax(0, 1.2fr);
    align-items: center;
    gap: 6px;
    padding: 4px 3px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    font-size: 10px;
    line-height: 1.2;
  }

  body.mode-sculpt .sculpt-info-label {
    color: rgba(255,255,255,.48);
  }

  body.mode-sculpt .sculpt-info-value {
    min-width: 0;
    overflow: hidden;
    color: rgba(255,255,255,.88);
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
  }

  @media (orientation: landscape) and (max-height: 600px) {
    body.mode-sculpt .properties-panel.panel-sculpt-compact {
      height: auto !important;
      max-height: none !important;
    }
  }

  /* Texture Paint: paint tools, color/brush settings, material, and framing. */
  body.mode-tpaint #ltool-transform,
  body.mode-tpaint #transform-fan,
  body.mode-tpaint #ltool-actions,
  body.mode-tpaint #rb-select,
  body.mode-tpaint .tab-btn[data-tab="edit"] {
    display: none !important;
  }
  body.mode-tpaint #ltool-frame {
    display: flex !important;
  }

  /* Animation keeps scene navigation and object transforms, but its timeline
     replaces modeling menus and object quick actions. */
  body.mode-animation #ltool-actions {
    display: none !important;
  }

  /* Pose works on bones, not ordinary scene objects. Keep the hierarchy body,
     Focus, transforms, and the Animation/Pose panel; remove shading and the
     generic object-selection path that cannot select bones. */
  body.mode-pose #ltool-actions,
  body.mode-pose #rb-select,
  body.mode-pose .outliner-shading {
    display: none !important;
  }
  body.mode-pose .tab-btn {
    display: none !important;
  }
  body.mode-pose .tab-btn[data-tab="animation"] {
    display: flex !important;
  }

  /* A tool session is modal: use the reserved space immediately before Select
     and visually quiet the edit-selection modes until Confirm or Cancel. */
  body.mode-edit #tool-session-bar.tool-session-active {
    left: auto !important;
    right: calc(max(8px, env(safe-area-inset-right, 0px)) + 54px) !important;
    bottom: 8px !important;
    gap: 4px !important;
    align-items: center !important;
    padding: 2px !important;
    border: 1px solid rgba(255,255,255,0.10) !important;
    border-radius: 11px !important;
    background: rgba(8,8,9,0.92) !important;
    box-shadow: 0 5px 18px rgba(0,0,0,0.42) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 14 !important;
  }

  body.mode-edit #tool-session-bar.tool-session-active .tool-session-btn {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 !important;
    border-radius: 9px !important;
    font-size: 20px !important;
  }

  body:has(#tool-session-bar.tool-session-active) #submode-row {
    opacity: 0.34 !important;
    filter: saturate(0.35) brightness(0.72) !important;
    pointer-events: none !important;
  }

  /* On exceptionally narrow phones, retain the three mode icons as context
     but remove their disabled labels so the session actions never collide. */
  @media (max-width: 340px) {
    body:has(#tool-session-bar.tool-session-active) #submode-row .sub-btn {
      width: 28px !important;
      min-width: 28px !important;
      padding-inline: 0 !important;
    }
    body:has(#tool-session-bar.tool-session-active) #submode-row .sub-btn span {
      display: none !important;
    }
  }

  /* Preserve the prototype's short-landscape rail arrangement. */
  @media (orientation: landscape) and (max-height: 420px) {
    body.mode-edit #tool-session-bar.tool-session-active {
      right: max(8px, env(safe-area-inset-right, 0px)) !important;
      bottom: 64px !important;
    }
  }

  /* Keep the UV zoom/reset stack clear of Select in the bottom-right corner. */
  body.m3-uv-minimal-controls #uv-zoom-btns {
    top: max(12px, env(safe-area-inset-top, 0px)) !important;
    right: max(10px, env(safe-area-inset-right, 0px)) !important;
    bottom: auto !important;
  }
