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

/* === Theme === */
:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-2: #f0f1f3;
  --border: #e0e2e6;
  --border-hover: #c8cad0;
  --text: #1a1d23;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.08);
  --amber: #f5c518;
  --amber-bg: rgba(245, 197, 24, 0.10);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.06);
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.06);
  --radius: 8px;
  --radius-lg: 12px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body {
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 120px;
  -webkit-font-smoothing: antialiased;
}

/* === Progress bar (top) === */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.3s ease, opacity 0.4s ease;
  opacity: 0;
  z-index: 200;
}
#progress-bar.active {
  opacity: 1;
  width: 70%;
  transition: width 8s cubic-bezier(0.1, 0.05, 0, 1), opacity 0.1s;
}
#progress-bar.done {
  width: 100%;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.4s ease 0.2s;
}

/* === Loading overlay === */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(248, 249, 250, 0.85);
  backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
#overlay.visible { display: flex; }

.overlay-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
#overlay p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Step indicator === */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 20px 0 28px;
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, var(--bg) 85%, transparent);
  z-index: 50;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
  white-space: nowrap;
}
.step.active { color: var(--accent); }
.step.done { color: var(--text-secondary); }

.step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  transition: all 0.2s;
  flex-shrink: 0;
}
.step.active .step-dot {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}
.step.done .step-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.step-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 12px;
  min-width: 16px;
}
.step-line.done { background: var(--accent); }

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.topbar-brand:hover { color: var(--accent); }

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0;
}

/* === Avatar dropdown === */
.avatar-wrap { position: relative; }

.avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, border-color 0.15s;
}
.avatar-btn:hover { opacity: 0.85; }
.avatar-btn[aria-expanded="true"] { border-color: var(--accent-hover); opacity: 0.9; }

.avatar-initial {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  font-family: var(--font);
  line-height: 1;
}

.avatar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 210px;
  z-index: 60;
  overflow: hidden;
  animation: dropdown-in 0.12s ease;
}
.avatar-dropdown.open { display: block; }

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar-dropdown-header {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.avatar-dropdown-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}
.avatar-dropdown-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-divider { height: 1px; background: var(--border); }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover { background: var(--danger-bg); }

/* === Header === */
header {
  margin-bottom: 36px;
}
header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.3;
}
header p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-top: 6px;
}

/* === Section headings === */
h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 36px 0 16px;
}

/* === Upload area === */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 64px 24px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
  background: var(--surface);
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.06);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-muted);
  transition: color 0.2s;
}
.upload-zone:hover .upload-icon,
.upload-zone.dragover .upload-icon {
  color: var(--accent);
}

.upload-zone p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.upload-zone .upload-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.upload-zone input[type=file] {
  display: none;
}

.file-preview {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.file-preview.visible { display: inline-flex; }
.file-preview .file-name { color: var(--text); font-weight: 500; }
.file-preview .file-size { color: var(--text-muted); }

.upload-actions {
  margin-top: 20px;
  display: none;
}
.upload-actions.visible { display: block; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-family: var(--font);
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-hover);
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-icon:hover {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(239, 68, 68, 0.2);
}

/* === TOC === */
.toc-list { margin-top: 8px; }

.toc-chapter {
  border: none;
  background: none;
  width: 100%;
  margin-bottom: 2px;
}
.toc-chapter summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s;
  list-style: none;
}
.toc-chapter-leaf {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 26px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  border-radius: var(--radius);
}
.toc-chapter-leaf .page-num {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
  margin-left: auto;
}
.toc-chapter summary::-webkit-details-marker { display: none; }
.toc-chapter summary::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.toc-chapter[open] summary::before {
  transform: rotate(45deg);
}
.toc-chapter summary:hover { background: var(--surface); }
.toc-chapter summary .page-num {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
  margin-left: auto;
}

.toc-sections {
  padding: 2px 0 8px 28px;
  border-left: 2px solid var(--border);
  margin-left: 18px;
}
.toc-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.toc-section .page-num {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: auto;
}

/* Highlight count badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 10px;
  background: var(--accent-glow);
  color: var(--accent);
}
.badge-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

/* === Highlights === */
.highlights-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.highlight-item {
  background: var(--surface);
  border-left: 3px solid var(--amber);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.875rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
  line-height: 1.5;
}
.highlight-item .meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.highlight-item .meta .sep { color: var(--border); }

/* === Flashcard cards === */
.cards-container { margin-top: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 12px 0;
  position: relative;
  box-shadow: var(--shadow);
  transition: opacity 0.3s, transform 0.3s, margin 0.3s, box-shadow 0.15s;
}
.card:hover {
  box-shadow: var(--shadow-lg);
}
.card.removing {
  opacity: 0;
  transform: scale(0.95);
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  max-height: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.card-meta .tag {
  padding: 2px 8px;
  background: var(--surface-2);
  border-radius: 4px;
  font-size: 0.6875rem;
  color: var(--text-secondary);
}

.card-field { margin-bottom: 12px; }
.card-field:last-of-type { margin-bottom: 0; }
.card-field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.card-field input[type=text],
.card-field textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}
.card-field input[type=text]:focus,
.card-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.card-field textarea { min-height: 72px; }

