/* ═══════════════════════════════════════════════════════════════════════
   VERSE CARD CREATOR — styles.css
   Luxury Christian Brand Aesthetic
   Colors: #2C1810 (deep brown) · #1A0E09 (almost black) · #C9A84C (gold)
           #E8C97A (light gold) · #F5E7B5 (cream)
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── 1. CSS CUSTOM PROPERTIES ──────────────────────────────────────── */
:root {
  /* Brand palette */
  --brown-deep:    #2C1810;
  --brown-darker:  #1A0E09;
  --brown-mid:     #3D2318;
  --brown-light:   #5C3520;
  --gold:          #C9A84C;
  --gold-light:    #E8C97A;
  --gold-pale:     #F5E7B5;
  --gold-dark:     #A07830;
  --cream:         #FAF3E0;
  --cream-dark:    #EDE0C4;

  /* UI surfaces */
  --sidebar-bg:    #1A0E09;
  --sidebar-panel: #221209;
  --panel-border:  rgba(201,168,76, 0.18);
  --panel-hover:   rgba(201,168,76, 0.06);

  /* Text */
  --text-primary:  #F5E7B5;
  --text-secondary: #C9A09A;
  --text-muted:    #8A6A55;
  --text-gold:     #C9A84C;

  /* Canvas area */
  --canvas-bg:     #0F0806;

  /* Sizing */
  --sidebar-width: 340px;
  --header-height: 56px;

  /* Effects */
  --gold-glow:     0 0 20px rgba(201,168,76, 0.3);
  --shadow-panel:  0 4px 24px rgba(0,0,0, 0.5);
  --radius-panel:  12px;
  --radius-btn:    8px;

  /* Transitions */
  --trans-fast:    150ms ease;
  --trans-mid:     250ms ease;
  --trans-slow:    400ms cubic-bezier(0.23, 1, 0.32, 1);
}

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

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

body {
  background: var(--canvas-bg);
  color: var(--text-primary);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.95rem;
  line-height: 1.5;
  min-height: 100vh;
  overflow: hidden; /* App shell, no body scroll */
}

/* Focus styles — accessible and styled */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─── 3. APP SHELL ───────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── 4. HEADER ──────────────────────────────────────────────────────── */
#app-header {
  height: var(--header-height);
  background: var(--brown-darker);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.6);
}

/* Subtle gold shimmer line at top */
#app-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-light), var(--gold), transparent);
  opacity: 0.8;
}

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

.header-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 6px rgba(201,168,76,0.45));
}

.header-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.05em;
  text-shadow: 0 1px 8px rgba(201,168,76,0.3);
}

.header-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-left: 1px solid var(--panel-border);
  padding-left: 10px;
  display: none; /* hidden on smaller screens */
}

@media (min-width: 900px) {
  .header-sub { display: block; }
}

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

/* Header buttons */
.hdr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(201,168,76,0.08);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-btn);
  color: var(--gold-light);
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background var(--trans-fast), border-color var(--trans-fast), color var(--trans-fast);
  white-space: nowrap;
}

.hdr-link {
  text-decoration: none;
}

.hdr-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.hdr-btn:hover {
  background: rgba(201,168,76,0.18);
  border-color: rgba(201,168,76,0.4);
  color: var(--gold);
}

.hdr-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.hdr-btn:disabled:hover {
  background: rgba(201,168,76,0.08);
  border-color: var(--panel-border);
  color: var(--gold-light);
}

/* ─── 5. MAIN WORKSPACE ──────────────────────────────────────────────── */
#workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── 6. SIDEBAR ─────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--panel-border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  transition: transform var(--trans-slow), width var(--trans-slow);

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--brown-mid) transparent;
}

#sidebar::-webkit-scrollbar {
  width: 4px;
}
#sidebar::-webkit-scrollbar-track {
  background: transparent;
}
#sidebar::-webkit-scrollbar-thumb {
  background: var(--brown-mid);
  border-radius: 2px;
}

#sidebar-inner {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100%;
}

/* ─── 7. SIDEBAR SECTIONS ────────────────────────────────────────────── */
.sidebar-section {
  background: var(--sidebar-panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-panel);
  overflow: hidden;
  transition: box-shadow var(--trans-mid);
}

.sidebar-section:hover {
  box-shadow: 0 0 0 1px rgba(201,168,76,0.12), var(--shadow-panel);
}

/* Section header */
.section-title {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(201,168,76,0.04);
}

.section-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.section-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 8px 14px 0;
  font-style: italic;
}

/* ─── 8. CONTROL GROUPS ──────────────────────────────────────────────── */
.control-group {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(201,168,76,0.06);
}

.control-group:last-child {
  border-bottom: none;
}

