/* ==========================================================================
   Maker Image Pro - Style System
   Professional Canva-style editor
   ========================================================================== */

/* ===== CSS CUSTOM PROPERTIES (THEME TOKENS) ===== */
:root {
  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  /* Radii */
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-xl: 16px;
  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --dur: 200ms;
  /* Font */
  --font: 'Noto Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* Layout */
  --topbar-h: 48px;
  --sidebar-w: 280px;
  --toolbar-w: 64px;
  /* Z-index */
  --z-sidebar: 10; --z-topbar: 20; --z-modal: 100; --z-context: 90; --z-drop: 80;
}

/* ----- DARK THEME (default) ----- */
[data-theme="dark"] {
  --bg-primary: #0f0f11;
  --bg-secondary: #18181b;
  --bg-tertiary: #1e1e22;
  --bg-elevated: #232328;
  --bg-hover: #2a2a30;
  --bg-active: #333338;
  --border: #2a2a30;
  --border-light: #222228;
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-muted: rgba(99,102,241,.15);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.6);
  --canvas-bg: #27272a;
  --scrollbar-bg: #1a1a1e;
  --scrollbar-thumb: #3a3a40;
}

/* ----- LIGHT THEME ----- */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-elevated: #ffffff;
  --bg-hover: #f3f4f6;
  --bg-active: #e5e7eb;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --accent: #4f46e5;
  --accent-hover: #6366f1;
  --accent-muted: rgba(79,70,229,.1);
  --danger: #dc2626;
  --danger-hover: #ef4444;
  --success: #16a34a;
  --warning: #d97706;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
  --canvas-bg: #e5e7eb;
  --scrollbar-bg: #f3f4f6;
  --scrollbar-thumb: #d1d5db;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all var(--dur) var(--ease);
  white-space: nowrap; line-height: 1.4;
  color: var(--text-primary); background: transparent;
}
.btn svg { flex-shrink: 0; }
.btn--primary {
  background: var(--accent); color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--bg-hover); }
.btn--icon { padding: 6px; }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: rgba(239,68,68,.1); }
.btn--block { width: 100%; justify-content: center; padding: 8px 14px; border: 1px solid var(--border); }
.btn--block:hover { border-color: var(--accent); color: var(--accent); }
.btn--tiny { padding: 2px 6px; font-size: 10px; }
.btn:disabled { opacity: .35; pointer-events: none; }

/* ===== INPUTS ===== */
.input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-tertiary);
  color: var(--text-primary); font-family: var(--font); font-size: 12px;
  transition: border-color var(--dur) var(--ease);
  outline: none;
}
.input:focus { border-color: var(--accent); }
.input--small { width: 80px; }
.input--tiny { width: 52px; }

select.input { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px;
}

.input-color {
  width: 28px; height: 28px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; padding: 0;
  background: none; appearance: none; -webkit-appearance: none;
}
.input-color::-webkit-color-swatch-wrapper { padding: 0; }
.input-color::-webkit-color-swatch { border: none; border-radius: 2px; }

.input-range {
  -webkit-appearance: none; width: 100%; height: 4px;
  border-radius: 2px; background: var(--border); outline: none; cursor: pointer;
}
.input-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-primary);
  box-shadow: var(--shadow-sm); cursor: pointer;
}
.input-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-primary); cursor: pointer;
}

.input-file {
  width: 100%; padding: 6px; border: 1px dashed var(--border);
  border-radius: var(--radius-sm); background: var(--bg-tertiary);
  font-size: 11px; color: var(--text-secondary); cursor: pointer;
}
.input-file:hover { border-color: var(--accent); }

.color-input-wrap {
  display: flex; align-items: center; gap: 6px;
}

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

.checkbox-label {
  display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer;
}

