:root {
  --font-main: 'Plus Jakarta Sans', 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Light Theme Palette */
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-glass: rgba(255, 255, 255, 0.92);
  --bg-subtle: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-text: #1d4ed8;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --success-text: #047857;
  
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-text: #b45309;
  
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-hover: #dc2626;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header */
.app-header {
  width: 100%;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-container {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.logo-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.logo-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--success-light);
  border: 1px solid #bbf7d0;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--success-text);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.status-dot.online {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  animation: pulse-green 2s infinite;
}
.status-dot.offline {
  background: var(--danger);
}

@keyframes pulse-green {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.obs-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.obs-badge i {
  color: var(--primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Master Visibility Button */
.btn-master-toggle {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-master-toggle:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.btn-master-toggle.hidden-state {
  background: #64748b;
  box-shadow: 0 4px 12px rgba(100, 116, 139, 0.2);
}

/* General Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  user-select: none;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-outline {
  background: #fff;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
}
.btn-outline.active-snap {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
}
.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.btn-secondary:hover {
  background: #e2e8f0;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}
.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
}

/* Layout */
.main-layout {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 16px 20px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(320px, 30vw, 440px);
  gap: 20px;
  flex: 1;
  align-items: start;
}

/* Left Workspace */
.workspace-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Active Preset Hero Banner */
.active-preset-banner {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.banner-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.banner-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  background: #eff6ff;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #bfdbfe;
}
.save-status-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
}
.save-status-badge.saved {
  background: var(--success-light);
  color: var(--success-text);
  border: 1px solid #bbf7d0;
}
.save-status-badge.unsaved {
  background: var(--warning-light);
  color: var(--warning-text);
  border: 1px solid #fde68a;
  animation: pulse-warn 1.5s infinite;
}
@keyframes pulse-warn {
  0% { transform: scale(0.98); }
  50% { transform: scale(1.02); }
  100% { transform: scale(0.98); }
}
.banner-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header {
  background: var(--bg-card);
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.stage-header h2 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}
.stage-header h2 i {
  color: var(--primary);
}
.badge-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
  display: block;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.zoom-group {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}
.btn-icon-sm {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.btn-icon-sm:hover {
  background: #e2e8f0;
  color: var(--text-main);
}
.zoom-label {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  min-width: 42px;
  text-align: center;
}

/* 1920x1080 Stage Viewport */
.stage-viewport {
  background: #020617;
  border-radius: var(--radius-lg);
  border: 1px solid #1e293b;
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  user-select: none;
}

.stage-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-canvas {
  position: absolute;
  width: 1920px;
  height: 1080px;
  background-color: #0b1120;
  background-image: 
    linear-gradient(45deg, #131d33 25%, transparent 25%), 
    linear-gradient(-45deg, #131d33 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #131d33 75%), 
    linear-gradient(-45deg, transparent 75%, #131d33 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
  border: 2px dashed #64748b;
  box-shadow: 0 0 50px rgba(0,0,0,0.9);
  overflow: hidden;
}

/* High Contrast Dense Grid */
.stage-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: 40px 40px;
  background-image: 
    linear-gradient(to right, rgba(59, 130, 246, 0.45) 1.5px, transparent 1.5px),
    linear-gradient(to bottom, rgba(59, 130, 246, 0.45) 1.5px, transparent 1.5px);
  pointer-events: none;
  display: none;
}
.stage-grid.show-grid {
  display: block;
}

/* Center Crosshair Lines in Grid */
.center-crosshair-v {
  position: absolute;
  top: 0;
  left: 960px;
  width: calc(2px * var(--inv-scale, 1));
  height: 100%;
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
  opacity: 0.85;
  pointer-events: none;
}
.center-crosshair-h {
  position: absolute;
  top: 540px;
  left: 0;
  width: 100%;
  height: calc(2px * var(--inv-scale, 1));
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
  opacity: 0.85;
  pointer-events: none;
}

/* Dynamic Smart Snap Guide Lines */
.snap-guide-v {
  position: absolute;
  top: 0;
  width: calc(2px * var(--inv-scale, 1));
  height: 100%;
  background: #ec4899;
  box-shadow: 0 0 10px #ec4899;
  z-index: 10;
  display: none;
  pointer-events: none;
}
.snap-guide-h {
  position: absolute;
  left: 0;
  height: calc(2px * var(--inv-scale, 1));
  width: 100%;
  background: #ec4899;
  box-shadow: 0 0 10px #ec4899;
  z-index: 10;
  display: none;
  pointer-events: none;
}

/* Movable & Resizable Element Box */
.stage-element {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  cursor: grab;
  transform-origin: center center;
  touch-action: none;
  user-select: none;
}
.stage-element:active {
  cursor: grabbing;
}

.element-content-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  pointer-events: none;
}

.element-content-wrapper img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.empty-stage-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  gap: 12px;
  text-align: center;
  padding: 40px;
  pointer-events: none;
}
.empty-stage-placeholder i {
  font-size: 64px;
  color: #475569;
}
.empty-stage-placeholder p {
  font-size: 20px;
  font-weight: 700;
  color: #e2e8f0;
}
.empty-stage-placeholder span {
  font-size: 14px;
  color: #94a3b8;
}

/* Transform Box & Handles with Adaptive Inverse-Scale */
.transform-box {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: calc(2px * var(--inv-scale, 1)) solid #3b82f6;
  box-shadow: 0 0 0 calc(1px * var(--inv-scale, 1)) rgba(255,255,255,0.4);
  pointer-events: none;
}

.handle {
  position: absolute;
  width: calc(18px * var(--inv-scale, 1));
  height: calc(18px * var(--inv-scale, 1));
  background: #ffffff;
  border: calc(2.5px * var(--inv-scale, 1)) solid #2563eb;
  border-radius: calc(3px * var(--inv-scale, 1));
  pointer-events: auto;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  touch-action: none;
  user-select: none;
}
.handle:hover {
  background: #2563eb;
  border-color: #ffffff;
}

.handle-nw { top: calc(-9px * var(--inv-scale, 1)); left: calc(-9px * var(--inv-scale, 1)); cursor: nwse-resize; }
.handle-n  { top: calc(-9px * var(--inv-scale, 1)); left: calc(50% - (9px * var(--inv-scale, 1))); cursor: ns-resize; }
.handle-ne { top: calc(-9px * var(--inv-scale, 1)); right: calc(-9px * var(--inv-scale, 1)); cursor: nesw-resize; }
.handle-e  { top: calc(50% - (9px * var(--inv-scale, 1))); right: calc(-9px * var(--inv-scale, 1)); cursor: ew-resize; }
.handle-se { bottom: calc(-9px * var(--inv-scale, 1)); right: calc(-9px * var(--inv-scale, 1)); cursor: nwse-resize; }
.handle-s  { bottom: calc(-9px * var(--inv-scale, 1)); left: calc(50% - (9px * var(--inv-scale, 1))); cursor: ns-resize; }
.handle-sw { bottom: calc(-9px * var(--inv-scale, 1)); left: calc(-9px * var(--inv-scale, 1)); cursor: nesw-resize; }
.handle-w  { top: calc(50% - (9px * var(--inv-scale, 1))); left: calc(-9px * var(--inv-scale, 1)); cursor: ew-resize; }

.handle-rot {
  position: absolute;
  top: calc(-48px * var(--inv-scale, 1));
  left: calc(50% - (16px * var(--inv-scale, 1)));
  width: calc(32px * var(--inv-scale, 1));
  height: calc(32px * var(--inv-scale, 1));
  border: none;
  background: transparent;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}
.rot-line {
  width: calc(2px * var(--inv-scale, 1));
  height: calc(18px * var(--inv-scale, 1));
  background: #3b82f6;
}
.rot-dot {
  width: calc(26px * var(--inv-scale, 1));
  height: calc(26px * var(--inv-scale, 1));
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(12px * var(--inv-scale, 1));
  box-shadow: 0 2px 6px rgba(37,99,235,0.4);
}

.live-dimension-badge {
  position: absolute;
  bottom: calc(-36px * var(--inv-scale, 1));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: calc(13px * var(--inv-scale, 1));
  font-weight: 700;
  padding: calc(4px * var(--inv-scale, 1)) calc(10px * var(--inv-scale, 1));
  border-radius: calc(5px * var(--inv-scale, 1));
  white-space: nowrap;
  pointer-events: none;
  border: calc(1px * var(--inv-scale, 1)) solid #334155;
}

/* Toolstrip Box with Padding Control */
.stage-toolstrip-box {
  background: var(--bg-card);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.toolstrip-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}

.padding-control-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.padding-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 80px;
}
.padding-input-wrap input {
  padding: 4px 22px 4px 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.padding-input-wrap span {
  position: absolute;
  right: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.padding-chips {
  display: flex;
  gap: 4px;
}
.btn-chip {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.btn-chip:hover {
  background: #e2e8f0;
}
.btn-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
}

.toolstrip-row-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.toolstrip-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.toolstrip-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-tool {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.btn-tool:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-text);
  transform: translateY(-1px);
}

/* Presets Section */
.presets-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.presets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}
.title-with-icon i {
  color: var(--primary);
  font-size: 16px;
}
.title-with-icon h3 {
  font-size: 15px;
  font-weight: 700;
}

.preset-action-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preset-list {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.preset-chip {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}
.preset-chip:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}
.preset-chip.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-text);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--primary);
}
.preset-chip .preset-name {
  font-size: 13px;
}
.preset-chip-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.7;
}
.preset-chip:hover .preset-chip-actions {
  opacity: 1;
}
.btn-preset-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
  border-radius: 3px;
}
.btn-preset-action:hover {
  background: rgba(0,0,0,0.08);
  color: var(--text-main);
}
.btn-preset-action.delete:hover {
  color: var(--danger);
}

