/* ========================================================
   Python Playground Modal & In-Browser IDE
   Harmonized with Uragan CMS design tokens:
   - Light mode: warm alabaster frosted glass
   - Dark mode: deep slate navy frosted glass
   - Accent token (--accent-color) & dark developer console
   ======================================================== */
.python-modal .modal-dialog {
  max-width: 1100px;
  width: 95vw;
  height: calc(100vh - 2.5rem);
  max-height: 880px;
  margin: 1.25rem auto;
  transition: max-width 0.25s ease;
}

.python-modal .modal-content {
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.python-modal .modal-body.python-modal-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0.65rem 0.9rem;
  position: relative;
}

.python-modal.show .modal-dialog.modal-fullscreen {
  max-width: 100% !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
}

.python-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.python-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(var(--accent-color-rgb), 0.14);
  border: 1px solid rgba(var(--accent-color-rgb), 0.3);
  color: var(--accent-color);
  flex-shrink: 0;
}

.python-header-subtitle {
  font-size: 0.78rem;
  opacity: 0.72;
  color: var(--text-color);
  margin-top: 2px;
  line-height: 1.35;
}

.python-header-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.python-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.python-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.python-status-badge.badge-loading {
  background: var(--status-warning-bg);
  color: var(--status-warning-color);
  border: 1px solid var(--status-warning-border);
}

body.dark .python-status-badge.badge-loading,
html[data-color-mode="dark"] .python-status-badge.badge-loading {
  background: var(--status-warning-bg);
  color: var(--status-warning-color);
  border-color: var(--status-warning-border);
}

.python-status-badge.badge-loading .python-status-dot {
  background: var(--status-warning-color);
  animation: python-pulse 1.3s ease-in-out infinite;
}

@keyframes python-pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.3); opacity: 1; }
}

.python-status-badge.badge-ready {
  background: var(--status-success-bg);
  color: var(--status-success-color);
  border: 1px solid var(--status-success-border);
}

body.dark .python-status-badge.badge-ready,
html[data-color-mode="dark"] .python-status-badge.badge-ready {
  background: var(--status-success-bg);
  color: var(--status-success-color);
  border-color: var(--status-success-border);
}

.python-status-badge.badge-ready .python-status-dot {
  background: var(--status-success-color);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.python-status-badge.badge-error {
  background: var(--status-danger-bg);
  color: var(--status-danger-color);
  border: 1px solid var(--status-danger-border);
}

.python-status-badge.badge-error .python-status-dot {
  background: var(--status-danger-color);
}

.python-help-btn,
.python-fullscreen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--frosted-border);
  background: var(--frosted-inner-surface);
  color: var(--text-color);
  opacity: 0.8;
  transition: all 0.2s ease;
  cursor: pointer;
}

.python-help-btn:hover,
.python-fullscreen-btn:hover {
  opacity: 1;
  background: rgba(var(--accent-color-rgb), 0.14);
  border-color: var(--accent-color);
  color: var(--text-color);
  transform: translateY(-1px);
}

.python-help-btn.active,
.python-fullscreen-btn.active {
  background: var(--accent-color);
  color: var(--accent-contrast-color);
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(var(--accent-color-rgb), 0.4);
}

.python-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.35rem 0.1rem;
}

.python-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.python-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.python-btn-action {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.38rem 0.75rem;
  border-radius: 8px;
  background: var(--frosted-inner-surface);
  color: var(--text-color);
  border: 1px solid var(--frosted-inner-border);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.python-btn-action:hover {
  background: rgba(var(--accent-color-rgb), 0.1);
  border-color: rgba(var(--accent-color-rgb), 0.45);
  color: var(--accent-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.python-btn-action:active {
  transform: translateY(1px);
}

.python-btn-action:disabled,
.python-btn-action.disabled {
  opacity: 0.42 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Custom Frosted Scripts Dropdown */
.python-scripts-dropdown-wrap {
  position: relative;
}

.python-scripts-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: var(--frosted-inner-surface);
  color: var(--text-color);
  border: 1px solid var(--frosted-inner-border);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.38rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
  max-width: 250px;
  text-align: left;
}

.python-scripts-select-btn:hover {
  background-color: rgba(var(--accent-color-rgb), 0.08);
  border-color: rgba(var(--accent-color-rgb), 0.45);
  color: var(--text-color);
  transform: translateY(-1px);
}

.python-scripts-select-btn:focus,
.python-scripts-select-btn.show {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(var(--accent-color-rgb), 0.35);
  color: var(--text-color);
  outline: none;
}

.python-scripts-selected-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 190px;
}

.custom-frosted-dropdown.python-scripts-menu {
  background: var(--frosted-bg-surface) !important;
  backdrop-filter: var(--frosted-blur);
  -webkit-backdrop-filter: var(--frosted-blur);
  border: 1px solid var(--frosted-border) !important;
  border-radius: 14px;
  box-shadow: var(--frosted-shadow-lg) !important;
  padding: 0.45rem;
  min-width: 270px;
  max-width: 330px;
  max-height: 380px;
  overflow-y: auto;
  z-index: 1070;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--text-color-rgb), 0.25) transparent;
}

