/**
 * CrashBasic Theme Variables
 * CSS custom properties for theming support
 */

:root {
  /* ========================================
   * Default Theme: Monaco Dark
   * ======================================== */

  /* Backgrounds */
  --cb-bg-primary: #1e1e1e;
  --cb-bg-secondary: #2d2d30;
  --cb-bg-tertiary: #252526;
  --cb-bg-input: #3c3c3c;
  --cb-bg-hover: #3e3e42;
  --cb-bg-active: #094771;
  --cb-bg-selected: #094771;

  /* Borders */
  --cb-border: #3e3e42;
  --cb-border-light: #454545;
  --cb-border-focus: #007acc;

  /* Text */
  --cb-text-primary: #d4d4d4;
  --cb-text-secondary: #cccccc;
  --cb-text-muted: #888888;
  --cb-text-disabled: #555555;
  --cb-text-inverse: #1e1e1e;

  /* Accent Colors */
  --cb-accent-primary: #0e639c;
  --cb-accent-hover: #1177bb;
  --cb-accent-active: #094771;
  --cb-accent-success: #16825d;
  --cb-accent-success-hover: #1a9d6f;
  --cb-accent-warning: #cc6633;
  --cb-accent-warning-hover: #e07539;
  --cb-accent-danger: #f44747;
  --cb-accent-danger-hover: #ff5555;
  --cb-accent-text: #ffffff;

  /* Status Bar */
  --cb-status-bar: #007acc;
  --cb-status-bar-text: #ffffff;

  /* Scrollbars */
  --cb-scrollbar-thumb: #424242;
  --cb-scrollbar-thumb-hover: #4e4e4e;
  --cb-scrollbar-track: #1e1e1e;

  /* Focus & Glow */
  --cb-focus-glow: rgba(14, 99, 156, 0.3);
  --cb-focus-outline: #007acc;

  /* Syntax Highlighting (for non-Monaco elements) */
  --cb-syntax-keyword: #569cd6;
  --cb-syntax-function: #dcdcaa;
  --cb-syntax-type: #4ec9b0;
  --cb-syntax-number: #b5cea8;
  --cb-syntax-string: #ce9178;
  --cb-syntax-comment: #6a9955;
  --cb-syntax-variable: #9cdcfe;

  /* Special UI */
  --cb-loading-bg: #1a1a2e;
  --cb-loading-text: #e0e0e0;
  --cb-loading-accent: #00d4ff;
  --cb-modal-overlay: rgba(0, 0, 0, 0.7);
  --cb-tooltip-bg: #252526;
  --cb-tooltip-text: #cccccc;

  /* Buttons */
  --cb-btn-bg: #3c3c3c;
  --cb-btn-text: #cccccc;
  --cb-btn-hover: #4e4e4e;
  --cb-btn-active: #555555;
  --cb-btn-primary-bg: #0e639c;
  --cb-btn-primary-text: #ffffff;

  /* Menu */
  --cb-menu-bg: #252526;
  --cb-menu-hover: #094771;
  --cb-menu-separator: #3e3e42;

  /* Widget */
  --cb-widget-header: #2d2d30;
  --cb-widget-body: #1e1e1e;

  /* Scrollbar (matches Monaco style) */
  --cb-scrollbar-thumb: rgba(121, 121, 121, 0.4);
  --cb-scrollbar-thumb-hover: rgba(100, 100, 100, 0.7);

  /* Debug Panel */
  --cb-debug-bg: #252526;
  --cb-debug-header: #333333;
  --cb-debug-border: #3e3e42;
}

/* Dark theme class (same as default) */
body.theme-dark {
  /* Uses :root defaults */
}

/* ========================================
 * Crash-tan Theme (Dark with Pink Accents)
 * Based on the Crash-tan Teaches BASIC book theme
 * ======================================== */
body.theme-crash-tan {
  /* Backgrounds - Dark blue base */
  --cb-bg-primary: #1a1a2e;
  --cb-bg-secondary: #16213e;
  --cb-bg-tertiary: #0f0f1a;
  --cb-bg-input: #1a1a2e;
  --cb-bg-hover: #252550;
  --cb-bg-active: #ff6b9d;
  --cb-bg-selected: #2a2a4e;

  /* Borders */
  --cb-border: #333355;
  --cb-border-light: #444466;
  --cb-border-focus: #ff6b9d;

  /* Text - Light for contrast */
  --cb-text-primary: #e6e6e6;
  --cb-text-secondary: #cccccc;
  --cb-text-muted: #888899;
  --cb-text-disabled: #555566;
  --cb-text-inverse: #1a1a2e;

  /* Accent Colors - Pink/Magenta primary (for highlights, borders, focus) */
  --cb-accent-primary: #ff6b9d;
  --cb-accent-hover: #ff8fb3;
  --cb-accent-active: #e05080;
  --cb-accent-success: #50fa7b;
  --cb-accent-success-hover: #6bffcc;
  --cb-accent-warning: #f1fa8c;
  --cb-accent-warning-hover: #f5fcb3;
  --cb-accent-danger: #ff5555;
  --cb-accent-danger-hover: #ff7777;
  --cb-accent-text: #ffffff;

  /* Status Bar */
  --cb-status-bar: #ff6b9d;
  --cb-status-bar-text: #ffffff;

  /* Scrollbars */
  --cb-scrollbar-thumb: #444466;
  --cb-scrollbar-thumb-hover: #555577;
  --cb-scrollbar-track: #1a1a2e;

  /* Focus & Glow */
  --cb-focus-glow: rgba(255, 107, 157, 0.35);
  --cb-focus-outline: #ff6b9d;

  /* Syntax Highlighting - Dracula-inspired for book theme */
  --cb-syntax-keyword: #ff79c6;
  --cb-syntax-function: #50fa7b;
  --cb-syntax-type: #8be9fd;
  --cb-syntax-number: #bd93f9;
  --cb-syntax-string: #f1fa8c;
  --cb-syntax-comment: #6272a4;
  --cb-syntax-variable: #f8f8f2;

  /* Special UI */
  --cb-loading-bg: #1a1a2e;
  --cb-loading-text: #e6e6e6;
  --cb-loading-accent: #ff6b9d;
  --cb-modal-overlay: rgba(0, 0, 0, 0.7);
  --cb-tooltip-bg: #16213e;
  --cb-tooltip-text: #e6e6e6;

  /* Buttons */
  --cb-btn-bg: #252550;
  --cb-btn-text: #e6e6e6;
  --cb-btn-hover: #333366;
  --cb-btn-active: #444477;
  --cb-btn-primary-bg: #c2185b;
  --cb-btn-primary-text: #ffffff;

  /* Menu */
  --cb-menu-bg: #16213e;
  --cb-menu-hover: #ff6b9d;
  --cb-menu-separator: #333355;

  /* Widget */
  --cb-widget-header: #16213e;
  --cb-widget-body: #1a1a2e;

  /* Debug Panel */
  --cb-debug-bg: #0f0f1a;
  --cb-debug-header: #16213e;
  --cb-debug-border: #333355;
}

/* ========================================
 * Dr. Brane Theme (Light with Maroon Accents)
 * Scientific/academic feel - Crash-tan's creator
 * ======================================== */
body.theme-dr-brane {
  /* Backgrounds - Aged parchment tones (toned down from bright paper) */
  --cb-bg-primary: #E0D8CF;
  --cb-bg-secondary: #D4CBC1;
  --cb-bg-tertiary: #C9BFB4;
  --cb-bg-input: #EAE3DB;
  --cb-bg-hover: #CBBFB3;
  --cb-bg-active: #7A1F2B;
  --cb-bg-selected: #BEB3A7;

  /* Borders */
  --cb-border: #A89A8F;
  --cb-border-light: #BEB3A7;
  --cb-border-focus: #7A1F2B;

  /* Text - Dark for contrast on parchment */
  --cb-text-primary: #1F1F1F;
  --cb-text-secondary: #3D3D3D;
  --cb-text-muted: #6A6A6A;
  --cb-text-disabled: #999999;
  --cb-text-inverse: #FFFFFF;

  /* Accent Colors - Maroon primary */
  --cb-accent-primary: #7A1F2B;
  --cb-accent-hover: #8B2A36;
  --cb-accent-active: #5C1720;
  --cb-accent-success: #2E7D32;
  --cb-accent-success-hover: #388E3C;
  --cb-accent-warning: #D4B84E;
  --cb-accent-warning-hover: #DCCA6A;
  --cb-accent-danger: #C62828;
  --cb-accent-danger-hover: #D32F2F;
  --cb-accent-text: #ffffff;

  /* Status Bar */
  --cb-status-bar: #7A1F2B;
  --cb-status-bar-text: #FFFFFF;

  /* Scrollbars */
  --cb-scrollbar-thumb: #A89A8F;
  --cb-scrollbar-thumb-hover: #968880;
  --cb-scrollbar-track: #D4CBC1;

  /* Focus & Glow */
  --cb-focus-glow: rgba(122, 31, 43, 0.35);
  --cb-focus-outline: #7A1F2B;

  /* Syntax Highlighting - Academic/professional */
  --cb-syntax-keyword: #7A1F2B;
  --cb-syntax-function: #3A8A90;
  --cb-syntax-type: #3A8A90;
  --cb-syntax-number: #7A3B0E;
  --cb-syntax-string: #1B5E20;
  --cb-syntax-comment: #807468;
  --cb-syntax-variable: #1A0A05;

  /* Special UI */
  --cb-loading-bg: #E0D8CF;
  --cb-loading-text: #1F1F1F;
  --cb-loading-accent: #7A1F2B;
  --cb-modal-overlay: rgba(0, 0, 0, 0.5);
  --cb-tooltip-bg: #1F1F1F;
  --cb-tooltip-text: #FFFFFF;

  /* Buttons */
  --cb-btn-bg: #D4CBC1;
  --cb-btn-text: #1F1F1F;
  --cb-btn-hover: #CBBFB3;
  --cb-btn-active: #BEB3A7;
  --cb-btn-primary-bg: #7A1F2B;
  --cb-btn-primary-text: #ffffff;

  /* Menu */
  --cb-menu-bg: #E0D8CF;
  --cb-menu-hover: #7A1F2B;
  --cb-menu-separator: #A89A8F;

  /* Widget */
  --cb-widget-header: #D4CBC1;
  --cb-widget-body: #E0D8CF;

  /* Debug Panel */
  --cb-debug-bg: #C9BFB4;
  --cb-debug-header: #D4CBC1;
  --cb-debug-border: #A89A8F;
}

