/* ============================================================
   Kaizin — LinkedIn Cover Generator
   Brand: brandbook.md v5.0 — Unified Light Tool Page
   Primary CTA: #32373c (charcoal pill), Accent: #03bfac (teal)
   Font: "Assistant" (Google Fonts)
   ============================================================ */

/* ── Custom Properties (Brandbook §Color, §Typography, §Spacing) ── */
:root {
  /* Backgrounds */
  --color-bg-primary:       #f3f3f3;
  --color-bg-secondary:     #ffffff;
  --color-bg-tertiary:      #f8f8f8;

  /* Surfaces */
  --color-surface:          #ffffff;
  --color-surface-subtle:   #f8f8f8;
  --color-border:           #e5e5e5;
  --color-border-subtle:    #eeeeee;

  /* Brand accent — Kaizin teal (focus rings, badges, upload zones, step dots) */
  --color-accent:           #03bfac;
  --color-accent-dark:      #029e8e;
  --color-accent-light:     rgba(3, 191, 172, 0.10);
  --color-accent-border:    rgba(3, 191, 172, 0.30);

  /* Primary CTA — Charcoal (kaiz-in.com button color) */
  --color-cta:              #32373c;
  --color-cta-hover:        #1e2226;

  /* Dark hero surface */
  --color-hero-bg:          #0a0a0a;
  --color-header-bg:        #000000;

  /* Text */
  --color-text-primary:     #000000;
  --color-text-body:        #474747;
  --color-text-secondary:   #6b7280;
  --color-text-muted:       #9ca3af;
  --color-text-accent:      #03bfac;

  /* Semantic */
  --color-success:          #10b981;
  --color-warning:          #f59e0b;
  --color-error:            #ef4444;

  /* Typography — "Assistant" per Kaizin brand */
  --font-family: 'Assistant', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing — 8px base, multiples of 4px */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* Transitions */
  --transition:      all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows — subtle, light-theme appropriate */
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-xl:  0 16px 48px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.06);
}

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

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

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-primary);
  color: var(--color-text-body);
  line-height: 1.6;
  font-size: 0.9375rem;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Utility ── */
.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Focus styles (Brandbook §Accessibility) ── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   BACKGROUND ORBS — Removed in light theme; element kept in
   HTML but hidden so no visual noise on white/light-gray bg.
   ============================================================ */
.bg-orbs {
  display: none;
}

/* ============================================================
   CARD PATTERN — Clean white card with subtle shadow
   Replaces glassmorphism from v1 (Brandbook §Card Pattern)
   ============================================================ */
.glass-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.glass-card-elevated {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  box-shadow: var(--shadow-xl);
}

/* ============================================================
   APP SHELL — Sidebar portal layout (Brandbook §Layout v6)
   Fixed 240px sidebar + fluid content area. Replaces the
   previous fixed top header. Header styles removed in v6.
   ============================================================ */

/* Root flex container: sidebar + content side-by-side */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  /* Smooth slide-in on mobile */
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Logo block */
.sidebar__logo {
  padding: var(--space-6) var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border-subtle);
}

.sidebar__logo a {
  display: inline-block;
  transition: var(--transition);
}

.sidebar__logo a:hover {
  opacity: 0.80;
}

/* Logo image: natural colours on light sidebar bg — no filter */
.sidebar__logo-img {
  width: 120px;
  height: auto;
  display: block;
}

/* "AI Tools Portal" label — teal, small-caps, 11px */
.sidebar__portal-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

/* Nav section */
.sidebar__nav {
  padding: var(--space-5) var(--space-3);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* "TOOLS" section label */
.sidebar__nav-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 0 var(--space-2) var(--space-2);
}

/* Nav item — link */
.sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: var(--transition);
  border-left: 3px solid transparent;
  /* Compensate left border so text stays aligned */
  padding-left: calc(var(--space-4) - 3px);
}

.sidebar__nav-item:hover {
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
}