.python-scripts-menu .dropdown-divider {
  border-top: 1px solid var(--frosted-inner-border) !important;
  opacity: 1 !important;
  margin: 0.35rem 0.2rem !important;
}

.python-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-color);
  opacity: 0.95;
}

.python-dropdown-count-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 9999px;
  background: rgba(var(--accent-color-rgb), 0.16);
  color: var(--accent-color);
  border: 1px solid rgba(var(--accent-color-rgb), 0.25);
}

.python-dropdown-empty {
  font-size: 0.78rem;
  color: var(--text-color);
  opacity: 0.6;
  font-style: italic;
  padding: 0.35rem 0.65rem;
}

.python-dropdown-item-wrap {
  display: flex;
  align-items: center;
  border-radius: 8px;
  position: relative;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  margin-bottom: 2px;
  background: transparent;
  border: 1px solid transparent;
}

.python-dropdown-item-wrap:hover {
  background-color: rgba(var(--accent-color-rgb), 0.1) !important;
  border-color: rgba(var(--accent-color-rgb), 0.22);
}

.python-dropdown-item-wrap.active {
  background-color: rgba(var(--accent-color-rgb), 0.14) !important;
  border-color: rgba(var(--accent-color-rgb), 0.35);
}

.python-scripts-menu .dropdown-item,
.python-scripts-menu .python-script-item,
.python-script-item,
.python-script-item.active,
.python-script-item:focus,
.python-script-item:active,
.python-script-item:hover,
.dropdown-item.python-script-item.active,
.dropdown-item.python-script-item:active {
  background: transparent !important;
  background-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
  color: var(--text-color) !important;
  text-decoration: none !important;
}

.python-script-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  color: var(--text-color) !important;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 8px;
  background: transparent !important;
  border: none !important;
  flex: 1 1 auto;
  text-align: left;
  min-width: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}

.python-script-item.active,
.python-dropdown-item-wrap.active .python-script-item {
  color: var(--accent-color) !important;
  font-weight: 600;
}

.python-script-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: transparent;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.python-script-dot.active,
.python-dropdown-item-wrap.active .python-script-dot {
  background-color: var(--accent-color) !important;
  box-shadow: 0 0 6px 2px rgba(var(--accent-color-rgb), 0.6) !important;
}

.python-script-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}

.python-script-time {
  font-size: 0.7rem;
  opacity: 0.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-left: 0.25rem;
  flex-shrink: 0;
}

.python-script-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin-right: 0.25rem;
  border-radius: 6px;
  background: transparent !important;
  border: none !important;
  color: var(--text-color);
  opacity: 0.45;
  cursor: pointer;
  transition: opacity 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.python-script-delete-btn:hover {
  opacity: 1;
  color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.15) !important;
}

/* Inline Script Save Bar */
.python-save-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.6rem;
  border-radius: 10px;
  background: var(--frosted-inner-surface);
  border: 1px solid var(--accent-color);
  box-shadow: 0 0 12px rgba(var(--accent-color-rgb), 0.25);
  animation: python-slide-down 0.2s ease;
}

@keyframes python-slide-down {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.python-save-icon {
  display: inline-flex;
  align-items: center;
  color: var(--accent-color);
  flex-shrink: 0;
}

.python-save-input {
  flex: 1 1 auto;
  font-size: 0.82rem;
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.28rem 0.6rem;
}

.python-save-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(var(--accent-color-rgb), 0.25);
  background: var(--card-bg);
  color: var(--text-color);
}