.control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 7px;
  cursor: default;
}

.control-label.small {
  font-size: 0.65rem;
  margin-top: 8px;
  color: var(--text-muted);
}

.control-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
  min-width: 36px;
  text-align: right;
}

/* Text inputs */
.control-input,
.control-textarea,
.control-select {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.9rem;
  padding: 9px 10px;
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
  -webkit-appearance: none;
  appearance: none;
}

.control-input:focus,
.control-textarea:focus,
.control-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201,168,76,0.15);
}

.control-input::placeholder,
.control-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.control-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.control-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23C9A84C' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.control-select option {
  background: var(--brown-deeper, #1A0E09);
  color: var(--text-primary);
}

/* Range slider */
.control-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(201,168,76,0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  position: relative;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--brown-deeper, #1A0E09);
  box-shadow: 0 0 8px rgba(201,168,76,0.5);
  cursor: pointer;
  transition: transform var(--trans-fast), box-shadow var(--trans-fast);
}

.control-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--brown-deeper, #1A0E09);
  box-shadow: 0 0 8px rgba(201,168,76,0.5);
  cursor: pointer;
}

.control-slider:hover::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 14px rgba(201,168,76,0.7);
}

/* ─── 9. BUTTON GROUPS (align / style) ───────────────────────────────── */
.btn-group {
  display: flex;
  gap: 4px;
}

.align-btn,
.style-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--trans-fast);
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
}

.align-btn svg {
  width: 20px;
  height: 16px;
}

.align-btn:hover,
.style-btn:hover {
  background: rgba(201,168,76,0.1);
  border-color: rgba(201,168,76,0.35);
  color: var(--gold-light);
}

.align-btn.active,
.style-btn.active {
  background: rgba(201,168,76,0.18);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 8px rgba(201,168,76,0.2);
}

.italic-btn {
  font-style: italic;
}

/* ─── 10. COLOR PICKER ───────────────────────────────────────────────── */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker {
  width: 40px;
  height: 34px;
  border: 2px solid rgba(201,168,76,0.3);
  border-radius: 6px;
  padding: 2px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--trans-fast);
}

.color-picker:hover {
  border-color: var(--gold);
}

.color-presets {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.color-preset {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--trans-fast), border-color var(--trans-fast);
  flex-shrink: 0;
}

.color-preset:hover {
  transform: scale(1.2);
  border-color: var(--gold);
}

.color-preset.active {
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(201,168,76,0.6);
}

/* ─── 11. TOGGLE SWITCH ──────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.toggle-row .control-label {
  margin-bottom: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

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

.toggle-thumb {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 11px;
  transition: background var(--trans-mid), border-color var(--trans-mid);
}

.toggle-thumb::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--trans-mid), background var(--trans-mid);
}

.toggle-switch input:checked + .toggle-thumb {
  background: rgba(201,168,76,0.25);
  border-color: var(--gold);
}

.toggle-switch input:checked + .toggle-thumb::after {
  transform: translateX(16px);
  background: var(--gold);
  box-shadow: 0 0 6px rgba(201,168,76,0.6);
}

/* Sub-controls (shown when toggle is on) */
.sub-controls {
  padding-top: 10px;
  border-top: 1px solid rgba(201,168,76,0.08);
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sub-controls.hidden {
  display: none;
}

/* ─── 12. TEMPLATE GRID ──────────────────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 14px;
}

.template-thumb {
  aspect-ratio: 5 / 7; /* postcard portrait ratio */
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--trans-fast), transform var(--trans-fast), box-shadow var(--trans-fast);
  background: var(--brown-mid);
  position: relative;
}

.template-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Fallback gradient background when image fails to load */
.template-thumb .thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-family: 'Cinzel', serif;
  color: var(--gold);
  text-align: center;
  padding: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.template-thumb:hover {
  border-color: rgba(201,168,76,0.5);
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.template-thumb.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 4px 20px rgba(201,168,76,0.3);
}

.template-thumb .thumb-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: var(--cream);
  font-size: 0.5rem;
  font-family: 'Cinzel', serif;
  text-align: center;
  padding: 6px 3px 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity var(--trans-fast);
}

.template-thumb:hover .thumb-label,
.template-thumb.active .thumb-label {
  opacity: 1;
}

/* ─── 13. DECORATION GRID ────────────────────────────────────────────── */
.decoration-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 10px 14px;
}

.deco-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(201,168,76,0.18);
  border-radius: 8px;
  color: var(--gold-light);
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all var(--trans-fast);
  text-align: center;
  line-height: 1.3;
}

