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

/* A6 — Focus ring global (keyboard navigation) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* =====================
   THÈME SOMBRE (défaut)
   ===================== */
:root,
[data-theme="dark"] {
  --bg: #07070e;
  --surface: rgba(16, 16, 24, 0.8);
  --surface-2: rgba(8, 8, 14, 0.65);
  --border: rgba(255, 255, 255, 0.07);
  --accent: #7C3AED;
  --accent-rgb: 124, 58, 237;
  --accent-hover: #9333ea;
  --text: #e8e8f2;
  /* WCAG AA: #9a9ab8 on #07070e gives ~5.2:1 ratio */
  --text-muted: #9a9ab8;
  --success: #4ade80;
  --error: #f87171;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

/* =====================
   THÈME CLAIR
   ===================== */
[data-theme="light"] {
  --bg: #eeeef8;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-2: rgba(250, 250, 255, 0.88);
  --border: rgba(0, 0, 0, 0.07);
  --accent: #5746d0;
  --accent-rgb: 87, 70, 208;
  --accent-hover: #6355e0;
  --text: #1a1a2e;
  /* WCAG AA: #595972 on #eeeef8 gives ~5.5:1 ratio */
  --text-muted: #595972;
  --success: #16a34a;
  --error: #dc2626;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

:root {
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", "Fira Code", "Consolas", monospace;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 45% at 50% -5%, rgba(124, 58, 237, 0.14), transparent),
    radial-gradient(ellipse 40% 30% at 90% 95%, rgba(167, 139, 250, 0.07), transparent);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  transition: background 0.3s, color 0.25s;
}

[data-theme="light"] body,
[data-theme="light"] {
  background-image:
    radial-gradient(ellipse 80% 45% at 50% -5%, rgba(99, 85, 224, 0.08), transparent);
}

.container {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* =====================
   HEADER
   ===================== */
header {
  padding: 0.5rem 0;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  text-align: left;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.8px;
  background: linear-gradient(135deg, #c4b5fd 0%, #7c6af7 45%, #e879f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px rgba(124, 106, 247, 0.35));
}

[data-theme="dark"] header h1 {
  background: linear-gradient(135deg, #e9d5ff 0%, #c084fc 50%, #f0abfc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 28px rgba(124, 58, 237, 0.4));
}


.subtitle {
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-size: 0.95rem;
}

/* Toggle thème */
#theme-toggle {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, transform 0.25s, box-shadow 0.2s;
}

#theme-toggle:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.25);
  transform: rotate(20deg);
}

/* =====================
   CARDS
   ===================== */
.card {
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.card:hover {
  border-color: rgba(var(--accent-rgb), 0.18);
}

label[for="user-idea"] {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

textarea {
  width: 100%;
  background: var(--surface-2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.85rem 1rem;
  resize: vertical;
  transition: border-color 0.2s, background 0.25s, box-shadow 0.2s;
  line-height: 1.6;
  min-height: 120px;
}

textarea:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.09), 0 0 24px rgba(var(--accent-rgb), 0.05);
}

textarea:focus:not(:focus-visible) {
  outline: none;
}

textarea::placeholder {
  color: var(--text-muted);
}

/* A7 — Fieldset/Legend reset */
.format-group {
  border: none;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.format-group legend.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;
}

/* A4 — Compteur de caractères */
.textarea-wrapper {
  position: relative;
}

.char-counter {
  position: absolute;
  bottom: 0.5rem;
  right: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
}

.char-counter.warn {
  color: var(--accent);
}

.char-counter.error {
  color: var(--error, #e55);
}

/* =====================
   OPTIONS ROW
   ===================== */
.options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.format-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.format-group .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

.chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, color 0.2s;
  user-select: none;
}

.chip:hover {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.3);
}

.chip:has(input:checked),
.chip--checked {
  border-color: rgba(var(--accent-rgb), 0.65);
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent-hover);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.18), 0 0 0 1px rgba(var(--accent-rgb), 0.15) inset;
}

.chip input[type="radio"],
.chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* =====================
   BOUTONS
   ===================== */
button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-weight: 600;
  transition: background 0.2s, opacity 0.2s, transform 0.1s;
}