.python-btn-save-confirm {
  background-color: var(--accent-color) !important;
  color: var(--accent-contrast-color) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.32rem 0.85rem;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(var(--accent-color-rgb), 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.python-btn-save-confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 10px 2px rgba(var(--accent-color-rgb), 0.55);
  color: var(--accent-contrast-color) !important;
}

.python-btn-save-cancel {
  background: rgba(var(--text-color-rgb), 0.08);
  color: var(--text-color) !important;
  border: 1px solid var(--frosted-inner-border);
  font-size: 0.78rem;
  padding: 0.32rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.python-btn-save-cancel:hover {
  background: rgba(var(--text-color-rgb), 0.16);
  border-color: rgba(var(--text-color-rgb), 0.35);
  color: var(--text-color) !important;
}

/* Toast notification */
.python-toast {
  position: absolute;
  top: 4.2rem;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  padding: 0.4rem 1.1rem;
  border-radius: 9999px;
  background: var(--frosted-bg-surface);
  backdrop-filter: var(--frosted-blur);
  -webkit-backdrop-filter: var(--frosted-blur);
  border: 1px solid var(--accent-color);
  color: var(--text-color);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: var(--frosted-shadow), 0 0 14px rgba(var(--accent-color-rgb), 0.35);
  z-index: 1080;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.python-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.python-exec-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.73rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  padding: 0.24rem 0.55rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

body:not(.dark) .python-exec-badge {
  background: rgba(var(--text-color-rgb), 0.07);
  color: var(--text-color);
  border-color: var(--frosted-inner-border);
}

/* Primary Run Button */
.python-btn-run {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.42rem 1.15rem;
  border-radius: 8px;
  background-color: var(--accent-color) !important;
  color: var(--accent-contrast-color) !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  box-shadow: 0 2px 10px rgba(var(--accent-color-rgb), 0.38);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.python-btn-run:hover:not(:disabled) {
  transform: translateY(-1px);
  background-color: var(--accent-color) !important;
  box-shadow: 0 0 14px 3px rgba(var(--accent-color-rgb), 0.6);
  color: var(--accent-contrast-color) !important;
}

.python-btn-run:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(var(--accent-color-rgb), 0.4);
}

.python-btn-run:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.python-btn-run.is-running {
  background-color: #dc2626 !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px 2px rgba(220, 38, 38, 0.55) !important;
  cursor: pointer !important;
  opacity: 1 !important;
  animation: pulseStopBtn 1.8s infinite ease-in-out;
}

.python-btn-run.is-running:hover {
  background-color: #b91c1c !important;
  box-shadow: 0 0 18px 4px rgba(220, 38, 38, 0.8) !important;
  transform: translateY(-1px);
}

.python-btn-run.is-running:active {
  transform: scale(0.97);
  background-color: #991b1b !important;
}

@keyframes pulseStopBtn {
  0%, 100% { box-shadow: 0 0 10px rgba(220, 38, 38, 0.5); }
  50% { box-shadow: 0 0 18px rgba(220, 38, 38, 0.85); }
}

/* Workspace */
.python-workspace {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: none;
  gap: 0;
  position: relative;
}

.python-editor-card {
  flex: 0 0 calc(55% - 6px);
  min-width: 160px;
  max-width: calc(100% - 170px);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--code-editor-bg);
  border: 1px solid var(--frosted-inner-border);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

body.dark .python-editor-card,
html[data-color-mode="dark"] .python-editor-card {
  background: var(--code-editor-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Draggable Splitter Divider */
.python-divider {
  flex: 0 0 12px;
  width: 12px;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
  user-select: none;
  touch-action: none;
  background: transparent;
  outline: none;
}

.python-divider-handle {
  width: 4px;
  height: 38px;
  border-radius: 2px;
  background: rgba(var(--text-color-rgb), 0.24);
  transition: background 0.15s ease, height 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.python-divider:hover .python-divider-handle,
.python-divider:focus-visible .python-divider-handle,
.python-divider.active .python-divider-handle {
  background: var(--accent-color);
  height: 54px;
  transform: scaleX(1.3);
  box-shadow: 0 0 10px 2px rgba(var(--accent-color-rgb), 0.6);
}

.python-workspace.python-resizing {
  user-select: none !important;
}

.python-workspace.python-resizing .python-code-input,
.python-workspace.python-resizing .python-terminal-body {
  pointer-events: none !important;
}

.python-workspace.python-resizing.resizing-col,
.python-workspace.python-resizing.resizing-col * {
  cursor: col-resize !important;
}

.python-workspace.python-resizing.resizing-row,
.python-workspace.python-resizing.resizing-row * {
  cursor: row-resize !important;
}

/* Terminal Card */
.python-terminal-card {
  flex: 1 1 0;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--code-terminal-card-bg);
  border: 1px solid rgba(43, 47, 51, 0.22);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 16px rgba(0, 0, 0, 0.15);
}

body.dark .python-terminal-card,
html[data-color-mode="dark"] .python-terminal-card {
  background: var(--code-terminal-card-bg);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.python-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  background: rgba(var(--text-color-rgb), 0.035);
  border-bottom: 1px solid var(--frosted-inner-border);
  flex-shrink: 0;
  gap: 0.5rem;
  min-width: 0;
  flex-wrap: nowrap;
}

body.dark .python-pane-header,
html[data-color-mode="dark"] .python-pane-header {
  background: rgba(0, 0, 0, 0.28);
}

.python-editor-pane-header {
  padding: 0.35rem 0.6rem;
  gap: 0.4rem;
  overflow: hidden;
}

.python-tabs-scroll-container {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px 2px 3px 2px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--text-color-rgb), 0.25) transparent;
}

.python-tabs-scroll-container::-webkit-scrollbar { height: 4px; }
.python-tabs-scroll-container::-webkit-scrollbar-track { background: transparent; }
.python-tabs-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(var(--text-color-rgb), 0.2);
  border-radius: 4px;
}
.python-tabs-scroll-container::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--text-color-rgb), 0.35);
}

