/* Standalone shell: MEO Enhanced expects VS Code theme variables.
   Provide a readable default palette; boot.js adds vscode-light/vscode-dark. */
:root {
  --vscode-font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --vscode-editor-font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --vscode-editor-font-weight: normal;
  --vscode-editor-font-size: 14px;
  --vscode-editor-background: #ffffff;
  --vscode-editor-foreground: #1f2328;
  --vscode-sideBar-background: #f6f8fa;
  --vscode-panel-border: #d0d7de;
  --vscode-focusBorder: #0969da;
  --vscode-button-background: #0969da;
  --vscode-button-foreground: #ffffff;
  --vscode-button-border: transparent;
  --vscode-toolbar-hoverBackground: rgba(0, 0, 0, 0.06);
  --vscode-input-background: #ffffff;
  --vscode-input-foreground: #1f2328;
  --vscode-dropdown-background: #ffffff;
  --vscode-dropdown-foreground: #1f2328;
  --vscode-menu-background: #ffffff;
  --vscode-menu-foreground: #1f2328;
  --vscode-errorForeground: #cf222e;
  --vscode-editorError-foreground: #cf222e;
  --vscode-editorWarning-foreground: #9a6700;
  --vscode-editorInfo-foreground: #0969da;
  --vscode-editorHint-foreground: #0969da;
  --vscode-inputValidation-errorBackground: #ffebe9;
  --vscode-inputValidation-errorBorder: #cf222e;
  --vscode-inputValidation-errorForeground: #1f2328;
  --vscode-list-activeSelectionBackground: #0969da;
  --vscode-list-activeSelectionForeground: #ffffff;
  --vscode-list-hoverBackground: #eef1f4;
  --vscode-widget-shadow: rgba(31, 35, 40, 0.12);
  --vscode-scrollbarSlider-background: rgba(31, 35, 40, 0.2);
  --vscode-scrollbarSlider-hoverBackground: rgba(31, 35, 40, 0.3);
  --vscode-scrollbarSlider-activeBackground: rgba(31, 35, 40, 0.4);
  --vscode-textLink-foreground: #0969da;
  --vscode-textLink-activeForeground: #0a3069;
  --vscode-descriptionForeground: #59636e;
  --vscode-disabledForeground: #818b98;
  --vscode-icon-foreground: #1f2328;
  color-scheme: light;
}

html.vscode-dark {
  --vscode-editor-background: #0d1117;
  --vscode-editor-foreground: #e6edf3;
  --vscode-sideBar-background: #161b22;
  --vscode-panel-border: #30363d;
  --vscode-focusBorder: #58a6ff;
  --vscode-button-background: #238636;
  --vscode-button-foreground: #ffffff;
  --vscode-toolbar-hoverBackground: rgba(255, 255, 255, 0.08);
  --vscode-input-background: #0d1117;
  --vscode-input-foreground: #e6edf3;
  --vscode-dropdown-background: #161b22;
  --vscode-dropdown-foreground: #e6edf3;
  --vscode-menu-background: #161b22;
  --vscode-menu-foreground: #e6edf3;
  --vscode-errorForeground: #ff7b72;
  --vscode-editorError-foreground: #ff7b72;
  --vscode-editorWarning-foreground: #d29922;
  --vscode-editorInfo-foreground: #58a6ff;
  --vscode-editorHint-foreground: #58a6ff;
  --vscode-inputValidation-errorBackground: #4b1113;
  --vscode-inputValidation-errorBorder: #f85149;
  --vscode-inputValidation-errorForeground: #ffffff;
  --vscode-list-activeSelectionBackground: #1f6feb;
  --vscode-list-activeSelectionForeground: #ffffff;
  --vscode-list-hoverBackground: #21262d;
  --vscode-widget-shadow: rgba(1, 4, 9, 0.6);
  --vscode-scrollbarSlider-background: rgba(230, 237, 243, 0.2);
  --vscode-scrollbarSlider-hoverBackground: rgba(230, 237, 243, 0.3);
  --vscode-scrollbarSlider-activeBackground: rgba(230, 237, 243, 0.4);
  --vscode-textLink-foreground: #58a6ff;
  --vscode-textLink-activeForeground: #79c0ff;
  --vscode-descriptionForeground: #9198a1;
  --vscode-disabledForeground: #6e7681;
  --vscode-icon-foreground: #e6edf3;
  color-scheme: dark;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--meo-background, var(--vscode-editor-background));
  color: var(--vscode-editor-foreground);
  font-family: var(--vscode-font-family, system-ui, sans-serif);
}

#app {
  position: fixed;
  inset: 0;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: clip;
}

#app > .mode-toolbar.meo-preload-toolbar {
  position: absolute;
  inset: 0 0 auto;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
  background: var(--vscode-sideBar-background);
}

#app > .editor-wrapper.meo-preload-editor-shell {
  position: absolute;
  inset: 40px 0 0;
  min-height: 0;
  display: flex;
}

#app > .editor-wrapper.meo-preload-editor-shell > .editor-host {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--meo-background, var(--vscode-editor-background));
}

/* Shared loading presentation (mirrors webview/src/adapters/loadingPresentationStyles.ts). */
:where(.surface-loading) {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--meo-preview-foreground, var(--meo-foreground, var(--vscode-editor-foreground)));
  background: var(--meo-preview-background, var(--meo-background, var(--vscode-editor-background)));
  font-size: 13px;
}

.meo-startup-loading {
  inset: 40px 0 0;
  color-scheme: dark;
  color: var(--vscode-editor-foreground, CanvasText);
  background: var(--vscode-editor-background, Canvas);
  --meo-ui-focus: var(--vscode-focusBorder, currentColor);
}

html.vscode-light .meo-startup-loading {
  color-scheme: light;
}

.surface-loading[hidden] {
  display: none;
}

.surface-loading-spinner {
  width: 22px;
  height: 22px;
  box-sizing: border-box;
  border: 2px solid color-mix(in srgb, currentColor 18%, transparent);
  border-top-color: var(--meo-ui-focus, currentColor);
  border-radius: 50%;
  animation: preview-loading-spin 0.85s linear infinite;
}

@keyframes preview-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .surface-loading-spinner {
    animation: none;
  }
}
