/* ===== CSS VARIABLES ===== */
:root {
  --bg: #0f1115;
  --text: #e9ecf1;
  --muted: #a5acb8;
  --panel: #171a20;
  --panel-2: #0b1220;
  --border: #2c3038;
  --canvas-border: #333841;
  --button-bg: #1d2129;
  --button-border: #303542;
  --button-text: #e9ecf1;
  --input-bg: #161a20;
  --input-text: #e9ecf1;
  --topbar-h: 64px;
  --gap: 28px;
  --accent: #7aa2ff;
  --accent-1: #3b82f6;
  --accent-2: #60a5fa;
  --active: #98b4ff;
  --hover: rgba(255, 255, 255, 0.05);
  --accent-rgb: 59, 130, 246;
  --page-width: 816px;   /* 8.5in @96dpi */
  --page-height: 1056px; /* 11in @96dpi */
  --thumb-scale: .18;
  --thumb-width: calc(var(--page-width) * var(--thumb-scale));
  --pn-font: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, "Helvetica Neue";
  --pn-style: normal;
  --pn-weight: 400;
  --page-bg-color: #0f1520;
  --page-font-color: #dbe6f5;
  --margin-amount: 12mm;
}

body[data-theme="light"] {
  --bg: #f6f7fb;
  --text: #0d1117;
  --muted: #57606a;
  --panel: #ffffff;
  --border: #d0d7de;
  --canvas-border: #c9d1d9;
  --button-bg: #f6f8fa;
  --button-border: #d0d7de;
  --button-text: #24292f;
  --input-bg: #ffffff;
  --input-text: #0d1117;
  --accent: #2f6feb;
  --active: #2f6feb;
}

/* ===== BASE STYLES ===== */
* { 
  box-sizing: border-box; 
}

html, body { 
  height: 100%; 
}

body { 
  margin: 0; 
  background: var(--bg); 
  color: var(--text); 
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; 
  position: relative;
}



/* ===== TITLE LOGO ===== */
.title-container {
  display: flex;
  align-items: center;
}

.title-logo {
  height: 36px;
  width: auto;
  opacity: 0.9;
}

/* ===== LAYOUT ===== */
.page { 
  display: grid; 
  grid-template-columns: 672px minmax(820px, 1fr); 
  gap: var(--gap); 
  padding: 16px 20px 24px; 
  align-items: start; 
}

/* ===== BOX MAKER LAYOUT ===== */
/* Box maker screen styles are now in screens.css */

.box-maker-app {
  display: grid;
  grid-template-columns: 345px 1fr 650px;
  height: calc(100vh - var(--topbar-h));
  min-height: 0; /* Allow grid items to shrink */
}

.box-maker-left {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 0; /* Allow grid item to shrink */
}

.box-maker-center {
  background: var(--bg);
  position: relative;
  width: 100%;
  height: 100%;
}

.box-maker-center canvas {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  position: relative !important;
  z-index: 1 !important;
  flex: 1; /* Take up all available space */
  min-height: 0; /* Allow canvas to shrink */
  max-height: none !important; /* Override the general canvas max-height rule */
  pointer-events: auto;
}

