/* Floating controls consume the shared garden semantic layer. */
.thg-root .thgp-controls { position:absolute; z-index:12; right:max(var(--thg-control-edge),var(--thg-inset-right)); bottom:calc(var(--thg-space-xl) + var(--thg-inset-bottom)); pointer-events:none; }
.thg-root .thgp-edit-toggle { min-width:var(--thg-touch); min-height:var(--thg-touch); padding:var(--thg-space-md) var(--thg-space-lg); border:1px solid var(--thg-border); border-radius:var(--thg-radius-round); background:var(--thg-surface); color:var(--thg-text); font-size:var(--thg-font-sm); pointer-events:auto; box-shadow:var(--thg-control-shadow); }
.thg-root[data-editing="true"] .thgp-controls { display:none; }
.thg-root .thgp-status { position:absolute; z-index:16; left:50%; bottom:calc(var(--thg-status-bottom) + var(--thg-inset-bottom)); transform:translateX(-50%); margin:0; padding:var(--thg-space-md) var(--thg-space-lg); width:max-content; max-width:calc(100% - var(--thg-space-xl) * 2); min-height:0; font-size:var(--thg-font-sm); line-height:var(--thg-line); color:var(--thg-toast-text); background:var(--thg-toast-bg); border-radius:var(--thg-radius-sm); text-align:center; overflow-wrap:anywhere; pointer-events:none; opacity:0; transition:opacity var(--thg-fast); }
.thg-root .thgp-status[data-visible="true"] { opacity:1; }
.thg-root[data-editing="true"] .thgp-status { bottom:auto; top:calc(var(--thg-status-top) + var(--thg-inset-top)); }
.thg-root .thgp-layout-notice { position:absolute; z-index:15; left:max(var(--thg-space-lg),var(--thg-inset-left)); right:max(var(--thg-space-lg),var(--thg-inset-right)); bottom:calc(var(--thg-notice-bottom) + var(--thg-inset-bottom)); margin:0; pointer-events:none; background:var(--thg-notice-bg); color:var(--thg-notice-text); }
/* The editor already presents the same connectivity/protection message. */
.thg-root[data-editing="true"] .thgp-layout-notice { display:none; }
.thg-root .thgp-panel { position:absolute; z-index:14; left:max(var(--thg-edge),var(--thg-inset-left)); right:max(var(--thg-edge),var(--thg-inset-right)); bottom:calc(var(--thg-edge) + var(--thg-inset-bottom)); display:flex; flex-direction:column; max-height:min(max(var(--thg-panel-height),var(--thg-panel-text-room)),calc(100% - var(--thg-inset-top) - var(--thg-inset-bottom) - var(--thg-panel-landscape-clearance))); min-height:0; overflow:hidden; padding:0; color:var(--thg-text); background:var(--thg-surface); border:1px solid var(--thg-border); border-radius:var(--thg-radius-md); box-shadow:var(--thg-shadow); font-family:var(--thg-font); font-size:var(--thg-font-md); }
.thg-root .thgp-editor-body { min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:var(--thg-space-sm) var(--thg-space-lg) 0; }
.thg-root .thgp-editor-body,.thg-root .thgp-actions { scrollbar-width:none; -ms-overflow-style:none; }
.thg-root .thgp-editor-body::-webkit-scrollbar,.thg-root .thgp-actions::-webkit-scrollbar { display:none; width:0; height:0; }
.thg-root .thgp-panel-heading { display:flex; align-items:center; justify-content:space-between; gap:var(--thg-space-md); }
.thg-root .thgp-panel-heading>span { min-width:0; font-weight:600; overflow-wrap:anywhere; }
.thg-root .thgp-editor-content { padding-bottom:var(--thg-space-lg); }
.thg-root .thgp-tools { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); padding:0; overflow:visible; gap:var(--thg-space-md); }
.thg-root .thgp-panel button,.thg-root .thgp-exit-dialog button { display:inline-flex; align-items:center; justify-content:center; gap:var(--thg-space-md); min-width:var(--thg-touch); min-height:var(--thg-touch); margin:0; padding:var(--thg-space-md); border:1px solid var(--thg-border); border-radius:var(--thg-radius-sm); background:var(--thg-surface); color:var(--thg-text); font-family:var(--thg-font); font-size:var(--thg-font-sm); line-height:var(--thg-line); white-space:normal; overflow-wrap:anywhere; }
.thg-root .thgp-panel-heading>button { flex:0 0 auto; border:0; background:transparent; padding-inline:var(--thg-space-md); color:var(--thg-text-muted); }
.thg-root .thgp-tools button { min-width:0; justify-content:flex-start; padding-inline:var(--thg-space-lg); text-align:left; }
.thg-root .thgp-tools button span { min-width:0; }
.thg-root .thgp-panel svg,.thg-root .thgp-exit-dialog svg { flex:0 0 auto; width:var(--thg-icon); height:var(--thg-icon); pointer-events:none; }
.thg-root .thgp-panel button[aria-pressed="true"] { background:var(--thg-tool-selected); border-color:var(--thg-tool-border); font-weight:600; }
.thg-root .thgp-panel select { margin:0; width:100%; min-height:var(--thg-touch); border:1px solid var(--thg-border); border-radius:var(--thg-radius-sm); padding:var(--thg-space-md); background:var(--thg-surface); color:var(--thg-text); font-family:var(--thg-font); font-size:var(--thg-font-md); }
.thg-root .thgp-panel select:focus-visible { outline:var(--thg-focus-width) solid var(--thg-focus); outline-offset:var(--thg-focus-offset); }
.thg-root .thgp-params { display:flex; align-items:center; flex-wrap:wrap; gap:var(--thg-space-md); margin-top:var(--thg-space-md); }
.thg-root .thgp-params label { flex:1 1 auto; min-width:0; }
.thg-root .thgp-params:empty { display:none; }
.thg-root .thgp-hint,.thg-root .thgp-connectivity { margin:var(--thg-space-md) 0; font-size:var(--thg-font-sm); line-height:var(--thg-line); color:var(--thg-text-muted); overflow-wrap:anywhere; }
.thg-root .thgp-connectivity { color:var(--thg-notice-text); }
.thg-root .thgp-aux { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:var(--thg-space-sm); padding-top:var(--thg-space-sm); }
.thg-root .thgp-aux button { min-width:0; padding-inline:var(--thg-space-sm); gap:var(--thg-space-sm); flex-wrap:wrap; }
.thg-root .thgp-view-tools { display:flex; flex-wrap:wrap; gap:var(--thg-space-md); padding-top:var(--thg-space-md); }
.thg-root .thgp-view-tools button { flex:1 1 auto; }
.thg-root .thgp-actions { flex:0 0 auto; max-height:max(0px,calc(var(--thg-viewport-height) - var(--thg-inset-top) - var(--thg-inset-bottom) - var(--thg-panel-landscape-clearance) - var(--thg-touch) - var(--thg-space-md))); min-height:0; overflow-y:auto; overscroll-behavior:contain; display:flex; justify-content:flex-end; flex-wrap:wrap; gap:var(--thg-space-md); padding:var(--thg-space-md) var(--thg-space-lg); border-top:1px solid var(--thg-border); background:var(--thg-surface); }
.thg-root .thgp-actions button { flex:0 1 auto; }
.thg-root .thgp-actions .thgp-save,.thg-root .thgp-exit-dialog button[data-action="continue"] { min-width:var(--thg-save-width); background:var(--thg-action); color:var(--thg-action-text); border-color:var(--thg-action); }
.thg-root .thgp-exit-dialog button[data-action="discard"] { color:var(--thg-danger); }
.thg-root .thgp-panel button:disabled,.thg-root .thgp-panel select:disabled { opacity:var(--thg-disabled); cursor:default; }
.thg-root .thgp-panel[data-collapsed="true"] .thgp-editor-content { display:none; }
.thg-root .thgp-panel[data-collapsed="true"] { max-height:calc(100% - var(--thg-inset-top) - var(--thg-inset-bottom) - var(--thg-panel-landscape-clearance)); }
.thg-root .thgp-panel[data-collapsed="true"] .thgp-editor-body { flex-shrink:1; }
.thg-root .thgp-exit-backdrop { position:absolute; inset:0; z-index:45; display:grid; place-items:center; overflow:auto; padding:calc(var(--thg-space-xl) + var(--thg-inset-top)) max(var(--thg-space-xl),var(--thg-inset-right)) calc(var(--thg-space-xl) + var(--thg-inset-bottom)) max(var(--thg-space-xl),var(--thg-inset-left)); background:var(--thg-overlay); }
.thg-root .thgp-exit-dialog { width:min(var(--thg-dialog-width),100%); max-height:100%; overflow:auto; overscroll-behavior:contain; padding:var(--thg-space-xxl); border:1px solid var(--thg-border); border-radius:var(--thg-radius-lg); background:var(--thg-surface); color:var(--thg-text); box-shadow:var(--thg-shadow); font-family:var(--thg-font); }
.thg-root .thgp-exit-dialog h2 { margin:0; font-size:var(--thg-font-lg); line-height:var(--thg-line); }
.thg-root .thgp-exit-dialog p { margin:var(--thg-space-md) 0 var(--thg-space-xl); color:var(--thg-text-muted); font-size:var(--thg-font-md); line-height:var(--thg-line); }
.thg-root .thgp-exit-dialog .thgp-exit-actions { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:var(--thg-space-md); }
.thg-root .thgp-door-mark { width:var(--thg-touch); height:var(--thg-touch); min-width:var(--thg-touch); min-height:var(--thg-touch); padding:0; margin:0; border:0; border-radius:var(--thg-radius-round); background:transparent; box-shadow:none; color:var(--thg-door); font-size:0; transform-origin:50% 50%; display:grid; place-items:center; }
.thg-root .thgp-door-mark::before { content:""; display:block; box-sizing:border-box; width:var(--thg-door-size); height:var(--thg-door-size); border:var(--thg-door-stroke) solid currentColor; border-radius:var(--thg-radius-round); background:transparent; box-shadow:var(--thg-door-shadow); animation:thgp-door-pulse var(--thg-door-pulse) ease-in-out infinite; pointer-events:none; }
.thg-root .thgp-door-mark[data-arrived="true"] { color:var(--thg-door-arrived); }
.thg-root .thgp-door-mark[aria-expanded="true"]::before { animation:none; opacity:1; }
.thg-root[data-editing="true"] .thgp-door-mark { opacity:var(--thg-disabled); }
.thg-root .thgp-menu { position:absolute; z-index:18; bottom:auto; transform:none; width:var(--thg-menu-width); max-width:calc(100% - var(--thg-space-xxl)); padding:var(--thg-space-sm); border:1px solid var(--thg-border); border-radius:var(--thg-radius-sm); background:var(--thg-surface); color:var(--thg-text); box-shadow:var(--thg-shadow); display:flex; flex-direction:column; gap:var(--thg-space-xs); }
.thg-root .thgp-menu button { width:100%; min-height:var(--thg-touch); padding:var(--thg-space-md); border:0; border-radius:var(--thg-radius-sm); background:transparent; color:var(--thg-text); font-size:var(--thg-font-sm); }
.thg-root .thgp-menu button+button { border-top:1px solid var(--thg-border); }
.thg-root[data-editing="true"] .thgp-interactive { cursor:crosshair; }
.thg-root[data-dragging="true"] .thgp-interactive,.thg-root[data-panning="true"] .thgp-interactive { cursor:grabbing; }
.thg-root .thgp-interactive { -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
@media(hover:hover) {
  .thg-root .thgp-edit-toggle:hover,.thg-root .thgp-panel button:not(:disabled):hover,.thg-root .thgp-exit-dialog button:hover,.thg-root .thgp-menu button:hover { background:var(--thg-hover); }
  .thg-root .thgp-panel button[aria-pressed="true"]:hover { background:var(--thg-tool-selected); }
  .thg-root .thgp-actions .thgp-save:not(:disabled):hover,.thg-root .thgp-exit-dialog button[data-action="continue"]:hover { background:var(--thg-action-hover); }
}
.thg-root .thgp-panel button:not(:disabled):active,.thg-root .thgp-edit-toggle:active,.thg-root .thgp-menu button:active,.thg-root .thgp-exit-dialog button:active { border-color:var(--thg-tool-border); }
@keyframes thgp-door-pulse { 0%,100% { opacity:1; } 50% { opacity:.36; } }
@media(prefers-reduced-motion:reduce) { .thg-root .thgp-door-mark::before { animation:none; }.thg-root .thgp-status { transition:none; } }
/* ds-allow-hardcode: viewport breakpoints are layout constraints, not control tokens. */
@media(max-width:340px) {
  .thg-root .thgp-tools button { padding-inline:var(--thg-space-md); gap:var(--thg-space-sm); }
  .thg-root .thgp-aux { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
/* ds-allow-hardcode: viewport breakpoints are layout constraints, not control tokens. */
@media(orientation:landscape) and (max-height:560px) {
  .thg-root .thgp-panel { left:auto; width:min(var(--thg-panel-landscape-width),54%); max-height:calc(100% - var(--thg-panel-landscape-clearance) - var(--thg-inset-top) - var(--thg-inset-bottom)); }
  .thg-root[data-editing="true"] .thgp-status { top:auto; bottom:var(--thg-space-lg); left:var(--thg-space-lg); transform:none; max-width:40%; }
}
@media(forced-colors:active) {
  .thg-root .thgp-panel button[aria-pressed="true"] { outline:var(--thg-focus-offset) solid Highlight; outline-offset:calc(-1 * var(--thg-focus-width)); }
}
/* Existing environment and retry states share the editor's theme and text scale. */
.thg-root .thg-environment-sheet,.thg-root .thg-message { color:var(--thg-text); background:var(--thg-surface); font-family:var(--thg-font); }
.thg-root .thg-message { justify-content:flex-start; overflow-y:auto; overscroll-behavior:contain; padding:calc(var(--thg-space-xxl) + var(--thg-inset-top)) max(var(--thg-space-xxl),var(--thg-inset-right)) calc(var(--thg-space-xxl) + var(--thg-inset-bottom)) max(var(--thg-space-xxl),var(--thg-inset-left)); }
.thg-root .thg-message>* { flex-shrink:0; }
.thg-root .thg-message>:first-child { margin-top:auto; }
.thg-root .thg-message>:last-child { margin-bottom:auto; }
.thg-root[data-loading="true"] .thg-message>:first-child { margin-bottom:auto; }
.thg-root .thg-environment-sheet h2 { font-size:var(--thg-font-heading); }
.thg-root .thg-environment-note,.thg-root .thg-environment-source,.thg-root .thg-message p { color:var(--thg-text-muted); font-size:var(--thg-font-sm); overflow-wrap:anywhere; }
.thg-root .thg-environment-group legend { font-size:var(--thg-font-md); }
.thg-root .thg-environment-error { color:var(--thg-danger); font-size:var(--thg-font-sm); }
.thg-root .thg-environment-option,.thg-root .thg-environment-actions button,.thg-root .thg-retry { min-width:0; min-height:var(--thg-touch); background:var(--thg-surface); color:var(--thg-text); border-color:var(--thg-border); font-size:var(--thg-font-sm); white-space:normal; overflow-wrap:anywhere; }
.thg-root .thg-environment-option[aria-pressed="true"] { background:var(--thg-tool-selected); border-color:var(--thg-tool-border); color:var(--thg-text); font-weight:600; }
.thg-root .thg-environment-actions .thg-environment-save { background:var(--thg-action); border-color:var(--thg-action); color:var(--thg-action-text); }
.thg-root .thg-environment-actions { flex-wrap:wrap; }
.thg-root .thg-environment-actions button,.thg-root .thg-retry { min-width:var(--thg-touch); }
.thg-root .thg-environment-actions button,.thg-root .thg-message p { font-size:var(--thg-font-md); }
.thg-root .thg-retry { font-size:var(--thg-font-sm) !important; }
html[data-appearance="dark"] .thg-root .thg-back,html[data-appearance="dark"] .thg-root .thg-environment { background:var(--thg-surface); border-color:var(--thg-border); color:var(--thg-text); }
html[data-appearance="dark"] .thg-root .thg-location { color:var(--thg-text-muted); }
@media(hover:hover) {
  .thg-root .thg-environment-option:not(:disabled):hover,.thg-root .thg-environment-actions button:not(:disabled):hover,.thg-root .thg-retry:hover { background:var(--thg-hover); }
  .thg-root .thg-environment-option[aria-pressed="true"]:hover { background:var(--thg-tool-selected); }
  .thg-root .thg-environment-actions .thg-environment-save:not(:disabled):hover { background:var(--thg-action-hover); }
}

/* Fixed system facilities share the scene projection and a 44px screen hit target. */
.thg-root .thgp-facility-mark { color:var(--thg-door); }
.thg-root .thgp-facility-mark::before { animation:none; background:var(--thg-toast-bg); }
.thg-root .thgp-facility-mark:hover::before,.thg-root .thgp-facility-mark[aria-expanded="true"]::before { border-color:var(--thg-selection); }
.thg-root .thgp-facility-mark:focus-visible { outline:var(--thg-focus-width) solid var(--thg-focus); outline-offset:var(--thg-focus-offset); }
.thg-root .thgp-facility-mark:active::before { background:var(--thg-action); }
.thg-root .thgp-facility-mark:disabled { pointer-events:none; }
.thg-root .thgp-facility-mark[hidden] { display:none; }