/* === Generate section === */
.generate-section {
  margin-top: 28px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.generate-section p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.generate-section .count {
  color: var(--text);
  font-weight: 600;
}
.generate-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* === Export bar (sticky bottom) === */
.export-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.export-bar .card-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.export-bar .card-count strong {
  color: var(--text);
}

/* === Toast notifications === */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.removing {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* === TOC toolbar === */
.toc-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}
.btn-link {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { text-decoration: underline; }

/* === TOC checkboxes === */
.toc-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
.toc-checkbox:disabled {
  opacity: 0.3;
  cursor: default;
}
.toc-title { flex: 1; }

/* === Generation progress === */
.progress-list { margin: 16px 0; }
.progress-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  font-size: 0.875rem;
  color: var(--text);
  border-radius: var(--radius);
}
.progress-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.progress-icon.pending { color: var(--text-muted); }
.progress-icon.in-progress {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.progress-icon.done { color: var(--success); font-weight: 700; }
.progress-icon.error { color: var(--danger); font-weight: 700; }
.progress-label { flex: 1; }
.progress-counter {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 12px;
  padding: 0 12px;
}

/* === Empty / error states === */
.empty {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 24px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
  padding: 12px 16px;
  background: var(--danger-bg);
  border-radius: var(--radius);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

#result { margin-top: 8px; }

/* === Responsive === */
@media (max-width: 600px) {
  body { padding: 0 16px 120px; }

  .steps { gap: 0; padding: 16px 0 24px; }
  .step span { display: none; }
  .step-line { min-width: 8px; margin: 0 6px; }

  .upload-zone { padding: 40px 16px; }

  .generate-section {
    flex-direction: column;
    text-align: center;
  }
}

/* === Auth pages === */
.auth-page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f0ff 0%, var(--bg) 40%, #f0f7ff 100%);
  z-index: 10;
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.auth-brand .brand-mark {
  width: 32px;
  height: 32px;
  font-size: 0.875rem;
}
.auth-brand:hover { color: var(--accent); }

.auth-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
  padding: 40px 36px;
}

.auth-card-header {
  margin-bottom: 28px;
  text-align: center;
}
.auth-card-header h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.auth-card-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.auth-error {
  background: var(--danger-bg);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.8125rem;
  padding: 10px 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.auth-form .field { margin-bottom: 20px; }

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

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

.auth-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-form input:hover {
  border-color: var(--border-hover);
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.auth-form input::placeholder { color: var(--text-muted); }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px; }

.input-action {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.input-action:hover { color: var(--text-secondary); }

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 6px;
  padding: 12px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-footer {
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.auth-footer a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; border-radius: var(--radius-lg); }
  .auth-card-header h1 { font-size: 1.25rem; }
}

/* === Button size variant === */
.btn-sm { padding: 7px 14px; font-size: 0.8125rem; }

/* === Topbar right === */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

/* === Card count === */
.card-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}
.card-count-low {
  color: var(--amber);
}

/* === Generate section extras === */
.low-balance-warning {
  font-size: 0.8125rem;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 8px 12px;
}

/* === Landing page === */
.landing-hero {
  text-align: center;
  padding: 72px 0 56px;
}
.landing-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 16px;
}
@keyframes highlight-sweep {
  from { background-size: 0% 55%; }
  to   { background-size: 100% 55%; }
}
.highlight-sweep {
  background: linear-gradient(#fde047 0 0) no-repeat left center;
  background-size: 0% 55%;
  animation: highlight-sweep 2.2s cubic-bezier(0.6, 0, 0.05, 1) forwards;
  animation-delay: 0.5s;
  padding: 0 2px;
  border-radius: 2px;
}

.landing-hero p {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 32px;
  line-height: 1.65;
}

.landing-ctas {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.landing-section {
  padding: 48px 0;
  border-top: 1px solid var(--border);
}

.landing-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.steps-list { display: flex; flex-direction: column; gap: 20px; }

.steps-list-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-content h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.step-content p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.pricing-tier {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pricing-price {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
}

.pricing-credits {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.pricing-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 16px;
}

@media (max-width: 600px) {
  .landing-hero { padding: 48px 0 40px; }
  .landing-hero h1 { font-size: 1.5rem; }
  .pricing-grid { grid-template-columns: 1fr; }
}

/* === Billing page === */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.page-subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.pricing-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pricing-badge {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-glow);
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 8px;
  align-self: flex-start;
  min-height: 20px;
  visibility: hidden;
}
.pricing-card.featured .pricing-badge {
  visibility: visible;
}

.pricing-rate {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex: 1;
}


/* === Success page === */
.success-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.success-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.success-balance {
  color: var(--text-secondary);
  font-size: 1rem;
}


/* === Legal pages === */
.legal-page {
  max-width: 720px;
  margin: 48px auto;
  padding: 0 24px 80px;
}

.legal-page h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.legal-date {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 40px;
}

.legal-page h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 8px;
}

.legal-page p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 0;
}

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

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

/* === Landing footer === */
.landing-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 48px;
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

.landing-footer-links {
  display: flex;
  gap: 24px;
}

.landing-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

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