:root {
  --bg: #f2f2f2;
  --card: #fafafa;
  --panel: #fff;
  --text: #222;
  --muted: #555;
  --border: #ccc;
  --primary: #e53935;
  --primary-dark: #c62828;
  --accent: #1565c0;
  --modal: #fff;
  --shadow: 0 2px 6px rgba(0,0,0,0.06);
}

body.dark-mode {
  --bg: #0f172a;
  --card: #0b1223;
  --panel: #0b1223;
  --modal: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;
  --primary: #ef4444;
  --primary-dark: #dc2626;
  --accent: #38bdf8;
  --shadow: 0 2px 8px rgba(0,0,0,0.5);
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.site-title {
  font-size: 1.6rem;
  text-align: center;
  margin: 0 0 0.4rem;
}

.recipes-assistant-wrapper {
  max-width: 1000px;
  margin: 1.5rem auto;
  padding: 0 1rem 2rem;
  background: var(--card);
}

body.simple-mode .advanced-field {
  display: none;
}

.recipes-assistant-wrapper h2 {
  text-align: center;
  margin-bottom: 0.25rem;
}

.recipes-assistant-wrapper p.sub {
  text-align: center;
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.field-help {
  font-weight: 400;
  display: block;
  font-size: 0.8rem;
}

/* Form */

.recipes-form {
  background: var(--panel);
  padding: 1rem 1.2rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.recipes-field-group {
  display: grid;
  gap: 0.35rem;
}

.recipes-field-group label {
  font-size: 0.9rem;
  font-weight: 600;
}

.recipes-form input[type="text"],
.recipes-form input[type="number"],
.recipes-form select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  box-sizing: border-box;
  background: var(--panel);
  color: var(--text);
}

.recipes-inline-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.6rem;
}

.recipes-checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.3rem 0.75rem;
  font-size: 0.85rem;
}

.recipes-checkbox-group label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.recipes-form button {
  margin-top: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.recipes-form button:hover {
  background: var(--primary-dark);
}

#recipes-status {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Recipes grid */

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.recipe-card {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.recipe-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  max-height: 180px;
}

.recipe-card-image-wrapper {
  position: relative;
}

.favorite-heart {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #0d6efd;
  color: #fff;
  border: 1px solid #0d6efd;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
  box-shadow: var(--shadow);
}

.favorite-heart.is-fav {
  background: #0d6efd;
  border-color: #0d6efd;
  color: #ef4444;
}

.favorite-heart:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 12px rgba(0,0,0,0.12);
}

