@font-face {
  font-family: "Alte Haas Grotesk";
  src: url("../fonts/AlteHaasGroteskRegular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Alte Haas Grotesk";
  src: url("../fonts/AlteHaasGroteskBold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Light theme (default) ── */
:root {
  --bg: #f3f3f8;
  --surface: #f8f8fc;
  --panel: #ffffff;
  --panel-raised: #ededf5;
  --border: #dddde8;
  --border-bright: #c8c8d8;
  --accent: #6d4fc2;
  --accent-dim: rgba(109, 79, 194, 0.09);
  --accent-hover: #7c5cfc;
  --text: #18182a;
  --text-muted: #52527a;
  --text-faint: #9898b8;
  --success: #16a34a;
  --danger: #dc2626;
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --container: 1100px;
  --r: 14px;
  --r-sm: 8px;
  --r-lg: 20px;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg: #0d0d12;
  --surface: #16161e;
  --panel: #1d1d28;
  --panel-raised: #26263a;
  --border: #2c2c3e;
  --border-bright: #3e3e56;
  --accent: #7c5cfc;
  --accent-dim: rgba(124, 92, 252, 0.13);
  --accent-hover: #9478fd;
  --text: #eeeef5;
  --text-muted: #7878a0;
  --text-faint: #464666;
  --success: #22c55e;
  --danger: #ef4444;
  --topbar-bg: rgba(13, 13, 18, 0.88);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-width: 320px;
}

body {
  min-height: 100vh;
  font-family: "Alte Haas Grotesk", sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ── Background ── */
.site-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(109, 79, 194, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 0%, rgba(59, 130, 246, 0.04) 0%, transparent 50%),
    var(--bg);
}

[data-theme="dark"] .site-bg {
  background:
    radial-gradient(ellipse at 15% 0%, rgba(124, 92, 252, 0.11) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 0%, rgba(56, 182, 255, 0.06) 0%, transparent 50%),
    var(--bg);
}

/* ── Layout ── */
.container {
  width: min(var(--container), calc(100% - 2rem));
  margin: 0 auto;
}

/* ── Header ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand {
  text-decoration: none;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-logo {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.main-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  font-size: 0.88rem;
  transition: color 140ms, background 140ms;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  color: var(--text);
  background: var(--accent-dim);
  outline: none;
}

/* ── Theme toggle ── */
.theme-toggle {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 140ms, color 140ms;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--panel-raised);
  color: var(--text);
}

.theme-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* light mode → show moon (to go dark) */
.theme-icon-sun  { display: none; }
.theme-icon-moon { display: block; }

/* dark mode → show sun (to go light) */
[data-theme="dark"] .theme-icon-sun  { display: block; }
[data-theme="dark"] .theme-icon-moon { display: none; }

/* ── Main ── */
.page-main {
  padding: 3rem 0 4.5rem;
  flex: 1;
}

/* ── Hero ── */
.hero {
  text-align: center;
  max-width: 660px;
  margin: 0 auto 2.25rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.85rem, 4vw, 2.9rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero p {
  margin: 0 0 1.4rem;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.hero-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.hero-tag {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
}

/* ── Upload card ── */
.upload-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.4rem;
  margin-bottom: 1.1rem;
}

.upload-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.upload-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}

.upload-card-hint {
  color: var(--text-faint);
  font-size: 0.8rem;
}

.upload-box {
  width: 100%;
  min-height: 160px;
  border: 2px dashed var(--border-bright);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.55rem;
  text-align: center;
  transition: border-color 160ms, background 160ms;
  padding: 1.75rem;
}

.upload-box:hover,
.upload-box:focus-visible,
.upload-box.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  outline: none;
}

.upload-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent-dim);
  border: 1px solid rgba(109, 79, 194, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.1rem;
}

[data-theme="dark"] .upload-icon {
  border-color: rgba(124, 92, 252, 0.28);
}

.upload-icon svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-label {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.92rem;
}

.upload-help {
  color: var(--text-faint);
  font-size: 0.82rem;
}

.upload-card-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.multi-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border-bright);
  background: var(--surface);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 140ms, border-color 140ms, background 140ms;
  flex-shrink: 0;
}

.multi-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.multi-toggle.is-active {
  color: var(--panel);
  border-color: var(--accent);
  background: var(--accent);
}

.multi-toggle svg {
  flex-shrink: 0;
}

/* ── Tool output ── */
.tool-output {
  margin-bottom: 1.1rem;
}

/* ── Image card (multi-image wrapper) ── */
.image-card {
  margin-bottom: 1.1rem;
}

.image-card-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  gap: 0.75rem;
}

.image-card-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: ui-monospace, "Cascadia Code", monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-card-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 0.82rem;
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  line-height: 1;
  transition: color 120ms, background 120ms;
  flex-shrink: 0;
}

.image-card-remove:hover {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
}

