@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@300;600&family=Space+Grotesk:wght@400;600&display=swap");

:root {
  --bg: #f8f1e7;
  --paper: #fff9f1;
  --ink: #1f1b16;
  --muted: #6b6056;
  --accent: #c44d2a;
  --accent-soft: #f3d4c1;
  --shadow: 0 20px 50px rgba(31, 27, 22, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fef8ef 0%, #f8f1e7 45%, #efe3d3 100%);
  min-height: 100vh;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 40px;
}


/* ── Progress Header (analysis page) ── */
.progress-header {
  position: relative;
  padding: 20px 0 28px;
  text-align: center;
  transition: padding 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.progress-brand {
  position: absolute;
  top: 22px;
  left: 0;
  margin: 0;
}

.progress-brand a {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: 28px;
  letter-spacing: 0.01em;
  color: #1f1b16;
  text-decoration: none;
  line-height: 1;
  position: relative;
  display: inline-block;
  padding: 8px 10px 8px 8px;
}

.progress-brand a::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  border-top: 1.5px solid #2A7585;
  border-left: 1.5px solid #2A7585;
}

.progress-brand a::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-bottom: 1.5px solid #2A7585;
  border-right: 1.5px solid #2A7585;
}

.progress-brand a:hover { color: var(--accent); }

.progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  padding: 0 24px;
  position: relative;
}

/* Connector line between steps */
.progress-step + .progress-step::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 48px;
  height: 2px;
  background: #e1d4c6;
  transform: translateX(24px);
  transition: background 0.2s ease;
}

.progress-step + .progress-step.done::before,
.progress-step + .progress-step.active::before {
  background: #2A7585;
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  border: 2px solid #e1d4c6;
  background: transparent;
  color: var(--muted);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.step-label {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s ease-in-out, font-size 0.2s ease-in-out, font-weight 0.2s ease-in-out;
}

/* Done step */
.progress-step.done .step-number {
  background: #2A7585;
  border-color: #2A7585;
  color: #fff;
  animation: checkmarkFadeIn 0.2s ease-in-out;
}

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

.progress-step.done .step-label {
  color: #2A7585;
}

/* Active step */
.progress-step.active .step-number {
  border-color: #2A7585;
  color: #2A7585;
}

.progress-step.active .step-label {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}

/* ── Compact sticky state ── */
.progress-header.compact {
  position: sticky;
  top: 0;
  z-index: 800;
  background: rgba(248, 241, 231, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 0;
  box-shadow: 0 2px 12px rgba(31, 27, 22, 0.08);
  border-bottom: 1px solid rgba(225, 212, 198, 0.6);
}

.progress-header.compact .progress-brand {
  display: none;
}

.progress-header.compact .step-number {
  width: 22px;
  height: 22px;
  font-size: 10px;
}

.progress-header.compact .step-label {
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: 13px;
  font-weight: 500;
}

.progress-header.compact .progress-step.active .step-label {
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: 13px;
  font-weight: 600;
}

.progress-header.compact .progress-step {
  gap: 6px;
  padding: 0 12px;
}

.progress-header.compact .progress-step + .progress-step::before {
  width: 24px;
  transform: translateX(12px);
}

.progress-spacer {
  height: 0;
}


.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #e1d4c6;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 25px rgba(196, 77, 42, 0.25);
}

.btn.primary:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 6px 16px rgba(196, 77, 42, 0.2);
}

.btn.ghost {
  background: transparent;
  border-color: #d9c8b9;
  color: var(--ink);
}

.btn.text-link {
  background: transparent;
  border: none;
  padding: 6px 4px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  box-shadow: none;
  transition: color 0.12s ease;
}

.btn.text-link:hover {
  color: var(--accent);
  text-decoration: underline;
  transform: none;
  box-shadow: none;
}

.btn:hover {
  transform: translateY(-1px);
}