/* Active state: teal left border, teal text, light teal bg */
.sidebar__nav-item--active {
  border-left-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
  font-weight: 600;
}

.sidebar__nav-item--active:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

/* Nav icon */
.sidebar__nav-icon {
  flex-shrink: 0;
  opacity: 0.80;
}

.sidebar__nav-item--active .sidebar__nav-icon {
  opacity: 1;
  color: var(--color-accent);
}

/* Sidebar footer — pinned to bottom */
.sidebar__footer {
  padding: var(--space-5) var(--space-5);
  border-top: 1px solid var(--color-border-subtle);
  margin-top: auto;
}

.sidebar__footer-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.sidebar__footer-link:hover {
  color: var(--color-accent);
}

/* ── Content area — sits to the right of the sidebar ── */
.content-area {
  margin-left: 240px;
  flex: 1;
  background: var(--color-bg-primary);
  min-height: 100vh;
}

/* Inner content: constrained width, centred, padded */
.content-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-10) var(--space-8);
}

/* ── Mobile top bar — hidden on desktop ── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-subtle);
  z-index: 190;
  padding: 0 var(--space-5);
  align-items: center;
  justify-content: space-between;
}

.mobile-topbar__logo {
  height: 28px;
  width: auto;
  display: block;
}

.mobile-topbar__hamburger {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--color-text-body);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  transition: var(--transition);
}

.mobile-topbar__hamburger:hover {
  background: var(--color-bg-primary);
}

/* Sidebar backdrop — shown behind open sidebar on mobile */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.40);
  z-index: 195;
  cursor: pointer;
}

/* ============================================================
   MAIN LAYOUT — legacy selector kept for any JS references.
   Layout is now handled by .content-area + .content-main
   on the app-shell sidebar layout (Brandbook §Layout v6).
   ============================================================ */
.main {
  position: relative;
  z-index: 1;
}

/* ============================================================
   PAGE TITLE — Content page heading style (Brandbook §Typography v6)
   Sidebar layout means no fixed header to clear. Left-aligned,
   tool-page hierarchy: breadcrumb → h1 → subtitle.
   ============================================================ */
.page-title {
  padding: 0 0 var(--space-8);
  border-bottom: 1px solid var(--color-border-subtle);
  margin-bottom: var(--space-8);
}

/* Small muted breadcrumb above h1 */
.page-breadcrumb {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.01em;
  margin-bottom: var(--space-3);
}

/* Content-page h1 — not a marketing headline, a tool page title */
.page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--color-text-primary);
}

.page-title__accent {
  color: var(--color-accent);
}

.page-title__sub {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-top: var(--space-2);
  line-height: 1.6;
}

/* ============================================================
   FORM SECTION
   Flat, no card wrapper — form fields sit directly on the
   light-gray page background. No border, shadow, or radius.
   No padding-top header clearance needed (sidebar layout v6).
   ============================================================ */
.form-section {
  padding-bottom: var(--space-20);
  animation: fadeUp 0.7s ease both;
}

/* ── Field Group ── */
.field-group {
  margin-bottom: var(--space-6);
}

.field-group--upload {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-3);
  letter-spacing: -0.01em;
}

.field-label__required {
  color: var(--color-accent);
  font-size: 0.875rem;
}

.field-label__optional {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  padding: 1px 7px;
  border-radius: 100px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Textarea (Brandbook §Inputs) ── */
.textarea-wrapper {
  position: relative;
}

.field-textarea {
  width: 100%;
  padding: var(--space-4) var(--space-4);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text-body);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  line-height: 1.6;
  resize: vertical;
  transition: var(--transition);
  min-height: 140px;
}

.field-textarea::placeholder {
  color: var(--color-text-muted);
}

.field-textarea:hover {
  border-color: #c8c8c8;
}

.field-textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(3, 191, 172, 0.12);
}

.textarea-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-2);
  padding: 0 var(--space-1);
}

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

.char-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  transition: var(--transition);
}

.char-count.warn  { color: var(--color-warning); }
.char-count.limit { color: var(--color-error); }

