/* Center main content like ChatGPT: one box in middle, no scroll on initial state */
main.container {
  height: calc(100svh - var(--header-h) - 1px); /* 1px header border */
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 16px;
  overflow: auto; /* allow content (results) to scroll inside */
  padding-block: 0; /* avoid vertical padding adding to height */
  padding-top: 80px; /* Position content 80px below header */
}
:root {
  --bg: #ffffff;
  --text: #353740;
  --muted: #6b6e75;
  --border: #e5e7eb;
  --card: #f9fafb;
  --accent: #10a39c;
  /* Softer, minimal shadows */
  --shadow: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 2px 6px rgba(0,0,0,0.06);
  --header-h: 48px;
}

/* Dark mode variables */
[data-theme="dark"] {
  --bg: #0f0f0f;
  --text: #e1e1e1;
  --muted: #a0a0a0;
  --border: #2a2a2a;
  --card: #1a1a1a;
  --accent: #04c9bf;
  --shadow: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-hover: 0 2px 6px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Albert Sans', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden; /* prevent page scroll; we'll scroll inside main */
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.header-inner.container { padding: 0; }

/* ChatGPT-like hero */
.top-hero { display: grid; place-items: center; margin-bottom: 16px; }
.hero-title { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 16px; }
.hero-description { font-size: 16px; line-height: 1.5; max-width: 580px; text-align: center; margin: 0; color: var(--muted); }

/* Center sections like OpenAI chat */
.upload-section, .results-section { display: grid; justify-items: center; text-align: center; gap: 12px; }

/* Center cards grid within narrow container */
.cards { justify-content: center; }

.app-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.8);
  backdrop-filter: saturate(180%) blur(8px);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .app-header {
  background: rgba(15,15,15,0.8);
  backdrop-filter: saturate(180%) blur(8px);
}

.header-inner { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  width: 100%; 
}
.app-header .container { padding: 0 20px; }
.brand { 
  display: inline-flex; 
  align-items: center; 
  gap: 8px; 
  font-weight: 700; 
  letter-spacing: -0.02em; 
  font-size: 16px; 
  margin-left: 0;
}
.brand .logo { width: auto; height: 16px; display: block; }
.brand svg { height: 20px; width: auto; display: block; }
.nav { 
  display: inline-flex; 
  gap: 12px; 
  align-items: center;
  margin-right: 0;
}
.nav-link { 
  color: var(--text); 
  text-decoration: none; 
  margin-right: 0;
  font-size: 14px;
  position: relative;
  padding: 8px 12px !important;
  border-radius: 8px;
}

/* Contact button icon animation */
.contact-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 4px;
  width: 16px;
  height: 16px;
}

.contact-icon-static {
  opacity: 1;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.contact-icon-animated {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.nav-link:hover .contact-icon-static {
  opacity: 0;
}

.nav-link:hover .contact-icon-animated {
  opacity: 1;
}

/* Dark mode toggle */
.dark-mode-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 16px;
  width: 36px;
  height: 36px;
  position: relative;
}

.dark-mode-toggle:hover {
  background: var(--card);
  border-color: var(--accent);
}

.toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  position: relative;
}

/* Static icons - shown by default */
.toggle-icon-static {
  opacity: 1;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Animated icons - hidden by default */
.toggle-icon-animated {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition: opacity 0.2s ease;
}

/* Show animated icons on hover */
.dark-mode-toggle:hover .toggle-icon-static {
  opacity: 0;
}

.dark-mode-toggle:hover .toggle-icon-animated {
  opacity: 1;
}

/* Icon visibility based on theme */
/* Light mode: show moon, hide sun */
.moon-static,
.moon-animated {
  display: block;
}

.sun-static,
.sun-animated {
  display: none;
}

/* Dark mode: show sun, hide moon */
[data-theme="dark"] .moon-static,
[data-theme="dark"] .moon-animated {
  display: none;
}

[data-theme="dark"] .sun-static,
[data-theme="dark"] .sun-animated {
  display: block;
}

/* Dark mode support for toggle icons */
.toggle-icon svg path {
  fill: var(--text);
  transition: fill 0.3s ease;
}

/* Button icons styling */
.btn svg,
.nav-link svg {
  margin-right: 8px;
  flex-shrink: 0;
}

.btn,
.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ensure button text and icons are properly aligned */
.btn svg {
  color: currentColor;
}

.nav-link svg {
  color: currentColor;
}



/* Contact button icon positioning fix */
.contact-icon-static,
.contact-icon-animated {
  display: flex;
  align-items: center;
  margin-right: 8px;
  width: 16px;
  height: 16px;
}

/* Dark mode support for contact icons */
[data-theme="dark"] .contact-icon-static svg path,
[data-theme="dark"] .contact-icon-animated svg path {
  fill: var(--text);
}

/* Reset button icon animation */
.reset-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 0;
  width: 16px;
  height: 16px;
}

.reset-icon-static {
  opacity: 1;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.reset-icon-animated {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.resetBtn:hover .reset-icon-static,
#resetBtn:hover .reset-icon-static {
  opacity: 0;
}

.resetBtn:hover .reset-icon-animated,
#resetBtn:hover .reset-icon-animated {
  opacity: 1;
}

/* Dark mode support for reset icons */
[data-theme="dark"] .reset-icon-static svg path,
[data-theme="dark"] .reset-icon-animated svg path {
  fill: var(--text);
}

/* Generate Again button icon animation */
.regen-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 0;
  width: 16px;
  height: 16px;
}