.analysis-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.analysis-panel {
  background: var(--paper);
  padding: 24px 28px;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.analysis-panel h2 {
  margin: 0 0 16px;
  font-family: "Fraunces", "Times New Roman", serif;
}

.preview-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 360px; /* Prevent layout collapse for ultra-wide/panoramic images */
}

.image-caption {
  margin: 0;
  padding: 14px 16px 6px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  word-break: break-word;
  background: #fff;
  border: 1px solid #efe1d2;
  border-bottom: none;
  border-radius: 20px 20px 0 0;
}

.preview-container .preview-frame {
  border-top: none;
  border-bottom: none;
}

.preview-container .preview-frame.upload-mode {
  border: 1px solid #efe1d2;
  border-radius: 20px;
}

/* ── Card footer bar ── */
.card-footer {
  margin: 0;
  padding: 10px 16px;
  background: #f5f0e8;
  border: 1px solid #efe1d2;
  border-top: none;
  border-radius: 0 0 20px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-footer-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #5a5047;
  line-height: 1.4;
  min-width: 0;
}

.card-footer-left .callout-icon {
  flex-shrink: 0;
  font-size: 14px;
  opacity: 0.7;
}

.card-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.card-footer-crop {
  padding: 6px 14px;
  font-size: 13px;
}

.analysis-stats {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 20px;
}

.analysis-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.analysis-section {
  margin-top: 48px;
  padding-top: 40px;
  border-top: 1px solid #e1d4c6;
}

.section-header {
  text-align: center;
  margin-bottom: 12px;
}

.analysis-section h2 {
  margin: 0;
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}


.section-hint {
  margin: 0 0 28px;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.01em;
}

.section-hint .hint-icon {
  color: #2A7585;
  font-size: 16px;
}

.export-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--paper);
  border-top: 1px solid #e3d4c6;
  box-shadow: 0 -8px 24px rgba(31, 27, 22, 0.1);
  padding: 14px 20px;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.2s ease-out, visibility 0.2s ease-out;
}

.export-bar.visible {
  transform: translateY(0);
  visibility: visible;
}

.export-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.export-bar-info {
  flex: 1;
  min-width: 0;
}

.source-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 28px;
  align-items: start;
}

.source-layout.upload-mode {
  align-items: center;
}

.source-layout.upload-mode .source-meta {
  padding-top: 0;
}

.preview-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 760px;
}

.preview-frame {
  background: #fff;
  padding: 16px;
  border: 1px solid #efe1d2;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 280px; /* Prevent layout collapse for ultra-wide/panoramic images */
  min-width: 200px;  /* Prevent ultra-narrow display for extreme portraits */
  overflow: hidden;  /* Prevent canvas overflow at reduced zoom */
}

/* ── Upload Dropzone ── */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px 24px;
  min-height: 320px;
  width: 100%;
  box-sizing: border-box;
  border: 2px dashed #e3d4c6;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.upload-dropzone:hover,
.upload-dropzone:focus-visible {
  border-color: #c9b9a8;
  background: #fdf8f3;
  outline: none;
}

.upload-dropzone.drag-over {
  border-color: #b5a494;
  background: #faf5ee;
  box-shadow: 0 8px 24px rgba(31, 27, 22, 0.08);
}

.dropzone-icon {
  color: var(--muted);
  width: 48px;
  height: 48px;
}

.dropzone-hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.upload-dropzone.fade-out {
  animation: fadeOut 0.2s ease forwards;
}

#preview-canvas.fade-in-canvas {
  animation: fadeIn 0.25s ease;
}

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

/* ── Phase Upload Placeholder (right panel) ── */
.phase-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

.placeholder-heading {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 12px;
}

.placeholder-subtext {
  font-size: 15px;
  color: var(--ink);
  margin: 0;
  line-height: 1.5;
}

