/* ============================================================
   ImageConvert Pro — Refined Design System
   Clean · Modern · Precise
   ============================================================ */

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

:root {
  /* Surfaces */
  --bg: #090b10;
  --bg-elevated: #0f131a;
  --bg-card: #161b26;
  --bg-hover: #1c2333;
  --bg-active: #222b3d;

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(99, 102, 241, 0.5);

  /* Text */
  --text: #f0f2f7;
  --text-secondary: #a0a8b8;
  --text-muted: #6b7385;

  /* Brand */
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.12);
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent: #22d3ee;

  /* Semantic */
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;

  /* Geometry */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --radius-full: 999px;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.45);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  line-height: 1.5;
  overflow: hidden;
}

/* Ambient glow */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% -5%, rgba(99, 102, 241, 0.12), transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 105%, rgba(34, 211, 238, 0.07), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow: hidden;
}

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.15rem 0;
  flex-shrink: 0;
  animation: fadeSlideDown 0.45s ease;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 50%, var(--accent) 100%);
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 2px 12px var(--primary-glow);
  flex-shrink: 0;
}
.logo-icon svg { width: 18px; height: 18px; }

.logo h1 {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.logo h1 span {
  background: linear-gradient(105deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo p {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 450;
  letter-spacing: 0.01em;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.25rem;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.btn-ghost:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-ghost.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

/* ─── Upload ─── */
.upload-section {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeScale 0.4s ease;
  overflow: hidden;
}

.upload-zone {
  width: 100%;
  max-width: 520px;
  background: var(--bg-elevated);
  border: 1.5px dashed var(--border-strong);
  border-radius: 20px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-slow);
  position: relative;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px var(--primary-glow);
}

.upload-visual {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 1.25rem;
}
.upload-circle {
  width: 80px;
  height: 80px;
  background: var(--primary-soft);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary-hover);
  position: relative;
  z-index: 2;
}
.upload-circle svg { width: 32px; height: 32px; }

.pulse-ring {
  position: absolute;
  inset: -4px;
  border: 1.5px solid var(--primary);
  border-radius: 50%;
  opacity: 0;
  animation: pulse 2.8s ease-out infinite;
}
.pulse-ring.delay { animation-delay: 1.4s; }

@keyframes pulse {
  0% { transform: scale(0.92); opacity: 0.5; }
  100% { transform: scale(1.55); opacity: 0; }
}

.upload-zone h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}
.upload-zone p {
  color: var(--text-muted);
  margin-bottom: 1.35rem;
  font-size: 0.85rem;
}

.supported-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}
.supported-formats span {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-xs);
  font-size: 0.65rem;
  font-weight: 550;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  transition: var(--transition);
}
.upload-zone:hover .supported-formats span {
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--primary-hover);
}

/* ─── Editor Layout ─── */
.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  animation: fadeSlideUp 0.35s ease;
  overflow: hidden;
}
.editor-section.hidden { display: none; }

.editor-layout {
  display: grid;
  grid-template-columns: 168px 1fr 292px;
  gap: 0.65rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── Queue Panel ─── */
.queue-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.queue-header span span {
  color: var(--primary-hover);
  font-variant-numeric: tabular-nums;
}

.btn-tiny {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-xs);
  font-weight: 500;
  transition: var(--transition);
}
.btn-tiny:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.queue-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.queue-item:hover { background: var(--bg-hover); }
.queue-item.active {
  border-color: rgba(99, 102, 241, 0.35);
  background: var(--primary-soft);
}

.queue-thumb {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--bg-card);
  flex-shrink: 0;
}

.queue-info { flex: 1; min-width: 0; }
.queue-info .q-name {
  font-size: 0.7rem;
  font-weight: 520;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-info .q-meta {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.queue-item .q-remove {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  transition: var(--transition);
  flex-shrink: 0;
}
.queue-item:hover .q-remove { opacity: 1; }
.queue-item .q-remove:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.12);
}

/* ─── Preview Panel ─── */
.preview-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.file-name {
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.preview-actions {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.tool-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition);
}
.tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}
.tool-btn.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-color: rgba(99, 102, 241, 0.3);
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background:
    linear-gradient(45deg, #12161f 25%, transparent 25%),
    linear-gradient(-45deg, #12161f 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #12161f 75%),
    linear-gradient(-45deg, transparent 75%, #12161f 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #0c0f15;
  overflow: hidden;
  position: relative;
}

.canvas-wrapper > img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
}

/* Comparison */
.compare-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  user-select: none;
}
.compare-container.hidden { display: none; }