.deco-btn:hover {
  background: rgba(201,168,76,0.1);
  border-color: rgba(201,168,76,0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.deco-btn:active {
  transform: translateY(0);
}

.deco-btn .deco-icon {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(201,168,76,0.4));
}

.deco-btn img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 3px rgba(201,168,76,0.4));
}

/* ─── 14. LAYERS LIST ────────────────────────────────────────────────── */
.layers-list {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--brown-mid) transparent;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  background: rgba(0,0,0,0.2);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--trans-fast);
  user-select: none;
}

.layer-item:hover {
  background: var(--panel-hover);
  border-color: rgba(201,168,76,0.15);
}

.layer-item.selected {
  background: rgba(201,168,76,0.1);
  border-color: rgba(201,168,76,0.3);
}

.layer-drag-handle {
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: grab;
  flex-shrink: 0;
}

.layer-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.layer-name {
  flex: 1;
  font-size: 0.75rem;
  color: var(--text-primary);
  font-family: 'Cormorant Garamond', serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-item.locked .layer-name {
  color: var(--text-muted);
  font-style: italic;
}

.layer-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.layer-action-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  transition: color var(--trans-fast), background var(--trans-fast);
}

.layer-action-btn:hover {
  color: var(--gold);
  background: rgba(201,168,76,0.1);
}

.layer-action-btn.delete:hover {
  color: #e05050;
  background: rgba(224,80,80,0.1);
}

.layer-action-btn.hidden-layer {
  opacity: 0.4;
}

/* ─── 15. DOWNLOAD SECTION ───────────────────────────────────────────── */
.download-info {
  display: flex;
  gap: 6px;
  padding: 10px 14px 0;
  flex-wrap: wrap;
}

.dl-badge {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(201,168,76,0.1);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  padding: 3px 8px;
}

.download-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 14px;
}

.dl-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 8px;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--trans-mid);
  border: none;
}

.dl-btn svg {
  width: 16px;
  height: 16px;
}

.dl-btn-primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold), var(--gold-light));
  color: var(--brown-darker);
  box-shadow: 0 4px 20px rgba(201,168,76,0.35);
}

.dl-btn-primary:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-light), #fff8d0);
  box-shadow: 0 6px 28px rgba(201,168,76,0.55);
  transform: translateY(-1px);
}

.dl-btn-secondary {
  background: rgba(201,168,76,0.08);
  border: 1px solid rgba(201,168,76,0.3);
  color: var(--gold-light);
}

.dl-btn-secondary:hover {
  background: rgba(201,168,76,0.15);
  border-color: var(--gold);
  transform: translateY(-1px);
}

.dl-btn:active {
  transform: translateY(0) !important;
}

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

/* ─── 16. CANVAS AREA ────────────────────────────────────────────────── */
#canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--canvas-bg);
  position: relative;
}

/* Subtle grid pattern on canvas background */
#canvas-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(201,168,76,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,168,76,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

#canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 20px;
  position: relative;
  z-index: 1;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--brown-mid) transparent;
}

#canvas-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
#canvas-wrapper::-webkit-scrollbar-thumb {
  background: var(--brown-mid);
  border-radius: 4px;
}

/* Canvas element wrapper — sized by JS */
#canvas-wrapper > .canvas-container {
  box-shadow:
    0 0 0 1px rgba(201,168,76,0.2),
    0 20px 80px rgba(0,0,0,0.8),
    0 0 120px rgba(0,0,0,0.5);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

/* Status bar */
#canvas-statusbar {
  height: 30px;
  background: var(--brown-darker);
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 1;
}

#status-msg {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
}

#canvas-dims {
  font-size: 0.6rem;
  font-family: 'Cinzel', serif;
  color: rgba(201,168,76,0.4);
  letter-spacing: 0.08em;
}