/* ── Screen-reader only utility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.preview-container:has(.preview-frame.cropping) {
  box-shadow: 0 0 0 2px rgba(196, 77, 42, 0.35);
  border-radius: 20px;
}

.preview-frame.cropping canvas {
  cursor: crosshair;
}



.preview-column .crop-status {
  margin-top: 8px;
}

.source-meta {
  display: flex;
  flex-direction: column;
  padding-top: 16px;
}

/* Phase 1: Content Selection */
.phase-content-selection {
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.phase1-intro {
  margin-bottom: 24px;
}

.phase1-title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 12px;
}

.phase1-helper {
  font-size: 15px;
  color: var(--ink);
  margin: 0 0 10px;
  line-height: 1.5;
}

.phase1-helper:last-child {
  margin-bottom: 0;
}

.analyze-cta {
  padding: 14px 24px;
  font-size: 16px;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(196, 77, 42, 0.3);
}

.analyze-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(196, 77, 42, 0.35);
}

.analyze-cta:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 6px 16px rgba(196, 77, 42, 0.2);
}

/* Phase 2: Analyzing state */
.phase-analyzing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  min-height: 200px;
}

.analyzing-spinner {
  width: 32px;
  height: 32px;
  border-width: 3px;
  margin-bottom: 16px;
}

.analyzing-text {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

/* Phase 3: Results */
.phase-results {
  padding: 20px 0;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.phase-results.fade-in {
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Success/failure message header */
.success-header {
  margin: 0 0 4px;
}

.success-title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 8px;
}

.success-subtext {
  font-size: 15px;
  color: var(--ink);
  margin: 0;
  line-height: 1.5;
}

.info-tooltip {
  position: relative;
  font-size: 13px;
  color: var(--muted);
  cursor: help;
  margin-left: 2px;
}

.info-tooltip::after {
  content: attr(aria-label);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #e6d7c8;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(31, 27, 22, 0.12);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
  z-index: 100;
}

.info-tooltip:hover::after,
.info-tooltip:focus::after {
  opacity: 1;
  visibility: visible;
}

.success-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.failure-header {
  margin: 0 0 4px;
}

.failure-title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 26px;
  font-weight: 600;
  color: #8B4532;
  margin: 0 0 8px;
}

.failure-subtitle {
  font-size: 15px;
  color: var(--ink);
  margin: 0;
}

/* Best fit recommendation card */
.best-fit-card {
  position: relative;
  background: #fff;
  border: 2px solid #2A7585;
  border-radius: 18px;
  padding: 18px 20px;
  margin-top: 20px;
}

.best-fit-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.best-fit-ratio-name {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.best-fit-badge {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #2A7585;
  background: #f5fbfc;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #2A7585;
}

.best-fit-loss {
  margin-bottom: 16px;
}

.best-fit-loss .loss-copy {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}

.best-fit-loss.loss-minimal .loss-copy {
  color: #2A7585;
}

.best-fit-loss.loss-acceptable .loss-copy {
  color: #6F5B42;
}

.best-fit-loss.loss-significant .loss-copy,
.best-fit-loss.loss-severe .loss-copy {
  color: #8B4532;
}

.loss-descriptor {
  font-size: 13px;
  font-weight: 400;
  margin-top: 2px;
}

.loss-minimal .loss-descriptor { color: #2A7585; }
.loss-acceptable .loss-descriptor { color: #6F5B42; }
.loss-significant .loss-descriptor { color: #a3401f; }
.best-fit-loss.loss-significant .loss-descriptor { color: #8B4532; }

.best-fit-sizes {
  margin-bottom: 12px;
}

.best-fit-sizes .sizes-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.best-fit-sizes .size-list {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.5;
}

.loss-subtext {
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 4px;
  line-height: 1.4;
}

.loss-prompt {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 8px;
  font-style: italic;
}

.best-fit-loss {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #efe1d2;
}

/* Primary CTA button */
.continue-cta {
  display: block;
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
  box-shadow: 0 8px 20px rgba(196, 77, 42, 0.25);
}

.continue-cta:hover {
  background: #b34428;
  transform: translateY(-1px);
}

.continue-cta:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 4px 12px rgba(196, 77, 42, 0.2);
}

.continue-cta:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.compare-all-link {
  display: block;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  padding: 8px;
  transition: color 0.12s ease;
}

.compare-all-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.upscale-link {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  margin-top: 8px;
  transition: color 0.12s ease;
}

.upscale-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.best-fit-card .upscale-link {
  text-align: left;
  margin-top: 12px;
}

.upscale-sizes-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 16px;
  margin-bottom: 4px;
}

.upscale-size-callout {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
}

/* Hidden section */
.analysis-section.hidden {
  display: none;
}

#preview-canvas {
  width: 100%;
  height: auto;
  max-width: 720px;
  max-height: 480px; /* Absolute cap prevents overflow at reduced zoom */
  border-radius: 0;
  background: #f2e6d7;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  touch-action: none;
}

/* Draggable cursor when in results phase */
.preview-frame.results-draggable {
  position: relative;
}

.preview-frame.results-draggable #preview-canvas {
  cursor: grab;
}

.preview-frame.results-draggable #preview-canvas.dragging {
  cursor: grabbing;
}

.preview-frame.results-draggable.drag-horizontal::after,
.preview-frame.results-draggable.drag-vertical::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(31, 27, 22, 0.4);
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 2;
}

