/* Light workspace palette. Every rule is opt-in so the existing dark skin
   and technical drawing/export colors remain owned by their original styles. */
body#structacad-workspace.cad-workspace[data-ui-theme="light"] {
  --ui-bg: #edf1f5;
  --ui-surface: #ffffff;
  --ui-raised: #f3f6fa;
  --ui-input: #ffffff;
  --ui-hover: #e6edf5;
  --ui-line: #cbd5e1;
  --ui-line-soft: #e2e8f0;
  --ui-text: #243247;
  --ui-muted: #556579;
  --ui-accent: #315e91;
  --ui-selected: #e3edf8;
  --ui-focus: #356ba8;
  --ui-color-scheme: light;
  --ui-action-bg: #315a83;
  --ui-action-hover: #3d6a97;
  --ui-action-border: #527da8;
  --ui-action-text: #f3f7fc;
  --ui-popover-shadow: 0 4px 14px #2432471a;
  --ui-dialog-shadow: 0 10px 32px #24324726;
  --app-bg: var(--ui-bg);
  --panel: var(--ui-surface);
  --panel-soft: var(--ui-raised);
  --menu-shell: var(--ui-bg);
  --menu-shell-deep: var(--ui-raised);
  --menu-panel: var(--ui-raised);
  --menu-panel-strong: var(--ui-surface);
  --sidebar-button-bg: var(--ui-surface);
  --sidebar-button-bg-strong: var(--ui-surface);
  --sidebar-button-border: var(--ui-line);
  --border: var(--ui-line);
  --border-strong: #aab9ca;
  --text: var(--ui-text);
  --text-primary: var(--ui-text);
  --text-soft: var(--ui-muted);
  --text-dim: #64748b;
  --accent: var(--ui-accent);
  --accent-soft: var(--ui-selected);
  --success: #236344;
  --success-soft: #ecf7f0;
  --warning: #805516;
  --warning-soft: #fff5df;
  --danger: #a12d3d;
  --overlay: #24324752;
  --grid-minor: #526b8510;
  --grid-major: #526b851a;
  color-scheme: light;
  background: var(--ui-bg) !important;
  color: var(--ui-text);

  /* Native controls must follow the selected theme, including popup options. */
  & :is(input, select, textarea) { color-scheme: light !important; }
  & :is(input, textarea)::placeholder { color: #64748b !important; opacity: 1; }
  & :is(input[type="checkbox"], input[type="radio"], input[type="range"]) { accent-color: var(--ui-accent); }
  & :is(select option, select optgroup) { background: var(--ui-input) !important; color: var(--ui-text) !important; }
  & select option:checked { background: var(--ui-selected) !important; color: var(--ui-accent) !important; }
  & select option:disabled { color: #748296 !important; }
  & :is(#sidebar, #properties-dock, [role="dialog"], dialog, .modal-content) { scrollbar-color: #aab9ca transparent; }
  & ::-webkit-scrollbar-thumb { background-color: #aab9ca; }

  /* Main canvas and chrome. Canvas strokes use the existing light render palette. */
  & #canvas-stage { background-color: #f8fafc !important; }
  & #workspace { background: #f8fafc !important; }
  & :is(.top-panel-options-trigger, #workspace-level-switch, .workspace-canvas-controls, #insert-reinforcement-tray-launch) {
    background: var(--ui-surface) !important; border-color: var(--ui-line) !important; color: var(--ui-text) !important; box-shadow: none !important;
  }
  & :is(.workspace-canvas-controls button, #workspace-level-switch button) {
    background: transparent !important; border-color: var(--ui-line) !important; color: var(--ui-text) !important;
  }
  & :is(.top-panel-options-trigger, .workspace-canvas-controls button, #workspace-level-switch button, #insert-reinforcement-tray-launch):hover:not(:disabled) {
    background: var(--ui-hover) !important; color: var(--ui-accent) !important;
  }
  & #top-panel { background: var(--ui-surface) !important; border-color: var(--ui-line) !important; }
  & #top-panel .top-panel-brand { color: var(--ui-text) !important; }
  & #top-panel .top-tool-group + .top-tool-group { border-color: var(--ui-line); }
  & #top-panel .top-panel-plan-badge { color: #805516 !important; }
  & #top-panel .top-panel-icon-button {
    background: transparent !important; border-color: transparent !important; color: var(--ui-muted) !important;
  }
  & #top-panel .top-panel-icon-button:hover:not(:disabled) { background: var(--ui-hover) !important; color: var(--ui-text) !important; }
  & #top-panel :is(.top-panel-theme-icon-button, .workspace-tool-shortcut, .workspace-history-button).is-active,
  & #mode-dock .dock-button.is-active {
    background: var(--ui-selected) !important; color: var(--ui-accent) !important; border-color: var(--ui-line) !important;
  }
  & #top-panel :is(.top-panel-export-button, #workspace-export-combined-btn) {
    background: var(--ui-action-bg) !important; border-color: var(--ui-action-border) !important; color: var(--ui-action-text) !important;
  }
  & #top-panel :is(.top-panel-export-button, #workspace-export-combined-btn):hover:not(:disabled) { background: var(--ui-action-hover) !important; }
  & #canvas-stage .workspace-bottom-bar { background: var(--ui-bg) !important; border-color: var(--ui-line) !important; }
  & :is(#coordinates-display, #tool-display) { color: var(--ui-muted) !important; }
  & #tool-display strong { color: var(--ui-text); }
  & #tool-display.is-tool-active { color: var(--ui-accent) !important; }
  & :is(.workspace-panel-edge-handle, .workspace-panel-collapsed-rail, .workspace-reinforcement-tray-resize-handle) {
    background: var(--ui-raised) !important; border-color: var(--ui-line) !important; color: var(--ui-muted) !important;
  }
  & :is(.workspace-level-indicator, .workspace-level-navigation, .workspace-viewport-controls, .workspace-3d-floating-actions) {
    background: var(--ui-surface) !important; border-color: var(--ui-line) !important; color: var(--ui-text) !important;
  }
  & :is(.workspace-level-button, .workspace-level-step-button, .workspace-view-button, .workspace-viewport-controls button, .workspace-3d-floating-actions button, #cad-help-hub .cad-help-toggle, .workspace-exit-beam-steel-mode) {
    background: var(--ui-surface) !important; border-color: var(--ui-line) !important; color: var(--ui-muted) !important;
  }
  & :is(.workspace-level-button, .workspace-level-step-button, .workspace-view-button, .workspace-viewport-controls button, .workspace-3d-floating-actions button, #cad-help-hub .cad-help-toggle, .workspace-exit-beam-steel-mode):hover:not(:disabled) {
    background: var(--ui-hover) !important; color: var(--ui-accent) !important;
  }
  & #cad-help-menu :is(button, a) { color: var(--ui-text) !important; }
  & #cad-help-menu :is(button, a):hover { background: var(--ui-hover) !important; }

  /* The 3D renderer already supplies a light scene; match its surrounding UI. */
  & :is(.workspace-3d-overlay, .workspace-3d-drawer) {
    background: var(--ui-raised) !important; border-color: var(--ui-line) !important; color: var(--ui-text) !important;
  }
  & .workspace-3d-control-label { color: var(--ui-muted) !important; }
  & .workspace-3d-scope { background: var(--ui-bg) !important; border-color: var(--ui-line) !important; }
  & :is(.workspace-3d-scope-button, .workspace-3d-frame-step, #workspace-3d-reset-btn, #workspace-3d-frame-select) {
    background: var(--ui-surface) !important; border-color: var(--ui-line) !important; color: var(--ui-text) !important;
  }
  & #workspace-3d-overlay .workspace-3d-scope-button.is-active { background: var(--ui-selected) !important; border-color: var(--ui-line) !important; color: var(--ui-accent) !important; }
  & :is(.workspace-3d-scope-button, #workspace-3d-reset-btn):hover:not(:disabled) { background: var(--ui-hover) !important; }

  /* Selected actions and hover text were explicit dark colors in the shared skin. */
  & #sidebar :is(.grid-system-launch, .cad-module-steel button, .project-unit-system-button, .project-action-button, .btn-preview, .btn-export):hover:not(:disabled) { color: var(--ui-text) !important; }
  & #sidebar :is(.primary-btn, #export-dock-run-btn),
  & :is(.import-provider-bridge-circle, .language-switch-button.is-active) {
    background: var(--ui-selected) !important; border-color: var(--ui-line) !important; color: var(--ui-accent) !important;
  }
  & #sidebar .project-picker-actions .project-action-button-danger:hover:not(:disabled) {
    color: var(--danger) !important; background: #fff0f1 !important;
  }
  & .top-panel-options-popover .model-space-theme-label { color: var(--ui-muted) !important; }
  & .workspace-labels-menu-toggle { background: var(--ui-raised) !important; border-color: var(--ui-line) !important; color: var(--ui-muted) !important; }
  & .workspace-labels-menu-toggle:hover { background: var(--ui-selected) !important; color: var(--ui-accent) !important; }
  & :is(.top-panel-options-popover, .workspace-light-menu, .workspace-overlap-picker, .cad-help-menu, .context-menu, .workspace-context-menu, .etabs-help-popover, .steel-assignment-scheme-quick-editor) {
    box-shadow: var(--ui-popover-shadow) !important;
  }

  /* Dialogs and contextual inspectors. Do not recolor SVG/canvas drawing previews. */
  & :is(.modal-content, .app-dialog-content, .workspace-entry-card, .workspace-guide-card, .import-provider-dialog, .export-dock-modal-content, .support-chat-panel) {
    box-shadow: var(--ui-dialog-shadow) !important;
  }
  & #workspace-entry-overlay { background: #64748b52 !important; }
  & dialog::backdrop { background: var(--overlay); }
  & :is(.overlay, .modal-overlay, .app-dialog-overlay, .workspace-guide-overlay, .etabs-import-cover-config-overlay) { background-color: var(--overlay); }
  & :is(.modal-title, .support-chat-header h2, .support-chat-view label, .grid-axis-table-position, .project-picker-title) { color: var(--ui-text) !important; }
  & :is(.workspace-guide-copy, .workspace-guide-step, .project-picker-meta, .workspace-card-subtitle) { color: var(--ui-muted) !important; }
  & :is(.workspace-reinforcement-table, .steel-assignment-scheme-quick-editor) select { color-scheme: light !important; }
  & :is(.steel-assignment-scheme-dialog-status.is-ok, .workspace-column-ratio-result.is-ok) {
    background: var(--success-soft) !important; border-color: #9bc8ad !important; color: var(--success) !important;
  }
  & .steel-assignment-scheme-dialog-status.is-fail {
    background: #fff0f1 !important; border-color: #e5a6af !important; color: var(--danger) !important;
  }
  & :is(.etabs-import-diameter-catalog-status.is-invalid, .etabs-import-settings-footer-summary.is-invalid) { color: var(--danger) !important; }
  & .etabs-import-settings-toggle-copy small { color: var(--warning); }
  & .etabs-import-settings-warning { background: var(--warning-soft); border-color: #c2984e; color: var(--warning); }
  & .etabs-import-settings-toggle-control { background: #8190a3; }
  & .etabs-import-settings-toggle input:checked + .etabs-import-settings-toggle-control { background: var(--ui-accent); }
  & .etabs-import-diameter-chip input:checked + span { background: var(--ui-selected); border-color: var(--ui-line); color: var(--ui-accent); }
  & :is(#app-dialog-confirm-btn, #etabs-import-cover-config-done, .steel-assignment-scheme-quick-editor-actions .primary) {
    background: var(--ui-action-bg) !important; border-color: var(--ui-action-border) !important; color: var(--ui-action-text) !important;
  }
  & :is(#app-dialog-confirm-btn, #etabs-import-cover-config-done, .steel-assignment-scheme-quick-editor-actions .primary):hover:not(:disabled) { background: var(--ui-action-hover) !important; }
}