/* ========================================
 * Victor Hardline Theme (Dark Corporate/Dystopian)
 * Cold, calculated - the villain's aesthetic
 * ======================================== */
body.theme-victor-hardline {
  /* Backgrounds - Near black with steel tones */
  --cb-bg-primary: #0F1115;
  --cb-bg-secondary: #1C1F26;
  --cb-bg-tertiary: #161920;
  --cb-bg-input: #1C1F26;
  --cb-bg-hover: #242933;
  --cb-bg-active: #00B4D8;
  --cb-bg-selected: #2F3644;

  /* Borders */
  --cb-border: #3A3F4B;
  --cb-border-light: #4A5058;
  --cb-border-focus: #00B4D8;

  /* Text - High contrast light on dark */
  --cb-text-primary: #EDEDED;
  --cb-text-secondary: #9AA0A6;
  --cb-text-muted: #5C6B73;
  --cb-text-disabled: #3A3F4B;
  --cb-text-inverse: #0F1115;

  /* Accent Colors - Compliance Blue primary */
  --cb-accent-primary: #00B4D8;
  --cb-accent-hover: #48CAE4;
  --cb-accent-active: #0096C7;
  --cb-accent-success: #06D6A0;
  --cb-accent-success-hover: #1DE9B6;
  --cb-accent-warning: #FFB703;
  --cb-accent-warning-hover: #FFC940;
  --cb-accent-danger: #EF476F;
  --cb-accent-danger-hover: #FF6B8A;
  --cb-accent-text: #0F1115;

  /* Status Bar */
  --cb-status-bar: #00B4D8;
  --cb-status-bar-text: #0F1115;

  /* Scrollbars */
  --cb-scrollbar-thumb: #3A3F4B;
  --cb-scrollbar-thumb-hover: #4A5058;
  --cb-scrollbar-track: #0F1115;

  /* Focus & Glow */
  --cb-focus-glow: rgba(0, 180, 216, 0.5);
  --cb-focus-outline: #00B4D8;

  /* Syntax Highlighting - Cold corporate colors */
  --cb-syntax-keyword: #00B4D8;
  --cb-syntax-function: #5C6B73;
  --cb-syntax-type: #00B4D8;
  --cb-syntax-number: #90E0EF;
  --cb-syntax-string: #9AA0A6;
  --cb-syntax-comment: #5C6B73;
  --cb-syntax-variable: #EDEDED;

  /* Special UI */
  --cb-loading-bg: #0F1115;
  --cb-loading-text: #EDEDED;
  --cb-loading-accent: #00B4D8;
  --cb-modal-overlay: rgba(0, 0, 0, 0.85);
  --cb-tooltip-bg: #1C1F26;
  --cb-tooltip-text: #EDEDED;

  /* Buttons */
  --cb-btn-bg: #2E2E2E;
  --cb-btn-text: #EDEDED;
  --cb-btn-hover: #3A3F4B;
  --cb-btn-active: #4A5058;
  --cb-btn-primary-bg: #0077b6;
  --cb-btn-primary-text: #ffffff;

  /* Menu */
  --cb-menu-bg: #1C1F26;
  --cb-menu-hover: #00B4D8;
  --cb-menu-separator: #3A3F4B;

  /* Widget */
  --cb-widget-header: #1C1F26;
  --cb-widget-body: #0F1115;

  /* Debug Panel */
  --cb-debug-bg: #161920;
  --cb-debug-header: #1C1F26;
  --cb-debug-border: #3A3F4B;
}

.grid-stack{position:relative}.grid-stack-rtl{direction:ltr}.grid-stack-rtl>.grid-stack-item{direction:rtl}.grid-stack-placeholder>.placeholder-content{background-color:rgba(0,0,0,.1);margin:0;position:absolute;width:auto;z-index:0!important}.grid-stack>.grid-stack-item{position:absolute;padding:0;top:0;left:0;width:var(--gs-column-width);height:var(--gs-cell-height)}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;width:auto;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item.size-to-content:not(.size-to-content-max)>.grid-stack-item-content{overflow-y:hidden}.grid-stack>.grid-stack-item>.grid-stack-item-content,.grid-stack>.grid-stack-placeholder>.placeholder-content{top:var(--gs-item-margin-top);right:var(--gs-item-margin-right);bottom:var(--gs-item-margin-bottom);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:none;touch-action:none}.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack-item>.ui-resizable-ne,.grid-stack-item>.ui-resizable-nw,.grid-stack-item>.ui-resizable-se,.grid-stack-item>.ui-resizable-sw{background-image:url("data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" stroke=\"%23666\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" viewBox=\"0 0 20 20\"><path d=\"m10 3 2 2H8l2-2v14l-2-2h4l-2 2\"/></svg>");background-repeat:no-repeat;background-position:center}.grid-stack-item>.ui-resizable-ne{transform:rotate(45deg)}.grid-stack-item>.ui-resizable-sw{transform:rotate(45deg)}.grid-stack-item>.ui-resizable-nw{transform:rotate(-45deg)}.grid-stack-item>.ui-resizable-se{transform:rotate(-45deg)}.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;top:var(--gs-item-margin-top);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:var(--gs-item-margin-top);left:25px;right:25px}.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;top:var(--gs-item-margin-top);right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;top:15px;bottom:15px;right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-se{cursor:se-resize;width:20px;height:20px;bottom:var(--gs-item-margin-bottom);right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:var(--gs-item-margin-bottom);right:25px}.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;bottom:var(--gs-item-margin-bottom);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;top:15px;bottom:15px;left:var(--gs-item-margin-left)}.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack-item.ui-draggable-dragging{will-change:left,top}.grid-stack-item.ui-resizable-resizing{will-change:width,height}.ui-draggable-dragging,.ui-resizable-resizing{z-index:10000}.ui-draggable-dragging>.grid-stack-item-content,.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack-animate,.grid-stack-animate .grid-stack-item{transition:left .3s,top .3s,height .3s,width .3s}.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack-animate .grid-stack-item.ui-resizable-resizing{transition:left 0s,top 0s,height 0s,width 0s}.grid-stack>.grid-stack-item[gs-y="0"]{top:0}.grid-stack>.grid-stack-item[gs-x="0"]{left:0}
/**
 * Tab Group Widget Styles
 * Chrome-inspired tab design for widget tab groups
 */

/* Tab Group Container */
.tab-group-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--cb-bg-primary);
}

/* Tab Bar */
.tab-group-tabs {
  display: flex;
  background-color: var(--cb-bg-secondary);
  flex-shrink: 0;
  overflow: hidden;
  height: 35px;
}