/* ===== TOPBAR ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h); z-index: var(--z-topbar);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-3);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  transition: background var(--dur) var(--ease);
}
.topbar__left, .topbar__center, .topbar__right {
  display: flex; align-items: center; gap: var(--sp-2);
}
.topbar__logo {
  display: flex; align-items: center; gap: var(--sp-2);
  padding-right: var(--sp-3); margin-right: var(--sp-2);
  border-right: 1px solid var(--border);
}
.topbar__title { font-size: 14px; font-weight: 400; color: var(--text-secondary); }
.topbar__title strong { color: var(--text-primary); font-weight: 600; }
.topbar__sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.topbar__zoom { display: flex; align-items: center; gap: 2px; }
.topbar__zoom-label {
  font-size: 11px; font-weight: 500; color: var(--text-secondary);
  min-width: 40px; text-align: center;
}
.topbar__file-actions { display: flex; gap: 2px; }

/* ===== EDITOR LAYOUT ===== */
.editor {
  display: flex;
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
}

/* ===== LEFT SIDEBAR ===== */
.sidebar--left {
  width: var(--toolbar-w);
  min-width: var(--toolbar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: var(--z-sidebar);
  transition: background var(--dur) var(--ease), width var(--dur) var(--ease);
  overflow: visible;
  position: relative;
}
[dir="rtl"] .sidebar--left {
  border-right: none;
  border-left: 1px solid var(--border);
}

.toolbar {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--sp-2) 0; gap: 2px;
}
.toolbar__btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 8px 4px; width: 56px;
  border: none; border-radius: var(--radius-md);
  background: transparent; color: var(--text-secondary);
  cursor: pointer; font-size: 9px; font-family: var(--font);
  transition: all var(--dur) var(--ease);
}
.toolbar__btn svg { color: var(--text-secondary); transition: color var(--dur) var(--ease); }
.toolbar__btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.toolbar__btn:hover svg { color: var(--text-primary); }
.toolbar__btn.active { background: var(--accent-muted); color: var(--accent); }
.toolbar__btn.active svg { color: var(--accent); }
.toolbar__sep { width: 36px; height: 1px; background: var(--border); margin: 4px 0; }

/* Tool sub-panel */
.tool-panel {
  position: absolute; left: var(--toolbar-w); top: 0;
  width: 220px; height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: var(--sp-3);
  overflow-y: auto;
  z-index: var(--z-sidebar);
  animation: slideInLeft .2s var(--ease);
}
[dir="rtl"] .tool-panel {
  left: auto; right: var(--toolbar-w);
  border-right: none;
  border-left: 1px solid var(--border);
  animation: slideInRight .2s var(--ease);
}
.tool-panel__title { font-size: 12px; font-weight: 600; margin-bottom: var(--sp-3); color: var(--text-primary); }
.tool-panel__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.tool-panel__section { margin-top: var(--sp-3); }
.tool-panel__section label { display: block; font-size: 11px; color: var(--text-secondary); margin-bottom: var(--sp-1); }

.shape-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-tertiary); color: var(--text-secondary);
  cursor: pointer; transition: all var(--dur) var(--ease);
}
.shape-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }

/* ===== CANVAS AREA ===== */
.canvas-area {
  flex: 1; position: relative;
  background: var(--canvas-bg);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur) var(--ease);
}

.canvas-wrapper {
  position: relative;
  box-shadow: var(--shadow-lg);
  transition: transform .1s linear;
}

/* Checkerboard pattern for transparent canvas */
.canvas-wrapper.transparent {
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.canvas-info {
  position: absolute; bottom: 12px; left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px; border-radius: 20px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  font-size: 10px; color: var(--text-tertiary);
  pointer-events: none; opacity: .7;
}

/* Drop overlay */
.drop-overlay {
  position: absolute; inset: 0;
  background: rgba(99,102,241,.12);
  border: 3px dashed var(--accent);
  display: none; align-items: center; justify-content: center;
  z-index: var(--z-drop);
  backdrop-filter: blur(4px);
}
.drop-overlay.active { display: flex; }
.drop-overlay__content {
  text-align: center; color: var(--accent);
}
.drop-overlay__content svg { margin-bottom: 8px; color: var(--accent); }
.drop-overlay__content p { font-size: 16px; font-weight: 600; }

/* ===== RIGHT SIDEBAR ===== */
.sidebar--right {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: var(--z-sidebar);
  transition: background var(--dur) var(--ease);
  overflow: hidden;
}
[dir="rtl"] .sidebar--right {
  border-left: none;
  border-right: 1px solid var(--border);
}

.sidebar-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1; padding: 10px 8px;
  border: none; background: transparent;
  color: var(--text-secondary); font-size: 11px; font-weight: 500;
  font-family: var(--font); cursor: pointer;
  transition: all var(--dur) var(--ease);
  border-bottom: 2px solid transparent;
}
.sidebar-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.sidebar-content {
  flex: 1; overflow-y: auto; padding: var(--sp-3);
}