/* Sidebar Right */
.sidebar-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-subtle);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 13px 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--text-main);
}
.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

.tab-content {
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  max-height: calc(100vh - 150px);
}
.tab-content.active {
  display: flex;
}

/* Upload Card */
.upload-card {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 2px dashed #cbd5e1;
  padding: 16px;
  text-align: center;
  transition: all 0.2s ease;
}
.upload-card.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.dropzone-icon {
  font-size: 32px;
  color: var(--primary);
  margin-bottom: 8px;
}
.dropzone h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}
.dropzone p {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.upload-btn-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.upload-progress-container {
  margin-top: 12px;
}
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.2s ease;
}
.progress-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

/* Slideshow Bar in Image Tab */
.quick-slideshow-bar {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.slideshow-info {
  display: flex;
  flex-direction: column;
}
.status-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}
.time-tag {
  font-size: 11px;
  color: var(--text-muted);
}
.slideshow-btns {
  display: flex;
  gap: 6px;
}

/* Gallery Section */
.gallery-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.gallery-header h4 {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.gallery-filter-search input {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  width: 150px;
}
.gallery-filter-search input:focus {
  border-color: var(--primary);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.image-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.image-card:hover {
  border-color: #94a3b8;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.image-card.active-live {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
}

.image-thumb-wrap {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #0f172a;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.image-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.live-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--success);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.image-card-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.image-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.image-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.btn-rename-img {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 11px;
}
.btn-rename-img:hover {
  color: var(--primary);
}
.image-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.image-card-actions {
  padding: 6px 10px 10px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.btn-card-action {
  flex: 1;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-card-action:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-text);
}
.btn-card-action.danger:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* Form Groups & Cards */
.form-group-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-group-card h4 {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}
.form-group-card h4 i {
  color: var(--primary);
}

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.label-with-val {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.label-with-val span {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-unit input {
  width: 100%;
  padding: 8px 32px 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.input-with-unit input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.input-with-unit span {
  position: absolute;
  right: 10px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

select, input[type="text"], input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  background: #ffffff;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

/* Switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(20px);
}

.obs-guide-text {
  font-size: 12px;
  line-height: 1.8;
  color: #334155;
  background: #ffffff;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.obs-guide-text code {
  background: #eff6ff;
  color: #1d4ed8;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  width: 100%;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  animation: modal-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-pop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-sm { max-width: 440px; }
.modal-lg { max-width: 900px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}
.btn-close-modal:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-subtle);
}

/* Cropper Container */
.cropper-container-wrapper {
  width: 100%;
  height: 460px;
  background: #0f172a;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}
.cropper-container-wrapper img {
  max-width: 100%;
}

.cropper-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.crop-aspect-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.toolbar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.btn-crop-aspect {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-crop-aspect.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
}
.crop-actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slide-in-toast 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes slide-in-toast {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Responsive Layout */
.mobile-only {
  display: none;
}

@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 14px;
    padding: 10px 12px 20px;
  }
}

/* Windows Split-Screen / Half Screen Support down to 680px */
@media (max-width: 992px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 12px;
    padding: 10px 10px 20px;
  }
  .stage-toolstrip-box {
    padding: 8px 12px;
  }
  .toolstrip-row-buttons {
    gap: 6px;
  }
  .btn-tool {
    padding: 4px 6px;
    font-size: 11px;
    gap: 3px;
  }
  .tab-btn {
    padding: 10px 4px;
    font-size: 11px;
    gap: 3px;
  }
  .tab-content {
    padding: 12px;
    gap: 10px;
  }
}

/* Narrow Mobile Phones (< 680px) */
@media (max-width: 680px) {
  .main-layout {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 8px;
  }
  .sidebar-panel {
    position: static;
    max-height: none;
  }
  .tab-content {
    max-height: none;
    padding: 12px;
  }
  .mobile-only {
    display: inline-flex;
  }
  .header-container {
    padding: 8px 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .header-left, .header-right {
    justify-content: space-between;
    width: 100%;
  }
  .logo-title {
    font-size: 15px;
  }
  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  .active-preset-banner {
    padding: 8px 10px;
    gap: 8px;
  }
  .stage-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .stage-actions {
    width: 100%;
    justify-content: space-between;
  }
  .toolstrip-row-top, .toolstrip-row-buttons {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .toolstrip-buttons {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    gap: 4px;
  }
  .btn-tool {
    justify-content: center;
  }
  .cropper-container-wrapper {
    height: 300px;
  }
}