.regen-icon-static {
  opacity: 1;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.regen-icon-animated {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.regen-icon-animated svg {
  width: 16px;
  height: 16px;
}

.regenBtn:hover .regen-icon-static,
#regenBtn:hover .regen-icon-static {
  opacity: 0;
}

.regenBtn:hover .regen-icon-animated,
#regenBtn:hover .regen-icon-animated {
  opacity: 1;
}

/* Dark mode support for regen icons */
[data-theme="dark"] .regen-icon-static svg path,
[data-theme="dark"] .regen-icon-animated svg path {
  /* Match button label color (black in dark mode for primary buttons) */
  fill: currentColor;
}

/* Force Generate Again icon to be black in dark mode */
[data-theme="dark"] #regenBtn .regen-icon-static svg,
[data-theme="dark"] #regenBtn .regen-icon-animated svg {
  color: #000000;
}
[data-theme="dark"] #regenBtn .regen-icon-static svg path,
[data-theme="dark"] #regenBtn .regen-icon-animated svg path {
  fill: #000000;
}

/* Restart button icon animation */
.restart-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 0;
  width: 16px;
  height: 16px;
}

.restart-icon-static {
  opacity: 1;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.restart-icon-animated {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.restart-icon-animated svg {
  width: 16px;
  height: 16px;
}

.btn:hover .restart-icon-static {
  opacity: 0;
}

.btn:hover .restart-icon-animated {
  opacity: 1;
}

/* Dark mode support for restart icons */
[data-theme="dark"] .restart-icon-static svg path,
[data-theme="dark"] .restart-icon-animated svg path {
  fill: var(--text);
}

/* Download button icon animation */
.download-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 0;
  width: 16px;
  height: 16px;
}

.download-icon-static {
  opacity: 1;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.download-icon-animated {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.download-icon-animated svg {
  width: 16px;
  height: 16px;
  /* Compensate for animated SVG viewBox of -3.2 -3.2 22.4 22.4 vs 16x16 static */
  transform: scale(1.4);
  transform-origin: 8px 8px;
}

.btn:hover .download-icon-static {
  opacity: 0;
}

.btn:hover .download-icon-animated {
  opacity: 1;
}

/* Dark mode support for download icons */
[data-theme="dark"] .download-icon-static svg path,
[data-theme="dark"] .download-icon-animated svg path {
  fill: var(--text);
}

/* Footer */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  text-align: center;
  z-index: 10;
}

.footer p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* hero */
.hero { display: none; }
.hero-inner { 
  background: linear-gradient(135deg, rgba(16,163,127,0.1), rgba(16,163,127,0) 60%), #f7faf9;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
}
.hero-title { margin: 0 0 8px; font-size: 36px; letter-spacing: -0.02em; }
.hero-sub { margin: 0 0 16px; color: var(--muted); font-size: 16px; }
.hero-cta { display: flex; gap: 12px; }

.upload-section { gap: 12px; }
.drop-area {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 48px;
  background: var(--card);
  box-shadow: none;
  display: grid;
  place-items: center;
  /* Keep box size stable between upload and loader states */
  min-height: 260px;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.drop-area:hover, .drop-area:focus {
  border-color: var(--accent);
  background: #f3f7f6;
  outline: none;
}
.drop-area.hover {
  border-color: var(--accent);
  background: #f3f7f6;
}

[data-theme="dark"] .drop-area:hover,
[data-theme="dark"] .drop-area:focus,
[data-theme="dark"] .drop-area.hover {
  background: #2a2a2a;
}
.drop-inner { text-align: center; }
.upload-loader {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 24px 0;
}
.upload-loader .loader-copy {
  color: var(--muted);
  font-size: 14px;
  margin: 8px 0 0;
}
/* Make loader icon respect theme colors */
.upload-loader svg path { fill: var(--text); }
.drop-inner .icon { 
  font-size: 28px; 
  margin-bottom: 12px; 
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Dark mode support for upload icon */
[data-theme="dark"] .drop-inner .icon svg path {
  fill: var(--text);
}
.drop-inner h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.drop-inner .muted { color: var(--muted); margin: 8px 0 16px; }
.drop-inner input[type="file"] { display: inline-block; }
.drop-inner input[type="file"] { opacity: 0; position: absolute; width: 100%; height: 100%; cursor: pointer; }

.results-section { margin-top: 16px; }
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 960px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}

/* Responsive visibility for animation preview cards (3 → 2 → 1) */
/* Medium screens: show first 2 cards in a 2-column grid, hide the 3rd+ */
@media (min-width: 640px) and (max-width: 959.98px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cards .card:nth-child(n+3) { display: none; }
}

/* Small screens: show only the first card in a single column */
@media (max-width: 639.98px) {
  .cards { grid-template-columns: 1fr; }
  .cards .card:nth-child(n+2) { display: none; }
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card .label {
  font-size: 14px;
  font-weight: 600;
}
.card .preview {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid;
  place-items: center;
  padding: 16px;
  aspect-ratio: 1 / 1; /* ensure square preview */
  /* Constrain preview size regardless of original SVG dimensions */
  max-width: 200px;
  min-width: 32px;
  margin: 0 auto; /* center within card */
}
/* Scale inline SVG within the square preview without overflow */
.card .preview > svg { width: 100%; max-height: 100%; height: auto; display: block; }

/* Consistent action/controls styling within cards */
.card .actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card .actions .btn {
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
}
.card .actions label {
  font-size: 14px;
  color: var(--text);
}
.card .actions input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Thin 1px separator between action groups */
.card .actions .action-sep {
  flex-basis: 100%;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

[data-theme="dark"] .btn.primary {
  color: #000000;
}
.btn.primary:hover { filter: brightness(1.02); }

.again-row { 
  margin-top: 16px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 10px;
  flex-wrap: wrap;
}

.hidden { display: none !important; }

svg { max-width: 100%; height: auto; }
