:root {
  --bg: #161619;
  --surface: #1f1f24;
  --surface-2: #2a2a31;
  --ink: #f3f1ee;
  --muted: #9c958d;
  --accent: #ff6a3d;
  --accent-soft: rgba(255, 106, 61, 0.18);
  --danger: #ff5a52;
  --border: #2e2e36;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  line-height: 1.6;
}

a {
  color: var(--accent);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(18, 18, 21, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-title {
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.add-btn {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: transform 0.1s ease, filter 0.1s ease;
}
.add-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.home-title {
  margin: 0.25rem 0 1.25rem;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}
.empty {
  color: var(--muted);
}

/* Filter bar */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.6rem;
}
.search {
  flex: 1 1 240px;
  padding: 0.7rem 1rem;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.search::placeholder {
  color: var(--muted);
}
.filter-select {
  font: inherit;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.search:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.result-count {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

/* Photo-first recipe grid */
.recipe-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.5rem 1.1rem;
}
/* On phones, lock to 3 columns so photos don't take over the screen */
@media (max-width: 640px) {
  .recipe-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem 0.6rem;
  }
  .card-info h2 {
    font-size: 0.85rem;
    line-height: 1.25;
  }
  .card-by {
    font-size: 0.72rem;
  }
  .card-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.45rem;
    top: 0.4rem;
    left: 0.4rem;
  }
  .container {
    padding: 1.25rem 1rem 3rem;
  }
}
.recipe-card a {
  display: block;
  color: inherit;
  text-decoration: none;
}
.card-photo {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.recipe-card a:hover .card-photo img {
  transform: scale(1.06);
}
.card-photo-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  opacity: 0.92;
}
.card-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.card-info {
  padding: 0.65rem 0.2rem 0;
}
.card-info h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}
.card-by {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.no-results {
  color: var(--muted);
  text-align: center;
  padding: 2rem 0;
}

/* Single recipe */
.recipe {
  max-width: 760px;
  margin: 0 auto;
}
.recipe-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.back-link:hover {
  text-decoration: underline;
}
.recipe-actions {
  display: flex;
  gap: 0.5rem;
}
.recipe-actions form {
  margin: 0;
}

.recipe h1 {
  margin: 0 0 0.4rem;
  font-size: 2rem;
  letter-spacing: -0.02em;
}
.byline {
  color: var(--muted);
  margin: 0 0 1.25rem;
}
.recipe-img {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.recipe-img-ph {
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
}
.recipe-desc {
  color: var(--muted);
  font-size: 1.08rem;
  margin-top: 0;
}
.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0.85rem 0;
  margin-bottom: 0.5rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.recipe h2 {
  margin-top: 1.85rem;
  font-size: 1.3rem;
}

/* Ingredients with check-off */
.ingredients {
  list-style: none;
  padding-left: 0;
}
.ingredients .ing {
  margin-bottom: 0.4rem;
}
.ingredients .ing label {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  cursor: pointer;
}
.ingredients .ing input {
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}
.ingredients .ing.checked span {
  text-decoration: line-through;
  color: var(--muted);
}

.instructions ol {
  padding-left: 1.25rem;
}
.instructions li {
  margin-bottom: 0.8rem;
}

.source {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.tags {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag {
  background: var(--surface-2);
  color: var(--ink);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover {
  border-color: var(--accent);
}
.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  border-color: var(--danger);
  background: rgba(255, 90, 82, 0.12);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
}
.btn-primary:hover {
  filter: brightness(1.08);
}

/* Form */
.recipe-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-top: 1rem;
  max-width: 720px;
}
.recipe-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
}
.recipe-form input[type="text"],
.recipe-form input[type="password"],
.recipe-form textarea,
.recipe-form select,
.recipe-form input[type="file"] {
  font: inherit;
  font-weight: 400;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
.recipe-form input[type="text"]:focus,
.recipe-form input[type="password"]:focus,
.recipe-form textarea:focus,
.recipe-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.recipe-form textarea {
  resize: vertical;
}
.recipe-form input[type="file"] {
  padding: 0.5rem;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}
.req {
  color: var(--accent);
}
.login-intro {
  color: var(--muted);
  max-width: 46ch;
}
.login-error {
  color: var(--danger);
  font-weight: 600;
}
.hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2.5rem 1rem;
}

/* Clean printout of a single recipe */
@media print {
  .site-header,
  .site-footer,
  .recipe-top,
  .tags {
    display: none !important;
  }
  body {
    background: #fff;
    color: #111;
  }
  .container {
    max-width: none;
    padding: 0;
  }
  .recipe-desc,
  .recipe-meta,
  .byline,
  .ingredients .ing.checked span {
    color: #444;
  }
  .recipe-img {
    max-height: 280px;
    box-shadow: none;
  }
  .ingredients .ing input {
    display: none;
  }
}