.python-terminal-card .python-pane-header,
body.dark .python-terminal-card .python-pane-header {
  background: var(--code-terminal-header-bg) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.python-pane-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  background: rgba(var(--text-color-rgb), 0.04);
  border: 1px solid transparent;
  color: rgba(var(--text-color-rgb), 0.7);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.python-pane-tab:hover {
  background: rgba(var(--text-color-rgb), 0.08);
  color: var(--text-color);
}

.python-pane-tab.active {
  font-weight: 600;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--frosted-inner-border);
  border-top: 2px solid var(--accent-color);
  color: var(--text-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.dark .python-pane-tab,
html[data-color-mode="dark"] .python-pane-tab {
  background: rgba(var(--text-color-rgb), 0.04);
  border: 1px solid transparent;
  color: rgba(var(--text-color-rgb), 0.65);
}

body.dark .python-pane-tab:hover,
html[data-color-mode="dark"] .python-pane-tab:hover {
  background: rgba(var(--text-color-rgb), 0.08);
  color: var(--text-color);
}

body.dark .python-pane-tab.active,
html[data-color-mode="dark"] .python-pane-tab.active {
  background: rgba(var(--text-color-rgb), 0.12);
  border: 1px solid rgba(var(--text-color-rgb), 0.16);
  border-top: 2px solid var(--accent-color);
  color: var(--text-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.python-file-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tab Running Dot Indicator */
.python-tab-running-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.75);
  font-size: 0;
  line-height: 0;
  margin-left: 0.25rem;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  animation: pythonRunDotPulse 1.4s ease-in-out infinite;
}

@keyframes pythonRunDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.python-tab-close-btn {
  background: transparent;
  border: none;
  padding: 1px 2px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  color: inherit;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  margin-left: 2px;
  line-height: 1;
}

.python-tab-close-btn:hover {
  opacity: 1;
  background: rgba(var(--text-color-rgb), 0.15);
  color: #dc3545;
}

body.dark .python-tab-close-btn:hover,
html[data-color-mode="dark"] .python-tab-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ff6b6b;
}

.python-new-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.42rem;
  border-radius: 6px;
  background: rgba(var(--text-color-rgb), 0.05);
  border: 1px dashed rgba(var(--text-color-rgb), 0.25);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  line-height: 1;
}

.python-new-tab-btn:hover {
  background: rgba(var(--text-color-rgb), 0.12);
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: scale(1.04);
}

body.dark .python-new-tab-btn,
html[data-color-mode="dark"] .python-new-tab-btn {
  background: rgba(var(--text-color-rgb), 0.06);
  border-color: rgba(var(--text-color-rgb), 0.2);
  color: var(--text-color);
}

body.dark .python-new-tab-btn:hover,
html[data-color-mode="dark"] .python-new-tab-btn:hover {
  background: rgba(var(--text-color-rgb), 0.12);
  border-color: var(--accent-color);
  color: var(--accent-contrast-color);
}

.python-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.82;
  flex-shrink: 0;
}

.python-shortcut-hint {
  font-size: 0.72rem;
  opacity: 0.55;
  color: var(--text-color);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.python-pane-title {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0 !important;
  opacity: 0.95;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

.python-pane-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.python-term-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 3px;
  flex-shrink: 0;
}

.python-term-dot.dot-red { background: #ff5f56; }
.python-term-dot.dot-yellow { background: #ffbd2e; }
.python-term-dot.dot-green { background: #27c93f; }

.python-btn-clear {
  font-size: 0.72rem;
  padding: 0.18rem 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1 !important;
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.python-btn-clear:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff !important;
}

.python-editor-wrapper {
  display: flex;
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background: var(--code-editor-viewport-bg);
}

body.dark .python-editor-wrapper,
html[data-color-mode="dark"] .python-editor-wrapper {
  background: var(--code-editor-viewport-bg);
}

.python-line-numbers {
  font-family: 'Fira Code', 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 0.65rem 0.45rem 0.65rem 0.75rem;
  color: var(--text-color);
  opacity: 0.45;
  text-align: right;
  user-select: none;
  background: rgba(var(--text-color-rgb), 0.02);
  border-right: 1px solid var(--frosted-inner-border);
  min-width: 38px;
  white-space: pre;
  overflow: hidden;
}

body.dark .python-line-numbers,
html[data-color-mode="dark"] .python-line-numbers {
  background: rgba(0, 0, 0, 0.18);
  opacity: 0.38;
}

.python-code-viewport {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.python-highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: none;
  font-family: 'Fira Code', 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  tab-size: 4;
  -moz-tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  box-sizing: border-box;
  background: transparent;
  color: var(--text-color);
  z-index: 1;
}

.python-highlight-layer code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: inherit;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
}

.python-code-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  font-family: 'Fira Code', 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 0.65rem 0.75rem;
  border: none;
  outline: none;
  background: transparent !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  resize: none;
  tab-size: 4;
  -moz-tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow: auto !important;
  box-sizing: border-box;
  caret-color: var(--accent-color) !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--text-color-rgb), 0.35) transparent;
  z-index: 2;
}

.python-code-input:focus {
  outline: none;
}

.python-code-input::selection {
  background: rgba(56, 189, 248, 0.32) !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
}

body.dark .python-code-input::selection,
html[data-color-mode="dark"] .python-code-input::selection {
  background: rgba(56, 189, 248, 0.42) !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
}

/* ========================================================
   Python Syntax Highlighting (Nordic Palette)
   ======================================================== */
.python-highlight-layer .token.comment {
  color: #94a3b8;
  font-style: italic;
  opacity: 0.85;
}

