/* Modern, clean design system */
:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-elevated: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --error: #dc2626;
  --success: #059669;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-elevated: #334155;
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --border: #334155;
  --accent: #3b82f6;
  --accent-light: #1e3a8a;
  --error: #ef4444;
  --success: #10b981;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

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

html { scroll-behavior: smooth; }
html, body { height: 100%; margin: 0; }

body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  border-bottom: 1px solid var(--border);
  background: var(--surface-elevated);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s ease;
}

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

.logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}

.brand:hover .logo {
  transform: scale(1.05);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-light);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary:disabled {
  filter: none;
  transform: none;
  box-shadow: var(--shadow-sm);
}

/* Hero section */
.hero {
  padding: 80px 0 60px;
  text-align: center;
}

.hero-title {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin: 0 0 40px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Main form */
.main-section {
  padding: 0 0 80px;
}

.form-container {
  max-width: 600px;
  margin: 0 auto;
}

.form {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.label {
  display: block;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 14px;
}

.input,
.textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.input.error,
.textarea.error {
  border-color: var(--error);
}

.input.error:focus,
.textarea.error:focus {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.1);
}

.field-error {
  color: var(--error);
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
}

/* Results */
.results {
  max-width: 800px;
  margin: 40px auto 0;
}

.results-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 24px;
  text-align: center;
}

.results-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
}

.result-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s ease;
}

.result-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.result-card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
}

.result-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.result-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

.result-list li:last-child {
  border-bottom: none;
}

/* Keywords copy section */
.keywords-section {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.keywords-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.keywords-input {
  flex: 1;
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 13px;
  background: var(--bg);
}

.keywords-row .btn {
  white-space: nowrap;
}

/* Settings */
.settings {
  max-width: 600px;
  margin: 40px auto 0;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.settings-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 20px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-group {
  display: flex;
  gap: 8px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* Loading states */
.loading {
  color: var(--text-tertiary);
}

.error {
  color: var(--error);
}

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

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

/* Utility classes */
.hidden { display: none; }

.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;
}

/* Animations */
.fade-in {
  opacity: 0;
  animation: fadeIn 0.6s ease forwards;
}

.slide-up {
  opacity: 0;
  transform: translateY(20px);
  animation: slideUp 0.6s ease forwards;
}

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

@keyframes slideUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }
  
  .hero {
    padding: 40px 0 30px;
  }
  
  .hero-title {
    font-size: clamp(28px, 8vw, 40px);
    line-height: 1.2;
  }
  
  .hero-subtitle {
    font-size: 16px;
    margin-bottom: 30px;
  }
  
  .form {
    padding: 20px;
    border-radius: var(--radius-lg);
  }
  
  .nav-actions {
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .nav {
    min-height: 56px;
    padding: 8px 0;
  }
  
  .brand {
    font-size: 18px;
  }
  
  .logo {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .btn-icon {
    width: 36px;
    height: 36px;
  }
  
  .input, .textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px 16px;
  }
  
  .textarea {
    min-height: 100px;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .result-card {
    padding: 16px;
  }
  
  .keywords-row {
    flex-direction: column;
    gap: 12px;
  }
  
  .keywords-row .btn {
    width: 100%;
  }
  
  .settings {
    padding: 20px;
  }
  
  .settings-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .settings-group {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  
  .settings-group .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }
  
  .hero {
    padding: 30px 0 20px;
  }
  
  .form {
    padding: 16px;
    border-radius: var(--radius);
  }
  
  .form-group {
    margin-bottom: 16px;
  }
  
  .brand {
    font-size: 16px;
    gap: 8px;
  }
  
  .logo {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  
  .nav-actions {
    gap: 6px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .btn-icon {
    width: 32px;
    height: 32px;
  }
  
  .hero-title {
    font-size: clamp(24px, 7vw, 32px);
  }
  
  .hero-subtitle {
    font-size: 14px;
  }
  
  .result-card {
    padding: 12px;
  }
  
  .result-card-title {
    font-size: 14px;
  }
  
  .settings {
    padding: 16px;
  }
}