.compare-img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.compare-after {
  position: absolute;
  top: 0; left: 0;
  width: 50%;
  height: 100%;
  overflow: hidden;
}

.compare-slider {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  cursor: ew-resize;
  z-index: 10;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
}

.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}
.compare-handle::before,
.compare-handle::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border-style: solid;
}
.compare-handle::before {
  left: 7px;
  border-width: 4px 5px 4px 0;
  border-color: transparent #333 transparent transparent;
}
.compare-handle::after {
  right: 7px;
  border-width: 4px 0 4px 5px;
  border-color: transparent transparent transparent #333;
}

.crop-controls {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--border);
  justify-content: center;
}
.crop-controls.hidden { display: none; }

/* ─── Tools Panel ─── */
.tools-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.tools-tabs {
  display: flex;
  gap: 0.15rem;
  padding: 0.4rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
  overflow-x: auto;
  scrollbar-width: none;
}
.tools-tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 550;
  cursor: pointer;
  transition: var(--transition);
  border-radius: var(--radius-xs);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.tab:hover { color: var(--text-secondary); background: var(--bg-hover); }
.tab.active {
  color: var(--text);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  flex-direction: column;
  gap: 0.9rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.tab-content.active { display: flex; }

.section-title {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

/* Format Grid */
.format-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
}

.format-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.35rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  font-family: inherit;
  color: var(--text);
}
.format-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.format-card.active {
  border-color: rgba(99, 102, 241, 0.45);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.15);
}
.format-ext {
  font-weight: 650;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.format-desc {
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* Sliders */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  outline: none;
  border: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--primary-soft), 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.quality-section .section-title span,
.adjust-header span:last-child {
  color: var(--primary-hover);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.target-size-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}
.target-size-row input,
.target-size-row select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.45rem 0.55rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  transition: var(--transition);
}
.target-size-row input { flex: 1; }
.target-size-row input:focus,
.target-size-row select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.resize-inputs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}
.input-group { flex: 1; }
.input-group.full { width: 100%; }
.input-group label {
  display: block;
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
  font-weight: 500;
}
.input-group input,
.input-group input[type="text"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.45rem 0.55rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  transition: var(--transition);
}
.input-group input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.link-icon {
  color: var(--text-muted);
  margin-top: 0.85rem;
  opacity: 0.6;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 450;
}
.checkbox input {
  accent-color: var(--primary);
  width: 13px;
  height: 13px;
}

/* Buttons */
.btn-convert {
  margin-top: auto;
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: var(--transition);
  box-shadow: 0 2px 12px var(--primary-glow);
  position: relative;
  overflow: hidden;
  letter-spacing: -0.01em;
}
.btn-convert::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}
.btn-convert:hover::before { transform: translateX(100%); }
.btn-convert:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-convert:active { transform: translateY(0); }
.btn-convert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.8rem;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-weight: 520;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.8rem;
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary.full { width: 100%; }

.btn-loader.hidden { display: none; }
.spinner {
  width: 18px;
  height: 18px;
  animation: spin 0.75s linear infinite;
}
.spinner.large {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Edit Tools */
.edit-tools {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
}
.edit-tool {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 500;
  transition: var(--transition);
}
.edit-tool:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: var(--bg-hover);
}
.edit-tool.active {
  border-color: rgba(99, 102, 241, 0.4);
  background: var(--primary-soft);
  color: var(--primary-hover);
}
.edit-tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Adjust */
.adjust-group { margin-bottom: 0.15rem; }
.adjust-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
  color: var(--text-secondary);
  font-weight: 450;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.4rem 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.color-row input[type="color"] {
  width: 32px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  padding: 1px;
}