/* Properties sections */
.props-section { margin-bottom: var(--sp-4); }
.props-section__title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-tertiary);
  margin-bottom: var(--sp-3); padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.props-hint { font-size: 11px; color: var(--text-tertiary); font-style: italic; }

.props-row {
  margin-bottom: var(--sp-3);
}
.props-row > label {
  display: block; font-size: 11px; color: var(--text-secondary);
  margin-bottom: var(--sp-1); font-weight: 500;
}
.props-row--half {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2);
}
.props-row--half > div > label {
  display: block; font-size: 10px; color: var(--text-tertiary);
  margin-bottom: 2px;
}
.props-row--actions {
  display: flex; gap: 2px; flex-wrap: wrap;
}

/* Presets grid */
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.preset-grid--small { grid-template-columns: 1fr 1fr 1fr 1fr; }
.preset-btn {
  padding: 8px 6px; border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--bg-tertiary);
  color: var(--text-secondary); font-size: 10px; font-family: var(--font);
  cursor: pointer; text-align: center; line-height: 1.4;
  transition: all var(--dur) var(--ease);
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }
.preset-btn small { color: var(--text-tertiary); font-size: 9px; }
.preset-btn--small { padding: 6px 4px; font-size: 9px; }

/* ===== LAYERS PANEL ===== */
.layers-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-3); padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.layers-header h4 { font-size: 12px; font-weight: 600; }
.layers-header__actions { display: flex; gap: 2px; }

.layers-list { list-style: none; }
.layer-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--dur) var(--ease);
  margin-bottom: 2px;
  font-size: 11px; color: var(--text-secondary);
}
.layer-item:hover { background: var(--bg-hover); }
.layer-item.active { background: var(--accent-muted); border-color: var(--accent); color: var(--accent); }
.layer-item.sortable-ghost { opacity: .4; }
.layer-item.sortable-drag { background: var(--bg-elevated); box-shadow: var(--shadow-md); }

.layer-item__preview {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--bg-tertiary); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; overflow: hidden; flex-shrink: 0;
}
.layer-item__preview img { width: 100%; height: 100%; object-fit: cover; }

.layer-item__name {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.layer-item__name input {
  width: 100%; border: none; background: transparent;
  color: inherit; font: inherit; outline: none;
  padding: 0;
}

.layer-item__actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity var(--dur) var(--ease); }
.layer-item:hover .layer-item__actions { opacity: 1; }

.layer-btn {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: none; border-radius: 3px;
  background: transparent; color: var(--text-tertiary);
  cursor: pointer; font-size: 10px; padding: 0;
  transition: all var(--dur) var(--ease);
}
.layer-btn:hover { background: var(--bg-active); color: var(--text-primary); }
.layer-btn.active { color: var(--accent); }
.layer-btn--danger:hover { color: var(--danger); }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal);
  backdrop-filter: blur(4px);
  animation: fadeIn .2s var(--ease);
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 420px; max-width: 90vw;
  animation: scaleIn .25s var(--ease);
}
.modal--large { width: 700px; max-height: 80vh; }
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4); border-bottom: 1px solid var(--border);
}
.modal__header h3 { font-size: 15px; font-weight: 600; }
.modal__close { font-size: 20px; line-height: 1; }
.modal__body { padding: var(--sp-4); max-height: 60vh; overflow-y: auto; }
.modal__body--crop { padding: 0; display: flex; align-items: center; justify-content: center; background: #000; min-height: 300px; }
.modal__body--crop img { max-width: 100%; max-height: 50vh; display: block; }
.modal__footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border);
}

