:root {
  --bg: #fdf6ec;
  --surface: #ffffff;
  --text: #3a2e27;
  --text-muted: #8a7b6c;
  --accent: #d9663b;
  --accent-dark: #b84f2a;
  --accent-soft: #f6dfd2;
  --green: #4a7c59;
  --border: #eee0d0;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(58, 46, 39, 0.08);
  font-size: 16px;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-dark); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-header h1 {
  font-size: 1.25rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header .back-link {
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 48px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent-soft);
  color: var(--accent-dark);
  transition: transform 0.05s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-danger { background: #fbe4e1; color: var(--danger); }
.btn-icon {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  font-size: 1.25rem; line-height: 1;
}
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: default; }

.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.8rem;
  border: none;
  box-shadow: 0 4px 14px rgba(217, 102, 59, 0.45);
  cursor: pointer;
  z-index: 20;
}

.recipe-card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--text);
}
.recipe-card h2 {
  margin: 0 0 6px 0;
  font-size: 1.1rem;
}
.recipe-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-card .meta {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--accent-dark);
  font-weight: 600;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
}
.empty-state .emoji { font-size: 2.5rem; display: block; margin-bottom: 12px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 10px 0;
  color: var(--accent-dark);
}

.servings-control {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  padding: 6px 0 4px;
}
.servings-control .count {
  font-size: 1.3rem;
  font-weight: 700;
  min-width: 90px;
  text-align: center;
}
.servings-control button {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 1.3rem;
  cursor: pointer;
}
.servings-control button:active { transform: scale(0.95); }
.servings-control button:disabled { opacity: 0.4; }

ul.ingredient-list, ul.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
ul.ingredient-list li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
ul.ingredient-list li:last-child { border-bottom: none; }
ul.ingredient-list li .bullet { color: var(--accent); }

ol.step-list { list-style: none; counter-reset: step; margin: 0; padding: 0; }
ol.step-list li {
  counter-increment: step;
  padding: 10px 0 10px 42px;
  position: relative;
  border-bottom: 1px solid var(--border);
}
ol.step-list li:last-child { border-bottom: none; }
ol.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

label { display: block; font-weight: 600; font-size: 0.9rem; margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=url], input[type=number], input[type=password], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 20px) center, calc(100% - 15px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 70px; }

#image-drop {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
#image-preview {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}
.image-placeholder {
  padding: 30px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.recipe-photo {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 12px;
}

.speed-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.speed-rapide { background: #e3efe4; color: var(--green); }
.speed-modere { background: #fdeecd; color: #a8710a; }
.speed-lent { background: #fbe4e1; color: var(--danger); }

.card-thumb {
  display: flex;
  gap: 12px;
}
.card-thumb img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
}
.card-thumb .card-thumb-body { flex: 1; min-width: 0; }

.dynamic-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.dynamic-row input, .dynamic-row textarea { flex: 1; }
.remove-row {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}
.remove-row:hover { color: var(--danger); }

.add-row-btn {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--accent-dark);
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
}

.import-box {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
}
.import-box .row { display: flex; gap: 8px; }
.import-box .row input { flex: 1; }
.import-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.import-toggle button {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.import-toggle button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.message {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.message.error { background: #fbe4e1; color: var(--danger); }
.message.success { background: #e3efe4; color: var(--green); }
.message.hidden { display: none; }

.actions-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.actions-row .btn { flex: 1; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}
.login-card .emoji { font-size: 2.4rem; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.text-muted { color: var(--text-muted); }
.source-link { font-size: 0.8rem; color: var(--text-muted); word-break: break-all; }
