/* ==========================================================================
   ShapeMyImage — Premium Minimalist Design System
   Color Identity: Monochrome Black & White with Auto/Manual Light & Dark Themes
   Responsive: Mobile-First across Desktop, Tablet, and Mobile
   ========================================================================== */

/* Dark Theme Design Tokens (Default) */
:root, [data-theme="dark"] {
  --bg-main: #09090b;
  --bg-secondary: #121215;
  --bg-surface: #18181b;
  --bg-card: #18181b;
  --bg-surface-hover: #222226;
  --bg-surface-active: #2a2a30;

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-inverse: #09090b;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.10);
  --border-focus: rgba(255, 255, 255, 0.35);
  --border-active: #f4f4f5;

  --checker-1: #141416;
  --checker-2: #1e1e22;
  --canvas-bg: #0c0c0e;

  --btn-primary-bg: #f4f4f5;
  --btn-primary-text: #09090b;
  --btn-secondary-bg: #18181b;
  --btn-secondary-border: #27272a;
  --btn-secondary-text: #f4f4f5;

  --slider-track: #27272a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.7);
  --header-bg: rgba(9, 9, 11, 0.85);

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 250ms cubic-bezier(0.16, 1, 0.3, 1);

  --max-content-width: 1240px;
  --header-height: 60px;
}

/* Light Theme Design Tokens — Apple Style Refined Aesthetics */
[data-theme="light"] {
  --bg-main: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-surface-hover: #f5f5f7;
  --bg-surface-active: #e5e5ea;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  --text-inverse: #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.05);
  --border-default: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(0, 0, 0, 0.28);
  --border-active: #000000;

  --checker-1: #e5e5ea;
  --checker-2: #ffffff;
  --canvas-bg: #e5e5ea;

  --btn-primary-bg: #000000;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #f5f5f7;
  --btn-secondary-border: #d2d2d7;
  --btn-secondary-text: #1d1d1f;

  --slider-track: #d2d2d7;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.09);
  --header-bg: rgba(245, 245, 247, 0.85);
}

/* Automatic System Light Preference (when user hasn't explicitly set theme) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-main: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-surface-hover: #f5f5f7;
    --bg-surface-active: #e5e5ea;

    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;
    --text-inverse: #ffffff;

    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-default: rgba(0, 0, 0, 0.08);
    --border-focus: rgba(0, 0, 0, 0.28);
    --border-active: #000000;

    --checker-1: #e5e5ea;
    --checker-2: #ffffff;
    --canvas-bg: #e5e5ea;

    --btn-primary-bg: #000000;
    --btn-primary-text: #ffffff;
    --btn-secondary-bg: #f5f5f7;
    --btn-secondary-border: #d2d2d7;
    --btn-secondary-text: #1d1d1f;

    --slider-track: #d2d2d7;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.09);
    --header-bg: rgba(245, 245, 247, 0.85);
  }
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

/* Accessibility: Focus visible */
:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 3px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: var(--max-content-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(16px, 4vw, 28px);
  padding-right: clamp(16px, 4vw, 28px);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.25;
}

p {
  color: var(--text-secondary);
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  transition: opacity var(--transition-fast);
}

.brand-logo:hover {
  opacity: 0.85;
}

.brand-icon {
  flex-shrink: 0;
}

.brand-name {
  color: var(--text-primary);
}

.site-nav {
  display: none;
}

@media (min-width: 768px) {
  .site-nav {
    display: block;
  }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
  padding: 6px 0;
}

