:root {
  --bg: #0f172a;
  --bg-alt: #111827;
  --card: #1f2937;
  --accent: #f97316;
  --accent-soft: rgba(249, 115, 22, 0.15);
  --text: #f9fafb;
  --muted: #9ca3af;
  --danger: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background: radial-gradient(circle at top, #1f2937, #020617);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.logo {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
}

.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.auth {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

#userEmail {
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-btn,
.secondary-btn {
  border-radius: 999px;
  border: none;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}

.primary-btn {
  background: linear-gradient(135deg, #f97316, #f97316cc);
  color: white;
}

.secondary-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: var(--muted);
}

/* Layout */
.container {
  max-width: 1000px;
  margin: 20px auto 40px;
  padding: 0 16px;
}

.top-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

#searchInput {
  flex: 1;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
}

#searchInput::placeholder {
  color: var(--muted);
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: radial-gradient(circle at top left, rgba(249, 115, 22, 0.12), transparent) , var(--card);
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
  border-color: var(--accent-soft);
}

.card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
}

.card-title {
  font-weight: 600;
  font-size: 1rem;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tag {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.favorite-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
}

/* Sections */
.hidden {
  display: none !important;
}

/* Modales */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal-content {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.9);
}

.modal-content.large {
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-content h2 {
  margin-bottom: 12px;
}

.modal-content input,
.modal-content textarea {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 0.9rem;
}

.modal-content textarea {
  min-height: 70px;
  resize: vertical;
}

.error-text {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* Recipe detail */
.recipe-detail-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.recipe-detail-header {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.recipe-detail-header img {
  width: 220px;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
}

.recipe-detail-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.recipe-section-title {
  margin-top: 10px;
  margin-bottom: 4px;
  font-size: 1rem;
  font-weight: 600;
}

.recipe-section-list {
  font-size: 0.9rem;
  color: var(--muted);
}

.recipe-section-list li {
  margin-left: 16px;
}

/* Comments */
.comments-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.comment {
  padding: 8px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.comment-author {
  font-size: 0.85rem;
  font-weight: 600;
}

.comment-text {
  font-size: 0.9rem;
  color: var(--text);
}

.comment-date {
  font-size: 0.75rem;
  color: var(--muted);
}

#addCommentArea {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Buttons */
.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: rgba(15, 23, 42, 0.8);
  color: var(--muted);
  border-radius: 999px;
  width: 26px;
  height: 26px;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .auth {
    width: 100%;
    justify-content: flex-end;
  }
  .recipe-detail-header {
    flex-direction: column;
  }
  .recipe-detail-header img {
    width: 100%;
    height: 180px;
  }
}