[data-theme="dark"] .image-card-remove:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* override body-image-info border-radius when inside a card */
.image-card .body-image-info {
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ── Image panel ── */
.body-image-info {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  height: 520px;
}

.preview-div {
  border-right: 1px solid var(--border);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
}

.preview-div-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.preview-reset-btn {
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.62rem;
  cursor: pointer;
  transition: border-color 140ms, color 140ms, background 140ms;
}

.preview-reset-btn:hover {
  border-color: var(--accent-hover);
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.preview-reset-btn.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.preview-img {
  width: 100%;
  flex: 1;
  min-height: 0;
  max-height: 480px;
  object-fit: contain;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--panel-raised);
  cursor: crosshair;
  touch-action: none;
  display: block;
}

.preview-stage {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  max-height: 480px;
}

.preview-stage .preview-img {
  height: 100%;
  max-height: none;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-radius: var(--r-sm);
}

.preview-img.is-picking {
  cursor: none;
}

.preview-footer {
  color: var(--text-faint);
  font-size: 0.78rem;
  text-align: center;
}

/* ── Color panel ── */
.color-panel {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  overflow-y: auto;
}

/* ── Big swatch ── */
.color-display {
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--border);
}

.color-swatch-large {
  width: 100%;
  height: 88px;
  background: var(--surface);
  transition: background 200ms, filter 160ms;
  cursor: pointer;
}

.color-swatch-large:hover {
  filter: brightness(0.88);
}

.color-swatch-info {
  padding: 0.55rem 0.8rem;
  background: var(--panel-raised);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.color-swatch-hex {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: ui-monospace, "Cascadia Code", monospace;
  color: var(--text);
}

.color-swatch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-bright);
  transition: background 200ms;
}

/* ── Code rows ── */
.color-codes {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.color-code-row {
  display: flex;
  align-items: center;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 140ms;
}

.color-code-row:hover {
  border-color: var(--border-bright);
}

.color-code-label {
  width: 58px;
  min-height: 42px;
  background: var(--panel-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  flex-shrink: 0;
}

.color-code-row input {
  flex: 1;
  border: 0;
  min-height: 42px;
  background: transparent;
  color: var(--text);
  padding: 0 0.6rem;
  font-size: 0.85rem;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

.color-code-row input:focus {
  outline: none;
}

.color-code-row input::placeholder {
  color: var(--text-faint);
}

.code-copy-btn {
  min-height: 42px;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: background 140ms;
  flex-shrink: 0;
  padding: 0;
}

.code-copy-btn:hover {
  background: var(--accent-dim);
}

.code-copy-btn img {
  width: 15px;
  opacity: 0.35;
  transition: opacity 160ms;
}

[data-theme="dark"] .code-copy-btn img {
  filter: invert(1);
}

.code-copy-btn:hover img {
  opacity: 0.7;
}

/* ── Palette & History ── */
.palette-section,
.history-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.palette-section.is-hidden,
.history-section.is-hidden {
  display: none;
}

.palette-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem;
}

.palette-swatch {
  aspect-ratio: 1;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 130ms, box-shadow 130ms;
  padding: 0;
  position: relative;
}

[data-theme="dark"] .palette-swatch {
  border-color: rgba(255, 255, 255, 0.07);
}

.palette-swatch:hover {
  transform: scale(1.12);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.palette-swatch.is-active {
  box-shadow: 0 0 0 2px var(--accent), 0 5px 14px rgba(0, 0, 0, 0.24);
  transform: scale(1.08);
}

[data-theme="dark"] .palette-swatch:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.history-swatches {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.history-swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 130ms;
  padding: 0;
}

[data-theme="dark"] .history-swatch {
  border-color: rgba(255, 255, 255, 0.08);
}

.history-swatch:hover {
  transform: scale(1.18);
}

/* ── Ad slots ── */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: var(--r);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-faint);
  margin-bottom: 1.1rem;
}

.ad-slot p {
  margin: 0;
  font-size: 0.8rem;
  width: 100%;
}

.ad-slot-horizontal {
  min-height: 96px;
}

.ad-slot ins.adsbygoogle {
  display: block;
  width: 100%;
}

/* ── Generic section ── */
.section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  margin-bottom: 1.1rem;
}

.section h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.section > p {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.section strong {
  color: var(--text);
}

/* ── Steps ── */
.steps {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(3, 1fr);
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.1rem;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent-dim);
  border: 1px solid rgba(109, 79, 194, 0.22);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

[data-theme="dark"] .step-number {
  border-color: rgba(124, 92, 252, 0.28);
}

.step-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
}

.step-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

/* ── FAQ ── */
.faq details {
  border-top: 1px solid var(--border);
  padding: 0.8rem 0;
}

.faq details:first-of-type {
  margin-top: 0.4rem;
}

.faq details:last-of-type {
  border-bottom: 1px solid var(--border);
}

.faq summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

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

.faq summary::after {
  content: "+";
  color: var(--text-faint);
  font-size: 1.05rem;
  flex-shrink: 0;
  font-weight: 400;
}

.faq details[open] summary::after {
  content: "−";
}