.nav-link:hover {
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Theme Toggle Button */
.btn-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-theme-toggle:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* Show correct icon based on active theme */
:root .theme-icon-sun,
[data-theme="dark"] .theme-icon-sun {
  display: block;
}
:root .theme-icon-moon,
[data-theme="dark"] .theme-icon-moon {
  display: none;
}

[data-theme="light"] .theme-icon-sun {
  display: none;
}
[data-theme="light"] .theme-icon-moon {
  display: block;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-icon-sun {
    display: none;
  }
  :root:not([data-theme="dark"]) .theme-icon-moon {
    display: block;
  }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  padding: 9px 16px;
  min-height: 42px;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation;
}

.btn-primary {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border-color: var(--btn-secondary-border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.btn-sm {
  padding: 5px 12px;
  min-height: 32px;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 12px 20px;
  min-height: 48px;
  font-size: 0.95rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  min-height: 32px;
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(128, 128, 128, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Hero Section: Minimalist Brand Card (Inspired by Image 2)
   ========================================================================== */
.hero-section {
  padding-top: clamp(20px, 3.5vw, 36px);
  padding-bottom: clamp(12px, 2vw, 20px);
  text-align: center;
}

.hero-container {
  max-width: 540px;
  margin: 0 auto;
}

.minimal-brand-card {
  position: relative;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 4.5vw, 40px) clamp(20px, 3.5vw, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
}

.minimal-brand-card:hover,
.minimal-brand-card.drag-over {
  border-color: var(--border-active);
  background-color: var(--bg-surface-hover);
  box-shadow: var(--shadow-md);
}

.brand-emblem-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  transition: transform var(--transition-fast);
}

.brand-emblem-icon .brand-icon {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.16));
}

.minimal-brand-card:hover .brand-emblem-icon {
  transform: translateY(-2px);
}

.hero-title {
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.hero-subtitle {
  font-size: clamp(0.9rem, 1.6vw, 1rem);
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.45;
}

.upload-card-btn {
  padding: 10px 32px;
  font-size: 0.9375rem;
  font-weight: 600;
  min-height: 44px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.file-input-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   Main Editor Section
   ========================================================================== */
.editor-section {
  padding-top: clamp(8px, 1.5vw, 16px);
  padding-bottom: clamp(40px, 5vw, 70px);
}

.section-header {
  text-align: center;
  margin-bottom: clamp(20px, 3vw, 36px);
}

.section-title {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 700;
  margin-bottom: 6px;
}

.section-desc {
  font-size: clamp(0.85rem, 1.4vw, 0.95rem);
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

@media (min-width: 992px) {
  .editor-grid {
    grid-template-columns: 1.35fr 1fr;
    gap: 28px;
  }
}

/* Preview Card */
.preview-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: clamp(10px, 2vw, 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

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

.preview-title {
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.info-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
}

.info-tag-sep {
  color: var(--text-muted);
}

.info-tag-ratio {
  color: var(--text-muted);
}

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

.crop-notice {
  background-color: var(--bg-surface-hover);
  border-left: 3px solid var(--text-primary);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.preview-canvas-wrapper {
  width: 100%;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--canvas-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow: hidden;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

#preview-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-md);
  touch-action: none;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.checker-square {
  width: 14px;
  height: 14px;
  background-image: 
    linear-gradient(45deg, var(--border-default) 25%, transparent 25%), 
    linear-gradient(-45deg, var(--border-default) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, var(--border-default) 75%), 
    linear-gradient(-45deg, transparent 75%, var(--border-default) 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 2px;
}

/* Controls Card */
.controls-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: clamp(10px, 2vw, 16px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.control-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.control-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Presets Grid */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .presets-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  min-height: 76px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  touch-action: manipulation;
}

.preset-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.preset-btn.active {
  background-color: var(--bg-surface-active);
  border-color: var(--border-active);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--border-active);
}

.preset-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.preset-name {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Light Theme High-Contrast Apple Polish */
[data-theme="light"] .preset-btn {
  background-color: #f5f5f7;
  border: 1px solid var(--border-default);
  color: #1d1d1f;
}

[data-theme="light"] .preset-btn:hover {
  background-color: #e5e5ea;
  border-color: var(--border-focus);
  color: #000000;
}

[data-theme="light"] .preset-btn.active {
  background-color: #ffffff;
  border-color: #000000;
  color: #000000;
  box-shadow: 0 0 0 1.5px #000000, 0 3px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .percent-val {
  background-color: #f5f5f7;
  border: 1px solid var(--border-default);
  color: #1d1d1f;
}

[data-theme="light"] .custom-slider::-webkit-slider-thumb {
  background: #000000;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .custom-slider::-moz-range-thumb {
  background: #000000;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .custom-slider::-webkit-slider-runnable-track,
[data-theme="light"] .custom-slider::-moz-range-track {
  background: #d2d2d7;
}

[data-theme="light"] .site-header {
  background-color: rgba(245, 245, 247, 0.85);
  border-bottom: 1px solid transparent;
}

[data-theme="light"] .showcase-media {
  background-color: #ebebf0;
}

/* Framing & Zoom Controls */
#framing-group {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zoom-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.zoom-controls-row .custom-slider {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.btn-zoom-adjust {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  touch-action: manipulation;
}

.btn-zoom-adjust:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.framing-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.framing-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.3;
}

.framing-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-mini-tool {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  touch-action: manipulation;
}

.btn-mini-tool:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.btn-mini-tool.active {
  background-color: var(--bg-surface-active);
  color: var(--text-primary);
  border-color: var(--border-active);
}

/* Light Theme High-Contrast Apple Polish for framing tools */
[data-theme="light"] .btn-zoom-adjust,
[data-theme="light"] .btn-mini-tool {
  background-color: #f5f5f7;
  border: 1px solid var(--border-default);
  color: #1d1d1f;
}

[data-theme="light"] .btn-zoom-adjust:hover,
[data-theme="light"] .btn-mini-tool:hover {
  background-color: #e5e5ea;
  border-color: var(--border-focus);
  color: #000000;
}

.preview-canvas-wrapper.interactive-drag #preview-canvas {
  cursor: grab;
}

.preview-canvas-wrapper.interactive-drag.is-dragging #preview-canvas {
  cursor: grabbing;
}

/* Slider Controls (Placed above presets) */
#slider-group {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.slider-dimmed {
  opacity: 0.45;
  pointer-events: none;
}

.slider-readout {
  display: flex;
  align-items: center;
  gap: 6px;
}

.percent-val {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
}

.radius-val {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.slider-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  outline: none;
  cursor: pointer;
  margin: 0;
  display: block;
}

.custom-slider:focus-visible {
  outline: 2px solid var(--text-primary);
}

.custom-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: var(--slider-track);
  border-radius: 3px;
  border: none;
}

.custom-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  background: var(--slider-track);
  border-radius: 3px;
  border: none;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--bg-surface);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  margin-top: -7px;
  transition: transform var(--transition-fast);
}

.custom-slider::-webkit-slider-thumb:hover,
.custom-slider:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

.custom-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--bg-surface);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition-fast);
}