.char-sep {
  opacity: 0.4;
  margin: 0 1px;
}

/* ── Upload Row ── */
.upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

/* ── Drop Zone (Brandbook §Upload Zone) ── */
.drop-zone {
  position: relative;
  border: 2px dashed var(--color-border);
  border-radius: 16px;
  background: var(--color-surface-subtle);
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
}

.drop-zone:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.drop-zone:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.drop-zone.drag-over {
  border-color: var(--color-accent);
  border-style: solid;
  background: var(--color-accent-light);
  box-shadow: 0 0 0 3px rgba(3, 191, 172, 0.12);
}

.drop-zone.has-file {
  border-color: var(--color-accent-border);
  border-style: solid;
  background: var(--color-accent-light);
}

.drop-zone__inner {
  text-align: center;
  padding: var(--space-5);
  pointer-events: none;
}

.drop-zone__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: var(--transition);
}

.drop-zone:hover .drop-zone__icon {
  background: #fff;
  border-color: var(--color-accent-border);
  color: var(--color-accent);
}

.drop-zone__label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

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

/* Drop zone preview */
.drop-zone__preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  width: 100%;
}

.preview-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.preview-thumb--round {
  border-radius: 50%;
}

.preview-remove {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 24px;
  height: 24px;
  background: rgba(239, 68, 68, 0.90);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: var(--transition);
}

.preview-remove:hover {
  background: var(--color-error);
  transform: scale(1.1);
}

.preview-name {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* ── Form Error ── */
.form-error {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: rgba(239, 68, 68, 0.07);
  border: 1px solid rgba(239, 68, 68, 0.20);
  border-radius: 10px;
  color: #b91c1c;
  font-size: 0.875rem;
  margin-bottom: var(--space-5);
  animation: fadeIn 0.3s ease;
}

.form-error svg {
  flex-shrink: 0;
  color: var(--color-error);
}

/* ── Form Actions ── */
.form-actions {
  display: flex;
  justify-content: center;
  padding-top: var(--space-2);
}

/* ============================================================
   BUTTONS (Brandbook §Component Patterns — buttons v3)
   Primary CTA: #32373c charcoal, pill shape (border-radius: 9999px)
   Secondary: white bg, #32373c border and text, pill shape
   Teal accent retained only for focus rings and small accents.
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: 15px 36px;
  background: var(--color-cta);
  border: none;
  border-radius: 9999px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.20);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.10), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.btn-primary:hover {
  background: var(--color-cta-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 13px 24px;
  background: #ffffff;
  border: 1.5px solid var(--color-cta);
  border-radius: 9999px;
  color: var(--color-cta);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--color-cta);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.btn-generate {
  min-width: 240px;
  font-size: 1.0625rem;
  padding: 16px 40px;
}

.btn-generate__icon {
  display: flex;
  align-items: center;
}

/* ============================================================
   LOADING SECTION (Brandbook §Animation)
   ============================================================ */
.loading-section {
  padding: var(--space-10) 0 var(--space-20);
  animation: fadeUp 0.5s ease both;
}

.loading-card {
  max-width: 500px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-10);
  text-align: center;
}

/* Loader ring — teal accent */
.loading-visual {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-8);
}

.loader-ring {
  position: absolute;
  inset: 0;
}

.loader-ring__inner {
  width: 80px;
  height: 80px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-ring__pulse {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(3, 191, 172, 0.20);
  border-radius: 50%;
  animation: ringPulse 2s ease-in-out infinite;
}

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

@keyframes ringPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50%       { opacity: 0.8; transform: scale(1.05); }
}

.loader-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  animation: iconGlow 2s ease-in-out infinite;
}

@keyframes iconGlow {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1; filter: drop-shadow(0 0 6px rgba(3,191,172,0.6)); }
}

.loading-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
  margin-bottom: var(--space-3);
}

.loading-status {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  min-height: 1.5em;
  transition: opacity 0.3s ease;
}

.loading-status.fade {
  opacity: 0;
}

