/* Core Layout & Structure - Common across themes */
* {
  box-sizing: border-box;
}

:root {
  /* Variables that themes MUST override or provide defaults for */
  /* --bg-color, --text-primary, --text-secondary, --text-inverse, --accent-color */

  /* Fallback defaults if theme fails */
  --font-family: system-ui, -apple-system, sans-serif;
  --transition-fast: 0.15s ease;
  --transition-smooth: 0.3s ease;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  color: var(--text-primary, #fff);
  overflow-x: hidden;
  min-height: 100vh;
  background: transparent !important; /* Force transparent to see app-background */
}

.hidden {
  display: none !important;
}

.app-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0; /* Changed from -1 to avoid being behind body background */
  overflow: hidden;
  background-color: var(--bg-color-override, var(--bg-color));
  background-image: var(--bg-image-override, var(--bg-image));
  background-size: cover;
  background-position: center;
  transition: background-color 0.5s ease;
}

/* Brightness Overlay */
.app-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  opacity: var(--bg-dim, 0);
  pointer-events: none;
  z-index: 9999; /* Higher than any injected media */
  transition: opacity 0.3s ease;
}

/* ... */

.bg-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  animation: bg-fade-in 0.6s ease forwards;
}

@keyframes bg-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Custom Scrollbar - Global Design */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb, rgba(128, 128, 128, 0.4)) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb, rgba(128, 128, 128, 0.4));
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 10px;
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover, rgba(128, 128, 128, 0.6));
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Hide scrollbar by default in some containers unless hovered */
.scrollable-hover {
  overflow-y: auto;
}
.scrollable-hover::-webkit-scrollbar-thumb {
  background: transparent;
}
.scrollable-hover:hover::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb, rgba(128, 128, 128, 0.4));
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* DIV Background - fullscreen with no overflow */
.bg-div {
  overflow: hidden;
  pointer-events: none;
}

/* YouTube iframe - scale up to hide black bars (simulates object-fit: cover) */
iframe.bg-media {
  width: 300%;
  height: 300%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border: none;
}

.app-container {
  padding: 24px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  z-index: 10; /* Above app-background */
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  position: sticky;
  top: 24px;
  z-index: 100;
  margin-bottom: 12px;
  gap: 16px;
  /* Visuals handled by theme */

  /* Fix for backdrop-filter seam/dark line artifacts */
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* Header Actions */
.header-center {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 0;
}

.app-header h1,
.header-actions {
  flex-shrink: 0;
}

.search-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
  /* Visuals by theme */
}

#search-input {
  width: 100%;
  box-sizing: border-box;
  outline: none;
  /* Font and sizing base */
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px 8px 40px;
  height: 36px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* Layout */
.containers-wrapper {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 400px;
  padding-bottom: 50px;
}

/* Common Button Classes */
.fluent-btn {
  /* Structure */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 20px;
  min-height: 38px;
  line-height: 1.2;
}

.icon-only {
  padding: 8px;
}

.icon-only-small {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px; /* Increased touch target */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}
.icon-only-small .ui-icon {
  font-size: 20px !important; /* Force readable size */
}

/* Container Structure */
.bookmark-container {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  position: relative;
  overflow: visible;
  /* Theme handles bg, border, shadow, radius */

  /* Fix for backdrop-filter seam/dark line artifacts */
  /* Forces GPU compositing layer to prevent rendering glitches */
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.container-header {
  display: flex;
  align-items: center; /* Strict vertical center */
  gap: 8px; /* Slightly tighter gap to keep actions grouped? Or keep 12 */
  padding: 10px;
  min-height: 48px; /* M3 Standard height */
  border-bottom: 1px solid transparent;
}

.drag-handle {
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}
.drag-handle img,
.drag-handle .ui-icon {
  pointer-events: none;
  -webkit-user-drag: none;
}
.drag-handle:active {
  cursor: grabbing;
}

.container-title {
  background: transparent;
  border: none;
  font-size: 16px;
  font-weight: 600;
  flex-grow: 1;
  padding: 4px 8px;
  font-family: inherit;
  /* colors by theme */
}

.container-icon {
  background: transparent;
  border: none;
  font-size: 20px;
  width: 32px;
  text-align: center;
  cursor: pointer;
  font-family: "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji",
    "Noto Color Emoji", sans-serif;
}

/* Grid Layout */
.container-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  min-height: 40px;
}