.custom-slider::-moz-range-thumb:hover,
.custom-slider:active::-moz-range-thumb {
  transform: scale(1.15);
}

.slider-marks {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.slider-explanation {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Export Area */
.export-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.download-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.download-hint:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
}

.export-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* ==========================================================================
   Showcase Section
   ========================================================================== */
.showcase-section {
  padding: clamp(48px, 6vw, 84px) 0;
  background-color: transparent;
  border-top: none;
  border-bottom: none;
}

.showcase-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 16px;
}

@media (min-width: 600px) {
  .showcase-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .showcase-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.showcase-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.showcase-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.showcase-media {
  width: 100%;
  height: 170px;
  background-color: var(--canvas-bg);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}

.showcase-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal);
}

.showcase-card:hover .showcase-img {
  transform: scale(1.03);
}

.shape-circle {
  width: 136px;
  height: 136px;
  clip-path: circle(50% at 50% 50%);
  aspect-ratio: 1 / 1;
}

.shape-squircle {
  width: 136px;
  height: 136px;
  border-radius: 34px;
  aspect-ratio: 1 / 1;
}

.shape-rounded-rect {
  width: 192px;
  height: 120px;
  border-radius: 28px;
  aspect-ratio: 16 / 10;
}

.shape-ellipse {
  width: 192px;
  height: 120px;
  clip-path: ellipse(50% 50% at 50% 50%);
  aspect-ratio: 16 / 10;
}

.shape-organic {
  width: 192px;
  height: 120px;
  border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  aspect-ratio: 16 / 10;
}

.shape-passport {
  width: 105px;
  height: 135px;
  border-radius: 4px;
  aspect-ratio: 7 / 9;
}

.showcase-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.showcase-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.showcase-name {
  font-size: 1rem;
  font-weight: 600;
}

.showcase-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.showcase-cta {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
}