#generate-btn {
  background: linear-gradient(135deg, #7c6af7 0%, #a78bfa 100%);
  color: #fff;
  padding: 0.65rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 50px;
  box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.2s, transform 0.15s, filter 0.2s;
  animation: btn-glow-pulse 3s ease-in-out infinite;
}

[data-theme="dark"] #generate-btn {
  background: linear-gradient(135deg, #6d28d9 0%, #7C3AED 100%);
}

@keyframes btn-glow-pulse {
  0%, 100% { box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.38), 0 4px 14px rgba(0, 0, 0, 0.3); }
  50%       { box-shadow: 0 0 38px rgba(var(--accent-rgb), 0.65), 0 4px 18px rgba(0, 0, 0, 0.3); }
}

@media (prefers-reduced-motion: reduce) {
  #generate-btn { animation: none; }
}

#generate-btn:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 32px rgba(var(--accent-rgb), 0.58), 0 4px 18px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

#generate-btn:active {
  transform: scale(0.97) translateY(0);
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.35), 0 2px 8px rgba(0, 0, 0, 0.3);
}

#generate-btn:disabled,
#generate-btn.loading {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
  transform: none;
  animation: none;
}


.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  transition: color 0.2s, background 0.2s;
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* =====================
   OUTPUT
   ===================== */
.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.format-badge {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent-hover);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.15);
}

.output-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#output-content {
  background: rgba(4, 4, 10, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 1.25rem;
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow-y: auto;
  color: var(--text);
  transition: background 0.25s, border-color 0.25s;
}

[data-theme="light"] #output-content {
  background: var(--surface-2);
  border-color: var(--border);
}

/* =====================
   LOADER
   ===================== */
#generate-btn.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

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

/* =====================
   ERREUR
   ===================== */
.error-box {
  background: rgba(248, 113, 113, 0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--error);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  box-shadow: 0 0 16px rgba(248, 113, 113, 0.06);
}

/* =====================
   FOOTER
   ===================== */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding-bottom: 1rem;
}

footer a {
  color: var(--accent-hover);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* =====================
   HISTORIQUE
   ===================== */
#history-section {
  gap: 0.75rem;
}

/* Axe 3 — Hiérarchie visuelle entre les sections */
[data-theme="dark"] #input-section {
  border-top-color: rgba(var(--accent-rgb), 0.4);
  box-shadow: var(--shadow), 0 0 0 1px rgba(var(--accent-rgb), 0.06) inset;
}

[data-theme="dark"] #output-section:not([hidden]) {
  box-shadow: var(--shadow), 0 0 48px rgba(var(--accent-rgb), 0.09);
}

[data-theme="dark"] #history-section {
  background: rgba(10, 10, 18, 0.55);
  box-shadow: none;
}

[data-theme="light"] #history-section {
  background: rgba(255, 255, 255, 0.5);
  box-shadow: none;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* A9 — État vide historique */
.history-empty {
  text-align: center;
  padding: 1.5rem 1rem;
}

.history-empty-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.history-empty-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.7;
}

.history-empty ul {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.history-example-btn {
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.history-example-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.6);
}

#history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.history-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.history-item:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.05);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.08) inset;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-format-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent-hover);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 20px;
  padding: 0.15rem 0.55rem;
}

.history-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.history-idea {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}

.history-cat-icon {
  font-size: 0.85rem;
  line-height: 1;
}

/* =====================
   CONTRÔLES HISTORIQUE
   ===================== */
#history-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-search-row {
  display: flex;
  gap: 0.5rem;
}

#history-search {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 0.45rem 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#history-search:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.09);
}

#history-search::placeholder {
  color: var(--text-muted);
}

.history-filter-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.btn-filter {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.25rem 0.65rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.btn-filter:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
  color: var(--text);
}

.btn-filter--active {
  border-color: rgba(var(--accent-rgb), 0.6);
  background: rgba(var(--accent-rgb), 0.13);
  color: var(--accent-hover);
}

/* =====================
   A2 — BARRE DE PROGRESSION INDÉTERMINÉE
   ===================== */
.progress-container {
  margin-top: 0.75rem;
}

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

