:root {
  --bg: #f7f5ef;
  --paper: #fffdf8;
  --ink: #1f2a37;
  --accent: #0f766e;
  --accent-soft: #d1fae5;
  --danger: #991b1b;
  --border: #dcd7ca;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f3efe4 0%, #f8f6f0 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 6rem;
}

.card,
.alt-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.9rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

h1,
h2 {
  margin-top: 0;
}

label {
  display: block;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 0.3rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font: inherit;
}

button,
.primary,
.secondary,
input[type="submit"] {
  border: 0;
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button[disabled] {
  cursor: wait;
  opacity: 0.75;
  position: relative;
  padding-right: 2.2rem;
}

button[disabled]::after {
  content: "";
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.85em;
  height: 0.85em;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
}

@keyframes btn-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.primary,
input[type="submit"] {
  background: var(--accent);
  color: white;
}

.secondary {
  background: var(--accent-soft);
  color: var(--ink);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.65rem;
}

.inline-form input,
.inline-form select,
.inline-form button {
  margin-top: 0;
  margin-bottom: 0;
}

.stack {
  display: grid;
  gap: 0.4rem;
}

.tags {
  color: #486070;
  font-size: 0.93rem;
}

.flash {
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  margin-bottom: 0.9rem;
}

.flash-notice {
  background: #dcfce7;
}

.flash-alert {
  background: #fee2e2;
  color: var(--danger);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 0.6rem;
}

.bottom-nav a,
.bottom-nav .inline-button {
  text-align: center;
  text-decoration: none;
  color: #4b5563;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 0.55rem 0.4rem;
}

.bottom-nav a.active {
  background: var(--accent-soft);
  color: #065f46;
}

.inline-button {
  border: 0;
}

.shopping-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #ece8dd;
}

.shopping-item.checked span {
  text-decoration: line-through;
  color: #6b7280;
}

/* Shopping list slot filter */
.slot-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.slot-filter-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  background: #f3f4f6;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.75rem;
  line-height: 1.3;
  border: 1px solid transparent;
}

.slot-filter-chip.active {
  background: var(--accent-soft);
  color: #065f46;
  border-color: var(--accent);
}

.slot-filter-day {
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slot-filter-title {
  font-size: 0.72rem;
  color: inherit;
}

.check-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
}

/* Week navigation */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
}

.week-nav-btn {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  background: var(--accent-soft);
}

.week-nav-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.back-link {
  display: block;
  text-align: center;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 0.75rem;
}

/* Plan meta header */
.plan-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e5e7eb;
  color: #374151;
}

.status-badge.status-draft     { background: #e5e7eb; color: #374151; }
.status-badge.status-generating { background: #fef3c7; color: #92400e; }
.status-badge.status-ready     { background: var(--accent-soft); color: #065f46; }
.status-badge.status-failed    { background: #fee2e2; color: var(--danger); }

/* Recipe hero image */
.recipe-hero-image {
  width: calc(100% + 2rem);
  margin: -1rem -1rem 1rem;
  height: 220px;
  object-fit: cover;
  border-radius: 14px 14px 0 0;
  display: block;
}

/* Slot card image header */
.slot-card:has(.slot-card-image) {
  overflow: hidden;
}

.slot-card-image {
  width: calc(100% + 2rem);
  margin: -1rem -1rem 0.75rem;
  height: 160px;
  object-fit: cover;
  display: block;
}

/* Recipe header with back link */
.recipe-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.recipe-header h1 {
  margin: 0;
}

.recipe-back-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

/* Alternatives trigger row */
.alt-trigger-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.alt-constraint-field {
  flex: 1;
  margin: 0;
  font-size: 0.82rem;
  padding: 0.3rem 0.5rem;
}

.alt-trigger-btn {
  white-space: nowrap;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
}

/* Alternative concept cards */
.alt-concept-card {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.alt-concept-card:last-of-type {
  border-bottom: none;
}

.alt-concept-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.alt-concept-meta {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 0.1rem;
}

.alt-concept-mood {
  font-size: 0.82rem;
  color: #4b5563;
  margin-bottom: 0.25rem;
}

.alt-preview-form {
  margin-top: 0.4rem;
}

/* Preview view */
.preview-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4b5563;
  margin: 0.75rem 0 0.3rem;
}

.preview-ingredients {
  margin: 0 0 0.5rem 1.2rem;
  padding: 0;
  font-size: 0.88rem;
}

.preview-steps {
  margin: 0 0 0.5rem 1.2rem;
  padding: 0;
  font-size: 0.88rem;
  line-height: 1.55;
}

.preview-steps li {
  margin-bottom: 0.35rem;
}

.preview-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Regenerate toggle */
.regenerate-details summary {
  list-style: none;
  cursor: pointer;
}
.regenerate-details summary::-webkit-details-marker { display: none; }

.regenerate-summary {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.4rem;
}

.regenerate-form {
  margin-top: 0.6rem;
}

/* Day sections */
.day-section {
  margin-bottom: 1rem;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #4b5563;
}

.add-slot-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

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

.add-slot-form {
  padding: 0.5rem 0 0.25rem;
}

.add-slot-select,
.add-slot-time {
  width: auto;
  margin: 0;
}

/* Past days */
.past-days-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0 0.5rem;
}

.past-days-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin: 0 0 0.5rem;
}

.day-section.past .day-header {
  color: #9ca3af;
}

.slot-card.past {
  opacity: 0.55;
}

/* Slot cards */
.slot-card {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.slot-type {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.slot-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.slot-title a {
  color: var(--ink);
  text-decoration: none;
}

.slot-title a:hover {
  text-decoration: underline;
}

/* Slot action row */
.slot-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.slot-action-link {
  font-size: 0.82rem;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-weight: 500;
}

.slot-actions details {
  display: inline;
}

.slot-actions details summary {
  display: inline;
  list-style: none;
}

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

.slot-actions details[open] {
  display: block;
  width: 100%;
}

.slot-action-danger {
  font-size: 0.82rem;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0;
  font-weight: 700;
  margin-left: auto;
}

/* Alternatives full-page */
.alt-page-header {
  margin-bottom: 0.9rem;
}

.alt-page-back {
  margin-bottom: 0.5rem;
}

.alt-page-back .back-link {
  margin-bottom: 0;
}

.alt-page-slot-info {
  margin-bottom: 0.4rem;
}

.alt-page-current {
  font-size: 0.9rem;
  color: #4b5563;
  margin-top: 0.15rem;
}

.alt-page-title {
  margin: 0.4rem 0 0.6rem;
  font-size: 1.1rem;
}

.alt-search-form {
  margin-top: 0;
}

.alt-concept-card-full {
  margin-bottom: 0.9rem;
}

.alt-concept-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}