.recipe-card-body {
  padding: 0.8rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.recipe-card-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.recipe-card button {
  align-self: flex-start;
  margin-top: 0.3rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.recipe-card button:hover {
  background: #0d47a1;
}

.recipe-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.btn-favorite {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-favorite:hover {
  background: rgba(21, 101, 192, 0.08);
}

.account-wrapper {
  margin-top: 1rem;
}

.account-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
}

.account-tabs-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.account-tab {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}

.account-tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-content {
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  box-shadow: var(--shadow);
}

.tab-content.active {
  display: block;
}

.favorites-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.favorite-lists {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.favorite-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.favorite-list-actions button {
  margin-left: 0.4rem;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.favorite-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.favorite-card-body {
  padding: 0.6rem 0.7rem;
}

.favorite-card-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.favorite-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.info-field {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
}

#account-main-logout {
  align-self: flex-start;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

#account-main-logout:hover {
  background: var(--primary-dark);
}

@media (max-width: 700px) {
  .account-layout {
    grid-template-columns: 1fr;
  }

  .account-tabs-vertical {
    flex-direction: row;
    gap: 0.6rem;
  }
}

#more-recipes-btn {
  margin: 1.5rem auto 0;
  display: none;
  padding: 0.6rem 1.3rem;
  border-radius: 999px;
  border: none;
  background: #424242;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}

#more-recipes-btn:hover {
  background: #212121;
}

/* Mode switches */
.mode-switches {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  user-select: none;
  touch-action: manipulation;
}

.mode-switch input {
  accent-color: var(--accent);
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  margin: 0;
}

.mode-switch input,
.mode-switch span {
  cursor: pointer;
}

.auth-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.7rem;
  display: grid;
  gap: 0.5rem;
}

.auth-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.auth-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.link-button {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

/* Loading indicator */

.loading-animated {
  position: relative;
  padding-left: 1.4rem;
}
.loading-animated::before {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: 50%;
  width: 0.7rem;
  height: 0.7rem;
  margin-top: -0.35rem;
  border-radius: 50%;
  border: 2px solid #999;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Modal */

.recipe-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.recipe-modal {
  background: var(--modal);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.18s ease-out;
  color: var(--text);
}

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

.recipe-modal-header {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.recipe-modal-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.recipe-modal-source {
  font-size: 0.8rem;
  color: var(--muted);
}

.recipe-modal-source a {
  color: var(--accent);
  text-decoration: none;
}
.recipe-modal-source a:hover {
  text-decoration: underline;
}

.recipe-modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  color: var(--text);
}

.recipe-modal-body {
  padding: 0.75rem 1rem 1rem;
  overflow-y: auto;
}

.recipe-modal-body h4 {
  margin: 0.2rem 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.recipe-modal-body ul,
.recipe-modal-body ol {
  margin: 0 0 0.7rem 1.1rem;
  padding: 0;
  font-size: 0.9rem;
}

.recipe-modal-body li {
  margin-bottom: 0.25rem;
}

.recipe-modal-body .recipe-meta-small {
  font-size: 0.8rem;
  color: #777;
  margin-bottom: 0.6rem;
}

.servings-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
  font-size: 0.9rem;
}

.servings-control input {
  width: 70px;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 0.9rem;
}

.servings-base {
  font-size: 0.8rem;
  color: #777;
}

/* Instacart button */

.instacart-block {
  margin: 0.5rem 0 0.8rem;
}

.instacart-btn {
  border-radius: 999px;
  border: none;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  background: #00b26f;
  color: #fff;
}
.instacart-btn:hover {
  background: #00915b;
}

/* Footer */

.site-footer {
  border-top: 1px solid #ddd;
  background: #ffffff;
  padding: 0.8rem 1rem;
}

.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #555;
}

.footer-links {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.footer-links a {
  color: #1565c0;
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
}
.recipe-card-source {
  font-size: 0.8rem;
  color: var(--muted);
}

.recipe-card-source a {
  color: var(--accent);
  text-decoration: none;
}
.recipe-card-source a:hover {
  text-decoration: underline;
}

/* Chips input */
.chips-input {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #dcdfe4;
  border-radius: 8px;
  background: var(--panel);
  position: relative;
}

.chips-input input {
  border: none;
  flex: 1;
  min-width: 140px;
  padding: 0.4rem 0.5rem;
  outline: none;
}

.suggestions-wrapper {
  position: relative;
  width: 100%;
}

.suggestions-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  z-index: 999;
  display: none;
  padding: 0.4rem;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex-direction: row;
}

.suggestions-panel .suggestion-item {
  all: unset;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  border-radius: 999px;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.suggestions-panel .suggestion-item:hover,
.suggestions-panel .suggestion-item:focus {
  background: rgba(21, 101, 192, 0.08);
}

.suggestions-panel .suggestion-item:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0.65rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1200;
}

.site-header .header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.site-header nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.site-header nav a,
.site-header nav button {
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.site-header nav button {
  color: var(--primary);
}

.list-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.list-picker {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1rem;
  max-width: 360px;
  width: 90%;
  display: grid;
  gap: 0.6rem;
}

.list-picker h4 {
  margin: 0;
  font-size: 1rem;
}

.list-picker .list-options {
  display: grid;
  gap: 0.35rem;
}

.list-picker .list-option {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}

.list-picker .list-option:hover {
  background: rgba(21,101,192,0.08);
}

.list-picker .new-list {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.list-picker .new-list input {
  flex: 1;
  padding: 0.35rem 0.45rem;
}

.vision-upload {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.vision-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

.vision-label input {
  display: none;
}

.vision-upload button {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

.vision-upload button:hover {
  opacity: 0.9;
}

.vision-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #eef3ff;
  color: #1f3a64;
  border-radius: 16px;
  padding: 0.25rem 0.6rem;
  font-size: 0.9rem;
}

.chip button {
  background: transparent;
  border: none;
  color: #1f3a64;
  cursor: pointer;
  font-weight: 700;
}

.chip button:focus {
  outline: 2px solid #e53935;
  outline-offset: 2px;
}