/* ─── 17. TOAST NOTIFICATION ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--brown-deep);
  border: 1px solid var(--gold);
  color: var(--gold-light);
  padding: 10px 20px;
  border-radius: 8px;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), var(--gold-glow);
  z-index: 9999;
  transition: opacity var(--trans-mid), transform var(--trans-mid);
  pointer-events: none;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}

/* ─── 18. MOBILE RESPONSIVE ──────────────────────────────────────────── */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
    --header-height: auto;
  }

  html,
  body {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  #app {
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  #app-header {
    position: sticky;
    top: 0;
    min-height: 56px;
    height: auto;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
  }

  .header-brand {
    min-width: 0;
    gap: 8px;
    padding-top: 2px;
  }

  .header-logo {
    width: 28px;
    height: 28px;
  }

  .header-title {
    font-size: 0.88rem;
    line-height: 1.15;
    max-width: 128px;
  }

  .header-sub {
    display: none;
  }

  .header-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }

  .hdr-btn {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 0.62rem;
  }

  .mobile-only {
    display: flex;
  }

  #workspace {
    flex-direction: column;
    position: relative;
    min-height: auto;
    overflow: visible;
  }

  #sidebar {
    position: relative;
    left: auto;
    bottom: auto;
    top: auto;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: none;
    transform: none;
    z-index: 1;
    border-right: 0;
    border-top: 1px solid var(--panel-border);
    box-shadow: inset 0 1px 0 rgba(201,168,76,0.08);
    overflow: visible;
  }

  #sidebar-inner {
    padding: 12px;
  }

  #canvas-area {
    width: 100%;
    height: min(58dvh, 520px);
    min-height: 360px;
    flex: 0 0 auto;
  }

  #canvas-wrapper {
    padding: 8px;
    align-items: flex-start;
  }

  .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .decoration-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .sidebar-section {
    padding: 14px;
    margin-bottom: 10px;
  }

  .control-group {
    margin-bottom: 14px;
  }

  .control-input,
  .control-select,
  .control-textarea {
    font-size: 16px;
  }

  .btn-group,
  .download-buttons {
    gap: 8px;
  }

  .style-btn,
  .align-btn,
  .dl-btn {
    min-height: 42px;
  }

  #canvas-statusbar {
    height: auto;
    min-height: 32px;
    gap: 10px;
    padding: 8px 10px;
  }
}

@media (max-width: 420px) {
  #app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-brand,
  .header-actions {
    width: 100%;
  }

  .header-title {
    max-width: none;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hdr-btn {
    justify-content: center;
    padding: 7px 6px;
  }

  #canvas-area {
    height: 54dvh;
    min-height: 320px;
  }

  .template-grid,
  .decoration-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile overlay when sidebar is open */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 190;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
  display: block;
}

/* ─── 19. UTILITY CLASSES ────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ─── 20. LOADING INDICATOR ──────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(201,168,76,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ─── 21. SELECTED OBJECT INDICATOR ─────────────────────────────────── */
/* Fabric.js selection styling — override defaults */
.canvas-container canvas {
  display: block;
}

/* ─── 22. SCROLLBAR FOR LAYERS ───────────────────────────────────────── */
.layers-list::-webkit-scrollbar {
  width: 4px;
}
.layers-list::-webkit-scrollbar-thumb {
  background: var(--brown-mid);
  border-radius: 2px;
}

/* ─── 23. CANVAS SAFE AREA INDICATOR ────────────────────────────────── */
/* Safe area is shown via a CSS outline on a positioned div,
   purely visual and non-interactive */
#safe-area-indicator {
  position: absolute;
  pointer-events: none;
  border: 1px dashed rgba(201,168,76,0.25);
  border-radius: 0;
  z-index: 5;
  /* Positioned by JavaScript to match safe margins */
  display: none; /* hidden by default; shown after canvas renders */
}

/* ─── 24. FONT PREVIEW IN DROPDOWN ──────────────────────────────────── */
#font-family option[value="Cormorant Garamond"] { font-family: 'Cormorant Garamond', serif; }
#font-family option[value="Playfair Display"]   { font-family: 'Playfair Display', serif; }
#font-family option[value="Cinzel"]             { font-family: 'Cinzel', serif; }
#font-family option[value="EB Garamond"]        { font-family: 'EB Garamond', serif; }
#font-family option[value="Libre Baskerville"]  { font-family: 'Libre Baskerville', serif; }
#font-family option[value="Great Vibes"]        { font-family: 'Great Vibes', cursive; }

/* ─── 25. ANIMATIONS ─────────────────────────────────────────────────── */

/* Fade in on load */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sidebar-section {
  animation: fadeInUp 0.4s ease both;
}

.sidebar-section:nth-child(1) { animation-delay: 0.05s; }
.sidebar-section:nth-child(2) { animation-delay: 0.10s; }
.sidebar-section:nth-child(3) { animation-delay: 0.15s; }
.sidebar-section:nth-child(4) { animation-delay: 0.20s; }
.sidebar-section:nth-child(5) { animation-delay: 0.25s; }
.sidebar-section:nth-child(6) { animation-delay: 0.30s; }
.sidebar-section:nth-child(7) { animation-delay: 0.35s; }

/* Template hover shimmer */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Download button pulse */
@keyframes goldPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(201,168,76,0.35); }
  50% { box-shadow: 0 4px 32px rgba(201,168,76,0.6); }
}

.dl-btn-primary {
  animation: goldPulse 3s ease-in-out infinite;
}

.dl-btn-primary:hover {
  animation: none;
}

/* ─── 26. PRINT MEDIA ────────────────────────────────────────────────── */
@media print {
  #sidebar, #app-header, #canvas-statusbar { display: none; }
  #canvas-area { flex: 1; }
}