/* Step dots */
.loading-steps {
  margin-bottom: var(--space-6);
}

.step-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border);
  transition: var(--transition-slow);
}

.step-dot.active {
  background: var(--color-accent);
  box-shadow: 0 0 8px rgba(3, 191, 172, 0.5);
  width: 20px;
  border-radius: 3px;
}

/* Progress bar */
.loading-bar-track {
  height: 3px;
  background: var(--color-border-subtle);
  border-radius: 100px;
  overflow: hidden;
  margin: 0 var(--space-8);
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--color-accent);
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(3, 191, 172, 0.40);
}

/* ============================================================
   LOADING — SKELETON GRID
   4 placeholder cards with shimmer animation shown while
   the backend generates the covers. Brandbook §Animation.
   ============================================================ */
.covers-grid--skeleton {
  margin-top: var(--space-8);
  pointer-events: none;
}

.cover-card--skeleton .cover-card__image-wrap {
  background: #e8e8e8;
}

.skeleton-block {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    #e8e8e8 0%,
    #f0f0f0 40%,
    #e8e8e8 80%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

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

.skeleton-avatar {
  position: absolute;
  bottom: -20px;
  left: 12px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #d8d8d8;
  border: 3px solid #ffffff;
  animation: shimmer 1.6s ease-in-out infinite;
}

.skeleton-line {
  height: 10px;
  border-radius: 100px;
  background: linear-gradient(
    90deg,
    #e8e8e8 0%,
    #f0f0f0 40%,
    #e8e8e8 80%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  margin-bottom: var(--space-2);
}

.skeleton-line--wide   { width: 60%; }
.skeleton-line--narrow { width: 35%; }

/* ============================================================
   RESULT SECTION — multi-cover layout
   ============================================================ */
.result-section {
  padding: 0 0 var(--space-20);
  animation: fadeUp 0.6s ease both;
}

/* Header row: title + action buttons */
.result-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.result-header__left {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.result-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.result-heading {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.result-success-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-success);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.20);
  border-radius: 100px;
  padding: var(--space-1) var(--space-3);
}

/* ============================================================
   COVERS GRID — 2x2 layout
   Brandbook §Layout (max 900px, 8px spacing unit)
   ============================================================ */
.covers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  max-width: 1200px;
  margin: 0 auto;
}

/* ============================================================
   COVER CARD — individual variant card
   Follows Brandbook §Card Pattern (white, subtle shadow, 20px radius)
   ============================================================ */
.cover-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  overflow: visible;  /* allow avatar bubble to protrude below the image area */
  display: flex;
  flex-direction: column;
  transition: var(--transition-slow);
}

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

/* Error state card */
.cover-card--error {
  opacity: 0.85;
}

/* Image wrap: 4:1 aspect-ratio, rounded top corners.
   overflow:visible so the avatar circle at bottom:-20px shows.
   The image itself carries the border-radius to preserve clipping. */
.cover-card__image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 1;
  background: var(--color-border-subtle);
  border-radius: 19px 19px 0 0;
  overflow: visible;
}

/* Cover image — clips to top corners via its own border-radius */
.cover-card__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 19px 19px 0 0;
  transition: var(--transition-slow);
}

/* LinkedIn avatar bubble — overlaid bottom-left, protruding 20px below image */
.cover-card__avatar {
  position: absolute;
  bottom: -20px;
  left: 12px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e8e8e8;
  border: 3px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaaaaa;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  z-index: 2;
  pointer-events: none;
}

/* Error placeholder inside image-wrap */
.cover-card__error-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--color-surface-subtle);
  border-radius: 19px 19px 0 0;
  color: var(--color-text-muted);
}

.cover-card__error-icon {
  width: 40px;
  height: 40px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.20);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-error);
}

.cover-card__error-msg {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-align: center;
  padding: 0 var(--space-4);
}

/* Card body: concept toggle + per-card action buttons */
.cover-card__body {
  padding: var(--space-5) var(--space-4) var(--space-4);
  padding-top: var(--space-8); /* extra top clearance for the protruding avatar */
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}