/* ===== CONTEXT MENU ===== */
.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px; min-width: 180px;
  z-index: var(--z-context);
  animation: scaleIn .15s var(--ease);
}
.context-menu__item {
  display: block; width: 100%; padding: 7px 12px;
  border: none; background: transparent;
  color: var(--text-primary); font-size: 12px; font-family: var(--font);
  text-align: start; cursor: pointer; border-radius: var(--radius-sm);
  transition: background var(--dur) var(--ease);
}
.context-menu__item:hover { background: var(--bg-hover); }
.context-menu__item--danger { color: var(--danger); }
.context-menu__item--danger:hover { background: rgba(239,68,68,.1); }
.context-menu__sep { height: 1px; background: var(--border); margin: 3px 8px; }

/* ===== SNAPPING GUIDES ===== */
.snap-guide-h, .snap-guide-v {
  position: absolute; background: var(--accent); z-index: 5; pointer-events: none;
}
.snap-guide-h { height: 1px; left: 0; right: 0; }
.snap-guide-v { width: 1px; top: 0; bottom: 0; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }

/* ===== FABRIC.JS CANVAS OVERRIDES ===== */
.canvas-container { position: relative !important; }
.upper-canvas { cursor: default !important; }

/* ===== TOASTIFY CUSTOMIZATION ===== */
.toastify {
  font-family: var(--font) !important;
  font-size: 12px !important;
  border-radius: var(--radius-md) !important;
  padding: 10px 36px 10px 16px !important;
  box-shadow: var(--shadow-md) !important;
  cursor: default !important;
  max-width: 360px !important;
}
[dir="rtl"] .toastify {
  padding: 10px 16px 10px 36px !important;
}
.toastify .toast-close {
  color: rgba(255,255,255,.7) !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  padding: 0 8px !important;
  opacity: 1 !important;
}
.toastify .toast-close:hover { color: #fff !important; }

/* ===== CROPPER.JS OVERRIDES ===== */
.cropper-container { font-size: 0 !important; }
.cropper-modal { background: rgba(0,0,0,.7) !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .sidebar--right { width: 240px; min-width: 240px; }
  .topbar__file-actions span { display: none; }
  .topbar__title { display: none; }
}

@media (max-width: 768px) {
  .sidebar--right { 
    position: fixed; right: -280px; top: var(--topbar-h); bottom: 0;
    width: 280px; transition: right .3s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar--right.open { right: 0; }
  [dir="rtl"] .sidebar--right {
    right: auto; left: -280px;
    transition: left .3s var(--ease);
  }
  [dir="rtl"] .sidebar--right.open { left: 0; }
  .sidebar--left { width: 48px; min-width: 48px; }
  .toolbar__btn span { display: none; }
  .toolbar__btn { width: 40px; padding: 8px 4px; }
  .tool-panel { width: 200px; }
  .topbar__center { display: none; }
}

@media (max-width: 480px) {
  .sidebar--left { 
    position: fixed; bottom: 0; left: 0; right: 0;
    width: 100% !important; height: 56px; min-width: auto;
    flex-direction: row; border-right: none; border-top: 1px solid var(--border);
  }
  [dir="rtl"] .sidebar--left { border-left: none; }
  .toolbar { flex-direction: row; overflow-x: auto; padding: 0 var(--sp-2); }
  .toolbar__sep { width: 1px; height: 24px; margin: 0 4px; }
  .tool-panel { 
    position: fixed; left: 0; bottom: 56px; width: 100%; height: auto;
    max-height: 50vh; border-right: none; border-top: 1px solid var(--border);
  }
  [dir="rtl"] .tool-panel { left: 0; right: 0; border-left: none; }
  .canvas-area { padding-bottom: 56px; }
}

/* ===== UTILITY ===== */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* ===== ACCENT BLOCK BUTTON ===== */
.btn--accent {
  background: var(--accent); color: #fff; border: none;
}
.btn--accent:hover { background: var(--accent-hover); }
.btn--accent.btn--block { border: none; }
.btn--accent.btn--block:hover { color: #fff; }

/* ===== AI PROCESSING OVERLAY ===== */
.ai-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: calc(var(--z-modal) + 10);
  backdrop-filter: blur(6px);
  animation: fadeIn .25s var(--ease);
}
.ai-overlay__card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 44px;
  text-align: center;
  max-width: 380px; width: 90vw;
  animation: scaleIn .3s var(--ease);
}
.ai-overlay__spinner {
  margin-bottom: 18px;
  display: flex; justify-content: center;
}
.ai-overlay__title {
  font-size: 16px; font-weight: 600; margin-bottom: 6px;
  color: var(--text-primary);
}
.ai-overlay__desc {
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 18px; line-height: 1.5;
}
.ai-overlay__progress {
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--bg-tertiary); overflow: hidden;
  margin-bottom: 8px;
}
.ai-overlay__progress-bar {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width .3s var(--ease);
}
.ai-overlay__percent {
  font-size: 11px; font-weight: 600; color: var(--accent);
}