/* ==========================================================================
   How It Works & FAQ
   ========================================================================== */
.how-section {
  padding: clamp(48px, 6vw, 84px) 0;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 16px;
}

@media (min-width: 768px) {
  .steps-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.step-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: clamp(20px, 3.5vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.step-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.step-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  font-feature-settings: 'tnum';
  opacity: 0.7;
}

.step-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.step-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.faq-section {
  padding: clamp(48px, 6vw, 84px) 0;
  border-top: none;
}

.faq-accordion {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.faq-item:hover {
  border-color: var(--border-focus);
}

.faq-item[open] {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
}

.faq-question {
  padding: 14px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-secondary);
  transition: transform var(--transition-fast);
}

.faq-item[open] .faq-question::after {
  content: '−';
}

.faq-answer {
  padding: 0 18px 16px 18px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  margin-top: auto;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: clamp(44px, 5vw, 64px) 0 32px 0;
}

.footer-top {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

@media (min-width: 768px) {
  .footer-top {
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
  }
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 440px;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 1.05rem;
}

.footer-tagline {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-nav {
  display: flex;
  gap: clamp(28px, 6vw, 56px);
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.footer-col a, .footer-link-btn {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-family: inherit;
  transition: color var(--transition-fast);
}

.footer-col a:hover, .footer-link-btn:hover {
  color: var(--text-primary);
}

.copyright {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 24px;
  line-height: 1.4;
}

@media (min-width: 440px) {
  .copyright {
    white-space: nowrap;
  }
}

@media (min-width: 768px) {
  .copyright {
    margin-top: auto;
    padding-top: 28px;
  }
}


/* ==========================================================================
   Toasts & Modals
   ========================================================================== */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 400px);
  width: auto;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  animation: toastSlideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.toast-fade {
  opacity: 0;
  transform: translateY(-8px);
}

@keyframes toastSlideDown {
  from {
    transform: translateY(-16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-family: var(--font-family);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  background-color: var(--bg-secondary);
}

.toast-error .toast-icon {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background-color: rgba(239, 68, 68, 0.1);
}

.toast-success .toast-icon {
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.4);
  background-color: rgba(34, 197, 94, 0.1);
}

.toast-error {
  border-color: #ef4444;
}

.toast-success {
  border-color: #22c55e;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* Modals */
.modal-dialog {
  border: none;
  background: transparent;
  margin: auto;
  padding: 0;
  max-width: 580px;
  width: 90vw;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.modal-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--text-primary);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 65vh;
  overflow-y: auto;
}

.modal-body h4 {
  color: var(--text-primary);
  margin-top: 4px;
}

/* ==========================================================================
   Developer Social Icons & Footer Enhancements
   ========================================================================== */
.footer-social-links {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.social-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.social-icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-default);
  background-color: var(--bg-card);
  transform: translateY(-1px);
}

/* ==========================================================================
   Standalone Legal & Guide Pages Styles
   ========================================================================== */
.page-legal {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.legal-main {
  flex: 1;
  padding: clamp(32px, 6vw, 64px) 0 clamp(48px, 8vw, 80px) 0;
}

.legal-container {
  max-width: 860px;
  margin: 0 auto;
}

.legal-header {
  margin-bottom: clamp(24px, 4vw, 36px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  transition: color var(--transition-fast);
}

.back-link:hover {
  color: var(--text-primary);
}

.legal-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.legal-subtitle {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.legal-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.legal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 3.5vw, 32px);
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.9375rem;
}

.legal-card h2 {
  font-size: 1.2rem;
  font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.legal-card p {
  margin-bottom: 12px;
}

.legal-card p:last-child {
  margin-bottom: 0;
}

.legal-card ul, .legal-card ol {
  margin: 10px 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legal-card li strong {
  color: var(--text-primary);
}

.legal-card a:not(.btn) {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-card .btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.license-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
  overflow-x: auto;
}

.license-box pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.775rem;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
  margin: 0;
}

.code-snippet-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 12px 0;
}

.code-snippet-box code {
  font-family: ui-monospace, monospace;
  font-size: 0.825rem;
  color: var(--text-primary);
}

.policy-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.8125rem;
}

.policy-table th, .policy-table td {
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--border-subtle);
}

.policy-table th {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
}

.policy-table td code {
  font-family: monospace;
  background-color: var(--bg-surface);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Mobile & Tablet Compact Studio Polish (< 768px)
   Eliminates excess gaps and unifies preview and tools on a single screen
   ========================================================================== */
@media (max-width: 767px) {
  .editor-section {
    padding-top: 4px;
    padding-bottom: 24px;
    scroll-margin-top: calc(var(--header-height) + 4px);
  }

  .editor-grid {
    gap: 8px;
  }

  /* Compact Preview Card */
  .preview-card {
    padding: 8px 10px;
    gap: 6px;
    border-radius: var(--radius-sm);
  }

  .preview-header {
    padding-bottom: 4px;
    gap: 6px;
  }

  .preview-title {
    font-size: 0.75rem;
  }

  .info-badge {
    padding: 2px 7px;
    font-size: 0.6875rem;
    gap: 4px;
  }

  .preview-header-right .btn-icon {
    padding: 3px 8px;
    font-size: 0.6875rem;
    min-height: 28px;
  }

  .preview-canvas-wrapper {
    min-height: 140px;
    max-height: clamp(150px, 26vh, 205px);
    padding: 6px;
  }

  #preview-canvas {
    max-height: clamp(140px, 24vh, 195px);
    width: auto;
    max-width: 100%;
    object-fit: contain;
  }

  .preview-footer {
    font-size: 0.6875rem;
    padding-top: 2px;
  }

  .checkerboard-legend {
    gap: 5px;
  }

  /* Compact Controls Card */
  .controls-card {
    padding: 10px 12px;
    gap: 8px;
    border-radius: var(--radius-sm);
  }

  .control-section {
    gap: 5px;
  }

  .control-label-row {
    gap: 6px;
  }

  .control-label {
    font-size: 0.75rem;
  }

  .control-hint {
    font-size: 0.6875rem;
  }

  /* Compact Corner Rounding */
  #slider-group {
    padding-bottom: 8px;
    gap: 4px;
  }

  .percent-val {
    font-size: 0.75rem;
    padding: 1px 6px;
  }

  .radius-val {
    font-size: 0.6875rem;
  }

  .slider-container {
    gap: 2px;
  }

  .slider-marks {
    display: none; /* removes redundant marks to keep preview and tools unified on mobile */
  }

  .custom-slider {
    height: 24px;
  }

  /* Compact Photo Zoom & Framing */
  #framing-group {
    padding-bottom: 8px;
    gap: 5px;
  }

  .zoom-controls-row {
    gap: 8px;
  }

  .btn-zoom-adjust {
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }

  .framing-actions-row {
    gap: 6px;
    margin-top: 2px;
  }

  .framing-hint {
    font-size: 0.6875rem;
  }

  .framing-buttons {
    gap: 4px;
  }

  .btn-mini-tool {
    padding: 3px 8px;
    font-size: 0.6875rem;
    min-height: 26px;
  }

  /* Compact Presets */
  #presets-section {
    gap: 6px;
  }

  .presets-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .preset-btn {
    min-height: 48px;
    padding: 6px 3px;
    gap: 3px;
  }

  .preset-icon-wrapper svg {
    width: 18px;
    height: 18px;
  }

  .preset-name {
    font-size: 0.6875rem;
  }

  /* Compact Export Button */
  .export-section {
    padding-top: 2px;
    gap: 4px;
  }

  .export-section .btn-lg {
    min-height: 42px;
    padding: 9px 14px;
    font-size: 0.875rem;
  }

  .download-hint {
    font-size: 0.6875rem;
  }
}

@media (max-width: 360px) {
  .presets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .editor-grid {
    gap: 16px;
  }
  .preview-card {
    padding: 12px 16px;
    gap: 10px;
  }
  .preview-canvas-wrapper {
    min-height: 220px;
    max-height: 320px;
    padding: 12px;
  }
  #preview-canvas {
    max-height: 300px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
  }
  .controls-card {
    padding: 14px 16px;
    gap: 12px;
  }
  #slider-group, #framing-group {
    padding-bottom: 10px;
  }
  .preset-btn {
    min-height: 64px;
  }
}