/* Light Settings Button */
/* Control Buttons Container */
.control-buttons-container {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 8px;
  z-index: 2000;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.light-settings-button {
  width: 48px;
  height: 48px;
  background: rgba(59, 130, 246, 0.3);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: auto;
}

.light-settings-button:hover {
  background: var(--button-bg);
  border-color: var(--accent);
  transform: scale(1.1);
}

.light-settings-button svg {
  width: 24px;
  height: 24px;
  color: var(--text);
}

/* Box Controls Button */
.box-controls-button {
  width: 48px;
  height: 48px;
  background: rgba(59, 130, 246, 0.3);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: auto;
}

.box-controls-button:hover {
  background: var(--button-bg);
  border-color: var(--accent);
  transform: scale(1.1);
}

.box-controls-button svg {
  width: 24px;
  height: 24px;
  color: var(--text);
}

/* Camera Settings Button */
.camera-settings-button {
  width: 48px;
  height: 48px;
  background: rgba(59, 130, 246, 0.3);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: auto;
}

.camera-settings-button:hover {
  background: var(--button-bg);
  border-color: var(--accent);
  transform: scale(1.1);
}

.camera-settings-button svg {
  width: 24px;
  height: 24px;
  color: var(--text);
}

/* Light Settings Panel */
.light-settings-panel {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 1500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.light-settings-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Box Controls Panel */
.box-controls-panel {
  position: absolute;
  bottom: 80px;
  left: calc(50% + 60px);
  transform: translateX(-50%) translateY(20px);
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 1500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.box-controls-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.box-controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.box-controls-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.close-box-controls {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.close-box-controls:hover {
  color: var(--text);
  background: var(--button-bg);
}

.close-box-controls svg {
  width: 16px;
  height: 16px;
}

.box-controls-content {
  padding: 20px;
}

.box-control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.box-control-row:last-child {
  margin-bottom: 0;
}

.box-control-row label {
  min-width: 80px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.box-control-row input[type="range"] {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 0;
  border: none;
}

.box-control-row input[type="range"]:hover {
  background: var(--accent);
}

.box-control-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.box-control-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.box-control-row input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.box-control-row input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.box-control-row .value-input {
  min-width: 50px;
  text-align: right;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  outline: none;
  transition: border-color 0.2s ease;
}

.box-control-row .value-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.box-control-row .value-input:hover {
  border-color: var(--accent);
}

/* Toggle container in box controls panel */
.box-control-row .toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.box-control-row .toggle-container .toggle-label {
  flex: 1;
  min-width: 0;
}

.box-control-row .toggle-container .toggle-switch {
  flex-shrink: 0;
}

/* Camera Settings Panel */
.camera-settings-panel {
  position: absolute;
  bottom: 80px;
  left: calc(50% - 60px);
  transform: translateX(-50%) translateY(20px);
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 1500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.camera-settings-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.camera-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.camera-settings-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.close-camera-settings {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.close-camera-settings:hover {
  color: var(--text);
  background: var(--button-bg);
}

.close-camera-settings svg {
  width: 16px;
  height: 16px;
}

.camera-settings-content {
  padding: 20px;
}

.camera-control-row {
  margin-bottom: 12px;
}

.camera-control-row:last-child {
  margin-bottom: 0;
}

.camera-control-row .themed-btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
}

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

.light-settings-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.close-light-settings {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.close-light-settings:hover {
  color: var(--text);
  background: var(--button-bg);
}

.close-light-settings svg {
  width: 16px;
  height: 16px;
}

.light-settings-content {
  padding: 20px;
}

.light-setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.light-setting-row:last-child {
  margin-bottom: 0;
}

.light-setting-row label {
  min-width: 80px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.light-setting-row input[type="range"] {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.light-setting-row input[type="range"]:hover {
  background: var(--accent);
}

.light-setting-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.light-setting-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.light-setting-row input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.light-setting-row input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.light-setting-row .value-input {
  min-width: 60px;
  text-align: right;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  outline: none;
  transition: border-color 0.2s ease;
}

.light-setting-row .value-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.light-setting-row .value-input:hover {
  border-color: var(--accent);
}

.box-maker-center {
  background: var(--bg);
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  min-height: 0; /* Allow grid item to shrink */
  display: flex; /* Ensure full height */
  flex-direction: column;
}

.box-maker-right {
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0; /* Allow grid item to shrink */
  overflow-y: auto; /* Allow scrolling if content is too tall */
  position: relative; /* For absolute positioning of template-actions */
}

.box-maker-tools h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

/* Add bottom padding to Box Name section for visual separation */
.box-maker-tools h3:first-of-type + .tool-row {
  padding-bottom: 20px;
}

.tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-row label {
  width: 120px;
  color: var(--muted);
}

.tool-row input,
.tool-row select {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--input-text);
}

.tool-row select option:disabled {
  color: var(--muted);
  font-style: italic;
}

.tool-row select option:enabled {
  color: var(--input-text);
}

.tool-row input[type="range"] {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 0; /* Override the general input padding */
  border: none; /* Remove border for cleaner look */
}

.tool-row input[type="range"]:hover {
  background: var(--accent);
}

.tool-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.tool-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.tool-row input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--panel);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.tool-row input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.tool-row span {
  min-width: 50px;
  text-align: right;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

/* Toggle Switch Styles */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-switch {
  position: relative;
  width: 52px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid var(--border);
}

.toggle-switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--muted);
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch.active {
  background: #4ade80;
  border-color: #22c55e;
}

.toggle-switch.active::before {
  background: #ffffff;
  transform: translateX(20px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.toggle-switch:hover {
  border-color: var(--accent);
}

.toggle-switch.active:hover {
  border-color: #16a34a;
}

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

.toggle-label {
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

/* Template Panel Styles */
.template-header {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.template-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 60%;
}

/* File Upload Area */
.file-upload-area {
  position: relative;
  min-width: 100%;
  height: 60px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
}

.file-upload-area:hover {
  border-color: var(--accent);
  background: var(--panel);
}

.file-upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.file-upload-area input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.upload-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
  z-index: 1;
}

.upload-overlay svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: color 0.3s ease;
}

.upload-overlay span {
  font-size: 13px;
  color: var(--muted);
  transition: color 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-upload-area:hover .upload-overlay svg,
.file-upload-area:hover .upload-overlay span {
  color: var(--text);
}

.file-upload-area.drag-over .upload-overlay svg,
.file-upload-area.drag-over .upload-overlay span {
  color: white;
}

.template-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.template-settings label {
  font-size: 12px;
  color: var(--muted);
}

.template-settings input,
.template-settings select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--input-text);
}

.template-canvas-container {
  flex: 1;
  overflow: auto;
  background: var(--bg);
  padding: 12px 12px 80px 12px; /* Increased bottom padding for fixed button bar */
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 600px; /* Ensure enough height for template with flaps */
}

.template-canvas-container canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  max-height: none !important; /* Override general canvas height limit for template */
  border: 1px solid var(--border);
  background: var(--bg);
}

.template-actions {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 650px; /* Match the right panel width from grid-template-columns */
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  z-index: 100; /* Ensure it stays above other content */
}

.tiny {
  font-size: 12px;
  color: var(--muted);
}

@media(max-width: 1200px) { 
  .page { 
    grid-template-columns: 1fr; 
  } 
  .preview-col { 
    position: static; 
    max-height: none; 
    overflow: visible; 
    min-width: 0; 
  } 
}

.controls { 
  display: flex; 
  flex-direction: column; 
  gap: 12px; 
  width: 672px; 
}

.preview-col { 
  position: sticky; 
  top: calc(var(--topbar-h) + 12px); 
  align-self: start; 
  max-height: calc(100vh - var(--topbar-h) - 24px); 
  overflow: auto; 
  padding-right: 4px; 
  min-width: 820px; 
}

.preview-col .previews { 
  display: flex; 
  gap: 24px; 
  transition: transform 0.2s ease; 
  justify-content: center;
}

.card-wrap { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 8px; 
}

canvas { 
  border: 1px solid var(--canvas-border); 
  max-width: 100%; 
  max-height: 600px; 
  width: auto; 
  height: auto; 
  background: #f5f5f5; 
}

/* Preview quality toggle */
.preview-quality-toggle {
  margin-top: 16px;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  width: 1000px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.preview-quality-toggle .switch {
  justify-content: center;
  margin-bottom: 4px;
}

.preview-quality-toggle .hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.7;
}

/* ===== UTILITY CLASSES ===== */
.subtle { 
  color: var(--muted); 
}

/* Font importer delete button styling */
.delete-font-btn {
  background: #dc3545 !important;
  color: white !important;
  border: none !important;
  border-radius: 6px !important;
  width: 24px !important;
  height: 24px !important;
  cursor: pointer !important;
  font-size: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-left: 10px !important;
  transition: background-color 0.2s ease !important;
}

.delete-font-btn:hover {
  background: #c82333 !important;
}

/* Font importer row styling */
.fonts-screen .list .row {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.fonts-screen .list .row .name {
  min-width: 120px !important;
  flex-shrink: 0 !important;
}

.fonts-screen .list .row .sample {
  flex: 1 !important;
  text-align: right !important;
  font-size: 12px; 
}

.danger { 
  color: #b05050; 
}

.pill { 
  border: 1px solid var(--border); 
  border-radius: 20px; 
  padding: 6px 10px; 
  background: var(--button-bg); 
}

.inline { 
  display: flex; 
  gap: 8px; 
  align-items: center; 
  flex-wrap: wrap; 
}

.two-col { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 12px; 
}

/* ===== ERROR OVERLAY ===== */
#errorOverlay {
  position: fixed; 
  left: 0; 
  right: 0; 
  bottom: 0; 
  z-index: 9999;
  display: none; 
  padding: 10px 14px;
  background: rgba(220, 38, 38, 0.95); 
  color: #fff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
}

#errorOverlay .row { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  gap: 12px; 
  flex-wrap: wrap; 
}

#errorOverlay .msg { 
  font-size: 13px; 
  white-space: pre-wrap; 
  word-break: break-word; 
}

#errorOverlay .support { 
  font-weight: 600; 
}

#errorOverlay button { 
  background: rgba(255,255,255,0.15); 
  color: #fff; 
  border: 1px solid rgba(255,255,255,0.3); 
  padding: 6px 10px; 
  border-radius: 8px; 
  cursor: pointer; 
}

#errorOverlay button:hover { 
  background: rgba(255,255,255,0.25); 
}

/* ===== COMPONENTS EDIT MENU ===== */
.components-edit-menu {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  width: 500px;
  height: 100vh;
  position: fixed;
  top: 0px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.edit-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.edit-menu-header h4 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.edit-menu-controls {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: center;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.edit-menu-controls label {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.edit-menu-content {
  flex: 1;
  padding: 8px;
}

.components-drag-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.components-drag-list.layout-single .component-edit-item {
  width: 100%;
}

.components-drag-list.layout-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.components-drag-list.layout-three {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.component-edit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: move;
  transition: all 0.2s ease;
  user-select: none;
  min-height: 48px;
  align-self: start;
}

.component-edit-item:hover {
  background: var(--hover);
  border-color: var(--accent);
}

.component-edit-item.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.component-edit-item.drag-over-top {
  border-top: 3px solid var(--accent);
  margin-top: 4px;
  transform: translateY(2px);
  transition: all 0.2s ease;
}

.component-edit-item.drag-over-bottom {
  border-bottom: 3px solid var(--accent);
  margin-bottom: 4px;
  transform: translateY(-2px);
  transition: all 0.2s ease;
}

.drag-handle {
  color: var(--muted);
  font-size: 18px;
  cursor: grab;
  user-select: none;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  min-width: 32px;
  text-align: center;
}

.drag-handle:hover {
  background: var(--hover);
  color: var(--text);
}

.drag-handle:active {
  cursor: grabbing;
  background: var(--accent);
  color: white;
}

.component-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.component-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.component-type {
  color: var(--muted);
  font-size: 12px;
}

.edit-menu-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.edit-menu-footer .btn {
  min-width: 80px;
}

/* Scrollbar styling for edit menu */
.components-edit-menu::-webkit-scrollbar {
  width: 8px;
}

.components-edit-menu::-webkit-scrollbar-track {
  background: var(--panel-2);
}

.components-edit-menu::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.components-edit-menu::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Color picker styling */
.color-picker {
  width: 40px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: none;
  padding: 0;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 4px;
  overflow: hidden;
}

.color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

/* Components list layout styles for the actual output */
.components-list.layout-two .components-list-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.components-list.layout-three .components-list-items {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.components-list.layout-two .components-list-items li,
.components-list.layout-three .components-list-items li {
  padding: 8px 12px;
  background: var(--components-background-color, var(--input-bg));
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--components-font-color, var(--text));
  align-self: start;
}

.components-list.layout-two .components-list-items li strong,
.components-list.layout-three .components-list-items li strong {
  color: var(--components-font-color, var(--text));
  font-weight: var(--components-font-weight);
  font-style: var(--components-font-style);
  text-decoration: var(--components-text-decoration);
}

.components-list.layout-single .components-list-items li {
  color: var(--components-font-color, var(--text));
}

.components-list.layout-single .components-list-items li strong {
  color: var(--components-font-color, var(--text));
  font-weight: var(--components-font-weight);
  font-style: var(--components-font-style);
  text-decoration: var(--components-text-decoration);
}

/* ===== UNSAVED CHANGES WARNING ===== */
.unsaved-changes-warning {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20000;
}

.warning-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.warning-dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.warning-dialog h3 {
  margin: 0 0 16px 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}

.warning-dialog p {
  margin: 0 0 24px 0;
  color: var(--muted);
  line-height: 1.5;
}

.warning-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.warning-buttons .btn {
  min-width: 100px;
}

/* Components List Edit Controls */
.font-style-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.font-style-controls .btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border: 2px outset #ccc;
  background: #f5f5f5;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 4px;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.font-style-controls .btn-icon:hover {
  background: #e0e0e0;
  border-color: #007acc;
}

.font-style-controls .btn-icon:active {
  border: 2px inset #999;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.2);
  transform: translate(1px, 1px);
}

.font-style-controls .btn-icon.active {
  background: #007acc !important;
  color: #ffffff !important;
  border: 2px inset #005a9e !important;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
  transform: translate(1px, 1px);
}

.font-style-controls .btn-icon.active:hover {
  background: #005a9e !important;
  border: 2px inset #004080 !important;
}

.spacing-slider {
  width: 100%;
  margin: 4px 0;
}

.spacing-value {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
  min-width: 40px;
  text-align: right;
}

/* Color Controls with Alpha */
.color-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alpha-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alpha-control label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 50px;
}

.alpha-slider {
  flex: 1;
  margin: 0;
}

.alpha-value {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 35px;
  text-align: right;
}