.preview-frame.results-draggable.drag-horizontal::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 7h16M1 7l4-4M1 7l4 4M17 7l-4-4M17 7l-4 4'/%3E%3C/svg%3E");
}

.preview-frame.results-draggable.drag-vertical::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='18' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 1v16M7 1L3 5M7 1l4 4M7 17l-4-4M7 17l4-4'/%3E%3C/svg%3E");
}

.preview-frame.results-draggable.drag-horizontal:hover::after,
.preview-frame.results-draggable.drag-vertical:hover::after {
  opacity: 1;
}

.preview-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}


.crop-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  font-size: 12px;
  color: var(--muted);
}

.source-meta .preview-hint {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

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

.unavailable-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0;
}

.unavailable-divider::before,
.unavailable-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e0d6cc;
}

.unavailable-divider-text {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.ratio-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid #efe1d2;
  cursor: default;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.ratio-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(31, 27, 22, 0.12);
}

.ratio-card h4 {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
  transition: color 0.15s ease, font-weight 0.15s ease;
}

.ratio-card:hover h4,
.ratio-card.selected h4 {
  color: var(--ink);
}

.ratio-card.closest-match {
  background: #fcfaf7;
  border: 2px solid #2A7585;
  box-shadow: none;
}

.ratio-card.closest-match h4 {
  color: var(--ink);
}


.closest-match-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #2A7585;
  background: #f5fbfc;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #2A7585;
  white-space: nowrap;
}


.ratio-preview-wrap {
  position: relative;
  margin-bottom: 10px;
  border-radius: 4px;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 280px; /* Cap portrait card height while keeping previews usable */
}

.ratio-preview-wrap.drag-horizontal::after,
.ratio-preview-wrap.drag-vertical::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: rgba(31, 27, 22, 0.4);
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 2;
}

.ratio-preview-wrap.drag-horizontal::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 7h16M1 7l4-4M1 7l4 4M17 7l-4-4M17 7l-4 4'/%3E%3C/svg%3E");
}

.ratio-preview-wrap.drag-vertical::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='18' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 1v16M7 1L3 5M7 1l4 4M7 17l-4-4M7 17l4-4'/%3E%3C/svg%3E");
}

.ratio-preview-wrap.drag-horizontal:hover::after,
.ratio-preview-wrap.drag-vertical:hover::after {
  opacity: 1;
}

/* Hide drag indicator when preview is committed */
.ratio-preview-wrap:has(.ratio-preview.committed)::after {
  display: none;
}

.ratio-preview {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  background: #f2e6d7;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  margin-left: auto;
  margin-right: auto;
  cursor: grab;
  touch-action: none;
}