/* Snapping alignment guide styles (drawn on canvas via Fabric, but these are fallback) */
.alignment-guide {
  position: absolute; z-index: 999; pointer-events: none;
}
.alignment-guide--h { height: 1px; background: #6366f1; left: 0; right: 0; }
.alignment-guide--v { width: 1px; background: #6366f1; top: 0; bottom: 0; }

/* ============ FLOATING DELETE BUTTON ============ */
.floating-delete-btn {
  position: absolute;
  z-index: 100;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .15s var(--ease), background .15s;
  pointer-events: auto;
}
.floating-delete-btn:hover { background: #dc2626; transform: scale(1.15); }
.floating-delete-btn:active { transform: scale(0.95); }

/* ============ FLOATING ACTION BAR ============ */
.floating-action-bar {
  position: absolute;
  z-index: 100;
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  pointer-events: auto;
}
.fab-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.fab-btn:hover { background: var(--bg-secondary); }
.fab-btn--danger { color: #ef4444; }
.fab-btn--danger:hover { background: #fef2f2; color: #dc2626; }
[data-theme="dark"] .fab-btn--danger:hover { background: #451a1a; }

/* ============ TEXT PRESETS ============ */
.text-presets {
  display: flex; flex-wrap: wrap; gap: 4px; width: 100%;
}
.btn--preset {
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  font-weight: 500; white-space: nowrap;
  border: 1px solid var(--border);
  transition: all .15s;
}
.btn--preset:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============ RANGE WITH VALUE DISPLAY ============ */
.range-with-value {
  display: flex; align-items: center; gap: 8px; width: 100%;
}
.range-with-value .input-range { flex: 1; }
.range-value {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  min-width: 36px; text-align: right;
}
[dir="rtl"] .range-value { text-align: left; }

/* ============ GRADIENT CONTROLS ============ */
.gradient-controls {
  display: flex; align-items: center; gap: 4px; width: 100%; flex-wrap: wrap;
}
.gradient-controls .input-color { width: 28px; height: 28px; flex-shrink: 0; }
.gradient-controls .input--small { flex: 1; min-width: 80px; }

/* ============ RTL DIRECTION TOGGLE ============ */
#textDirRTL.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* ============ ANIMATION TOOL PANEL ============ */
.tool-panel--animate {
  width: 300px;
  padding: var(--sp-3) var(--sp-3) var(--sp-4);
}

.anim-section {
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-light);
}
.anim-section:last-of-type { border-bottom: none; }

.anim-section__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-2);
}

.anim-label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-primary); margin-bottom: var(--sp-1);
  letter-spacing: 0.02em;
}

.anim-hint {
  font-size: 10px; color: var(--text-tertiary);
  margin-bottom: var(--sp-2); line-height: 1.4;
}

.anim-layer-actions {
  display: flex; gap: 4px;
}
.anim-layer-actions .btn--tiny {
  font-size: 10px; padding: 2px 6px;
}

/* Layers list in animation panel */
.anim-layers-list {
  list-style: none; padding: 0; margin: 0;
  max-height: 140px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}
.anim-layers-list::-webkit-scrollbar { width: 4px; }
.anim-layers-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.anim-layer-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; font-size: 11px; color: var(--text-secondary);
  cursor: pointer; transition: background var(--dur) var(--ease);
  border-bottom: 1px solid var(--border-light);
}
.anim-layer-item:last-child { border-bottom: none; }
.anim-layer-item:hover { background: var(--bg-hover); }
.anim-layer-item.selected { background: var(--accent-muted); color: var(--accent); }
.anim-layer-item input[type="checkbox"] { flex-shrink: 0; }
.anim-layer-item__name {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.anim-layer-item__badge {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg-hover); color: var(--text-tertiary);
}

