:root {
  color-scheme: dark;
  --bg: #12071f;
  --panel: rgba(38, 18, 58, 0.82);
  --text: #fbf6ff;
  --muted: rgba(251, 246, 255, 0.7);
  --gold: #f5d991;
  --line: rgba(245, 217, 145, 0.22);
  --purple: #a56cff;
  --purple-dark: #5d2b8f;
  --warn: #ffb4a2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 12%, rgba(165, 108, 255, 0.32), transparent 28rem),
    radial-gradient(circle at 85% 22%, rgba(245, 217, 145, 0.16), transparent 24rem),
    linear-gradient(145deg, #0c0615, var(--bg) 48%, #250d3e);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(245, 217, 145, 0.65) 0 1px, transparent 1.5px);
  background-position: 0 0, 48px 72px;
  background-size: 120px 120px, 180px 180px;
  opacity: 0.28;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: clamp(18px, 4vw, 48px);
}

.panel {
  width: min(820px, 100%);
  padding: clamp(22px, 4vw, 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), rgba(22, 9, 35, 0.9));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
}

.heading {
  margin-bottom: 18px;
}

.heading p {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.heading .sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(3rem, 9vw, 6rem);
  line-height: 0.85;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid rgba(245, 217, 145, 0.24);
  border-radius: 8px;
  background: rgba(12, 6, 21, 0.72);
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
}

input[type="text"] {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 120px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
}

/* Inline ghost-text autocomplete */
.ac-wrap {
  position: relative;
  display: block;
}

.ac-ghost {
  position: absolute;
  inset: 0;
  margin: 0;
  pointer-events: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: transparent;
  border-color: transparent !important;
  border-style: solid;
  color: transparent;
}

.ac-ghost .ac-sug {
  color: rgba(251, 246, 255, 0.4);
}

.ac-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ac-chips:empty {
  display: none;
}

.ac-chip {
  min-height: auto;
  padding: 5px 12px;
  border: 1px solid rgba(245, 217, 145, 0.35);
  border-radius: 999px;
  background: rgba(165, 108, 255, 0.18);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.ac-chip:active {
  background: rgba(165, 108, 255, 0.4);
}

.discover {
  margin-top: 18px;
}

.discover-label {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.discover-card {
  border-color: rgba(245, 217, 145, 0.4);
  background: linear-gradient(180deg, rgba(165, 108, 255, 0.14), rgba(12, 6, 21, 0.55));
}

.discover-card .meta {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.85rem;
}

.discover-card h3 a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
}

.discover-card h3 a:hover {
  color: var(--gold);
}

.discover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.discover-actions .ghost {
  min-height: auto;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.day-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.day-actions .ghost {
  min-height: auto;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
}

.secondary {
  color: #231429;
  background: var(--gold);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.ghost:hover {
  color: var(--text);
  border-color: var(--gold);
}

/* Segmented "Plan" control: 2 days / 3 days / Week */
.plan-seg {
  display: inline-flex;
  align-items: center;
  height: 46px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(245, 217, 145, 0.08);
}

.plan-seg-label {
  padding: 0 12px;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--gold);
  letter-spacing: 0.02em;
  border-right: 1px solid var(--gold);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.plan-days {
  min-height: 0;
  height: 100%;
  border-radius: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 800;
  border-right: 1px solid rgba(245, 217, 145, 0.3);
}

.plan-days:last-child {
  border-right: 0;
}

.plan-days:hover {
  background: var(--gold);
  color: #231429;
}

.status {
  min-height: 24px;
  margin-top: 16px;
  color: var(--gold);
  font-size: 0.92rem;
}

.results {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.results:empty {
  margin-top: 0;
}

.section-title {
  margin: 18px 0 4px;
  color: var(--gold);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.9rem;
  line-height: 1;
}

.card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 6, 21, 0.55);
  padding: 16px 18px;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.thumb {
  width: 240px;
  height: 240px;
  object-fit: cover;
  border-radius: 12px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.05);
}

.modal-img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.card h3 a,
.card h3 .recipe-link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
  cursor: pointer;
}

.card h3 a:hover,
.card h3 .recipe-link:hover {
  color: var(--gold);
}

.card .why {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.card .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.meta-stars {
  color: var(--gold);
  letter-spacing: 1px;
}

.meta-rating {
  margin-left: 4px;
}

.missing {
  margin: 0;
  font-size: 0.86rem;
  color: var(--warn);
}

.missing.none {
  color: #9be7a0;
}

.day-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--purple-dark);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.shopping {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 6, 21, 0.55);
  padding: 16px 18px;
}

