:root {
  --ink: #26221b;
  --ink-soft: #5b5648;
  --parchment: #f6f1e6;
  --parchment-deep: #eee5d2;
  --card-bg: #fffdf8;
  --forest: #1e3a34;
  --forest-soft: #2c5049;
  --gold: #a9822f;
  --gold-soft: #d8c185;
  --halal: #2f6f52;
  --halal-bg: #e8f1ea;
  --haram: #7a2e2e;
  --haram-bg: #f5e9e8;
  --doute: #93641f;
  --doute-bg: #f6ecd9;
  --border: #d8cfb8;
  --radius: 4px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Work Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
  --ink: #ece6d6;
  --ink-soft: #b7ae98;
  --parchment: #171512;
  --parchment-deep: #211e19;
  --card-bg: #1c1a15;
  --forest: #6fae9e;
  --forest-soft: #8ec3b4;
  --gold: #d3ac5c;
  --gold-soft: #e6cd94;
  --halal: #7fbf9e;
  --halal-bg: #1c2a23;
  --haram: #d98b8b;
  --haram-bg: #2c1c1c;
  --doute: #dcb567;
  --doute-bg: #2c2416;
  --border: #35312a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  transition: background 0.25s ease, color 0.25s ease;
}

/* --- Motifs géométriques discrets (coins) --- */
.corner-mark {
  position: fixed;
  width: 220px;
  height: 220px;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}
.corner-mark--tl { top: -55px; right: -55px; }
.corner-mark--br { bottom: -55px; left: -55px; }
.corner-mark svg { width: 100%; height: 100%; fill: var(--forest); }

/* --- Frise en pointillés géométriques (tuile étoile à 8 branches) --- */
.tile-divider {
  height: 14px;
  margin: 0 auto 32px;
  max-width: 640px;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='14' viewBox='0 0 28 14'%3E%3Cpath d='M14 1 L16.5 6 L22 6 L17.5 9 L19 14 L14 11 L9 14 L10.5 9 L6 6 L11.5 6 Z' fill='%23a9822f'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: center;
}
[data-theme="dark"] .tile-divider { opacity: 0.5; }

.page {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 56px 24px 0;
}

.site-header { text-align: center; margin-bottom: 0; }

.crescent {
  width: 26px;
  height: 26px;
  margin: 0 auto 10px;
  color: var(--gold);
}
.crescent svg { width: 100%; height: 100%; }

.site-header h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2.1rem;
  margin: 0 0 8px;
  color: var(--forest);
}

.subtitle { color: var(--ink-soft); margin: 0; font-size: 0.98rem; }

/* --- Bouton mode sombre --- */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--forest);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 640px;
  margin: 0 auto;
}
.step + .step { margin-top: 20px; }

label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

.hint { font-size: 0.82rem; color: var(--ink-soft); margin: 10px 0 0; }

input[type="text"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--parchment);
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 3px rgba(30, 58, 52, 0.12);
}

/* --- Autocomplétion --- */
.autocomplete { position: relative; }

.suggestions {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  max-height: 280px;
  overflow-y: auto;
  z-index: 5;
}
.suggestions li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.suggestions li:hover, .suggestions li.active { background: var(--parchment); }
.suggestions li img {
  width: 32px; height: 32px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--parchment-deep);
}
.suggestions li .s-title { font-size: 0.92rem; color: var(--ink); display: block; }
.suggestions li .s-artist { font-size: 0.8rem; color: var(--ink-soft); display: block; }
.suggestions .no-results { color: var(--ink-soft); font-size: 0.85rem; padding: 10px; cursor: default; }

.btn-primary, .btn-secondary {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--forest); color: #fdfbf5; }
.btn-primary:hover { background: var(--forest-soft); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-secondary { background: transparent; color: var(--ink-soft); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--ink-soft); }

.error { color: var(--haram); font-size: 0.9rem; margin-top: 14px; }

.link-btn {
  display: block;
  margin: 16px 0 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  text-align: left;
}
.link-btn:hover { color: var(--forest); }

.manual-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.manual-form label:first-of-type { margin-top: 0; }

textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--parchment);
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  resize: vertical;
  line-height: 1.5;
}
textarea:focus {
  outline: none;
  border-color: var(--forest-soft);
  box-shadow: 0 0 0 3px rgba(30, 58, 52, 0.12);
}

.manual-form .btn-primary { width: 100%; margin-top: 18px; }

.eyebrow { font-size: 0.8rem; color: var(--gold); margin: 0 0 6px; letter-spacing: 0.02em; }

#confirm-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.5rem;
  margin: 0 0 2px;
  color: var(--forest);
}
.confirm-artist { color: var(--ink-soft); margin: 0 0 18px; }

.lyrics-preview {
  max-height: 140px;
  overflow: hidden;
  position: relative;
  background: var(--parchment);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  white-space: pre-line;
}
.lyrics-preview::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--parchment));
}

.actions { display: flex; gap: 12px; margin-top: 24px; }
.actions .btn-primary, .actions .btn-secondary { flex: 1; }

.loader {
  width: 28px; height: 28px;
  margin: 0 auto 16px;
  border: 3px solid var(--parchment-deep);
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
#step-loading { text-align: center; color: var(--ink-soft); }
@keyframes spin { to { transform: rotate(360deg); } }

.verdict-badge {
  display: inline-block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  padding: 8px 20px;
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.verdict-badge.halal { background: var(--halal-bg); color: var(--halal); }
.verdict-badge.haram { background: var(--haram-bg); color: var(--haram); }
.verdict-badge.doute { background: var(--doute-bg); color: var(--doute); }

.verdict-note { color: var(--ink-soft); margin: 0 0 8px; font-size: 0.95rem; }

.verdict-meta {
  color: var(--ink-soft);
  font-size: 0.78rem;
  margin: 0 0 24px;
  opacity: 0.75;
}

#reasons-block h3, .lyrics-heading {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--forest);
  margin: 0 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.reasons-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.reasons-list li { background: var(--haram-bg); border-left: 3px solid var(--haram); padding: 10px 14px; border-radius: var(--radius); font-size: 0.9rem; }
.reasons-list li .quote { font-style: italic; color: var(--ink); display: block; margin-bottom: 4px; }
.reasons-list li .why { color: var(--ink-soft); font-size: 0.85rem; }

.full-lyrics {
  white-space: pre-line;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--parchment);
  padding: 18px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.full-lyrics mark {
  background: var(--haram-bg);
  color: var(--haram);
  padding: 1px 3px;
  border-radius: 2px;
}

#step-result .btn-secondary { width: 100%; }

.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  padding: 0 24px 40px;
  max-width: 640px;
  margin: 0 auto;
}

@media (max-width: 480px) {
  .page { padding: 40px 16px 0; }
  .card { padding: 22px; }
  .site-header h1 { font-size: 1.7rem; }
}