/* Individual Tab */
.tab-group-tab {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background-color: var(--cb-bg-secondary);
  border-right: 1px solid var(--cb-border);
  cursor: pointer;
  user-select: none;
  min-width: 120px;
  max-width: 200px;
  position: relative;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.tab-group-tab:hover {
  background-color: var(--cb-bg-hover);
}

.tab-group-tab.active {
  background-color: var(--cb-bg-primary);
  border-bottom: 2px solid var(--cb-accent-primary);
}

/* Tab Drag Handle */
.tab-drag-handle {
  cursor: grab;
  color: var(--cb-text-muted);
  font-size: 10px;
  margin-right: 6px;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 2px;
  line-height: 1;
}

.tab-group-tab:hover .tab-drag-handle {
  opacity: 1;
}

.tab-drag-handle:hover {
  color: var(--cb-text-secondary);
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.tab-drag-handle:active {
  cursor: grabbing;
}

/* Tab Icon */
.tab-icon {
  font-size: 14px;
  margin-right: 6px;
  flex-shrink: 0;
}

/* Tab Title */
.tab-title {
  flex: 1;
  font-size: 13px;
  color: var(--cb-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.tab-group-tab.active .tab-title {
  color: var(--cb-text-primary);
  font-weight: 500;
}

/* Tab Close Button */
.tab-close {
  background: none;
  border: none;
  color: var(--cb-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  line-height: 1;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
  border-radius: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-group-tab:hover .tab-close {
  opacity: 1;
}

.tab-close:hover {
  color: var(--cb-text-inverse);
  background-color: var(--cb-accent-danger);
}

/* Tab Popout Button */
.tab-popout {
  background: none;
  border: none;
  color: var(--cb-text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  line-height: 1;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
  border-radius: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-group-tab:hover .tab-popout {
  opacity: 1;
}

.tab-popout:hover {
  color: var(--cb-text-inverse);
  background-color: var(--cb-accent-primary);
}

/* Tab Help Button */
.tab-help {
  background: none;
  border: none;
  color: var(--cb-text-muted);
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  width: 16px;
  height: 16px;
  line-height: 1;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
  border-radius: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-group-tab:hover .tab-help {
  opacity: 1;
}

.tab-help:hover {
  color: var(--cb-text-inverse);
  background-color: var(--cb-accent-primary);
}

/* Tab Content Area */
.tab-group-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  background-color: var(--cb-bg-primary);
}

.tab-group-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  overflow: auto;
}

/* Ensure direct children of tab panel fill the space */
.tab-group-panel > * {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
}

.tab-group-panel.active {
  display: block;
}

/* Drop Zone Overlay (for future drag-drop implementation) */
.tab-group-drop-zone {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--cb-focus-glow);
  border: 2px dashed var(--cb-accent-primary);
  display: none;
  z-index: 1000;
  pointer-events: none;
}

.tab-group-drop-zone.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone-center {
  background-color: var(--cb-focus-glow);
  border: 2px solid var(--cb-accent-primary);
  border-radius: 8px;
  padding: 24px 32px;
  text-align: center;
  pointer-events: none;
}

.drop-zone-icon {
  font-size: 48px;
  margin-bottom: 8px;
  opacity: 0.8;
}

.drop-zone-text {
  color: var(--cb-accent-primary);
  font-weight: bold;
  font-size: 14px;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

/* Animations */
@keyframes tab-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-group-tab {
  animation: tab-fade-in 0.2s ease-out;
}

/* Focus state for accessibility */
.tab-group-tab:focus {
  outline: 1px solid var(--cb-focus-outline);
  outline-offset: -1px;
}

/* Scrollbar styling for tab content */
.tab-group-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--cb-scrollbar-thumb) var(--cb-scrollbar-track);
}

.tab-group-panel::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.tab-group-panel::-webkit-scrollbar-track {
  background: var(--cb-scrollbar-track);
}

.tab-group-panel::-webkit-scrollbar-thumb {
  background: var(--cb-scrollbar-thumb);
  border-radius: 5px;
}

.tab-group-panel::-webkit-scrollbar-thumb:hover {
  background: var(--cb-scrollbar-thumb-hover);
}

/* Empty state */
.tab-group-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--cb-text-muted);
  font-size: 14px;
}

/* Tab group in GridStack - ensure proper sizing */
.grid-stack-item .tab-group-container {
  width: 100%;
  height: 100%;
}

/* Tab Overflow Dropdown */
.tab-overflow-container {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  position: relative;
  margin-left: auto;
  background-color: var(--cb-bg-secondary);
  border-left: 1px solid var(--cb-border);
}

.tab-overflow-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--cb-text-secondary);
  cursor: pointer;
  padding: 0 10px;
  height: 35px;
  font-size: 12px;
  transition: background-color 0.2s;
}

.tab-overflow-btn:hover {
  background-color: var(--cb-bg-hover);
}

.tab-overflow-btn.visible {
  display: flex;
}

.tab-overflow-count {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 4px;
  min-width: 14px;
  text-align: center;
}

.tab-overflow-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 180px;
  max-width: 280px;
  max-height: 300px;
  overflow-y: auto;
  background-color: var(--cb-menu-bg);
  border: 1px solid var(--cb-border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.tab-overflow-menu.open {
  display: block;
}

.tab-overflow-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.15s;
  border-bottom: 1px solid var(--cb-border);
}

.tab-overflow-item:last-child {
  border-bottom: none;
}

.tab-overflow-item:hover {
  background-color: var(--cb-bg-hover);
}

.tab-overflow-item.active {
  background-color: var(--cb-menu-hover);
}

.tab-overflow-item-icon {
  font-size: 14px;
  margin-right: 8px;
  flex-shrink: 0;
}

.tab-overflow-item-title {
  flex: 1;
  font-size: 13px;
  color: var(--cb-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-overflow-item.active .tab-overflow-item-title {
  color: var(--cb-text-primary);
  font-weight: 500;
}

/* Scrollbar for overflow menu */
.tab-overflow-menu::-webkit-scrollbar {
  width: 6px;
}

.tab-overflow-menu::-webkit-scrollbar-track {
  background: var(--cb-menu-bg);
}

.tab-overflow-menu::-webkit-scrollbar-thumb {
  background: var(--cb-scrollbar-thumb);
  border-radius: 3px;
}

.tab-overflow-menu::-webkit-scrollbar-thumb:hover {
  background: var(--cb-scrollbar-thumb-hover);
}

/* Load IBM BIOS font for authentic retro text rendering */
@font-face {
  font-family: 'IBM BIOS';
  src: url(/assets/Web437_IBM_BIOS-bde4fb6491be7e095556.woff) format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: block; /* Ensure font loads before use */
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--cb-bg-primary);
  color: var(--cb-text-primary);
  overflow: hidden;
}

.main-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--cb-bg-primary);
}

/* Browser recommendation banner */
.browser-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(90deg, #4285f4, #34a853);
  color: #fff;
  padding: 8px 16px;
  font-size: 13px;
  text-align: center;
  position: relative;
  z-index: 10000;
}

.browser-banner a {
  text-decoration: underline;
}

.browser-banner a:hover {
  text-decoration: none;
}

.browser-banner-dismiss {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.browser-banner-dismiss:hover {
  opacity: 1;
}

.toolbar-container {
  flex-shrink: 0;
}

.content-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  background-color: var(--cb-bg-primary);
}

/* Gridstack container fills content area */
#grid-container {
  width: 100%;
  height: 100%;
}

.toolbar {
  background-color: var(--cb-bg-secondary);
  border-bottom: 1px solid var(--cb-border);
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

/* Add padding for window controls in Electron */
body.electron-app .toolbar {
  padding-left: 80px; /* Space for macOS traffic lights */
  -webkit-app-region: drag; /* Make toolbar draggable */
}

/* Make buttons clickable (not draggable) */
body.electron-app .toolbar-btn {
  -webkit-app-region: no-drag;
}

.toolbar-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.toolbar-left {
  flex: 0 0 auto;
}

/* Ensure first button group doesn't overlap window controls */
body.electron-app .toolbar-left:first-child {
  margin-left: 8px; /* Additional spacing from window controls */
}

.toolbar-center {
  flex: 0 0 auto;
  margin: 0 auto;
}

.toolbar-right {
  flex: 0 0 auto;
  margin-right: 8px;
}

.toolbar-btn {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
  border: none;
  padding: 10px 48px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  width: auto;
  text-align: center;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toolbar-btn:hover {
  background-color: var(--cb-accent-hover);
}

.toolbar-btn:disabled {
  background-color: var(--cb-text-disabled);
  color: var(--cb-text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.toolbar-btn.save-btn {
  background-color: var(--cb-accent-primary);
}

.toolbar-btn.save-btn:hover {
  background-color: var(--cb-accent-hover);
}

.toolbar-btn.run-btn {
  background-color: var(--cb-accent-success);
}

.toolbar-btn.run-btn:hover {
  background-color: var(--cb-accent-success-hover);
}

.version-info {
  color: #ffd700;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  white-space: nowrap;
  user-select: none;
}

.toolbar-btn.stop-btn {
  background-color: var(--cb-accent-warning);
}

.toolbar-btn.stop-btn:hover {
  background-color: var(--cb-accent-warning-hover);
}

/* View Menu Dropdown Styles */
.view-menu-container {
  position: relative;
}

.view-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background-color: var(--cb-bg-secondary);
  border: 1px solid var(--cb-border-light);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  min-width: 200px;
  z-index: 10000;
  padding: 4px 0;
}

.view-menu-dropdown.hidden {
  display: none;
}

.view-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--cb-text-primary);
  font-size: 13px;
  user-select: none;
}

.view-menu-item:hover {
  background-color: var(--cb-menu-hover);
}

.view-menu-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.view-menu-label {
  flex: 1;
}

.view-menu-popup-btn {
  background: none;
  border: none;
  color: var(--cb-text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
  border-radius: 2px;
  opacity: 0.7;
  transition: all 0.2s;
}

.view-menu-popup-btn:hover {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
  opacity: 1;
}

.view-menu-separator {
  height: 1px;
  background-color: var(--cb-border-light);
  margin: 4px 0;
}

/* Main Menu Dropdown Styles */
.main-menu-container {
  position: relative;
}

.main-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background-color: var(--cb-menu-bg);
  border: 1px solid var(--cb-border-light);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  min-width: 250px;
  z-index: 10000;
  padding: 4px 0;
  overflow: visible;
}

.main-menu-dropdown.hidden {
  display: none;
}

/* Menu section headers */
.menu-section-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--cb-text-muted);
  padding: 8px 16px 4px 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
}

/* Menu items */
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--cb-text-primary);
  font-size: 13px;
  user-select: none;
  transition: background 0.2s;
}

.menu-item:hover {
  background-color: var(--cb-menu-hover);
}

.menu-item[data-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.menu-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.menu-label {
  flex: 1;
}

.menu-shortcut {
  font-size: 11px;
  color: var(--cb-text-muted);
  margin-left: auto;
}

.menu-separator {
  height: 1px;
  background-color: var(--cb-menu-separator);
  margin: 4px 0;
}

/* Submenu styles */
.menu-item.has-submenu {
  position: relative;
}

.menu-item.has-submenu:hover > .submenu {
  display: block;
}

.submenu-arrow {
  font-size: 10px;
  color: var(--cb-text-muted);
  margin-left: auto;
}

.submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: -4px;
  background-color: var(--cb-menu-bg);
  border: 1px solid var(--cb-border-light);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  min-width: 220px;
  padding: 4px 0;
  z-index: 10001;
}

/* Show submenu on hover */
.menu-item.has-submenu:hover {
  background-color: var(--cb-menu-hover);
}

.editor-container {
  flex: 1;
  overflow: hidden;
  /* Removed height: 100% - it was causing editor to extend into status bar */
}

/* Graphics Modal Styles */
.game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
  outline: none;
  overflow: auto;
}

.game-canvas.hidden {
  opacity: 0;
  pointer-events: none;
}

.game-canvas:focus {
  outline: 2px solid var(--cb-focus-outline);
  outline-offset: -2px;
}

.game-canvas-content {
  background-color: var(--cb-bg-secondary);
  border: none;
  border-radius: 6px;
  max-width: none;
  max-height: none;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.game-canvas-header {
  background-color: var(--cb-bg-input);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--cb-border-light);
  border-radius: 6px 6px 0 0;
}

.graphics-title {
  color: var(--cb-text-primary);
  font-size: 14px;
  font-weight: 500;
}

.keyboard-status {
  color: var(--cb-accent-success);
  font-size: 12px;
  font-weight: normal;
}

.keyboard-status.completed {
  color: var(--cb-accent-primary);
  font-weight: 500;
}

.keyboard-status.stopped {
  color: var(--cb-accent-danger);
  font-weight: 500;
}

.keyboard-status.hidden {
  display: none;
}

.graphics-controls {
  display: flex;
  gap: 4px;
}

