:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --border: #1e1e24;
  --border-hover: #2a2a32;
  --text-primary: #e5e5e5;
  --text-secondary: #8b8b8b;
  --text-muted: #555;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --accent-glow-strong: rgba(59, 130, 246, 0.25);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.08);
  --error-border: rgba(239, 68, 68, 0.2);
  --success: #22c55e;
  --radius-lg: 8px;
  --radius-md: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

.header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.logo {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.prompt-section {
  margin-bottom: 0.5rem;
}

.prompt-input {
  width: 100%;
  min-height: 120px;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.prompt-input::placeholder {
  color: var(--text-muted);
}

.prompt-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
}

.options-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex: 1;
}

.option-label {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.select-input {
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8b8b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.select-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Number input shouldn't show the select dropdown arrow */
input.select-input {
  background-image: none;
  padding-right: 0.75rem;
  cursor: text;
}

/* ---- Style section / theme picker ---- */
.style-section {
  margin-bottom: 1.25rem;
}

.style-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.625rem;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.625rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition),
    transform var(--transition);
  text-align: left;
}

.theme-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.theme-swatches {
  display: flex;
  gap: 0;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.theme-swatches .sw {
  flex: 1;
}

.theme-swatches .sw-bg {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.theme-name {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-card.active .theme-name {
  color: var(--text-primary);
}

.generate-btn {
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
}

.generate-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.generate-btn:active:not(:disabled) {
  transform: scale(0.995);
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.generate-btn .btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.generate-btn.loading .btn-label {
  opacity: 0.8;
}

.generate-btn.loading .btn-spinner {
  display: block;
}

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

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.35s ease forwards;
}

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

.progress-section {
  margin-top: 2rem;
}

.progress-track {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
}

.status-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.token-counter {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.result-section {
  margin-top: 2rem;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.result-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--success);
  font-weight: 700;
}

.result-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.result-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.stat.mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.stat-divider {
  width: 3px;
  height: 3px;
  background: var(--text-muted);
  border-radius: 50%;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition);
}

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

.outline-details {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.outline-summary {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.outline-summary:hover {
  color: var(--text-primary);
}

.outline-list {
  list-style: none;
  padding: 0 1rem 0.75rem;
}

.outline-list li {
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.outline-list li:first-child {
  border-top: 1px solid var(--border);
}

.slide-number {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  min-width: 1.5rem;
  text-align: right;
}

.slide-type {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  white-space: nowrap;
}

.slide-title {
  color: var(--text-primary);
}

.error-section {
  margin-top: 2rem;
}

.error-card {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
}

.error-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 0.75rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--error-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  color: var(--error);
  font-weight: 700;
}

.error-message {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.retry-btn {
  padding: 0.5rem 1.25rem;
  background: transparent;
  border: 1px solid var(--error-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.retry-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
}

.footer span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 520px) {
  .main {
    padding: 1.5rem 1rem 3rem;
  }

  .options-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .result-stats {
    flex-direction: column;
    gap: 0.25rem;
  }

  .stat-divider {
    display: none;
  }
}