.ratio-preview.dragging {
  cursor: grabbing;
}

.ratio-preview.committed {
  cursor: default;
  box-shadow: 0 4px 12px rgba(31, 27, 22, 0.15), 0 2px 4px rgba(31, 27, 22, 0.1);
  transform: translateY(-2px);
  background: transparent;
}

/* Committed state for top preview canvas */
#preview-canvas.committed {
  box-shadow: 0 4px 12px rgba(31, 27, 22, 0.15), 0 2px 4px rgba(31, 27, 22, 0.1);
  transform: translateY(-2px);
  cursor: default !important;
  background: transparent;
}

/* Hide drag indicator on top preview when committed */
.preview-frame.results-draggable:has(#preview-canvas.committed)::after {
  display: none;
}

.ratio-card .loss {
  margin-top: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid #efe1d2;
}

.loss-line {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 0;
}

.loss.loss-minimal .loss-line { color: #2A7585; }
.loss.loss-acceptable .loss-line { color: #6F5B42; }
.loss.loss-significant .loss-line { color: #a3401f; }

.loss-pct {
  font-weight: 600;
}

.loss.loss-minimal .loss-pct { color: #2A7585; }
.loss.loss-acceptable .loss-pct { color: #6F5B42; }
.loss.loss-significant .loss-pct { color: #a3401f; }

.loss.loss-unavailable {
  color: var(--muted);
  font-weight: 600;
}

.ratio-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 8px;
}

.ratio-title-row h4 {
  margin: 0;
}

.ratio-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.ratio-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
}

.ratio-card .note {
  font-size: 14px;
  color: var(--muted);
  margin-top: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ratio-card .note .note-label {
  display: block;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.ratio-card .note .size-hint {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.ratio-card .note .size-list {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.ratio-card.selected {
  border: 2px solid var(--accent);
  background: #fff;
  box-shadow: 0 16px 32px rgba(196, 77, 42, 0.18);
  transform: translateY(-3px);
}

.ratio-checkbox {
  transition: transform 0.12s ease;
}

.ratio-checkbox:checked {
  transform: scale(1.1);
}

.ratio-card.unavailable {
  /* Unavailable cards show real content but are not selectable */
}

.ratio-card.unavailable .ratio-checkbox {
  display: none;
}

.ratio-card.unavailable .ratio-title-row {
  cursor: default;
}

.ratio-card.unavailable,
.ratio-card.unavailable:hover {
  border: 1px solid #efe1d2;
  transform: none;
  box-shadow: 0 8px 20px rgba(31, 27, 22, 0.08);
}

.ratio-card.unavailable:hover h4 {
  color: var(--muted);
}

.ratio-card.unavailable .ratio-preview {
  opacity: 0.6;
}

.size-unavailable-message {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.export-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}

.export-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.export-progress {
  margin-top: 10px;
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.export-progress.show {
  display: flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e0d2c3;
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

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


.export-bar .btn.primary {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.export-bar .btn.primary.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.resolution-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.resolution-badge.free {
  background: #e8f3ea;
  color: #2c5f36;
}

.resolution-badge.coming-soon {
  background: #fbf3d7;
  color: #7c5a00;
}

/* Waitlist modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(31, 27, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  position: relative;
  background: var(--paper);
  border-radius: 20px;
  padding: 32px 30px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(31, 27, 22, 0.25);
}

.modal-dismiss {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}

.modal-dismiss:hover,
.modal-dismiss:focus-visible {
  color: var(--ink);
  background: rgba(31, 27, 22, 0.06);
  outline: none;
}

.modal-card h3 {
  margin: 0 0 20px;
  padding-right: 28px;
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 20px;
}

.modal-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.modal-sizes {
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.5;
}

.modal-subtext {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.waitlist-form input[type="email"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #e1d4c6;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  margin-bottom: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.waitlist-form input[type="email"]:focus {
  border-color: #c9b9a8;
  box-shadow: 0 0 0 3px rgba(196, 77, 42, 0.1);
}

.modal-submit {
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
  border-radius: 12px;
}

.modal-card .modal-trust-line {
  margin: 32px 0 0;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  line-height: 1.3;
  white-space: nowrap;
  text-align: center;
}

.role-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.role-option {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e1d4c6;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.role-option:hover {
  border-color: var(--accent);
  background: #fffcfa;
  box-shadow: 0 4px 12px rgba(196, 77, 42, 0.1);
}

.role-option:active {
  background: #fff8f5;
}

@media (max-width: 768px) {
  .upload-dropzone {
    padding: 32px 16px;
    min-height: 220px;
  }

  .source-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .card-footer {
    flex-direction: column;
    gap: 8px;
  }

  .card-footer-right {
    justify-content: center;
  }

  .analysis-panel {
    padding: 20px;
  }

  .ratio-grid {
    grid-template-columns: 1fr;
  }

  .export-bar {
    padding: 12px 16px;
  }

  .export-bar-inner {
    gap: 12px;
  }

  .progress-brand {
    position: static;
    display: block;
    text-align: center;
    margin-bottom: 12px;
  }

  .progress-step {
    padding: 0 14px;
  }

  .progress-step .step-label {
    font-size: 13px;
  }

  .progress-step.active .step-label {
    font-size: 16px;
  }

  .step-number {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .progress-step + .progress-step::before {
    width: 28px;
    transform: translateX(14px);
  }

  .progress-header.compact .step-label {
    font-size: 11px;
  }

  .progress-header.compact .progress-step.active .step-label {
    font-size: 11px;
  }

  .progress-header.compact .progress-step {
    padding: 0 6px;
  }

  .progress-header.compact .progress-step + .progress-step::before {
    width: 12px;
    transform: translateX(6px);
  }
}

/* ── Mobile Wall ── */
.mobile-wall {
  display: none;
  min-height: 100vh;
  padding: 0 24px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 20vh;
}

.mobile-wall-content {
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.mobile-wall-brand {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: 32px;
  letter-spacing: 0.01em;
  color: #1f1b16;
  line-height: 1;
  position: relative;
  display: inline-block;
  padding: 14px 16px 14px 14px;
  margin: 0 0 48px;
}

.mobile-wall-brand::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  border-top: 1.5px solid #2A7585;
  border-left: 1.5px solid #2A7585;
}

.mobile-wall-brand::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  border-bottom: 1.5px solid #2A7585;
  border-right: 1.5px solid #2A7585;
}

.mobile-wall-headline {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 16px;
  line-height: 1.3;
}

.mobile-wall-subtext {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 32px;
  line-height: 1.5;
}

.mobile-wall-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-wall-form input[type="email"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #e1d4c6;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  outline: none;
}

.mobile-wall-form input[type="email"]:focus {
  border-color: #c9b9a8;
  box-shadow: 0 0 0 3px rgba(196, 77, 42, 0.1);
}

.mobile-wall-submit {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  border-radius: 12px;
}

.mobile-wall-trust {
  margin: 20px 0 0;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  line-height: 1.3;
  white-space: nowrap;
}

.mobile-wall-confirmed {
  font-size: 15px;
  color: var(--ink);
  margin: 0;
}

.mobile-wall-footer {
  margin-top: 24px;
  padding: 24px 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ── App Footer ── */
.app-footer {
  text-align: center;
  padding: 24px 0;
  font-size: 13px;
  color: var(--muted);
}

.footer-link {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--ink);
}

.footer-sep {
  margin: 0 8px;
  color: var(--muted);
}

@media (max-width: 768px) {
  .mobile-wall {
    display: flex;
  }

  .page,
  .export-bar,
  .modal-overlay {
    display: none !important;
  }
}

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

  /* Keep loading spinners functional */
  .spinner,
  .analyzing-spinner {
    animation-duration: 0.8s !important;
    animation-iteration-count: infinite !important;
  }
}