.modal-btn {
  background-color: var(--cb-btn-bg);
  color: var(--cb-text-primary);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 0px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-btn:hover {
  background-color: var(--cb-btn-hover);
}

.modal-btn:last-child:hover {
  background-color: var(--cb-accent-warning);
}

/* Screenshot button - better contrast */
#graphics-screenshot {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
  font-size: 18px;
}

#graphics-screenshot:hover {
  background-color: var(--cb-accent-hover);
}

.screenshot-container {
  position: relative;
  display: inline-block;
}

.screenshot-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--cb-menu-bg);
  border: 1px solid var(--cb-border-light);
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  margin-top: 4px;
  z-index: 1000;
  min-width: 180px;
}

.screenshot-menu.hidden {
  display: none;
}

.screenshot-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--cb-text-primary);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.2s;
}

.screenshot-menu-item:hover {
  background-color: var(--cb-menu-hover);
}

.screenshot-menu-item:first-child {
  border-radius: 4px 4px 0 0;
}

.screenshot-menu-item:last-child {
  border-radius: 0 0 4px 4px;
}

.game-canvas-body {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.graphics-canvas-container {
  background-color: #000;
}

/* Play URL Mode - borderless fullscreen */
.game-canvas.play-url-mode {
  background-color: #000;
}

.game-canvas.play-url-mode .game-canvas-content {
  background-color: transparent;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.game-canvas.play-url-mode .game-canvas-body {
  width: 100%;
  height: 100%;
}

.game-canvas.play-url-mode .graphics-canvas-container {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.game-canvas.play-url-mode .graphics-canvas-container canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
}

/* Full Screen Mode - scale canvas to fit browser while maintaining aspect ratio */
.game-canvas.full-screen-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000;
}

.game-canvas.full-screen-mode .game-canvas-content {
  width: 100%;
  height: 100%;
  /* Don't use flex - it interferes with Phaser's Scale Manager */
  display: block;
  padding: 0;
  margin: 0;
}

.game-canvas.full-screen-mode .game-canvas-body {
  width: 100%;
  height: 100%;
  /* Don't use flex - let Phaser manage the canvas */
  display: block;
  padding: 0;
  margin: 0;
}

.game-canvas.full-screen-mode .graphics-canvas-container {
  width: 100%;
  height: 100%;
  /* Critical: Don't interfere with Phaser's positioning */
  display: block;
  position: relative;
  padding: 0;
  margin: 0;
}

/* Full screen canvas scaling - DO NOT override Phaser's inline styles */
.game-canvas.full-screen-mode .graphics-canvas-container canvas {
  /* Let Phaser's FIT scale mode handle all sizing via inline styles */
  /* Removed !important overrides that were breaking Phaser's calculations */
  display: block;
}

/* Alternative approach using the full-screen-canvas class directly */
.full-screen-canvas {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000;
}

.full-screen-canvas canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  display: block;
}

.status-bar {
  background-color: var(--cb-status-bar);
  color: var(--cb-status-bar-text);
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  flex-shrink: 0;
}

.status-left, .status-right {
  display: flex;
  gap: 16px;
}

.status-item {
  padding: 0 4px;
}

#status-storage {
  cursor: pointer;
  padding: 0 8px;
  font-weight: bold;
}

#status-storage:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

/* Debug UI Styles - toolbar styles moved to index.html to avoid conflicts */

