/* CSS Variables */
:root {
  --color-bg: #0f0f12;
  --color-surface: #1a1a1f;
  --color-border: #2a2a32;
  --color-text: #e8e8ed;
  --color-text-muted: #8a8a96;
  --color-accent: #6366f1;
  --color-accent-hover: #818cf8;
  --color-success: #22c55e;
  --color-error: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

/* Header */
header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.25rem;
}

nav a:hover {
  color: var(--color-accent);
}

/* Ad slots */
.ad-slot {
  min-height: 90px;
  background: var(--color-border);
  border-radius: var(--radius);
  margin: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.ad-mid {
  min-height: 280px;
  margin: 2rem 0;
}

/* Main */
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

article {
  padding: 0;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--color-text-muted);
}

.hero-description {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  margin: 0 0 2rem;
}

/* Format toggle */
.format-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.format-btn {
  flex: 1;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.format-btn:hover {
  border-color: var(--color-accent);
}

.format-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--color-accent);
  background: rgba(99, 102, 241, 0.08);
}

.drop-text {
  font-size: 1.125rem;
  margin: 0 0 0.5rem;
}

.drop-text span {
  color: var(--color-accent);
  text-decoration: underline;
}

.drop-hint {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* Loading & Error */
.loading-state,
.error-message {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: var(--radius);
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-text-muted);
}

.error-message {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-error);
}

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

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

.hidden {
  display: none !important;
}

/* Result section */
.result-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.preview-container {
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  max-height: 400px;
}

.preview-container img {
  display: block;
  max-width: 100%;
  max-height: 400px;
  margin: 0 auto;
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.download-row label {
  flex: 0 0 auto;
}

.download-row input[type="text"] {
  flex: 1;
  min-width: 140px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

.primary-btn {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: var(--color-accent-hover);
}

/* Footer */
footer {
  padding: 2rem 1.5rem;
  text-align: center;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

footer .ad-slot {
  max-width: 728px;
  margin: 0 auto 1rem;
}

/* Mobile */
@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }

  .drop-zone {
    padding: 2rem 1rem;
  }

  .format-toggle {
    flex-direction: column;
  }

  .download-row {
    flex-direction: column;
    align-items: stretch;
  }
}