/* Concept toggle inside card */
.cover-card__concept-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-family: var(--font-family);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: var(--transition);
  text-align: left;
}

.cover-card__concept-toggle:hover {
  color: var(--color-text-primary);
}

.cover-card__concept-chevron {
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.cover-card__concept-toggle[aria-expanded="true"] .cover-card__concept-chevron {
  transform: rotate(180deg);
}

.cover-card__concept-body {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
  padding: var(--space-3) var(--space-3);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border-subtle);
  border-radius: 10px;
  animation: fadeIn 0.25s ease;
}

/* Per-card action buttons row */
.cover-card__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: auto;
}

.cover-card__actions .btn-secondary {
  flex: 1;
  font-size: 0.8125rem;
  padding: 10px 12px;
}

.cover-card__actions .btn-primary {
  flex: 1;
  font-size: 0.8125rem;
  padding: 10px 12px;
}

/* Download-all button sizing */
.btn-download-all {
  gap: var(--space-2);
}

/* LinkedIn mock preview */
.linkedin-mock {
  overflow: hidden;
  margin-bottom: var(--space-6);
  border-radius: 20px;
}

.linkedin-mock__cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 1;
  overflow: hidden;
  background: var(--color-border-subtle);
}

.linkedin-mock__cover {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: var(--transition-slow);
}

.linkedin-mock__cover-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.20) 50%, transparent 100%);
  animation: shimmerSlide 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shimmerSlide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.linkedin-mock__profile-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-6) var(--space-4);
  background: #ffffff;
  border-top: 1px solid var(--color-border);
}

/* Avatar overlaid on the cover image, bottom-left — matches real LinkedIn layout */
.linkedin-mock__avatar-overlay {
  position: absolute;
  bottom: -28px;
  left: 16px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #e8e8e8;
  border: 3px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 2;
}

.linkedin-mock__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-surface-subtle);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.linkedin-mock__profile-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mock-name-bar {
  height: 12px;
  width: 140px;
  background: var(--color-border);
  border-radius: 4px;
}

.mock-role-bar {
  height: 9px;
  width: 200px;
  background: var(--color-border-subtle);
  border-radius: 4px;
}

.linkedin-mock__connect-btn {
  padding: 6px 16px;
  border-radius: 100px;
  border: 1px solid var(--color-accent-border);
  color: var(--color-accent);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  user-select: none;
}

/* Result actions */
.result-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.btn-download {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

/* Concept expander */
.concept-expander {
  overflow: hidden;
}

.concept-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition);
  text-align: left;
}

.concept-toggle:hover {
  color: var(--color-text-primary);
}

.concept-toggle__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.concept-chevron {
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.concept-toggle[aria-expanded="true"] .concept-chevron {
  transform: rotate(180deg);
}

.concept-body {
  padding: 0 var(--space-5) var(--space-5);
  border-top: 1px solid var(--color-border-subtle);
  animation: fadeIn 0.3s ease;
}

.concept-text {
  padding-top: var(--space-4);
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.65;
  white-space: pre-wrap;
}

/* ============================================================
   FULLSCREEN MODAL
   Dark overlay + centered image at maximum 4:1 readable size.
   Brandbook §Animation (fade transition), §Accessibility (focus trap).
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  animation: fadeIn 0.2s ease;
  cursor: pointer; /* click outside to close */
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  width: 100%;
  max-width: 960px;
  cursor: default; /* prevent close when clicking inside */
}

/* Close button — top-right of overlay */
.modal-close {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  z-index: 510;
  font-family: var(--font-family);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.08);
}

/* Navigation arrows */
.modal-nav {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
}

.modal-nav:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.08);
}

.modal-nav:disabled {
  opacity: 0.30;
  cursor: not-allowed;
  transform: none;
}

/* Image container: 4:1 ratio, fills remaining width */
.modal-image-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}

.modal-image {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 1;
  object-fit: contain;
  border-radius: 12px;
  display: block;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.60);
}