.progress-bar-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--accent), #a855f7, var(--accent));
  background-size: 200% 100%;
  border-radius: 2px;
  animation: progress-indeterminate 1.4s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.6);
}

@keyframes progress-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.4rem;
  font-style: italic;
}

/* =====================
   A8 — CONFIRMATION INLINE
   ===================== */
.confirm-actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-danger {
  background: rgba(229, 85, 85, 0.15);
  color: #e55;
  border: 1px solid rgba(229, 85, 85, 0.3);
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: rgba(229, 85, 85, 0.25);
}

/* =====================
   A11 — BADGE RACCOURCI CLAVIER
   ===================== */
.kbd-hint {
  font-family: monospace;
  font-size: 0.7rem;
  opacity: 0.5;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* =====================
   SCROLLBAR
   ===================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* =====================
   RESPONSIVE MOBILE
   ===================== */
@media (max-width: 600px) {
  body {
    padding: 1rem 0.75rem;
  }

  .container {
    gap: 1rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .subtitle {
    font-size: 0.85rem;
  }

  #theme-toggle {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .card {
    padding: 1rem;
    gap: 0.85rem;
  }

  /* Format chips : scroll horizontal sur mobile */
  .options-row {
    flex-direction: column;
    align-items: stretch;
  }

  .format-group {
    overflow-x: auto;
    padding-bottom: 0.25rem;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .format-group .label {
    flex-shrink: 0;
  }

  .chip {
    flex-shrink: 0;
  }

  #generate-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    justify-content: center;
  }

  /* Output actions : pleine largeur */
  .output-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .output-actions {
    width: 100%;
  }

  .output-actions button {
    flex: 1;
    text-align: center;
  }

  #output-content {
    font-size: 0.9rem;
    max-height: 50vh;
    padding: 1rem;
  }

  /* Historique */
  .history-item-actions {
    flex-direction: row;
  }

  .history-item-actions button {
    flex: 1;
    text-align: center;
  }

  .history-filter-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.2rem;
    -webkit-overflow-scrolling: touch;
  }

  .btn-filter {
    flex-shrink: 0;
  }

  footer {
    font-size: 0.75rem;
  }

  /* A11 — Hide kbd hints on mobile */
  .kbd-hint {
    display: none;
  }
}

@media (max-width: 380px) {
  header h1 {
    font-size: 1.3rem;
  }

  .card {
    padding: 0.85rem;
  }
}

/* Prevent any chip group with wrap from causing horizontal overflow */
@media (max-width: 600px) {
  .chip-group {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .chip-group .chip {
    font-size: 0.78rem;
    padding: 0.25rem 0.55rem;
  }
}

/* =====================
   BOUCLE D'AFFINAGE
   ===================== */
#refine-panel {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.refine-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.refine-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-refine {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
}

.btn-refine:hover:not(:disabled) {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent-hover);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.12);
}

.btn-refine:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.refine-row {
  display: flex;
  gap: 0.5rem;
}

#refine-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 0.5rem 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#refine-input:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.09);
}

#refine-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#refine-input::placeholder {
  color: var(--text-muted);
}

#refine-btn {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-hover);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 8px;
  padding: 0.5rem 1.1rem;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

#refine-btn:hover:not(:disabled) {
  background: rgba(var(--accent-rgb), 0.22);
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.2);
}

#refine-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .refine-actions {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }

  .btn-refine {
    flex-shrink: 0;
  }

  .refine-row {
    flex-direction: column;
  }

  #refine-btn {
    width: 100%;
  }
}

/* =====================
   HERO SECTION
   ===================== */
.hero-section {
  text-align: center;
  padding: 3rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.15;
  background: linear-gradient(135deg, #c4b5fd 0%, #7c6af7 45%, #e879f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px rgba(124, 106, 247, 0.3));
}

[data-theme="dark"] .hero-title {
  background: linear-gradient(135deg, #e9d5ff 0%, #c084fc 50%, #f0abfc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 28px rgba(124, 58, 237, 0.4));
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 600px;
  line-height: 1.65;
}

.hero-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 50px;
  padding: 0.35rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-hover);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.15);
}