/* Animation rows */
.anim-row { margin-bottom: var(--sp-2); }
.anim-row:last-child { margin-bottom: 0; }
.anim-row--half { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }

.anim-field { display: flex; flex-direction: column; gap: 2px; }
.anim-field__label {
  font-size: 10px; color: var(--text-tertiary); font-weight: 500;
}
.anim-field__input {
  display: flex; align-items: center; gap: 6px;
}
.anim-field__input .input-range { flex: 1; }
.anim-field__value {
  font-size: 10px; font-weight: 600; color: var(--text-secondary);
  min-width: 42px; text-align: center;
  background: var(--bg-tertiary); padding: 2px 4px;
  border-radius: var(--radius-sm);
}

/* Preview area */
.anim-preview {
  width: 100%; aspect-ratio: 16/10;
  background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.anim-preview img {
  max-width: 100%; max-height: 100%; object-fit: contain;
}
.anim-preview__hint {
  font-size: 11px; color: var(--text-tertiary); text-align: center; padding: 12px;
}
.anim-preview__info {
  display: flex; gap: var(--sp-2); flex-wrap: wrap;
  margin-top: var(--sp-1); padding: 4px 0;
}
.anim-preview__info span {
  font-size: 10px; color: var(--text-tertiary);
  background: var(--bg-tertiary); padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Actions bar */
.anim-actions {
  display: flex; gap: var(--sp-2); padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.anim-actions .btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; }
.anim-actions .btn svg { flex-shrink: 0; }

/* Per-layer controls */
.anim-per-layer-card {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px;
  margin-bottom: var(--sp-2);
}
.anim-per-layer-card__header {
  font-size: 11px; font-weight: 600; color: var(--text-primary);
  margin-bottom: 6px; display: flex; align-items: center; gap: 4px;
}
.anim-per-layer-card select { font-size: 11px; padding: 3px 6px; }

/* ==========================================================================
   ABOUT MODAL
   ========================================================================== */
.about-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: aboutOverlayIn .25s ease;
}
@keyframes aboutOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.about-modal {
  position: relative;
  width: 360px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  animation: aboutModalIn .3s cubic-bezier(.22, .61, .36, 1);
}
@keyframes aboutModalIn {
  from { opacity: 0; transform: scale(.9) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.about-modal__close {
  position: absolute;
  top: 12px;
  left: 14px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-tertiary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.about-modal__close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.about-modal__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000));
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}
.about-modal__name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.about-modal__version {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0 0 16px;
}
.about-modal__desc {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin: 0 0 18px;
}
.about-modal__dev {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.about-modal__dev span {
  font-size: 11px;
  color: var(--text-tertiary);
}
.about-modal__dev strong {
  font-size: 16px;
  color: var(--accent);
  font-weight: 700;
}
.about-modal__credits {
  margin-bottom: 16px;
}
.about-modal__credits-title {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}
.about-modal__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.about-modal__tags span {
  display: inline-block;
  font-size: 11px;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  transition: border-color .15s;
}
.about-modal__tags span:hover {
  border-color: var(--accent);
}
.about-modal__license {
  font-size: 11px;
  color: var(--text-tertiary);
  margin: 0;
}