.shopping h4 {
  margin: 12px 0 4px;
  color: var(--gold);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.shopping h4:first-child {
  margin-top: 0;
}

.shopping ul {
  margin: 0;
  padding-left: 18px;
  list-style: none;
}

.shopping li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
  color: var(--muted);
}

.shop-item {
  flex: 1;
}

.shop-remove {
  min-height: auto;
  width: 22px;
  height: 22px;
  padding: 0;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.shop-remove:hover {
  border-color: var(--warn);
  color: var(--warn);
}

.shopping-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.copy-btn {
  min-height: auto;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--gold);
  color: #231429;
  font-size: 0.8rem;
  font-weight: 800;
}

.recipe-count {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 3, 12, 0.78);
  z-index: 50;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(640px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--panel), rgba(14, 6, 24, 0.96));
  padding: 28px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  min-height: auto;
  padding: 4px 10px;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
}

.modal-card h2 {
  margin: 0 0 6px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2rem;
  line-height: 1;
}

.modal-card .meta {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 0.85rem;
}

.modal-card h3 {
  margin: 16px 0 6px;
  color: var(--gold);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.modal-card ul,
.modal-card ol {
  margin: 0;
  padding-left: 20px;
  line-height: 1.55;
}

.modal-card a {
  color: var(--purple);
}

.music-player {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
}

.music-toggle {
  font-family: "DM Sans", sans-serif;
  font-size: 1rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 20, 24, 0.85);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.2s, color 0.2s;
}

.music-toggle:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.music-toggle.playing {
  border-color: var(--purple);
  color: var(--purple);
}

/* Keep the YouTube iframe alive but out of sight; it only provides audio. */
.yt-player-offscreen {
  position: fixed;
  left: -9999px;
  bottom: 0;
  width: 200px;
  height: 113px;
  pointer-events: none;
  opacity: 0;
}

.yt-player-offscreen iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---- Full-screen Ken Burns slideshow overlay ---- */
.slideshow {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  overflow: hidden;
}

.slideshow[hidden] {
  display: none;
}

.slideshow-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.slide-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Show the whole dish (letterboxed) rather than cropping to fill. */
  object-fit: contain;
  will-change: transform, opacity;
  cursor: pointer;
}

.slide-img.fade {
  animation: slide-fade 0.6s ease;
}

@keyframes slide-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Ken Burns: slow zoom + drift. Re-triggered per slide via class toggle. */
.slide-img.kb {
  animation: slide-fade 0.6s ease, ken-burns 12s ease-out forwards;
}

@keyframes ken-burns {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.04) translate(0, -1%); }
}

.slideshow-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  min-height: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.slideshow-close:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.slideshow-refresh {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 2;
  min-height: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.slideshow-refresh:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.slide-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  min-height: auto;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.slide-prev { left: 16px; }
.slide-next { right: 16px; }

.slide-nav:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.slide-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 40px clamp(18px, 5vw, 60px) clamp(22px, 5vw, 44px);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55) 35%, rgba(0, 0, 0, 0.86));
  color: #fff;
}

.slide-caption .slide-title {
  margin: 0 0 8px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1.02;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  border-bottom: 2px solid transparent;
}

.slide-caption .slide-title:hover {
  border-bottom-color: var(--gold);
  color: var(--gold);
}

.slide-caption .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.82);
}

.slide-caption .slide-desc {
  max-width: 60ch;
  margin: 0 0 14px;
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

.slide-caption .meta-stars {
  color: var(--gold);
  letter-spacing: 1px;
}

.slide-add {
  min-height: auto;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--gold);
  color: #231429;
  font-size: 0.92rem;
  font-weight: 800;
}

.slide-add:hover {
  filter: brightness(1.06);
}

.slide-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  transform: translate(-50%, -50%) scale(0.92);
  padding: 14px 24px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid var(--gold);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.slide-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

@media (max-width: 560px) {
  .slide-nav {
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
  }
}

@media (max-width: 560px) {
  .actions button {
    width: 100%;
  }

  /* Stack cards: big thumbnail on top, description below. */
  .card {
    flex-direction: column;
    align-items: stretch;
  }

  .thumb {
    width: 100%;
    height: 220px;
  }
}