.debug-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.debug-button {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
  border: none;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.debug-button:hover {
  background-color: var(--cb-accent-hover);
}

.debug-button:disabled {
  background-color: var(--cb-text-disabled);
  cursor: not-allowed;
  opacity: 0.6;
}

.debug-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.separator {
  width: 1px;
  height: 24px;
  background-color: #555;
  margin: 0 4px;
}

.debug-state {
  color: var(--cb-text-primary);
  font-size: 12px;
  font-weight: 500;
  margin-left: auto;
}

/* Debug Widget Header */
.debug-header {
  padding: 12px;
  background: var(--cb-bg-secondary);
  border-bottom: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.debug-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.debug-title {
  margin: 0 0 4px 0;
  font-size: 16px;
  color: var(--cb-text-primary);
}

.debug-subtitle {
  margin: 0;
  color: var(--cb-text-muted);
  font-size: 12px;
}

.debug-status-badge {
  font-size: 12px;
  font-weight: 500;
}

/* Debug Toolbar Wrapper */
.debug-toolbar-wrapper {
  padding: 8px;
  background: var(--cb-bg-tertiary);
  border-bottom: 1px solid var(--cb-border);
  flex-shrink: 0;
}

/* Debug Button Variants */
.debug-btn-primary {
  background: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
}

.debug-btn-danger {
  background: var(--cb-accent-danger);
  color: var(--cb-text-inverse);
}

.debug-btn-success {
  background: var(--cb-accent-success);
  color: var(--cb-text-inverse);
}

.debug-btn-secondary {
  background: var(--cb-btn-bg);
  color: var(--cb-text-primary);
}

/* Debug Widget Tabs */
.debug-tabs {
  display: flex;
  background: var(--cb-bg-secondary);
  border-bottom: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.debug-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--cb-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 12px;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.debug-tab:hover:not(.active) {
  background: var(--cb-bg-hover);
  color: var(--cb-text-primary);
}

.debug-tab.active {
  color: var(--cb-text-primary);
  border-bottom-color: var(--cb-accent-primary);
}

.debug-tab-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.debug-tab-content > .debug-panel {
  flex: 1;
  min-height: 0;
}

/* Variable Detail Modal */
.variable-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--cb-modal-overlay, rgba(0, 0, 0, 0.7));
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.variable-detail-modal {
  background: var(--cb-bg-secondary);
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  width: 500px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.variable-detail-header {
  padding: 12px 16px;
  background: var(--cb-bg-tertiary);
  border-bottom: 1px solid var(--cb-border);
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.variable-detail-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.variable-detail-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--cb-syntax-variable);
  font-family: 'Courier New', monospace;
}

.variable-detail-type {
  font-size: 11px;
  color: var(--cb-text-muted);
  text-transform: uppercase;
}

.variable-detail-close {
  background: transparent;
  border: none;
  color: var(--cb-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.variable-detail-close:hover {
  background: var(--cb-bg-hover);
  color: var(--cb-text-primary);
}

.variable-detail-body {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
  max-height: 400px;
}

.variable-detail-value {
  background: var(--cb-bg-primary);
  border: 1px solid var(--cb-border-light);
  border-radius: 4px;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--cb-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.variable-detail-footer {
  padding: 12px 16px;
  background: var(--cb-bg-tertiary);
  border-top: 1px solid var(--cb-border);
  border-radius: 0 0 8px 8px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.variable-detail-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.variable-detail-btn-secondary {
  background: var(--cb-btn-bg);
  color: var(--cb-text-primary);
}

.variable-detail-btn-secondary:hover {
  background: var(--cb-btn-hover);
}

.variable-detail-btn-primary {
  background: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
}

.variable-detail-btn-primary:hover {
  filter: brightness(1.1);
}

/* Clickable variable items in debug panel */
.variable-item-clickable {
  cursor: pointer;
  transition: background-color 0.2s;
}

.variable-item-clickable:hover {
  background: var(--cb-bg-hover) !important;
}

.state-idle { color: var(--cb-text-muted); }
.state-running { color: var(--cb-accent-success); }
.state-paused { color: var(--cb-accent-warning); }
.state-stepping { color: var(--cb-accent-primary); }

.debug-panels-container {
  display: none;
  background-color: var(--cb-bg-primary);
  border-top: 1px solid var(--cb-border);
  height: 300px;
  min-height: 200px;
  flex-shrink: 0;
  overflow: hidden;
  width: 100%;
}

.debug-panels-container.visible {
  display: block;
}

.debug-panels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: 100%;
  gap: 1px;
  background-color: var(--cb-border);
}

.debug-panel {
  background-color: var(--cb-debug-bg);
  border: 1px solid var(--cb-debug-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 100px;
}

.debug-panel.debug-console {
  grid-column: 1 / -1;
}

.debug-panel-header {
  background-color: var(--cb-debug-header);
  color: var(--cb-text-primary);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--cb-debug-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.debug-panel-content {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--cb-text-primary);
}

.panel-placeholder {
  color: var(--cb-text-muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.panel-button {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
  border: none;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
}

.panel-button:hover {
  background-color: var(--cb-accent-hover);
}

/* Variable panel styles */
.debug-variable {
  display: flex;
  padding: 4px 0;
  border-bottom: 1px solid #333;
  gap: 8px;
  align-items: center;
}

.debug-variable-name {
  font-weight: 500;
  color: var(--cb-syntax-variable);
  min-width: 80px;
}

.debug-variable-value {
  color: var(--cb-syntax-string);
  flex: 1;
  font-family: 'Courier New', monospace;
}

.debug-variable-type {
  color: var(--cb-syntax-type);
  font-size: 10px;
}

.debug-variable-scope {
  color: #888;
  font-size: 10px;
}

/* Watch panel styles */
.watch-input {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.watch-input input {
  flex: 1;
  background-color: var(--cb-bg-input);
  color: var(--cb-text-primary);
  border: 1px solid var(--cb-border-light);
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 12px;
}

.watch-input button {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
  border: none;
  border-radius: 3px;
  padding: 4px 8px;
  cursor: pointer;
}

.debug-watch {
  display: flex;
  padding: 4px 0;
  border-bottom: 1px solid #333;
  align-items: center;
  gap: 8px;
}

.debug-watch-expression {
  font-weight: 500;
  color: var(--cb-syntax-variable);
  flex: 1;
}

.debug-watch-value {
  color: var(--cb-syntax-string);
  font-family: 'Courier New', monospace;
}

.debug-watch-error {
  color: var(--cb-accent-danger);
  font-style: italic;
}

.debug-watch-remove {
  color: var(--cb-accent-danger);
  cursor: pointer;
  font-weight: bold;
  padding: 0 4px;
}

/* Breakpoints panel styles */
.debug-breakpoint {
  display: flex;
  padding: 4px 0;
  border-bottom: 1px solid #333;
  align-items: center;
  cursor: pointer;
  gap: 8px;
}

.debug-breakpoint:hover {
  background-color: var(--cb-bg-hover);
}

.debug-breakpoint-line {
  font-weight: 500;
  color: var(--cb-syntax-variable);
  min-width: 60px;
}

.debug-breakpoint-condition {
  color: var(--cb-syntax-string);
  flex: 1;
  font-style: italic;
}

.debug-breakpoint-remove {
  color: var(--cb-accent-danger);
  cursor: pointer;
  background: none;
  border: none;
  font-weight: bold;
  padding: 2px 4px;
}

/* Console styles */
.debug-console-output {
  flex: 1;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 8px;
  background-color: #0c0c0c;
}

.debug-console-input {
  display: flex;
  align-items: center;
  padding: 8px;
  border-top: 1px solid var(--cb-border);
  background-color: var(--cb-bg-primary);
}

.debug-console-prompt {
  color: var(--cb-syntax-variable);
  margin-right: 8px;
  font-family: 'Courier New', monospace;
}

.debug-console-input-field {
  flex: 1;
  background-color: var(--cb-bg-input);
  color: var(--cb-text-primary);
  border: 1px solid var(--cb-border-light);
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
}

.debug-console-entry {
  margin-bottom: 4px;
}

.debug-console-input-echo {
  color: var(--cb-syntax-variable);
}

.debug-console-output-value {
  color: var(--cb-syntax-string);
}

.debug-console-error {
  color: var(--cb-accent-danger);
}

/* Call stack styles */
.debug-stack-frame {
  display: flex;
  padding: 4px 0;
  border-bottom: 1px solid #333;
  cursor: pointer;
  gap: 8px;
}

.debug-stack-frame:hover {
  background-color: var(--cb-bg-hover);
}

.debug-stack-frame.active {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
}

.debug-stack-frame-name {
  font-weight: 500;
  flex: 1;
}

.debug-stack-frame-line {
  color: var(--cb-text-muted);
  font-size: 11px;
}

@media (max-width: 768px) {
  .content-container {
    flex-direction: column;
  }

  .canvas-container {
    width: 100%;
    height: 300px;
  }

  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .debug-panels {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, 1fr);
  }
}

/* Modal Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  background-color: var(--cb-bg-secondary);
  border: 1px solid var(--cb-border-light);
  border-radius: 4px;
  min-width: 400px;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.2s ease-out;
  pointer-events: auto;
  overflow: hidden;
}

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--cb-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--cb-bg-input);
}

.modal-header h3 {
  margin: 0;
  color: var(--cb-text-primary);
  font-size: 14px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 20px;
  flex-shrink: 0;
}

.modal-body label {
  display: block;
  margin-bottom: 8px;
  color: var(--cb-text-primary);
  font-size: 12px;
  font-weight: 500;
}

.modal-body input[type="text"],
.modal-body input[type="file"] {
  width: 100%;
  padding: 8px 12px;
  background-color: var(--cb-bg-input);
  border: 1px solid var(--cb-border-light);
  border-radius: 3px;
  color: var(--cb-text-primary);
  font-size: 13px;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.modal-body input:focus {
  outline: none;
  border-color: var(--cb-border-focus);
  box-shadow: 0 0 0 2px var(--cb-focus-glow);
}

.input-hint {
  font-size: 11px;
  color: #999;
  margin-bottom: 0;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--cb-border-light);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background-color: var(--cb-bg-tertiary);
}

.modal-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  min-width: fit-content;
  white-space: nowrap;
}

.modal-btn.primary {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
}

.modal-btn.primary:hover {
  background-color: var(--cb-accent-hover);
}

.modal-btn.secondary {
  background-color: var(--cb-btn-bg);
  color: var(--cb-btn-text);
}

.modal-btn.secondary:hover {
  background-color: var(--cb-btn-hover);
}

.modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #444 !important;
}

/* Import Modal Styles */
.import-options {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.import-option {
  text-align: center;
}

.import-option h4 {
  margin: 0 0 12px 0;
  color: var(--cb-text-primary);
  font-size: 14px;
}

.import-divider {
  text-align: center;
  color: #888;
  font-size: 12px;
  padding: 8px 0;
}

.drop-zone {
  border: 2px dashed var(--cb-border-light);
  border-radius: 4px;
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: var(--cb-bg-tertiary);
  color: var(--cb-text-muted);
  font-size: 13px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--cb-accent-primary);
  background-color: var(--cb-bg-selected);
  color: var(--cb-text-primary);
}

/* ============================================================================
   Tutorial System Styles
   ============================================================================ */

/* Tutorial Overlay Container */
.tutorial-overlay-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10001;
  pointer-events: none;
  display: none;
  animation: tutorialFadeIn 0.2s ease-out;
}

@keyframes tutorialFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Spotlight Mask */
.tutorial-spotlight-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.tutorial-spotlight-svg {
  position: absolute;
  top: 0;
  left: 0;
}

/* Spotlight Highlight (pulsing border around target) */
.tutorial-spotlight-highlight {
  position: absolute;
  border: 2px solid var(--cb-focus-outline);
  border-radius: 4px;
  box-shadow: 0 0 0 4px var(--cb-focus-glow);
  pointer-events: none;
  animation: tutorialPulse 2s ease-in-out infinite;
}

@keyframes tutorialPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(0, 122, 204, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(0, 122, 204, 0.2); }
}

/* Tooltip */
.tutorial-tooltip {
  position: absolute;
  pointer-events: auto;
  background-color: var(--cb-tooltip-bg);
  border: 1px solid var(--cb-border-light);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-width: 360px;
  min-width: 280px;
  animation: tutorialTooltipSlide 0.2s ease-out;
}

@keyframes tutorialTooltipSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tutorial-tooltip-content {
  position: relative;
}

/* Close X button */
.tutorial-close-x {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--cb-text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 2px;
  z-index: 1;
}

.tutorial-close-x:hover {
  color: var(--cb-text-inverse);
  background-color: var(--cb-accent-warning);
}

/* Tooltip Header */
.tutorial-tooltip-header {
  padding: 16px 40px 12px 16px;
  border-bottom: 1px solid var(--cb-border-light);
}

.tutorial-tooltip-title {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--cb-text-primary);
}

.tutorial-step-indicator {
  font-size: 11px;
  color: var(--cb-text-muted);
}

/* Tooltip Body */
.tutorial-tooltip-body {
  padding: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--cb-tooltip-text);
}

.tutorial-tooltip-body code {
  background-color: var(--cb-bg-primary);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--cb-syntax-string);
}

.tutorial-tooltip-body strong {
  color: var(--cb-text-primary);
  font-weight: 600;
}

.tutorial-tooltip-body ul,
.tutorial-tooltip-body ol {
  margin: 8px 0;
  padding-left: 20px;
}

.tutorial-tooltip-body li {
  margin: 4px 0;
}

/* Tooltip Footer */
.tutorial-tooltip-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--cb-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tutorial-nav-buttons {
  display: flex;
  gap: 8px;
}

/* Tutorial Buttons */
.tutorial-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.15s ease;
}

.tutorial-btn-back {
  background-color: var(--cb-btn-bg);
  color: var(--cb-btn-text);
}

.tutorial-btn-back:hover {
  background-color: var(--cb-btn-hover);
}

.tutorial-btn-primary {
  background-color: var(--cb-accent-primary);
  color: var(--cb-text-inverse);
}

.tutorial-btn-primary:hover {
  background-color: var(--cb-accent-hover);
}

.tutorial-btn-arrow {
  font-size: 14px;
}

/* Progress Dots */
.tutorial-progress {
  display: flex;
  gap: 6px;
}

.tutorial-progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--cb-btn-bg);
  transition: background-color 0.2s ease;
}

.tutorial-progress-dot.active {
  background-color: var(--cb-accent-primary);
}

/* Widget Help Button */
.widget-control-btn.widget-help {
  font-size: 14px;
  font-weight: bold;
  color: var(--cb-text-muted);
}

.widget-control-btn.widget-help:hover {
  color: var(--cb-text-inverse);
  background-color: var(--cb-accent-primary);
}

/* ========================================
 * Resources Widget
 * ======================================== */

/* Error and empty states */
.resource-error-state,
.resource-empty-state {
  text-align: center;
  padding: 20px;
}

.resource-error-state {
  color: var(--cb-accent-danger);
}

.resource-empty-state {
  color: var(--cb-text-muted);
}

/* Toolbar */
.resource-toolbar {
  padding: 8px;
  background: var(--cb-bg-secondary);
  border-bottom: 1px solid var(--cb-border);
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.resource-toolbar .toolbar-btn {
  padding: 4px 8px;
  background: var(--cb-btn-primary-bg);
  color: var(--cb-btn-primary-text);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

.resource-toolbar .toolbar-btn.danger {
  background: var(--cb-accent-danger);
}

/* New dropdown */
.new-dropdown-container {
  position: relative;
  display: inline-block;
}

.new-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  min-width: 140px;
  background: var(--cb-menu-bg);
  border: 1px solid var(--cb-border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  margin-top: 2px;
}

.new-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--cb-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.new-dropdown-item:hover {
  background: var(--cb-bg-hover);
}

/* Drop zone */
.file-drop-zone {
  margin: 8px;
  padding: 24px;
  background: var(--cb-bg-primary);
  border: 2px dashed var(--cb-border-light);
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
}

.file-drop-zone .drop-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.file-drop-zone .drop-text {
  color: var(--cb-text-primary);
  margin-bottom: 4px;
}

.file-drop-zone .drop-hint {
  color: var(--cb-text-muted);
  font-size: 11px;
}

/* Resource container and tabs */
.resource-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.resource-tabs {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--cb-bg-tertiary);
  border-bottom: 1px solid var(--cb-border);
}

.resource-tab-btn {
  padding: 4px 12px;
  background: var(--cb-btn-bg);
  color: var(--cb-text-primary);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

.resource-tab-btn.active {
  background: var(--cb-btn-primary-bg);
  color: var(--cb-btn-primary-text);
}

/* Resource list */
.resource-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Folder header */
.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background-color: var(--cb-bg-hover);
  border-bottom: 1px solid var(--cb-border-light);
  font-weight: 600;
  font-size: 12px;
  margin: 4px 0;
  user-select: none;
}

.folder-info {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
}

.folder-toggle {
  width: 16px;
  text-align: center;
  font-size: 10px;
}

.folder-icon {
  font-size: 14px;
}

.folder-name {
  font-size: 12px;
}

.folder-count {
  color: var(--cb-text-muted);
  font-size: 10px;
  margin-left: 4px;
}

/* Root folder drop zone */
.root-folder-drop {
  padding: 8px 12px;
  color: var(--cb-text-muted);
  font-size: 11px;
  border: 1px dashed var(--cb-border);
  border-radius: 4px;
  margin: 4px 8px;
  text-align: center;
  transition: background-color 0.15s, border-color 0.15s;
}

/* Resource item */
.resource-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  margin: 2px 0;
  background: var(--cb-bg-secondary);
  border-radius: 3px;
  font-size: 12px;
  color: var(--cb-text-primary);
  cursor: grab;
}