.python-highlight-layer .token.string,
.python-highlight-layer .token.triple-quoted-string {
  color: #86efac;
}

.python-highlight-layer .token.keyword {
  color: #f472b6;
  font-weight: 600;
}

.python-highlight-layer .token.builtin {
  color: #38bdf8;
}

.python-highlight-layer .token.boolean {
  color: #fb923c;
  font-weight: 600;
}

.python-highlight-layer .token.function,
.python-highlight-layer .token.function-definition {
  color: #60a5fa;
  font-weight: 600;
}

.python-highlight-layer .token.class-name {
  color: #fde047;
  font-weight: 600;
}

.python-highlight-layer .token.number {
  color: #fbbf24;
}

.python-highlight-layer .token.decorator {
  color: #c084fc;
}

.python-highlight-layer .token.operator {
  color: #cbd5e1;
}

.python-highlight-layer .token.punctuation {
  color: #94a3b8;
}

/* Light Mode Overrides */
body:not(.dark) .python-highlight-layer,
html[data-color-mode="light"] .python-highlight-layer {
  color: #1e293b;
}

body:not(.dark) .python-highlight-layer .token.comment,
html[data-color-mode="light"] .python-highlight-layer .token.comment {
  color: #64748b;
  font-style: italic;
}

body:not(.dark) .python-highlight-layer .token.string,
body:not(.dark) .python-highlight-layer .token.triple-quoted-string,
html[data-color-mode="light"] .python-highlight-layer .token.string,
html[data-color-mode="light"] .python-highlight-layer .token.triple-quoted-string {
  color: #15803d;
}

body:not(.dark) .python-highlight-layer .token.keyword,
html[data-color-mode="light"] .python-highlight-layer .token.keyword {
  color: #be185d;
  font-weight: 600;
}

body:not(.dark) .python-highlight-layer .token.builtin,
html[data-color-mode="light"] .python-highlight-layer .token.builtin {
  color: #0284c7;
}

body:not(.dark) .python-highlight-layer .token.boolean,
html[data-color-mode="light"] .python-highlight-layer .token.boolean {
  color: #c2410c;
  font-weight: 600;
}

body:not(.dark) .python-highlight-layer .token.function,
body:not(.dark) .python-highlight-layer .token.function-definition,
html[data-color-mode="light"] .python-highlight-layer .token.function,
html[data-color-mode="light"] .python-highlight-layer .token.function-definition {
  color: #1d4ed8;
  font-weight: 600;
}

body:not(.dark) .python-highlight-layer .token.class-name,
html[data-color-mode="light"] .python-highlight-layer .token.class-name {
  color: #b45309;
  font-weight: 600;
}

body:not(.dark) .python-highlight-layer .token.number,
html[data-color-mode="light"] .python-highlight-layer .token.number {
  color: #b45309;
}

body:not(.dark) .python-highlight-layer .token.decorator,
html[data-color-mode="light"] .python-highlight-layer .token.decorator {
  color: #7c3aed;
}

body:not(.dark) .python-highlight-layer .token.operator,
html[data-color-mode="light"] .python-highlight-layer .token.operator {
  color: #475569;
}

body:not(.dark) .python-highlight-layer .token.punctuation,
html[data-color-mode="light"] .python-highlight-layer .token.punctuation {
  color: #64748b;
}

/* Code Editor Scrollbars */
.python-code-input::-webkit-scrollbar { width: 8px; height: 8px; }
.python-code-input::-webkit-scrollbar-track { background: transparent; border-radius: 6px; }
.python-code-input::-webkit-scrollbar-thumb {
  background: rgba(var(--text-color-rgb), 0.28);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.python-code-input::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--text-color-rgb), 0.52);
}

/* Terminal Body & Scrollbars */
.python-terminal-body {
  flex: 1 1 auto;
  padding: 0.75rem 0.85rem;
  background: var(--code-terminal-body-bg);
  color: var(--code-terminal-text);
  font-family: 'Fira Code', 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.52;
  overflow: auto !important;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.32) transparent;
}

.python-terminal-body::-webkit-scrollbar { width: 8px; height: 8px; }
.python-terminal-body::-webkit-scrollbar-track { background: transparent; border-radius: 6px; }
.python-terminal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.python-terminal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.52);
}