/* "2 / 4" indicator */
.modal-indicator {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  letter-spacing: 0.03em;
  font-family: var(--font-family);
}

/* ============================================================
   YOUTUBE THUMBNAIL TOOL — 16:9 aspect-ratio modifier
   Applied to .cover-card__image-wrap and .modal-image on the
   YouTube Thumbnail Generator page. Overrides the default 4:1
   LinkedIn ratio. Brandbook §Multi-Variant Result Layout.
   ============================================================ */

/* Image wrap: 16:9 aspect-ratio for YouTube thumbnails */
.cover-card__image-wrap--16-9 {
  aspect-ratio: 16 / 9;
}

/* YouTube text input field — single-line, consistent with textarea style */
.field-input {
  width: 100%;
  padding: var(--space-4);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text-body);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  line-height: 1.6;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.field-input::placeholder {
  color: var(--color-text-muted);
}

.field-input:hover {
  border-color: #c8c8c8;
}

.field-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(3, 191, 172, 0.12);
}

/* 3-column upload row for YouTube (3 reference images) */
.upload-row--3col {
  grid-template-columns: 1fr 1fr 1fr;
}

/* YouTube modal image: 16:9 ratio */
.modal-image--16-9 {
  aspect-ratio: 16 / 9;
}

/* YouTube card body: no avatar protrusion, reduce top padding */
.cover-card__body--no-avatar {
  padding-top: var(--space-5);
}

/* ============================================================
   FOOTER — Removed in v6 (sidebar layout).
   Footer link now lives in .sidebar__footer.
   .footer and .footer__link selectors kept as no-ops so
   any cached markup doesn't break visually.
   ============================================================ */
.footer {
  display: none;
}

.footer__link {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.footer__link:hover {
  color: var(--color-accent);
}

/* ============================================================
   ANIMATIONS (Brandbook §Animation Standards)
   ============================================================ */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   RESPONSIVE — Mobile (Brandbook §Layout v6)
   Sidebar collapses; mobile top bar is shown instead.
   Content area fills full width below the top bar.
   ============================================================ */
@media (max-width: 768px) {

  /* Show mobile top bar */
  .mobile-topbar {
    display: flex;
  }

  /* Hide sidebar by default on mobile — slides in when .sidebar--open */
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.sidebar--open {
    transform: translateX(0);
  }

  /* Content area takes full width; top padding clears the mobile top bar */
  .content-area {
    margin-left: 0;
  }

  .content-main {
    padding: var(--space-10) var(--space-4);
    padding-top: calc(56px + var(--space-6)); /* 56px = mobile-topbar height */
  }

  .page-title {
    padding-bottom: var(--space-6);
    margin-bottom: var(--space-6);
  }

  .upload-row {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* 3-col upload row also collapses to single column on mobile */
  .upload-row--3col {
    grid-template-columns: 1fr;
  }

  /* Result header stacks on mobile */
  .result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }

  .result-header__actions {
    width: 100%;
  }

  .result-header__actions .btn-secondary,
  .result-header__actions .btn-primary {
    flex: 1;
    justify-content: center;
  }

  /* Covers grid: single column on tablet/mobile */
  .covers-grid {
    grid-template-columns: 1fr;
  }

  /* Per-card actions stay side-by-side unless very narrow */
  .cover-card__actions {
    flex-wrap: wrap;
  }

  .loading-card {
    padding: var(--space-10) var(--space-6);
  }

  /* Modal nav: smaller gap on mobile */
  .modal-inner {
    gap: var(--space-2);
    padding: 0 var(--space-1);
  }

  .modal-nav {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  .btn-generate {
    width: 100%;
  }

  .content-main {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  /* Modal: stack nav outside image vertically on very small screens */
  .modal-inner {
    flex-direction: column;
    gap: var(--space-3);
  }

  .modal-nav--prev,
  .modal-nav--next {
    order: 0;
  }

  .modal-image-wrap {
    order: -1;
    width: 100%;
  }
}