.resource-item.in-folder {
  margin-left: 20px;
}

.resource-item .drag-handle {
  margin-right: 8px;
  font-size: 14px;
  cursor: grab;
}

.resource-item .resource-details {
  flex: 1;
  min-width: 0;
}

.resource-item .resource-name {
  font-weight: 500;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-item .resource-meta {
  font-size: 10px;
  color: var(--cb-text-muted);
}

.resource-item .entry-badge {
  background: var(--cb-accent-primary);
  padding: 2px 4px;
  border-radius: 2px;
  margin-left: 4px;
  color: var(--cb-text-inverse);
  font-size: 9px;
}

.resource-item .resource-actions {
  display: flex;
  gap: 4px;
}

.resource-item .action-btn {
  padding: 2px 6px;
  color: white;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  font-size: 10px;
}

/* Folder actions */
.folder-actions .action-btn {
  padding: 2px 6px;
  background: var(--cb-accent-danger);
  color: var(--cb-text-inverse);
  border: none;
  border-radius: 2px;
  cursor: pointer;
  font-size: 10px;
}

/* Resource footer */
.resource-footer {
  padding: 8px;
  background: var(--cb-bg-tertiary);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.resource-stats {
  color: var(--cb-text-muted);
  font-size: 11px;
}

/**
 * Instrument Editor Widget Styles
 */

.instrument-editor-widget {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px;
  color: var(--cb-text-primary);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  overflow-y: auto;
  background: var(--cb-bg-primary);
}

.ie-section {
  margin-bottom: 12px;
  padding: 8px;
  background: var(--cb-bg-tertiary);
  border-radius: 4px;
}

.ie-section-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: var(--cb-syntax-keyword);
  font-size: 11px;
  text-transform: uppercase;
}

.ie-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.ie-label {
  width: 70px;
  color: var(--cb-syntax-variable);
}

.ie-label-name {
  width: auto;
  margin-left: 12px;
}

.ie-label-cutoff {
  width: auto;
  margin-left: 8px;
}

.ie-wave-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ie-inst-number {
  width: 60px;
  flex: none;
}

.ie-inst-select {
  flex: 2;
}

.ie-filter-type {
  width: 100px;
  flex: none;
}

.ie-add-layer {
  margin-left: 8px;
  padding: 2px 6px;
}

.ie-remove-layer {
  padding: 2px 6px;
}

.ie-input {
  flex: 1;
  background: var(--cb-bg-input);
  border: 1px solid var(--cb-border-light);
  color: var(--cb-text-primary);
  padding: 4px 6px;
  border-radius: 3px;
}

.ie-input:focus {
  border-color: var(--cb-border-focus);
  outline: none;
}

select.ie-input {
  padding: 3px 6px;
}

.ie-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--cb-border-light);
  border-radius: 2px;
}

.ie-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--cb-accent-primary);
  border-radius: 50%;
  cursor: pointer;
}

.ie-value {
  width: 45px;
  text-align: right;
  color: var(--cb-syntax-string);
}