.python-terminal-output {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.python-term-stdout { color: #f1f5f9; }
.python-term-stderr { color: #f87171; font-weight: 500; }
.python-term-info { color: #38bdf8; opacity: 0.9; }
.python-term-warn { color: #fbbf24; font-weight: 500; }

/* Python Canvas Container */
.python-canvas-container {
  margin-top: 0.85rem;
  border-radius: 10px;
  background: #080c14;
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45), 0 0 15px rgba(56, 189, 248, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: pythonCanvasFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pythonCanvasFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.python-canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.65rem;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.python-canvas-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #38bdf8;
  letter-spacing: 0.02em;
}

.python-canvas-icon {
  display: inline-flex;
  align-items: center;
}

.python-canvas-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.python-canvas-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.68rem;
  line-height: 1.2;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: all 0.15s ease;
}

.python-canvas-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  color: #f1f5f9;
  border-color: rgba(56, 189, 248, 0.4);
}

.python-canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
  background: #05080f;
  overflow: hidden;
}

.python-graphics-canvas {
  display: block;
  border-radius: 6px;
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

/* Unsaved Changes Dot Indicator */
.python-unsaved-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-color);
  box-shadow: 0 0 6px rgba(var(--accent-color-rgb), 0.6);
  font-size: 0;
  line-height: 0;
  margin-left: 0.25rem;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.22s ease-out, transform 0.22s ease-out;
  animation: pythonDotFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pythonDotFadeIn {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}

.python-unsaved-dot.python-dot-fading-out {
  opacity: 0 !important;
  transform: scale(0.4) !important;
  pointer-events: none;
}

/* Unsaved Changes Prompt Overlay */
.python-unsaved-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  border-radius: inherit;
  animation: pythonOverlayFadeIn 0.18s ease-out;
}

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

.python-unsaved-card {
  background: var(--frosted-bg-surface) !important;
  backdrop-filter: var(--frosted-blur);
  -webkit-backdrop-filter: var(--frosted-blur);
  border: 1px solid var(--frosted-border) !important;
  border-radius: 18px;
  padding: 1.6rem 1.8rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--frosted-shadow-lg);
  text-align: center;
  animation: pythonCardPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pythonCardPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.python-unsaved-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
  margin-bottom: 0.6rem;
}

.python-unsaved-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-color);
  margin-bottom: 0.45rem;
}

.python-unsaved-text {
  color: var(--text-color);
  opacity: 0.85;
  font-size: 0.88rem;
  line-height: 1.45;
  margin-bottom: 1.2rem;
}

.python-unsaved-name-wrap label {
  color: var(--text-color) !important;
  opacity: 0.85;
  font-size: 0.82rem;
  font-weight: 500;
}

.python-unsaved-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 440px) {
  .python-unsaved-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
}

.python-unsaved-btn-save {
  background-color: var(--accent-color) !important;
  color: var(--accent-contrast-color) !important;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  padding: 0.45rem 1.15rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(var(--accent-color-rgb), 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
}

.python-unsaved-btn-save:hover {
  transform: translateY(-1px);
  background-color: var(--accent-color) !important;
  box-shadow: 0 0 12px 3px rgba(var(--accent-color-rgb), 0.55);
  color: var(--accent-contrast-color) !important;
}

.python-unsaved-btn-discard {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.35);
  font-weight: 500;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}

.python-unsaved-btn-discard:hover {
  background: #ef4444;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.python-unsaved-btn-cancel {
  background: rgba(var(--text-color-rgb), 0.08);
  color: var(--text-color) !important;
  border: 1px solid var(--frosted-inner-border);
  font-weight: 500;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}

.python-unsaved-btn-cancel:hover {
  background: rgba(var(--text-color-rgb), 0.16);
  border-color: rgba(var(--text-color-rgb), 0.35);
  color: var(--text-color) !important;
  transform: translateY(-1px);
}

/* Help & Documentation Overlay */
.python-help-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  border-radius: inherit;
  animation: pythonOverlayFadeIn 0.18s ease-out;
}

.python-help-card {
  background: var(--frosted-bg-surface) !important;
  backdrop-filter: var(--frosted-blur);
  -webkit-backdrop-filter: var(--frosted-blur);
  border: 1px solid var(--frosted-border) !important;
  border-radius: 18px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--frosted-shadow-lg);
  animation: pythonCardPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.python-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--frosted-inner-border);
}

.python-help-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.python-help-icon {
  display: inline-flex;
  align-items: center;
  color: var(--accent-color);
  flex-shrink: 0;
}

.python-help-title {
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--text-color);
}

.python-help-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--frosted-inner-border);
  background: rgba(var(--text-color-rgb), 0.06);
  color: var(--text-color);
  opacity: 0.75;
  transition: all 0.18s ease;
  cursor: pointer;
}

.python-help-close-btn:hover {
  opacity: 1;
  background: rgba(var(--accent-color-rgb), 0.16);
  border-color: var(--accent-color);
  color: var(--text-color);
  transform: translateY(-1px);
}

.python-help-body {
  padding: 1.2rem 1.4rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

.python-help-section { margin-bottom: 1.5rem; }
.python-help-section:last-child { margin-bottom: 0.25rem; }

.python-help-section-title {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--accent-color);
  margin-bottom: 0.45rem;
  letter-spacing: 0.01em;
}

.python-help-text {
  color: var(--text-color);
  opacity: 0.88;
  font-size: 0.86rem;
  line-height: 1.55;
  margin-bottom: 0.65rem;
}

.python-help-code {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--frosted-inner-border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #e6edf3;
  margin-bottom: 0.75rem;
  overflow-x: auto;
}

body:not(.dark) .python-help-code,
html[data-color-mode="light"] .python-help-code,
[data-bs-theme="light"] .python-help-code {
  background: rgba(0, 0, 0, 0.05);
  color: #24292f;
  border-color: rgba(0, 0, 0, 0.12);
}