.faq p {
  margin: 0.6rem 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.faq a {
  color: var(--accent);
  text-decoration: none;
}

.faq a:hover {
  text-decoration: underline;
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  margin-top: auto;
}

.footer-grid {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.4rem 0;
}

.footer-brand {
  margin: 0;
  font-weight: 700;
  font-size: 0.92rem;
}

.footer-muted {
  margin: 0.3rem 0 0;
  color: var(--text-faint);
  font-size: 0.8rem;
}

.footer-links {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.83rem;
  transition: color 140ms;
}

.footer-links a:hover {
  color: var(--text);
}

.footer-copy {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  padding: 0.7rem 0;
}

/* ── Loupe ── */
#loupe {
  position: fixed;
  left: 0;
  top: 0;
  width: 220px;
  height: 220px;
  will-change: transform;
  border-radius: 50%;
  /* No CSS border — the colored ring is drawn on the canvas itself */
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  display: none;
  overflow: hidden;
  z-index: 9999;
}

#loupeCanvas {
  position: absolute;
  inset: 0;
  width: 220px;
  height: 220px;
  /* Crisp pixel rendering — no browser interpolation */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#loupeHex {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.06em;
  font-weight: 700;
  font-family: ui-monospace, "Cascadia Code", monospace;
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
  /* Ensure it sits above the canvas pixels */
  pointer-events: none;
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  top: 74px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 99999;
  pointer-events: none;
}

.toast {
  min-width: 190px;
  max-width: 290px;
  padding: 9px 13px;
  color: #fafafa;
  font-size: 13px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transform: translateY(-4px);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: rgba(22, 163, 74, 0.96); }
.toast.error   { background: rgba(220, 38, 38, 0.96); }
.toast.info    { background: rgba(30, 30, 48, 0.97); border: 1px solid var(--border); }

/* ── Custom colour picker popup ── */
.color-picker-popup {
  position: fixed;
  z-index: 10001;
  background: var(--panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--r);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.12);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 224px;
  touch-action: none;
  user-select: none;
}

.color-picker-popup[hidden] { display: none; }

.cp-gradient-box {
  position: relative;
  width: 100%;
  height: 152px;
  border-radius: 6px;
  cursor: crosshair;
  overflow: hidden;
  flex-shrink: 0;
}

.cp-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cp-bottom-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cp-hue-slider {
  position: relative;
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: pointer;
  flex-shrink: 0;
}

.cp-hue-cursor {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cp-preview {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  flex-shrink: 0;
}

/* ── Legal pages ── */
.legal-main {
  padding: 2.5rem 0 4rem;
  flex: 1;
}

.legal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2rem 2.25rem;
  max-width: 700px;
  margin: 0 auto;
}

.legal-card h1 {
  margin: 0 0 0.2rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.legal-date {
  display: block;
  color: var(--text-faint);
  font-size: 0.82rem;
  margin-bottom: 1.75rem;
}

.legal-card h2 {
  margin: 1.6rem 0 0.4rem;
  font-size: 1rem;
}

.legal-card p,
.legal-card li {
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0;
}

.legal-card ul {
  margin: 0.5rem 0 0;
  padding-left: 1.4rem;
}

.legal-card li {
  margin-bottom: 0.3rem;
}

.legal-card a {
  color: var(--accent);
  text-decoration: none;
}

.legal-card a:hover {
  text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .body-image-info {
    grid-template-columns: 1fr;
    height: auto;
  }

  .preview-div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  /* Give the stage a concrete height so object-fit:contain works in auto-height layout */
  .preview-stage {
    flex: none;
    height: 280px;
  }

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

@media (max-width: 600px) {
  .topbar-inner {
    min-height: 54px;
  }

  .main-nav {
    display: none;
  }

  .page-main {
    padding-top: 1.75rem;
    padding-bottom: 3rem;
  }

  .hero {
    margin-bottom: 1.5rem;
  }

  .hero h1 {
    font-size: 1.65rem;
  }

  /* Upload card */
  .upload-card {
    padding: 1rem;
  }

  .upload-card-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  .upload-card-actions {
    width: 100%;
    justify-content: space-between;
  }

  .upload-box {
    min-height: 120px;
    padding: 1.25rem;
  }

  /* Image panel */
  .preview-stage {
    height: 220px;
  }

  .preview-div {
    padding: 0.9rem;
    gap: 0.6rem;
  }

  .color-panel {
    padding: 1rem;
    gap: 0.9rem;
  }

  .color-swatch-large {
    height: 64px;
  }

  /* Bigger touch targets for history */
  .history-swatch {
    width: 32px;
    height: 32px;
  }

  /* Color picker: use more of the screen width on phones */
  .color-picker-popup {
    width: calc(100vw - 24px);
    max-width: 300px;
  }

  /* Generic sections */
  .section {
    padding: 1.2rem;
  }

  .legal-card {
    padding: 1.4rem;
  }

  .footer-grid {
    flex-direction: column;
    gap: 0.75rem;
  }
}

@media (max-width: 400px) {
  /* Hide format hint on very narrow screens — multi-toggle already uses the row */
  .upload-card-hint {
    display: none;
  }

  .preview-stage {
    height: 180px;
  }
}
