:root {
  --bg: #f5f4f0;
  --surface: #fffef7;
  --surface-2: #f0ede3;
  --text: #1d1d18;
  --muted: #575748;
  --accent: #2b6d3d;
  --danger: #a12b2b;
  --line: #d7d2c2;
  --font-scale: 100%;
}

body[data-theme="forest"] {
  --bg: #ecf4ed;
  --surface: #f7fcf8;
  --surface-2: #e0efe3;
  --text: #122019;
  --muted: #3f5b4c;
  --accent: #236044;
  --danger: #9a2d2d;
  --line: #b9d1bf;
}

body[data-theme="high-contrast"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #efefef;
  --text: #000000;
  --muted: #1b1b1b;
  --accent: #004f2c;
  --danger: #8f0000;
  --line: #000000;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: var(--font-scale);
  color: var(--text);
  background: radial-gradient(circle at top right, #eef7e9 0%, var(--bg) 45%);
}

.site-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.site-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.site-header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 1rem;
}

.collapsible-panel {
  padding: 0;
}

.collapsible-summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3.35rem;
  padding: 0.95rem 1rem;
  cursor: pointer;
  list-style: none;
}

.collapsible-summary::-webkit-details-marker {
  display: none;
}

.collapsible-summary::before {
  content: "+";
  display: grid;
  place-items: center;
  flex: 0 0 1.45rem;
  width: 1.45rem;
  height: 1.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
}

.collapsible-panel[open] .collapsible-summary {
  border-bottom: 1px solid var(--line);
}

.collapsible-panel[open] .collapsible-summary::before {
  content: "-";
}

.collapsible-summary h2 {
  margin: 0;
}

.collapsible-summary:hover h2 {
  color: var(--accent);
}

.collapsible-content {
  padding: 1rem;
}

.is-hidden {
  display: none !important;
}

h2 {
  margin-top: 0;
}

label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-weight: 600;
}

input,
select,
textarea,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  background: #fff;
  color: var(--text);
  font: inherit;
}

button {
  cursor: pointer;
  background: var(--surface-2);
}

.button-link {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  text-align: center;
  display: inline-block;
}

.button-link:hover {
  border-color: #b4ad99;
}

button:hover {
  border-color: #b4ad99;
}

button.danger {
  border-color: #dfb5b5;
  color: var(--danger);
}

button.small {
  width: auto;
  padding: 0.3rem 0.55rem;
}

.row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}

.row > * {
  flex: 1;
  min-width: 140px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.muted {
  color: var(--muted);
}

.status {
  min-height: 1.2rem;
  margin: 0.6rem 0 0;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.7rem;
  font-weight: 500;
}

.inline-check input {
  width: auto;
}

.ingredient-check {
  width: auto;
  margin-right: 0.45rem;
}

#recipeServingsInput {
  width: 6rem !important;
  max-width: 6rem;
}

.report {
  margin: 0.6rem 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem;
  background: #fbfaf5;
  white-space: pre-wrap;
  display: none;
}

.recipe-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.recipe-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fff;
  cursor: default;
  user-select: text;
}

.recipe-card h3 {
  margin: 0 0 0.25rem;
}

.recipe-open-link {
  cursor: pointer;
}

.recipe-card p {
  margin: 0.3rem 0;
}

.recipe-ingredients {
  white-space: pre-line;
}

.recipe-source {
  font-size: 0.9rem;
}

.source-card {
  margin: 0.75rem 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
}

.source-card p {
  margin: 0.25rem 0;
}

.source-card .source-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.source-card .button-link {
  margin-top: 0.45rem;
}

.recipe-quality-badge {
  display: inline-block;
  width: auto;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 700;
}

.recipe-quality-badge.clean {
  background: #eaf7ee;
  border-color: #99cfaa;
  color: #1e663b;
}

.recipe-quality-badge.needs-review {
  background: #fff8df;
  border-color: #e8cb74;
  color: #8a6a00;
}

.recipe-quality-badge.incomplete {
  background: #fdeceb;
  border-color: #e7a6a2;
  color: #8f2f2f;
}

.recipe-list.is-compact .recipe-card .recipe-notes,
.recipe-list.is-compact .recipe-card .recipe-ingredients,
.recipe-list.is-compact .recipe-card details,
.recipe-list.is-compact .recipe-card .scale-servings-input,
.recipe-list.is-compact .recipe-card .recipe-rating-input,
.recipe-list.is-compact .recipe-card label {
  display: none;
}

.drag-recipe-button {
  cursor: grab;
}

.recipe-photo {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-bottom: 0.45rem;
  display: none;
}

.recipe-photo.is-loading {
  background: linear-gradient(110deg, #f0efe9 8%, #e1dfd5 18%, #f0efe9 33%);
  background-size: 200% 100%;
  animation: recipe-photo-shimmer 1.2s linear infinite;
}

@keyframes recipe-photo-shimmer {
  to {
    background-position-x: -200%;
  }
}

.planner-grid {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 130px repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.planner-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0.45rem;
  background: #fff;
}

.planner-cell.header {
  background: #ece9dc;
  font-weight: 700;
}

.planner-grid .planner-cell:nth-child(4n) {
  border-right: 0;
}

.planner-grid .planner-cell.last-row {
  border-bottom: 0;
}

.planner-cell select {
  width: 100%;
}

.planner-cell.drop-active {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

@media (max-width: 760px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .planner-grid {
    grid-template-columns: 1fr;
  }

  .planner-cell {
    border-right: 0;
  }

  .planner-cell.header {
    position: sticky;
    top: 0;
  }
}