.python-shortcut-list {
  background: rgba(var(--text-color-rgb), 0.04);
  border: 1px solid var(--frosted-inner-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.84rem;
  line-height: 1.85;
  color: var(--text-color);
  white-space: pre-line;
}

/* ========================================================
   Python IntelliSense Autocomplete & Mobile Accessory Bar
   ======================================================== */
.python-autocomplete-popup {
  position: absolute;
  z-index: 100;
  min-width: 210px;
  max-width: 320px;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 1px rgba(255, 255, 255, 0.2);
  padding: 4px;
  font-family: 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  font-size: 0.81rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
  animation: pythonPopupFadeIn 0.12s ease-out;
}

body:not(.dark) .python-autocomplete-popup,
html[data-color-mode="light"] .python-autocomplete-popup {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.14);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16), 0 0 1px rgba(0, 0, 0, 0.12);
  scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

@keyframes pythonPopupFadeIn {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.python-ac-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.1s ease, color 0.1s ease;
  color: #e2e8f0;
}

body:not(.dark) .python-ac-item,
html[data-color-mode="light"] .python-ac-item {
  color: #1e293b;
}

.python-ac-item:hover,
.python-ac-item.active {
  background: rgba(56, 189, 248, 0.22);
  color: #38bdf8;
}

body:not(.dark) .python-ac-item:hover,
body:not(.dark) .python-ac-item.active,
html[data-color-mode="light"] .python-ac-item:hover,
html[data-color-mode="light"] .python-ac-item.active {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
}

.python-ac-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.32rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  line-height: 1.2;
}

.python-ac-badge.fn { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.python-ac-badge.kw { background: rgba(244, 114, 182, 0.2); color: #f472b6; border: 1px solid rgba(244, 114, 182, 0.4); }
.python-ac-badge.mod { background: rgba(52, 211, 153, 0.2); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.4); }
.python-ac-badge.var { background: rgba(251, 191, 36, 0.2); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.4); }
.python-ac-badge.snip { background: rgba(192, 132, 252, 0.2); color: #c084fc; border: 1px solid rgba(192, 132, 252, 0.4); }

.python-ac-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.python-ac-match {
  color: #38bdf8;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(56, 189, 248, 0.5);
  text-underline-offset: 2px;
}

body:not(.dark) .python-ac-match,
html[data-color-mode="light"] .python-ac-match {
  color: #0284c7;
  text-decoration-color: rgba(2, 132, 199, 0.5);
}

.python-ac-hint {
  font-size: 0.7rem;
  opacity: 0.55;
  margin-left: auto;
  flex-shrink: 0;
  font-style: italic;
}

/* Accessory Bar */
.python-accessory-bar {
  display: flex;
  align-items: center;
  background: rgba(var(--text-color-rgb), 0.04);
  border-top: 1px solid var(--frosted-inner-border);
  padding: 0.32rem 0.5rem;
  min-height: 42px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  z-index: 5;
}

body.dark .python-accessory-bar,
html[data-color-mode="dark"] .python-accessory-bar {
  background: rgba(0, 0, 0, 0.28);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.python-accessory-scroll {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
}

.python-accessory-scroll::-webkit-scrollbar {
  display: none;
}

.python-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.26rem 0.62rem;
  font-family: 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--frosted-inner-border);
  background: rgba(var(--text-color-rgb), 0.06);
  color: var(--text-color);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-x;
  transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease, color 0.15s ease;
}

body.dark .python-chip,
html[data-color-mode="dark"] .python-chip {
  background: rgba(var(--text-color-rgb), 0.07);
  border-color: rgba(var(--text-color-rgb), 0.12);
  color: var(--text-color);
}

.python-chip:hover {
  background: rgba(var(--accent-color-rgb), 0.15);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.python-chip:active {
  transform: scale(0.94);
  background: rgba(var(--accent-color-rgb), 0.25);
}

.python-chip.python-chip-completion {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(56, 189, 248, 0.15);
}

body:not(.dark) .python-chip.python-chip-completion,
html[data-color-mode="light"] .python-chip.python-chip-completion {
  background: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.3);
  color: #0284c7;
}

.python-chip.python-chip-completion:active {
  background: rgba(56, 189, 248, 0.3);
}

.python-chip-completion .python-chip-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 0.28rem;
  opacity: 0.9;
}

.python-chip.python-chip-tab {
  font-weight: 600;
  background: rgba(var(--text-color-rgb), 0.1);
  border-color: rgba(var(--text-color-rgb), 0.2);
}

.python-chip-divider {
  width: 1px;
  height: 18px;
  background: var(--frosted-inner-border);
  flex-shrink: 0;
  margin: 0 0.15rem;
}

/* Empty state view */
.python-editor-empty-state {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: rgba(var(--text-color-rgb), 0.03);
  z-index: 10;
  text-align: center;
  padding: 1.5rem;
  user-select: none;
  animation: pythonFadeIn 0.2s ease-out;
}

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

