:root {
  --bg: #150c1f;
  --bg-elevated: #241733;
  --card: #2c1f3e;
  --card-alt: #3a2c4f;
  --accent: #9d5cf5;
  --accent-light: #b57bff;
  --text: #f5f2fa;
  --text-muted: #a89bbd;
  --danger: #ff6b6b;
  --radius: 18px;
  --radius-sm: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 90px;
}

.hidden { display: none !important; }

h1, h2 { margin: 0; }

/* ===================== AUTH ===================== */
#view-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card { width: 100%; }

.logo {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 32px;
  background: linear-gradient(90deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-form h2 { font-size: 20px; margin-bottom: 16px; }

.auth-form input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-alt);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 15px;
}

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

.switch-link {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 16px;
}
.switch-link a { color: var(--accent-light); text-decoration: none; }

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 4px 0 12px;
}

/* ===================== BUTTONS ===================== */
.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:active { opacity: 0.85; }

.btn-secondary {
  width: 100%;
  padding: 12px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-light);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 20px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
}

.icon-btn {
  background: var(--card);
  border: none;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================== TOP BAR / TITLES ===================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 20px 12px;
}
.page-title { font-size: 30px; font-weight: 800; }

.stock-section-title {
  font-size: 22px;
  font-weight: 800;
  padding: 20px 20px 12px;
}
.stock-section-title span { color: var(--text-muted); font-weight: 500; }

/* ===================== RECIPE GRID ===================== */
.recipes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 20px;
}

.recipe-card {
  cursor: pointer;
}

.recipe-card .thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}
.recipe-card .thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.recipe-card .rating-badge {
  position: absolute;
  bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
}
.recipe-card .recipe-title {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

.add-card {
  grid-column: 1 / -1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
}
.add-card .plus { font-size: 28px; display: block; margin-bottom: 8px; }

/* ===================== MODAL VIEW (detail / add / repartition) ===================== */
.modal-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  z-index: 50;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--card);
}
.detail-header h1 { font-size: 22px; font-weight: 800; }

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detail-photo {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 16/11;
  object-fit: cover;
  margin-bottom: 24px;
  background: var(--card);
}

.detail-section { margin-bottom: 28px; }
.detail-section h2 { font-size: 22px; font-weight: 800; margin-bottom: 14px; }

.ingredients-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 12px;
}
.ingredient-item { display: flex; align-items: center; gap: 12px; }
.ingredient-dot {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  flex-shrink: 0;
}
.ingredient-name { font-weight: 600; font-size: 14px; }
.ingredient-qty { color: var(--text-muted); font-size: 13px; }

.step-block { margin-bottom: 28px; }
.step-block h3 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.step-photo {
  width: 100%;
  border-radius: var(--radius-sm);
  aspect-ratio: 16/10;
  object-fit: cover;
  margin-bottom: 12px;
  background: var(--card);
}
.step-block ul { margin: 0; padding-left: 18px; color: var(--text); font-size: 14.5px; line-height: 1.5; }
.step-tip {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--accent-light);
  font-size: 13.5px;
  margin-top: 10px;
}

.detail-footer {
  padding: 16px 20px 24px;
  border-top: 1px solid var(--card);
}

/* ===================== ADD RECIPE FORM ===================== */
.add-form label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.add-form input[type=text],
.add-form input[type=file],
.add-form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-alt);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
}
.add-form h2 { font-size: 18px; margin: 20px 0 12px; }

.ingredient-row {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}
.ingredient-row input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-alt);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
}
.row-remove {
  background: var(--card);
  border: none;
  color: var(--danger);
  border-radius: var(--radius-sm);
  width: 38px;
  cursor: pointer;
}

.step-row {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
}
.step-row label { color: var(--text-muted); }
.step-row textarea { min-height: 80px; resize: vertical; }

/* ===================== REPARTITION ===================== */
.question-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 24px;
  line-height: 1.3;
}
.counter-label { color: var(--text-muted); font-size: 15px; margin-bottom: 10px; }
.counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 28px;
}
.counter-btn {
  width: 56px;
  height: 64px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}
.counter-btn:disabled { background: var(--card-alt); color: var(--text-muted); cursor: default; }
.counter-value { font-size: 26px; font-weight: 800; }

/* ===================== STOCK CARD action ===================== */
.stock-card .thumb { position: relative; }

/* ===================== RATING MODAL ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-card {
  background: var(--card-alt);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
}
.modal-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 20px; }
.stars { display: flex; gap: 10px; justify-content: flex-start; margin-bottom: 12px; }
.star {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}
.star.active { color: #fff; background: var(--accent); }
.rating-hint { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-actions .btn-primary { width: auto; padding: 14px 28px; }

/* ===================== BOTTOM NAV ===================== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--card);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  gap: 10px;
  z-index: 40;
}
.nav-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.nav-btn.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  color: #fff;
}

@media (min-width: 480px) {
  body { background: #0a060f; }
  #app { background: var(--bg); box-shadow: 0 0 60px rgba(0,0,0,0.5); }
}
