/* Existing spatial-editor materials, now a bounded, native-scrolling workspace. */
:root {
  color-scheme: dark;
  --editor-bg: #070a0f; --editor-surface: rgba(15,20,27,.94); --editor-surface-strong: #121821;
  --editor-line: rgba(183,213,233,.14); --editor-line-bright: rgba(57,199,255,.34);
  --editor-accent: #39c7ff; --editor-accent-soft: rgba(57,199,255,.12);
  --editor-text: #f4f8fb; --editor-muted: #a5b4c1; --editor-danger: #ff9ca4; --editor-success: #86dfb6;
  --editor-radius: 18px; --editor-ease: cubic-bezier(.22,1,.36,1);
  font-family: "Satoshi","Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--editor-bg); color: var(--editor-text); }
/* A modal inspector or native dialog owns scrolling; the page retains its position. */
html.editor-panel-open,html:has(.editor-dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
button,input,select,textarea { font: inherit; }
button,a,input,select,textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible { outline: 2px solid var(--editor-accent); outline-offset: 3px; }
a { color: var(--editor-accent); text-underline-offset: 4px; }
p { color: var(--editor-muted); line-height: 1.6; }
.editor-skip-link { position: fixed; top: -80px; left: 12px; z-index: 100; padding: 16px; background: var(--editor-bg); }
.editor-skip-link:focus { top: 10px; }
.editor-app { height: 100dvh; min-height: 420px; display: flex; flex-direction: column; padding: max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); gap: 12px; }
.editor-toolbar { display: flex; align-items: center; gap: 18px; flex: 0 0 auto; border: 1px solid var(--editor-line); background: var(--editor-surface); border-radius: var(--editor-radius); padding: 12px; min-width: 0; }
.editor-identity { min-width: 0; flex: 1; }
.editor-identity h1 { font-size: 18px; font-weight: 600; line-height: 1.35; margin: 3px 0; overflow-wrap: anywhere; }
.editor-identity > span:last-child { font-size: 12px; color: var(--editor-muted); }
.editor-eyebrow { font-size: 11px; letter-spacing: .1em; color: var(--editor-accent); font-weight: 650; }
.editor-button,.editor-viewport-switch button { min-height: 44px; border: 1px solid var(--editor-line); border-radius: 10px; padding: 10px 14px; background: rgba(255,255,255,.035); color: var(--editor-text); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-size: 14px; transition: background 160ms var(--editor-ease), border-color 160ms var(--editor-ease); }
.editor-button:hover:not(:disabled) { border-color: var(--editor-line-bright); background: var(--editor-accent-soft); }
.editor-button-primary { background: #167caa; border-color: #278fbd; color: white; }
button:disabled { opacity: .45; cursor: not-allowed; }
.editor-toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#editorSaveState { font-size: 13px; color: var(--editor-muted); max-width: 190px; }
#editorSaveState[data-state="saved"] { color: var(--editor-success); }
#editorSaveState[data-state="error"],#editorSaveState[data-state="conflict"] { color: var(--editor-danger); }
.editor-message { background: var(--editor-surface-strong); border-left: 2px solid var(--editor-accent); padding: 10px 16px; font-size: 14px; }
.editor-workspace { display: grid; grid-template-columns: 232px minmax(0,1fr) 300px; gap: 12px; flex: 1; min-height: 0; min-width: 0; }
.editor-panel { background: var(--editor-surface); border: 1px solid var(--editor-line); border-radius: var(--editor-radius); display: flex; flex-direction: column; overflow: hidden; min-height: 0; min-width: 0; }
.editor-panel-head,.editor-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; gap: 8px; flex-shrink: 0; }
.editor-panel h2 { font-size: 16px; margin: 3px 0; font-weight: 550; overflow-wrap: anywhere; }
.editor-page-label { padding: 0 16px 12px; color: var(--editor-muted); font-size: 13px; }
input,textarea,select { display: block; width: 100%; min-width: 0; font-size: 16px; color: var(--editor-text); background: var(--editor-bg); border: 1px solid var(--editor-line); border-radius: 10px; padding: 12px; line-height: 1.5; margin-top: 8px; }
textarea { resize: vertical; min-height: 150px; }
label { display: block; font-size: 14px; color: var(--editor-text); }
.editor-tree-scroll,.editor-inspector-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; flex: 1; padding: 12px 16px 20px; }
.editor-tree-group { margin-bottom: 24px; }
.editor-tree-group > strong { display: block; font-size: 12px; color: var(--editor-muted); padding: 4px 8px 10px; }
.editor-tree-item { display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 8px; min-height: 44px; width: 100%; padding: 10px; background: none; color: var(--editor-muted); border: 1px solid transparent; border-radius: 9px; font-size: 14px; cursor: pointer; overflow-wrap: anywhere; }
.editor-tree-item[aria-current="true"],.editor-tree-item:hover { background: var(--editor-accent-soft); border-color: var(--editor-line-bright); color: var(--editor-text); }
.editor-tree-item small { font-size: 10px; color: var(--editor-muted); }
.editor-panel-foot { padding: 12px 16px; border-top: 1px solid var(--editor-line); flex-shrink: 0; }
.editor-panel-foot p,.editor-panel-foot a { font-size: 12px; margin: 0 0 6px; }
.editor-inspector-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.editor-center { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.editor-canvas-toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.editor-viewport-switch { display: flex; gap: 3px; }
.editor-viewport-switch button { font-size: 12px; padding: 8px; }
.editor-viewport-switch button[aria-pressed="true"] { background: var(--editor-accent-soft); border-color: var(--editor-line-bright); }
.editor-preview-stage { flex: 1; min-height: 0; overflow: auto; position: relative; border: 1px solid var(--editor-line); border-radius: var(--editor-radius); background: #101721; display: flex; flex-direction: column; align-items: center; }
.editor-preview-stage iframe { border: 0; background: #fff; width: 100%; min-height: 100%; flex: 1; max-width: none; margin-inline: auto; }
#editorPreviewStatus { position: absolute; z-index: 1; top: 8px; left: 12px; right: 12px; padding: 10px 14px; border: 1px solid var(--editor-line); background: #101721; border-radius: 10px; font-size: 13px; pointer-events: none; }
.editor-canvas-foot { display: flex; justify-content: space-between; padding: 12px 4px 0; gap: 16px; color: var(--editor-muted); font-size: 12px; }
.editor-field-hint,.editor-count { font-size: 13px; color: var(--editor-muted); line-height: 1.6; }
.editor-field-error,#editorDialogError { color: var(--editor-danger); font-size: 14px; line-height: 1.5; }
.editor-image-preview { width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; background: #0b0f16; margin-bottom: 16px; }
.editor-image-list { display: grid; gap: 8px; margin-block: 18px; }
.editor-image-list button { text-align: left; justify-content: flex-start; overflow-wrap: anywhere; }
.editor-connection { margin: auto; padding: 48px 24px; max-width: 660px; text-align: center; }
.editor-connection h2 { font-size: clamp(26px,4vw,42px); line-height: 1.15; font-weight: 550; }
.editor-connection p { margin: 20px 0 28px; }
.editor-connection .editor-button { margin: 4px; }
.editor-staff-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-staff-tools button,.editor-staff-tools a { font-size: 12px; }
.editor-dialog { max-width: min(880px,calc(100% - 24px)); width: 100%; max-height: min(86dvh,var(--editor-visible-height,86dvh)); padding: 0; border: 1px solid var(--editor-line-bright); border-radius: var(--editor-radius); background: var(--editor-surface-strong); color: var(--editor-text); }
.editor-dialog[open] { display: flex; flex-direction: column; }
.editor-dialog::backdrop { background: rgba(0,0,0,.75); }
.editor-dialog-head h2 { margin: 0; font-size: 22px; }
.editor-dialog-body { padding: 4px 22px 24px; overflow: auto; min-height: 0; }
.editor-dialog-body article { padding: 18px 0; border-bottom: 1px solid var(--editor-line); overflow-wrap: anywhere; }
.editor-dialog-body pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.6; color: var(--editor-muted); margin: 8px 0; }
.editor-dialog-body .editor-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.editor-diff > div { min-width: 0; }
#editorDialogError { padding-inline: 22px; }
#editorInspectorClose { display: none; }
@media (max-width:1180px) {
  .editor-workspace { grid-template-columns: 210px minmax(0,1fr); }
  .editor-inspector { display: none; position: fixed; z-index: 12; top: var(--editor-visible-top,12px); right: max(12px,env(safe-area-inset-right)); bottom: max(12px,env(safe-area-inset-bottom)); width: min(380px,calc(100% - 24px)); max-height: var(--editor-visible-height,calc(100dvh - 24px)); box-shadow: 0 16px 50px #0009; }
  .editor-inspector.is-open { display: flex; background: var(--editor-surface-strong); }
  #editorInspectorClose { display: inline-flex; }
}
@media (max-width:700px) {
  .editor-app { height: auto; min-height: 100dvh; padding: max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left)); }
  .editor-toolbar { flex-wrap: wrap; gap: 10px; padding: 10px; }
  .editor-back { padding-inline: 10px; }
  .editor-eyebrow { font-size: 10px; }
  .editor-identity h1 { font-size: 16px; }
  .editor-toolbar-actions { width: 100%; }
  #editorSaveState { flex: 1; max-width: none; }
  .editor-toolbar-actions .editor-button { padding-inline: 11px; font-size: 13px; }
  .editor-workspace { display: block; }
  .editor-tree-panel { min-height: 360px; }
  .editor-tree-scroll { overflow: visible; }
  .editor-center { height: 68dvh; margin-top: 12px; }
  .editor-inspector { top: var(--editor-visible-top,8px); right: 8px; bottom: auto; width: calc(100% - 16px); height: var(--editor-visible-height,calc(100dvh - 16px)); max-height: var(--editor-visible-height,calc(100dvh - 16px)); }
  .editor-panel-head { padding: 12px 16px; }
  .editor-inspector-scroll { overscroll-behavior: contain; }
  .editor-center.is-preview { position: fixed; inset: 8px; margin: 0; padding: 10px; background: var(--editor-bg); border: 1px solid var(--editor-line); border-radius: 14px; z-index: 15; height: calc(100dvh - 16px); }
  .editor-dialog-body .editor-diff { grid-template-columns: 1fr; gap: 4px; }
  .editor-staff-tools { margin-top: 14px; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { transition-duration: .12s !important; animation: none !important; scroll-behavior: auto !important; } }
