/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --primary: #E8531A;
  --primary-dark: #C4421A;
  --primary-light: #FCEEE8;
  --secondary: #F4A72A;
  --bg: #FFF8F0;
  --card-bg: #FFFFFF;
  --text: #2C1810;
  --text-muted: #7C5842;
  --border: #F0D9C5;
  --shadow: 0 2px 8px rgba(44, 24, 16, 0.08);
  --shadow-hover: 0 6px 20px rgba(44, 24, 16, 0.14);
  --radius: 14px;
  --radius-sm: 8px;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

img { max-width: 100%; }

/* ── Screens ────────────────────────────────────────────────── */
.screen { display: block; }
.screen[hidden] { display: none !important; }

/* ── Auth Screen ───────────────────────────────────────────── */
#auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #FFF8F0 0%, #FFE8D0 100%);
}

.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 36px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-hover);
}

.auth-logo {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 8px;
}

.auth-title {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  color: var(--primary);
  margin-bottom: 6px;
}

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

/* ── Dev Banner ─────────────────────────────────────────────── */
.dev-banner {
  background: #FFF8DC;
  border: 1.5px solid #F4A72A;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.95rem;
  color: #5C4A00;
  margin-bottom: 20px;
}

.dev-label {
  display: inline-block;
  background: #F4A72A;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 8px;
  vertical-align: middle;
}

/* ── Form Elements ──────────────────────────────────────────── */
.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
  outline: none;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.otp-input {
  text-align: center;
  font-size: 1.8rem;
  letter-spacing: 0.3em;
  font-weight: 700;
}

.form-error {
  color: #C0392B;
  font-size: 0.875rem;
  margin-top: 8px;
  padding: 8px 12px;
  background: #FEF0EE;
  border-radius: 6px;
  border-left: 3px solid #C0392B;
}

.otp-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  min-height: 48px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(232, 83, 26, 0.3);
}

.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(232, 83, 26, 0.35); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--border);
}

.btn-ghost:hover { background: var(--border); }

.btn-full { width: 100%; margin-top: 12px; }

.btn-sm { padding: 8px 14px; font-size: 0.85rem; min-height: 36px; }

.btn-generate {
  font-size: 1.05rem;
  padding: 16px;
  border-radius: var(--radius-sm);
}

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

/* ── Spinner ────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ── App Header ─────────────────────────────────────────────── */
.app-header {
  background: var(--card-bg);
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-logo {
  font-size: 1.1rem;
  color: var(--primary);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

/* ── App Main ───────────────────────────────────────────────── */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Generate Section ───────────────────────────────────────── */
.generate-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

.ingredients-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.2s;
  min-height: 80px;
}

.ingredients-input:focus {
  border-color: var(--primary);
  background: #fff;
}

/* ── Creativity Dial ─────────────────────────────────────────── */
.creativity-section { margin-top: 20px; }

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

.creativity-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.creativity-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
}

.dial-row {
  display: flex;
  gap: 6px;
}

.dial-btn {
  flex: 1;
  padding: 12px 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.dial-btn:hover { border-color: var(--primary); color: var(--primary); }

.dial-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(232, 83, 26, 0.3);
}

.dial-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  padding: 0 2px;
}

/* ── Feed Section ───────────────────────────────────────────── */
.feed-section { }

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

.recipe-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--border);
  padding: 3px 10px;
  border-radius: 20px;
}

.feed-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-icon { font-size: 3rem; display: block; margin-bottom: 12px; }

/* ── Recipe Feed ────────────────────────────────────────────── */
.recipe-feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 560px) {
  .recipe-feed { grid-template-columns: 1fr 1fr; }
}

/* ── Recipe Card ────────────────────────────────────────────── */
.recipe-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1.5px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

.recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
}

.recipe-card:active { transform: scale(0.98); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.card-dish-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

.creativity-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-1 { background: #EDF7ED; color: #276228; }
.badge-2 { background: #E8F5E9; color: #2E7D32; }
.badge-3 { background: #FFF3E0; color: #E65100; }
.badge-4 { background: #FCE4EC; color: #880E4F; }
.badge-5 { background: #EDE7F6; color: #4527A0; }

.card-tagline {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
  line-height: 1.4;
}

.card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.card-meta span::before { margin-right: 4px; }

.card-ingredients {
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  line-height: 1.5;
}

.card-date {
  font-size: 0.72rem;
  color: #BBB;
  margin-top: 8px;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 24, 16, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-overlay[hidden] { display: none !important; }

.modal-sheet {
  background: var(--card-bg);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 28px 20px 40px;
  position: relative;
  animation: slideUp 0.2s ease;
  overscroll-behavior: contain;
}

@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal-sheet { border-radius: var(--radius); max-height: 85dvh; }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--border);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.modal-close:hover { background: #E0D0C8; }

/* ── Modal Content ──────────────────────────────────────────── */
.modal-body { padding-right: 32px; }

.modal-dish-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.25;
  padding-right: 8px;
}

.modal-tagline {
  font-size: 1rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
}

.modal-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
  margin-top: 22px;
}

.modal-ingredients {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-ingredients li {
  font-size: 0.95rem;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--secondary);
  color: var(--text);
}

.modal-instructions {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-instructions li {
  display: flex;
  gap: 12px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
}

.step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.modal-chefs-note {
  background: #FFF8DC;
  border: 1.5px solid var(--secondary);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.9rem;
  color: #5C4A00;
  margin-top: 22px;
  line-height: 1.55;
}

.chefs-note-label {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}