.empty-state {
  text-align: center;
  font-size: 13px;
  padding: 20px;
  display: none;
}

.container-grid:empty + .empty-state {
  display: block;
}

/* Bookmark Item Structure */
.bookmark-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 10px 16px 10px;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  user-select: none;
  overflow: hidden;
}

.bookmark-icon {
  font-size: 32px;
  margin-bottom: 8px;
  line-height: 1;
}

.bookmark-label {
  font-size: 13px;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.bookmark-item:hover .bookmark-actions {
  opacity: 1;
}

.bookmark-actions button {
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Animation Utilities (Common) */
.animate-entry .bookmark-container {
  animation: fade-in-up 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

/* Stagger logic is universal enough to keep here */
.animate-entry .bookmark-container:nth-child(1) {
  animation-delay: 0.05s;
}
.animate-entry .bookmark-container:nth-child(2) {
  animation-delay: 0.1s;
}
.animate-entry .bookmark-container:nth-child(3) {
  animation-delay: 0.15s;
}
.animate-entry .bookmark-container:nth-child(4) {
  animation-delay: 0.2s;
}
.animate-entry .bookmark-container:nth-child(5) {
  animation-delay: 0.25s;
}
.animate-entry .bookmark-container:nth-child(n + 6) {
  animation-delay: 0.3s;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Modal Structure */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.2s ease-out;
}

.modal-content {
  width: 90%;
  max-width: 480px;
  transform-origin: center;
  animation: zoom-in 0.2s ease-out backwards;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  /* Visuals by theme */
}

.modal-header {
  padding: 24px 24px 0 24px;
  margin-bottom: 8px; /* Slightly tighter than body padding */
}

.modal-body {
  padding: 24px;
  flex-grow: 1; /* Allow body to expand if needed */
}

.modal-footer {
  padding: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background-color: transparent; /* Or subtly distinct if needed */
}

.modal-body.scrollable {
  max-height: 55vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 16px;
  scrollbar-width: thin;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes zoom-in {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes zoom-out {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.95);
    opacity: 0;
  }
}

.modal-overlay.hiding {
  animation: fade-out 0.2s ease-out forwards;
}

.modal-overlay.hiding .modal-content {
  animation: zoom-out 0.2s ease-out forwards;
}

.fluent-dialog {
  max-width: 380px;
  padding: 32px;
  text-align: center;
  border: 1px solid var(--glass-border);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5),
    0 2px 4px rgba(255, 255, 255, 0.05) inset;
  background: var(--glass-bg-accent, rgba(30, 30, 30, 0.85));
  backdrop-filter: blur(40px) saturate(1.8);
}

.fluent-dialog h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}

.fluent-dialog .modal-actions {
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.dialog-modal {
  border: 1px solid var(--glass-border);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
}

/* Removed legacy dialog input styles */

.modal-content.compact {
  max-width: 400px;
  height: auto;
  max-height: 80vh;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="number"],
.settings-section input[type="text"],
.settings-section input[type="url"],
.fluent-input {
  width: 100%;
  box-sizing: border-box;
  background-color: var(--item-bg, rgba(255, 255, 255, 0.05));
  color: var(--text-primary, #fff);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  border-bottom: 2px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm, 4px);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.form-group input:focus,
.settings-section input:focus,
.fluent-input:focus {
  border-color: var(--accent-color, #60cdff);
  background-color: var(--item-hover-bg, rgba(255, 255, 255, 0.08));
  border-bottom-color: var(--accent-color, #60cdff);
}

/* Select/Dropdown Styling */
select,
.select-styled {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--item-bg, rgba(255, 255, 255, 0.05));
  color: var(--text-primary, #fff);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-sm, 6px);
  padding: 8px 36px 8px 14px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  min-width: 120px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Custom dropdown arrow - Fluent Style */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23ffffff' d='M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
}

select option {
  background-color: #1e1e1e;
  color: #fff;
  padding: 12px;
}

:root[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23000000' d='M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
}

:root[data-theme="light"] select option {
  background-color: #fff;
  color: #000;
}

select:hover,
.select-styled:hover {
  background-color: var(--item-hover-bg, rgba(255, 255, 255, 0.08));
  border-color: var(--glass-border, rgba(255, 255, 255, 0.15));
}

select:focus,
.select-styled:focus {
  border-color: var(--accent-color, #60cdff);
  box-shadow: 0 0 0 2px rgba(96, 205, 255, 0.2);
}

select option {
  background-color: var(--modal-bg, #1e1e1e);
  color: var(--text-primary, #fff);
  padding: 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px; /* Default padding since content padding was removed */
}
.modal-actions.space-between {
  justify-content: space-between;
}
.actions-right {
  display: flex;
  gap: 12px;
}

.radio-group {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
}

/* Settings components */
.input-with-action {
  display: flex;
  gap: 8px;
}
.input-with-action input[type="text"] {
  flex-grow: 1;
}

.settings-type-selector {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  padding: 12px;
  scrollbar-width: thin; /* Firefox */
}
.settings-type-selector::-webkit-scrollbar {
  height: 6px;
}
.settings-type-selector::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb, rgba(128, 128, 128, 0.4));
  border-radius: 10px;
}
.settings-type-selector::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover, rgba(128, 128, 128, 0.6));
}

.settings-type-selector.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
  position: relative;
}

.settings-type-selector.disabled .type-option {
  cursor: not-allowed;
}

.settings-type-selector.disabled::after {
  content: "Not supported with this theme";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent-color, #0078d4);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.type-option {
  cursor: pointer;
  position: relative;
  flex: 1 0 calc(33.33% - 8px);
  min-width: 80px;
  max-width: 120px;
}
.type-card {
  padding: 12px 10px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
  height: 100%;
}

.type-card span:last-child {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.9;
  letter-spacing: 0.2px;
}

.type-card .ui-icon {
  font-size: 20px !important;
}

.code-editor-input {
  width: 100%;
  background: #1e1e1e;
  color: #d4d4d4;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 12px;
  font-family: "Consolas", monospace;
  font-size: 13px;
  resize: vertical;
  line-height: 1.5;
  outline: none;
  box-sizing: border-box;
}

.code-editor-input:focus {
  border-color: var(--accent-color, #60cdff);
}

/* Toggle Switch (New) */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.toggle-label {
  font-size: 14px;
  margin-bottom: 0 !important;
}
/* Toggle switch: 44x22 container, 14px knob, 4px margins */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.2s ease;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 4px;
  top: 4px;
  background-color: #fff;
  transition: 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.toggle-switch input:checked + .slider {
  background-color: var(--accent-color, #60cdff);
  border-color: var(--accent-color, #60cdff);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(22px);
  background-color: #fff;
}

/* Toast Structure */
.toast-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  animation: slide-in-toast 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast-action-btn {
  background: transparent;
  border: none;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  margin: -4px -8px -4px 0;
  transition: background 0.2s;
}

@keyframes slide-in-toast {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.toast.hiding {
  animation: fade-out 0.2s forwards;
}
@keyframes fade-out {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Desktop Styles */
@media (min-width: 768px) {
  .app-container {
    max-width: 900px;
  }
}

/* Drag Overlay Drop Hint */
.drag-over-container::after {
  content: "Add to Group";
  position: absolute;
  inset: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  backdrop-filter: blur(2px);
  z-index: 10;
  pointer-events: none;
  animation: dash-pulse 2s infinite linear;
}

@keyframes dash-pulse {
  0% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.8;
  }
}

.drop-hint-new-group {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-top: 12px;
  transition: all 0.2s;
}

.drop-hint-new-group .hint-content {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.drop-hint-new-group .hint-icon {
  font-size: 24px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* Generic Code Editor Modal */
.modal-editor-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 20px;
  overflow-y: auto;
}

.modal-editor-actions {
  justify-content: space-between !important;
}

.editor-field-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
  margin-bottom: 8px;
}

.editor-extra-buttons {
  display: flex;
  gap: 12px;
}

/* Settings Modal Refactor Utilities */
.settings-section {
  margin-bottom: 24px;
}

.settings-header {
  font-weight: 600;
  font-size: 13px;
  display: block;
  margin: 16px 0 10px;
  color: var(--text-primary);
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-section label.editor-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.settings-divider {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 24px 0;
}

:root[data-theme="light"] .settings-divider {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.settings-info {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
  opacity: 0.8;
}

.preset-variables-container {
  display: none;
  padding: 16px;
  background: var(--item-bg, rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

:root[data-theme="light"] .preset-variables-container {
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.full-width-btn {
  width: 100% !important;
}

.settings-grid-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.settings-grid-row > * {
  flex: 1;
}
.monaco-editor-container {
  width: 100%;
  height: 100%;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.code-editor-input {
  /* ... existing code editor input styles ... */
  display: block; /* Fallback if monaco doesn't load */
}

.settings-header-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.settings-header-with-action .editor-label {
  margin-bottom: 0 !important;
}

.preset-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.preset-select {
  background-color: var(--glass-bg-accent, rgba(45, 45, 45, 0.6));
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 6px 32px 6px 12px;
  max-width: 160px;
  font-size: 13px;
  cursor: pointer;
  background-position: right 10px center;
  background-size: 14px;
  backdrop-filter: blur(10px);
}

.preset-select:hover {
  background-color: var(--item-hover-bg, rgba(255, 255, 255, 0.1));
  border-color: var(--accent-color);
}

.preset-select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(var(--accent-color-rgb), 0.2);
}

/* Color Presets Grid */
.color-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.color-preset-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-preset-swatch:hover {
  transform: scale(1.15);
  border-color: var(--accent-color);
}

.color-preset-swatch.active {
  border-color: white;
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--accent-color);
}

.color-delete-zone {
  margin-top: 12px;
  padding: 16px;
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  transition: all 0.3s ease;
  background: rgba(255, 0, 0, 0.02);
}

.color-delete-zone.drag-over {
  background: rgba(244, 67, 54, 0.15);
  border-color: #f44336;
  color: #f44336 !important;
  transform: scale(1.02);
}

.color-delete-zone i,
.color-delete-zone .ui-icon {
  font-size: 24px;
  opacity: 0.6;
}

.color-delete-zone span {
  font-size: 12px;
  font-weight: 500;
}

.dialog-modal {
  max-width: 400px;
  width: 90%;
}

/* Angle Knob */
.angle-knob-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.angle-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--glass-border);
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s;
}

.angle-knob:hover {
  border-color: var(--accent-color);
}

.angle-knob-indicator {
  position: absolute;
  width: 4px;
  height: 16px;
  background: var(--accent-color, #60cdff);
  border-radius: 2px;
  top: 4px;
  left: 50%;
  transform-origin: center 20px;
  transform: translateX(-50%) rotate(0deg);
}

/* Gradient Stop Rows */
.gradient-stop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
}

.gradient-stop-row:active {
  cursor: grabbing;
}

.gradient-stop-row input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.gradient-stop-row input[type="number"] {
  width: 60px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text-primary);
  font-size: 13px;
  flex-shrink: 0;
}

.gradient-stop-row .remove-stop {
  flex-shrink: 0;
  opacity: 0.7;
}

.gradient-stop-row .remove-stop:hover {
  opacity: 1;
}

.gradient-stop-row.drag-over {
  border-color: var(--accent-color);
  background: rgba(96, 205, 255, 0.1);
}

.gradient-stop-row .drag-handle {
  cursor: grab;
  opacity: 0.4;
  flex-shrink: 0;
}

.gradient-stop-row .drag-handle:hover {
  opacity: 0.8;
}

/* Fix preset dropdown options in dark mode */
.preset-select option,
select.full-width-btn option {
  background-color: #2a2a2a;
  color: #fff;
}

:root[data-theme="light"] .preset-select option,
:root[data-theme="light"] select.full-width-btn option {
  background-color: #fff;
  color: #000;
}