.ie-btn {
  background: var(--cb-accent-primary);
  border: none;
  color: var(--cb-text-inverse);
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

.ie-btn:hover {
  background: var(--cb-accent-hover);
}

.ie-btn-danger {
  background: var(--cb-accent-danger);
}

.ie-btn-danger:hover {
  background: var(--cb-accent-danger-hover);
}

.ie-wave-btn {
  padding: 4px 8px;
  background: var(--cb-bg-input);
  border: 1px solid var(--cb-border-light);
  color: var(--cb-text-primary);
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
}

.ie-wave-btn.active {
  background: var(--cb-accent-primary);
  border-color: var(--cb-border-focus);
}

.ie-layer {
  background: var(--cb-bg-secondary);
  padding: 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  border-left: 3px solid var(--cb-accent-primary);
}

.ie-layer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.ie-envelope-display {
  height: 60px;
  background: var(--cb-bg-primary);
  border-radius: 4px;
  margin-top: 4px;
  position: relative;
}

.ie-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Piano Keyboard */
.ie-keyboard {
  display: flex;
  height: 50px;
  margin-top: 4px;
  overflow-x: auto;
  position: relative;
}

.ie-key {
  flex: 0 0 24px;
  min-width: 24px;
  background: linear-gradient(to bottom, #fff 0%, #e8e8e8 100%);
  border: 1px solid #333;
  border-left: none;
  cursor: pointer;
  border-radius: 0 0 3px 3px;
  position: relative;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1);
}

.ie-key:first-child {
  border-left: 1px solid #333;
}

.ie-key.black {
  flex: 0 0 14px;
  min-width: 14px;
  background: linear-gradient(to bottom, #333 0%, #111 100%);
  margin-left: -7px;
  margin-right: -7px;
  height: 60%;
  z-index: 1;
  border-radius: 0 0 2px 2px;
  border: 1px solid #000;
  box-shadow: 2px 2px 3px rgba(0,0,0,0.3);
}

.ie-key:hover {
  background: linear-gradient(to bottom, #d0e8ff 0%, #b0d0ff 100%);
}

.ie-key.black:hover {
  background: linear-gradient(to bottom, #555 0%, #333 100%);
}

.ie-key:active,
.ie-key.active {
  background: linear-gradient(to bottom, #90c0ff 0%, #70a0ff 100%);
}

.ie-key.black:active,
.ie-key.black.active {
  background: linear-gradient(to bottom, #666 0%, #444 100%);
}

.ie-octave-marker {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 8px;
  color: #999;
  pointer-events: none;
}

/**
 * Music Tracker Widget Styles
 */

.music-tracker-widget {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--cb-text-primary);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 11px;
  background: var(--cb-bg-primary);
  overflow: hidden;
}

/* Toolbar */
.mt-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--cb-bg-tertiary);
  border-bottom: 1px solid var(--cb-border);
  flex-wrap: wrap;
}

.mt-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mt-btn {
  background: var(--cb-accent-primary);
  border: none;
  color: var(--cb-text-inverse);
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

.mt-btn:hover {
  background: var(--cb-accent-hover);
}

.mt-btn.active {
  background: var(--cb-accent-success);
}

.mt-btn.danger {
  background: var(--cb-accent-danger);
}

.mt-input {
  background: var(--cb-bg-input);
  border: 1px solid var(--cb-border-light);
  color: var(--cb-text-primary);
  padding: 3px 6px;
  border-radius: 3px;
  width: 60px;
}

.mt-input:focus {
  border-color: var(--cb-border-focus);
  outline: none;
}

select.mt-input {
  width: 80px;
}

select.mt-song-select {
  width: 120px;
}

.mt-label {
  color: var(--cb-syntax-variable);
  font-size: 10px;
}

/* Main layout */
.mt-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.mt-sidebar {
  width: 180px;
  background: var(--cb-bg-tertiary);
  border-right: 1px solid var(--cb-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mt-sidebar-section {
  padding: 6px;
  border-bottom: 1px solid var(--cb-border);
}

.mt-sidebar-title {
  font-weight: bold;
  color: var(--cb-syntax-keyword);
  font-size: 10px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.mt-pattern-list {
  flex: 1;
  overflow-y: auto;
}

.mt-pattern-item {
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mt-pattern-item:hover {
  background: var(--cb-bg-hover);
}

.mt-pattern-item.selected {
  background: var(--cb-bg-selected);
}

.mt-pattern-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-pattern-item .mt-btn {
  padding: 2px 4px;
  font-size: 9px;
  opacity: 0.6;
  min-width: 18px;
}

.mt-pattern-item:hover .mt-btn {
  opacity: 1;
}

.mt-dup-pattern {
  background: var(--cb-bg-input) !important;
  color: var(--cb-text-primary) !important;
}

.mt-dup-pattern:hover {
  background: var(--cb-accent-primary) !important;
  color: var(--cb-text-inverse) !important;
}

.mt-del-pattern {
  background: var(--cb-bg-input) !important;
  color: var(--cb-text-primary) !important;
}

.mt-del-pattern:hover {
  background: var(--cb-accent-danger) !important;
  color: var(--cb-text-inverse) !important;
}

.mt-arrangement {
  max-height: 100px;
  overflow-y: auto;
  font-size: 10px;
}

.mt-arr-step {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  cursor: pointer;
  border-radius: 2px;
}

.mt-arr-step:hover {
  background: var(--cb-bg-hover);
}

.mt-arr-pattern {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.mt-arr-repeat {
  color: var(--cb-syntax-number);
  flex-shrink: 0;
}

/* Editor */
.mt-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Track headers */
.mt-track-headers {
  display: flex;
  background: var(--cb-bg-secondary);
  border-bottom: 1px solid var(--cb-border);
  padding: 4px;
  gap: 2px;
}

.mt-track-header {
  width: 120px;
  padding: 4px;
  background: var(--cb-bg-tertiary);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}

.mt-track-header.selected {
  border: 1px solid var(--cb-border-focus);
}

.mt-track-header-name {
  font-weight: bold;
  color: var(--cb-syntax-keyword);
}

.mt-track-controls {
  display: flex;
  gap: 2px;
}

.mt-track-btn {
  padding: 2px 5px;
  font-size: 9px;
  background: var(--cb-bg-input);
  border: none;
  color: var(--cb-text-primary);
  border-radius: 2px;
  cursor: pointer;
  min-width: 18px;
}

.mt-track-btn:hover {
  background: var(--cb-bg-hover);
}

.mt-track-btn.danger {
  color: var(--cb-text-muted);
}

.mt-track-btn.danger:hover {
  background: var(--cb-accent-danger);
  color: var(--cb-text-inverse);
}

.mt-track-btn.muted {
  background: var(--cb-accent-danger);
}

.mt-track-btn.solo {
  background: var(--cb-accent-success);
}

.mt-track-btn.repeat {
  background: var(--cb-accent-info, #3b82f6);
}

/* Grid container */
.mt-grid-container {
  flex: 1;
  overflow: auto;
  background: var(--cb-bg-primary);
}

.mt-grid {
  display: flex;
  min-width: max-content;
}

.mt-track-col {
  width: 120px;
  border-right: 1px solid var(--cb-border);
}

.mt-note-row {
  height: 20px;
  border-bottom: 1px solid var(--cb-border);
  display: flex;
  align-items: center;
  padding: 0 4px;
  cursor: pointer;
}

.mt-note-row:hover {
  background: var(--cb-bg-hover);
}

.mt-note-row.beat {
  border-bottom-color: var(--cb-border-light);
}

.mt-note-row.has-note {
  background: var(--cb-bg-selected);
}

/* MML Editor */
.mt-mml-editor {
  padding: 8px;
  background: var(--cb-bg-tertiary);
  border-top: 1px solid var(--cb-border);
}

.mt-mml-input {
  width: 100%;
  background: var(--cb-bg-input);
  border: 1px solid var(--cb-border-light);
  color: var(--cb-text-primary);
  padding: 6px;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', monospace;
  resize: vertical;
  min-height: 40px;
}

.mt-mml-input:focus {
  border-color: var(--cb-border-focus);
  outline: none;
}

/* Tracker View */
.mt-tracker-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mt-tracker-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--cb-bg-secondary);
  border-bottom: 1px solid var(--cb-border);
}

.mt-tracker-grid-wrap {
  flex: 1;
  overflow: auto;
  background: var(--cb-bg-primary);
}

.mt-tracker-grid {
  display: flex;
  min-width: max-content;
}

.mt-tracker-row-nums {
  position: sticky;
  left: 0;
  background: var(--cb-bg-tertiary);
  z-index: 1;
  border-right: 1px solid var(--cb-border);
}

.mt-tracker-row-num {
  height: 20px;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--cb-border);
  color: var(--cb-text-muted);
  font-size: 10px;
}

.mt-tracker-row-num.beat {
  background: var(--cb-bg-secondary);
  color: var(--cb-text-secondary);
}

.mt-tracker-row-num.current {
  background: var(--cb-bg-selected);
  color: var(--cb-text-inverse);
}

/* Playback highlight - shows current position during playback */
.mt-tracker-row-num.playback-highlight {
  background: #4caf50;
  color: #fff;
}

.mt-tracker-cell.playback-highlight {
  background: rgba(76, 175, 80, 0.3) !important;
}

.mt-tracker-col {
  min-width: 90px;
  border-right: 1px solid var(--cb-border);
}

.mt-tracker-col.selected {
  background: rgba(86, 156, 214, 0.1);
}

.mt-tracker-cell {
  height: 20px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--cb-border);
  cursor: pointer;
  font-family: 'Consolas', monospace;
  font-size: 11px;
}

.mt-tracker-cell:hover {
  background: var(--cb-bg-hover);
}

.mt-tracker-cell.beat {
  border-bottom-color: var(--cb-border-light);
}

.mt-tracker-cell.has-note {
  background: var(--cb-bg-selected);
  color: var(--cb-syntax-variable);
}

.mt-tracker-cell .note {
  color: var(--cb-syntax-type);
}

.mt-tracker-cell .octave {
  color: var(--cb-syntax-string);
}

.mt-tracker-cell .vol {
  color: var(--cb-syntax-number);
  margin-left: 4px;
  font-size: 9px;
}

.mt-tracker-cell .len {
  color: var(--cb-syntax-variable);
  margin-left: 2px;
  font-size: 9px;
}

/* Piano Roll View */
.mt-piano-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mt-piano-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--cb-bg-secondary);
  border-bottom: 1px solid var(--cb-border);
}

.mt-piano-main {
  flex: 1;
  display: flex;
  overflow: auto;
}

.mt-piano-keys {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--cb-bg-tertiary);
  border-right: 1px solid var(--cb-border);
  position: sticky;
  left: 0;
  z-index: 2;
}

.mt-piano-key {
  height: 12px;
  min-height: 12px;
  max-height: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
  font-size: 9px;
  min-width: 40px;
  cursor: pointer;
  user-select: none;
  box-sizing: content-box;
  border-bottom: 1px solid #1a1a1a;
}

.mt-piano-key.white {
  background: linear-gradient(to right, #e8e8e8, #fff);
  color: #333;
}

.mt-piano-key.white:hover {
  background: linear-gradient(to right, #d0d0d0, #e8e8e8);
}

.mt-piano-key.white:active {
  background: linear-gradient(to right, #b0b0b0, #c8c8c8);
}

.mt-piano-key.black {
  background: linear-gradient(to right, #333, #444);
  color: #aaa;
}

.mt-piano-key.black:hover {
  background: linear-gradient(to right, #444, #555);
}

.mt-piano-key.black:active {
  background: linear-gradient(to right, #555, #666);
}

.mt-piano-key.octave-c {
  box-shadow: inset 0 2px 0 #569cd6;
}

.mt-piano-grid-wrap {
  flex: 1;
}

.mt-piano-grid {
  display: flex;
  flex-direction: column;
  min-width: max-content;
}

.mt-piano-row {
  height: 12px;
  min-height: 12px;
  max-height: 12px;
  display: flex;
  box-sizing: content-box;
  border-bottom: 1px solid #2a2a2a;
}

.mt-piano-row.black-row {
  background: #1a1a1a;
}

.mt-piano-row.white-row {
  background: #222;
}

.mt-piano-row.octave-c {
  box-shadow: inset 0 2px 0 #569cd6;
}

/* Rest row - at top of piano roll */
.mt-piano-row.rest-row {
  background: #2d2d3a;
  border-bottom: 2px solid #569cd6;
}

.mt-piano-key.rest-key {
  background: #3d3d4a;
  color: #569cd6;
  font-size: 9px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 2px solid #569cd6;
}

/* Rest cell styling */
.mt-rest-cell.rest-single,
.mt-rest-cell.rest-start,
.mt-rest-cell.rest-continue,
.mt-rest-cell.rest-end {
  background: #e74c3c;
  border-right: none;
  margin-right: 0;
}

.mt-rest-cell.rest-single {
  box-shadow: inset 3px 0 0 rgba(0,0,0,0.3);
  border-right: 1px solid #333;
  border-radius: 2px;
}

.mt-rest-cell.rest-start {
  box-shadow: inset 3px 0 0 rgba(0,0,0,0.3);
  border-radius: 2px 0 0 2px;
}

.mt-rest-cell.rest-end {
  border-right: 1px solid #333;
  border-radius: 0 2px 2px 0;
}

/* Rest length colors - use same colors as notes but with different saturation */
.mt-rest-cell.len-1.rest-single,
.mt-rest-cell.len-1.rest-start,
.mt-rest-cell.len-1.rest-continue,
.mt-rest-cell.len-1.rest-end { background: #8e44ad; }

.mt-rest-cell.len-2.rest-single,
.mt-rest-cell.len-2.rest-start,
.mt-rest-cell.len-2.rest-continue,
.mt-rest-cell.len-2.rest-end { background: #2980b9; }

.mt-rest-cell.len-4.rest-single,
.mt-rest-cell.len-4.rest-start,
.mt-rest-cell.len-4.rest-continue,
.mt-rest-cell.len-4.rest-end { background: #16a085; }

.mt-rest-cell.len-8.rest-single,
.mt-rest-cell.len-8.rest-start,
.mt-rest-cell.len-8.rest-continue,
.mt-rest-cell.len-8.rest-end { background: #27ae60; }

.mt-rest-cell.len-16.rest-single,
.mt-rest-cell.len-16.rest-start,
.mt-rest-cell.len-16.rest-continue,
.mt-rest-cell.len-16.rest-end { background: #d68910; }

.mt-piano-cell {
  width: 20px;
  min-width: 20px;
  border: none;
  border-right: 1px solid #333;
  cursor: crosshair;
  box-sizing: border-box;
}

.mt-piano-cell.beat {
  border-right-color: #444;
}

.mt-piano-cell:hover {
  background: rgba(86, 156, 214, 0.3);
}

/* Hover preview for note placement - shows how big the note will be */
.mt-piano-cell.hover-preview {
  background: rgba(86, 156, 214, 0.25);
}

.mt-piano-cell.hover-preview-start {
  background: rgba(86, 156, 214, 0.4);
  box-shadow: inset 3px 0 0 rgba(86, 156, 214, 0.5);
  border-radius: 2px 0 0 2px;
}

.mt-piano-cell.hover-preview-start.hover-preview-end {
  border-radius: 2px;
}

/* Note styling */
.mt-piano-cell.note-single,
.mt-piano-cell.note-start,
.mt-piano-cell.note-continue,
.mt-piano-cell.note-end {
  border-right: none;
  margin-right: 0;
}

/* Note length colors */
.mt-piano-cell.len-1 { background: #9b59b6; }
.mt-piano-cell.len-1:hover { background: #a86cc1; }

.mt-piano-cell.len-2 { background: #3498db; }
.mt-piano-cell.len-2:hover { background: #5faee3; }

.mt-piano-cell.len-4 { background: #4ec9b0; }
.mt-piano-cell.len-4:hover { background: #6ed4c0; }

.mt-piano-cell.len-8 { background: #2ecc71; }
.mt-piano-cell.len-8:hover { background: #54d98c; }

.mt-piano-cell.len-16 { background: #f39c12; }
.mt-piano-cell.len-16:hover { background: #f5ab35; }

.mt-piano-cell.note-single {
  box-shadow: inset 3px 0 0 rgba(0,0,0,0.3);
  border-right: 1px solid #333;
  border-radius: 2px;
}

.mt-piano-cell.note-start {
  box-shadow: inset 3px 0 0 rgba(0,0,0,0.3);
  border-radius: 2px 0 0 2px;
}

.mt-piano-cell.note-end {
  border-right: 1px solid #333;
  border-radius: 0 2px 2px 0;
}

/* Ghost notes (onion skin) - notes from other tracks shown faded */
.mt-piano-cell.ghost-note {
  background: rgba(150, 150, 150, 0.25);
}

.mt-piano-cell.ghost-single {
  box-shadow: inset 2px 0 0 rgba(150, 150, 150, 0.3);
  border-radius: 2px;
  border-right: 1px solid rgba(150, 150, 150, 0.3);
}

.mt-piano-cell.ghost-start {
  box-shadow: inset 2px 0 0 rgba(150, 150, 150, 0.3);
  border-radius: 2px 0 0 2px;
}

.mt-piano-cell.ghost-end {
  border-right: 1px solid rgba(150, 150, 150, 0.3);
  border-radius: 0 2px 2px 0;
}

.mt-piano-cell.ghost-continue {
  border-right: none;
}

.mt-piano-beat-header {
  display: flex;
  align-items: center;
  background: var(--cb-bg-secondary);
  border-bottom: 1px solid var(--cb-border);
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: max-content;
  height: 17px;
  min-height: 17px;
  max-height: 17px;
  box-sizing: content-box;
  overflow: hidden;
}

/* Header placeholder in piano keys to align with beat header */
.mt-piano-key-header {
  height: 17px;
  min-height: 17px;
  max-height: 17px;
  background: var(--cb-bg-tertiary);
  border-bottom: 1px solid var(--cb-border);
  box-sizing: content-box;
  position: sticky;
  top: 0;
  z-index: 3;
}

.mt-piano-beat-num {
  width: 20px;
  min-width: 20px;
  height: 100%;
  text-align: center;
  font-size: 9px;
  line-height: 16px;
  color: var(--cb-text-muted);
  border-right: 1px solid var(--cb-border);
  box-sizing: border-box;
}

.mt-piano-beat-num.beat {
  color: var(--cb-text-secondary);
  background: var(--cb-bg-hover);
}

/* Piano roll playback highlight */
.mt-piano-beat-num.playback-highlight {
  background: #4caf50;
  color: #fff;
}

.mt-piano-cell.playback-highlight {
  background: rgba(76, 175, 80, 0.4) !important;
  box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.8);
}

/* Instrument select in toolbar */
.mt-inst-select {
  width: 130px;
}

/* Piano roll drag and drop */
.piano-dragging {
  cursor: grabbing !important;
}

.piano-dragging .mt-piano-cell {
  cursor: grabbing !important;
}

.mt-piano-cell.note-single,
.mt-piano-cell.note-start {
  cursor: grab;
}

.mt-piano-cell.drag-preview {
  background: rgba(86, 156, 214, 0.5) !important;
  box-shadow: inset 0 0 0 2px rgba(86, 156, 214, 0.8);
}

.mt-piano-cell.drag-preview:first-of-type {
  border-radius: 2px 0 0 2px;
}

.mt-piano-cell.drag-preview:last-of-type {
  border-radius: 0 2px 2px 0;
}

/* Pattern end marker - shows where content ends for looping reference */
.mt-piano-cell.pattern-end {
  border-left: 2px solid #e74c3c !important;
  box-shadow: inset 4px 0 8px rgba(231, 76, 60, 0.3);
}

.mt-piano-beat-num.pattern-end {
  border-left: 2px solid #e74c3c !important;
  background: rgba(231, 76, 60, 0.3) !important;
  color: #e74c3c !important;
  font-weight: bold;
}

/* Cells beyond pattern end - dimmed to show they're empty/padding area */
.mt-piano-cell.beyond-pattern {
  background: rgba(0, 0, 0, 0.15);
}

.mt-piano-cell.beyond-pattern:hover {
  background: rgba(86, 156, 214, 0.2);
}

.mt-piano-beat-num.beyond-pattern {
  opacity: 0.5;
}

/* Pattern end marker in rest row */
.mt-rest-cell.pattern-end {
  border-left: 2px solid #e74c3c !important;
}

/* Ensure pattern-end is visible even with notes */
.mt-piano-cell.note-single.pattern-end,
.mt-piano-cell.note-start.pattern-end,
.mt-piano-cell.note-continue.pattern-end,
.mt-piano-cell.note-end.pattern-end {
  border-left: 2px solid #e74c3c !important;
}

/**
 * Main styles for CrashBasic IDE
 * Extracted from index.html inline styles
 */

/* ===== Base Styles ===== */
body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--cb-bg-primary);
    color: var(--cb-text-primary);
    overflow: hidden;
}

/* ===== Loading Screen ===== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loading-logo {
    font-size: 48px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

.loading-logo-img {
    max-width: 400px;
    width: 80%;
    height: auto;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

.loading-text {
    font-size: 18px;
    color: #ddd;
    margin-bottom: 30px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #ffffff40;
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-progress {
    width: 300px;
    height: 6px;
    background-color: #ffffff20;
    border-radius: 3px;
    margin-top: 20px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background-color: #ffffff;
    border-radius: 3px;
    width: 0%;
    animation: progress 3s ease-out forwards;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes progress {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* ===== Main Container ===== */
.main-container {
    display: none;
    flex-direction: column;
    height: 100vh;
}

.content-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Gridstack container fills content area */
#grid-container {
    width: 100%;
    height: 100%;
}

/* ===== Error Overlay ===== */
.error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.error-dialog {
    background-color: var(--cb-bg-secondary);
    border: 1px solid var(--cb-border);
    border-radius: 6px;
    padding: 20px;
    max-width: 500px;
    max-height: 300px;
    overflow-y: auto;
}

.error-title {
    color: var(--cb-accent-danger);
    font-weight: bold;
    margin-bottom: 10px;
}

.error-message {
    color: var(--cb-text-secondary);
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.error-close {
    margin-top: 15px;
    text-align: right;
}

.error-close button {
    background-color: var(--cb-accent-primary);
    color: var(--cb-text-inverse);
    border: none;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
}

.error-close button:hover {
    background-color: var(--cb-accent-hover);
}

/* ===== Status Bar ===== */
#status-bar-container {
    flex-shrink: 0;
    flex-grow: 0;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

/* ===== Gridstack Widget Styles ===== */
.grid-stack {
    background-color: var(--cb-bg-primary);
}

.grid-stack-item {
    background-color: transparent;
}

.grid-stack-item-content {
    background-color: var(--cb-bg-tertiary);
    border: 1px solid var(--cb-border);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Widget Header */
.widget-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background-color: var(--cb-widget-header);
    border-bottom: 1px solid var(--cb-border);
    flex-shrink: 0;
    cursor: move;
}

.widget-icon {
    font-size: 16px;
    margin-right: 8px;
}

.widget-title {
    flex: 1;
    font-weight: bold;
    font-size: 12px;
    color: var(--cb-text-secondary);
}

.widget-type-selector {
    flex: none;
    max-width: 140px;
    background: transparent;
    border: none;
    color: var(--cb-text-secondary);
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
    margin-right: auto; /* Push controls to the right, leave space for dragging */
    border-radius: 3px;
    outline: none;
    text-overflow: ellipsis;
}

.widget-type-selector:hover {
    background: var(--cb-bg-hover);
}

.widget-type-selector:focus {
    background: var(--cb-bg-hover);
    outline: 1px solid var(--cb-border);
}

.widget-type-selector option {
    background: var(--cb-bg-primary);
    color: var(--cb-text-primary);
}

.widget-type-selector optgroup {
    background: var(--cb-bg-secondary);
    color: var(--cb-text-muted);
    font-weight: bold;
    font-style: normal;
}

.widget-controls {
    display: flex;
    gap: 4px;
}

.widget-control-btn {
    background: none;
    border: none;
    color: var(--cb-text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 16px;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.widget-control-btn:hover {
    background-color: var(--cb-bg-hover);
}

/* Widget Body */
.widget-body {
    flex: 1;
    overflow: auto;
    position: relative;
    /* Thin scrollbar for Firefox */
    scrollbar-width: thin;
    scrollbar-color: var(--cb-scrollbar-thumb) transparent;
}

/* Webkit scrollbar styling (Chrome, Safari, Edge) - matches Monaco style */
.widget-body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.widget-body::-webkit-scrollbar-track {
    background: transparent;
}

.widget-body::-webkit-scrollbar-thumb {
    background: var(--cb-scrollbar-thumb);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.widget-body::-webkit-scrollbar-thumb:hover {
    background: var(--cb-scrollbar-thumb-hover);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.widget-body::-webkit-scrollbar-corner {
    background: transparent;
}

/* Toolbar Icon Buttons */
.toolbar-icons {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.toolbar-icon-btn {
    background: none;
    border: 1px solid var(--cb-border);
    color: var(--cb-text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    font-size: 16px;
    border-radius: 3px;
    transition: all 0.2s;
}

.toolbar-icon-btn:hover {
    background-color: var(--cb-bg-hover);
    border-color: var(--cb-accent-primary);
}

.toolbar-icon-btn.active {
    background-color: var(--cb-accent-primary);
    border-color: var(--cb-accent-primary);
}

.toolbar-icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Widget-specific styles */