body.dark .python-editor-empty-state,
html[data-color-mode="dark"] .python-editor-empty-state {
  background: rgba(0, 0, 0, 0.32);
}

.python-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  color: var(--text-color);
}

.python-empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-color);
  opacity: 0.88;
}

.python-empty-subtitle {
  font-size: 0.84rem;
  color: var(--text-color);
  opacity: 0.6;
  max-width: 330px;
  line-height: 1.45;
  margin-bottom: 0.4rem;
}

.python-empty-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: var(--accent-color) !important;
  color: var(--accent-contrast-color) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  border-radius: 8px;
  padding: 0.42rem 1.05rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(var(--accent-color-rgb), 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.python-empty-new-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 12px 3px rgba(var(--accent-color-rgb), 0.55);
}

/* ========================================================
   Responsive & Fullscreen Layout
   ======================================================== */
.python-modal.show .modal-dialog.modal-fullscreen {
  max-width: 100% !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
}

.python-modal.show .modal-dialog.modal-fullscreen .modal-content {
  height: 100% !important;
  max-height: 100% !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0.35rem !important;
}

.python-modal.show .modal-dialog.modal-fullscreen .modal-body.python-modal-body {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding: 0.6rem 0.85rem !important;
}

.python-modal.show .modal-dialog.modal-fullscreen .python-workspace {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: row !important;
  gap: 0 !important;
}

.python-modal.show .modal-dialog.modal-fullscreen .python-editor-card,
.python-modal.show .modal-dialog.modal-fullscreen .python-terminal-card {
  height: 100% !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

.python-modal.show .modal-dialog.modal-fullscreen .python-editor-wrapper,
.python-modal.show .modal-dialog.modal-fullscreen .python-terminal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
}

@media (max-width: 991.98px) {
  .python-modal .modal-dialog,
  .python-modal .modal-dialog.modal-fullscreen-lg-down {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
  }

  .python-modal .modal-content {
    height: 100% !important;
    max-height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    padding: 0.25rem !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .python-modal .modal-body.python-modal-body {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 0.45rem 0.6rem !important;
  }

  .python-toolbar {
    flex-shrink: 0;
    margin-bottom: 0.45rem !important;
    padding: 0.1rem 0;
  }

  .python-workspace {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    gap: 0 !important;
  }

  .python-editor-card {
    flex: 0 0 calc(50% - 8px);
    min-height: 80px;
    max-height: calc(100% - 94px);
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .python-divider {
    flex: 0 0 16px !important;
    width: 100% !important;
    height: 16px !important;
    cursor: row-resize !important;
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    position: relative !important;
    z-index: 10 !important;
  }

  .python-divider::before {
    content: '';
    position: absolute;
    top: -8px;
    bottom: -8px;
    left: 0;
    right: 0;
    z-index: 2;
  }

  .python-divider-handle {
    width: 48px !important;
    height: 4px !important;
    border-radius: 2px !important;
  }

  .python-divider:hover .python-divider-handle,
  .python-divider:focus-visible .python-divider-handle,
  .python-divider.active .python-divider-handle {
    width: 64px !important;
    height: 5px !important;
    transform: scaleY(1.3) !important;
  }

  .python-terminal-card {
    flex: 1 1 0;
    min-height: 80px;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .python-editor-wrapper {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
  }

  .python-code-input,
  .python-line-numbers {
    height: 100% !important;
  }

  .python-terminal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
  }

  .python-shortcut-hint,
  .python-header-subtitle,
  .python-fullscreen-btn {
    display: none !important;
  }
}

@media (max-width: 575.98px) {
  .python-modal .modal-header {
    padding: 0.55rem 0.75rem;
    gap: 0.4rem;
  }

  .python-header-title-wrap {
    gap: 0.45rem;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .python-header-title-wrap > div {
    min-width: 0;
    overflow: hidden;
  }

  .python-modal .modal-title {
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .python-header-controls {
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .python-status-badge {
    padding: 0.2rem 0.45rem;
    font-size: 0.68rem;
    max-width: 115px;
  }

  .python-status-badge .python-status-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .python-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .python-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    flex-wrap: nowrap;
  }

  .python-scripts-dropdown-wrap {
    flex: 1 1 0;
    min-width: 0;
  }

  .python-scripts-select-btn {
    width: 100%;
    max-width: 100%;
    font-size: 0.78rem;
    padding: 0.35rem 0.6rem;
  }

  .python-scripts-selected-text {
    max-width: 100%;
  }

  .python-btn-action {
    padding: 0.35rem 0.55rem;
    font-size: 0.76rem;
  }

  .python-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: space-between;
  }

  .python-status-badge {
    padding: 0.2rem 0.45rem;
    font-size: 0.7rem;
  }

  .python-btn-run {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0.38rem 0.75rem;
  }
}

@media (max-width: 459.98px) {
  .python-btn-action .python-btn-label {
    display: none;
  }

  .python-btn-action svg {
    margin-right: 0 !important;
  }

  .python-btn-action {
    padding: 0.35rem 0.5rem;
  }
}