.hero-counter-value {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .hero-section {
    padding: 2rem 0.5rem 1.25rem;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }
}

/* =====================
   HOW IT WORKS
   ===================== */
.how-it-works {
  padding: 2rem 0;
}

.how-it-works-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
  color: var(--text);
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.step-card:hover {
  border-color: rgba(var(--accent-rgb), 0.3);
  box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.08);
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.15);
  border: 1.5px solid rgba(var(--accent-rgb), 0.4);
  color: var(--accent-hover);
  font-size: 0.95rem;
  font-weight: 800;
  flex-shrink: 0;
}

.step-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.step-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.step-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

@media (max-width: 768px) {
  .steps-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .step-card {
    flex-direction: row;
    text-align: left;
    align-items: flex-start;
    padding: 1rem 1.1rem;
    gap: 1rem;
  }

  .step-number {
    flex-shrink: 0;
  }

  .step-icon {
    display: none;
  }
}

/* =====================
   EXAMPLES SECTION
   ===================== */
.examples-section {
  padding: 1.5rem 0;
}

.examples-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.examples-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.example-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.example-card:hover {
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.08);
}

.example-before,
.example-after {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.1rem;
  flex: 1;
}

.example-before {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}

.example-after {
  background: rgba(var(--accent-rgb), 0.04);
}

.example-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.example-before .example-label {
  color: var(--text-muted);
}

.example-after .example-label {
  color: var(--accent);
}

.example-text {
  font-size: 0.875rem;
  line-height: 1.65;
  margin: 0;
}

.example-before .example-text {
  color: var(--text-muted);
  font-style: italic;
}

.example-after .example-text {
  color: var(--text);
}

.example-arrow {
  display: flex;
  align-items: center;
  padding: 0 0.6rem;
  font-size: 1.1rem;
  color: var(--accent);
  opacity: 0.6;
  flex-shrink: 0;
  background: var(--surface);
}

@media (max-width: 640px) {
  .example-card {
    flex-direction: column;
  }

  .example-before {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .example-arrow {
    justify-content: center;
    padding: 0.25rem 1rem;
    transform: rotate(90deg);
  }
}

/* =====================
   FAQ SECTION
   ===================== */
.faq-section {
  padding: 1.5rem 0;
}

.faq-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.faq-item.open {
  border-color: rgba(var(--accent-rgb), 0.3);
}

.faq-question {
  width: 100%;
  background: none;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.faq-question:hover {
  background: rgba(var(--accent-rgb), 0.04);
  color: var(--accent-hover);
}

.faq-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.25s ease;
  display: inline-block;
}

.faq-item.open .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.2s;
}

.faq-answer-inner {
  padding: 0 1.25rem 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.faq-item.open .faq-answer {
  max-height: 600px;
}

/* =====================
   ADVANCED OPTIONS
   ===================== */
.advanced-options {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
  margin-top: 0.25rem;
}

.advanced-toggle {
  background: none;
  border: none;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  transition: color 0.2s, background 0.2s;
}

.advanced-toggle:hover {
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.05);
}

.advanced-toggle-chevron {
  font-size: 0.7rem;
  transition: transform 0.25s ease;
  display: inline-block;
}

.advanced-options.open .advanced-toggle-chevron {
  transform: rotate(180deg);
}

.advanced-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.advanced-options.open .advanced-content {
  max-height: 800px;
}

.advanced-content-inner {
  padding-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* =====================
   SHARE SECTION
   ===================== */
.share-section {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 0.25rem;
}

.share-section.visible {
  display: flex;
}

.share-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.35rem 0.9rem;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
}

.share-btn:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent-hover);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.12);
}

.share-btn-icon {
  font-size: 1rem;
  line-height: 1;
}

.cta-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.cta-links-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cta-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.cta-link:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.07);
  color: var(--accent-hover);
  text-decoration: none;
}

@media (max-width: 600px) {
  .share-actions {
    flex-direction: column;
  }

  .share-btn {
    width: 100%;
    justify-content: center;
    border-radius: 8px;
  }

  .cta-links {
    flex-direction: column;
    align-items: stretch;
  }

  .cta-link {
    justify-content: center;
  }
}