.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
}
.pos-grid button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.4rem;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}
.pos-grid button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.pos-grid button.active {
  border-color: rgba(99, 102, 241, 0.4);
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.btn-row {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.3rem;
}
.btn-row .btn-secondary {
  padding: 0.4rem 0.3rem;
  font-size: 0.72rem;
  flex: 1;
}

/* Output extras */
.preset-checks {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.social-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}
.social-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.35rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.08rem;
  font-family: inherit;
  color: var(--text);
  text-align: center;
}
.social-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
  background: var(--bg-hover);
}
.social-card .s-name {
  font-weight: 580;
  font-size: 0.68rem;
}
.social-card .s-size {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Footer */
.footer {
  text-align: center;
  padding: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-weight: 520;
  font-size: 0.8rem;
  z-index: 1000;
  opacity: 0;
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  backdrop-filter: blur(12px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: rgba(52, 211, 153, 0.35); }
.toast.error { border-color: rgba(248, 113, 113, 0.35); }

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(6px);
}
.overlay.hidden { display: none; }
.overlay-content { text-align: center; color: var(--text); }
.overlay-content p {
  margin-top: 0.85rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Light theme */
body.light {
  --bg: #f5f6f9;
  --bg-elevated: #ffffff;
  --bg-card: #f0f1f5;
  --bg-hover: #e6e8ef;
  --bg-active: #dfe2ea;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.1);
  --text: #1a1d27;
  --text-secondary: #4a5160;
  --text-muted: #8a919e;
  --primary-soft: rgba(99, 102, 241, 0.08);
  --primary-glow: rgba(99, 102, 241, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.1);
}
body.light::before {
  background:
    radial-gradient(ellipse 70% 50% at 15% -5%, rgba(99, 102, 241, 0.06), transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 105%, rgba(34, 211, 238, 0.04), transparent 55%);
}
body.light .canvas-wrapper {
  background-color: #e8eaef;
  background-image:
    linear-gradient(45deg, #dde0e8 25%, transparent 25%),
    linear-gradient(-45deg, #dde0e8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dde0e8 75%),
    linear-gradient(-45deg, transparent 75%, #dde0e8 75%);
}
body.light .header-actions {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
body.light .tab.active {
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}
.modal-box {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: min(400px, 92vw);
  max-height: 78vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: fadeScale 0.22s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-close {
  width: 30px;
  height: 30px;
  font-size: 1.2rem;
  line-height: 1;
}
.modal-body {
  padding: 0.9rem 1.1rem;
  overflow-y: auto;
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.sc-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.sc-row span {
  margin-left: auto;
  color: var(--text-secondary);
  font-weight: 450;
}
kbd {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.12rem 0.35rem;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 1px 0 var(--border);
}

.preset-save-row {
  display: flex;
  gap: 0.4rem;
}
.preset-save-row input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.5rem 0.65rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
}
.presets-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 36px;
}
.preset-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.preset-item:hover {
  border-color: rgba(99, 102, 241, 0.3);
  background: var(--bg-hover);
}
.preset-item .pi-name { flex: 1; font-weight: 520; }
.preset-item .pi-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.preset-item .pi-del {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0 0.2rem;
  border-radius: 4px;
}
.preset-item .pi-del:hover { color: var(--danger); }
.empty-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.4rem 0;
}

/* Animations */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.hidden { display: none !important; }

/* Cropper */
.cropper-view-box, .cropper-face { border-radius: 0; }
.cropper-modal { background: rgba(0, 0, 0, 0.5); }

/* Responsive */
@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: 150px 1fr 260px; }
}
@media (max-width: 850px) {
  .editor-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 120px 1fr minmax(220px, 38%);
  }
  .queue-panel { max-height: none; }
  .queue-list { flex-direction: row; overflow-x: auto; }
  .header-actions { gap: 0.15rem; padding: 0.2rem; }
  .btn-ghost { width: 30px; height: 30px; }
}
@media (max-width: 500px) {
  .app { padding: 0.65rem; }
  .format-grid, .edit-tools, .social-grid { grid-template-columns: 1fr 1fr; }
  .logo h1 { font-size: 1rem; }
  .logo p { display: none; }
}


/* Queue footer — keeps Convert All inside the panel */
.queue-footer {
  padding: 0.55rem 0.55rem 0.65rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-batch {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--primary-soft);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: var(--radius-sm);
  color: var(--primary-hover);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: -0.01em;
}
.btn-batch:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--text);
}
.btn-batch:active {
  transform: scale(0.98);
}

/* ─── Queue item progress ─── */
.queue-item {
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  padding: 0.4rem;
}
.queue-item .q-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.q-progress {
  height: 3px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.q-progress.is-converting,
.q-progress.is-done,
.q-progress.is-error {
  opacity: 1;
}

.q-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--primary);
  transition: width 0.25s ease;
}
.q-progress.is-converting .q-progress-bar {
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.q-progress.is-converting .q-progress-bar.indeterminate {
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary));
  background-size: 200% 100%;
  animation: progressShimmer 1.1s ease infinite;
}
.q-progress.is-done .q-progress-bar {
  background: var(--success);
}
.q-progress.is-error .q-progress-bar {
  background: var(--danger);
}

@keyframes progressShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.q-status-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
}
.q-status-icon[data-status="converting"] {
  opacity: 1;
  border: 1.5px solid var(--primary);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
.q-status-icon[data-status="done"] {
  opacity: 1;
  background: var(--success);
  position: relative;
}
.q-status-icon[data-status="done"]::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid #0a0c10;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.q-status-icon[data-status="error"] {
  opacity: 1;
  background: var(--danger);
}
