:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --panel: rgba(255, 252, 247, 0.96);
  --panel-strong: #fffaf2;
  --border: rgba(98, 73, 46, 0.16);
  --text: #2b2118;
  --muted: #6e5a48;
  --accent: #9c4f2d;
  --accent-soft: #f3d2bf;
  --accent-strong: #7a391d;
  --success: #426a4c;
  --shadow: 0 20px 40px rgba(50, 31, 15, 0.12);
  --radius: 18px;
  --radius-small: 12px;
  font-family: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(215, 180, 130, 0.32), transparent 28%),
    radial-gradient(circle at top right, rgba(156, 79, 45, 0.14), transparent 18%),
    linear-gradient(180deg, #f9f5ec 0%, var(--bg) 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar,
.search-panel,
.results-panel,
.detail-card {
  backdrop-filter: blur(14px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem;
  background: linear-gradient(180deg, rgba(246, 241, 231, 0.94) 70%, rgba(246, 241, 231, 0));
}

.topbar h1,
.assistant-head h2,
.voice-tray h3 {
  margin: 0.1rem 0 0;
  line-height: 1;
}

.topbar h1 {
  font-size: 2rem;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
}

.search-panel,
.results-panel,
.mealplan-panel {
  margin: 0 1rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-panel {
  padding: 1rem;
}

.mealplan-panel {
  padding: 1rem;
}

.mealplan-header {
  margin-bottom: 0.75rem;
}

.mealplan-days {
  color: var(--muted);
  font-size: 0.9rem;
}

.mealplan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}

.mealplan-day {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.mealplan-daylabel {
  margin: 0;
  font-weight: 700;
  color: var(--accent-strong);
  font-size: 0.82rem;
}

.mealplan-lunch {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.mealplan-dinner-link {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  text-align: left;
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
}

.mealplan-dinner-empty {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

.mealplan-kidprep {
  margin: 0;
  color: var(--accent);
  font-size: 0.74rem;
}

.mealplan-queued {
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
}

.mealplan-queued ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.search-header {
  display: grid;
  gap: 0.75rem;
}

.secure-badge {
  align-self: end;
  justify-self: start;
  border: 1px solid rgba(66, 106, 76, 0.2);
  background: rgba(230, 243, 232, 0.9);
  color: var(--success);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.search-label,
.filter-grid label span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

#search-input,
.filter-grid select,
#assistant-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--panel-strong);
  color: var(--text);
  min-height: 2.8rem;
  padding: 0.7rem 0.85rem;
}

#assistant-input {
  resize: vertical;
  min-height: 4rem;
}

.filter-grid {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.assistant-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(250, 245, 237, 0.98), rgba(255, 251, 246, 0.9));
}

.assistant-head {
  display: grid;
  gap: 0.5rem;
}

.assistant-head h2 {
  font-size: 1.25rem;
}

.assistant-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.assistant-thread {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
  max-height: 20vh;
  overflow-y: auto;
  padding-right: 0.35rem;
  overscroll-behavior: contain;
}

.assistant-message {
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  max-width: 100%;
}

.assistant-message p {
  margin: 0;
  line-height: 1.45;
}

.assistant-message-user {
  background: rgba(156, 79, 45, 0.12);
  border: 1px solid rgba(156, 79, 45, 0.2);
}

.assistant-message-assistant {
  background: rgba(255, 250, 242, 0.95);
  border: 1px solid var(--border);
}

.assistant-grounding {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border-radius: var(--radius-small);
  background: rgba(243, 210, 191, 0.4);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.4;
}

.assistant-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.accent-button,
.ghost-button,
.load-more {
  border-radius: 999px;
  padding: 0.7rem 1rem;
}

.accent-button {
  border: 1px solid rgba(122, 57, 29, 0.2);
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff9f3;
}

.ghost-button,
.load-more {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
}

.content {
  padding-bottom: 2rem;
}

.results-panel {
  padding: 0.75rem;
}

.results-header {
  padding: 0.25rem 0.35rem 0.75rem;
}

#results-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.results-list {
  display: grid;
  gap: 0.75rem;
}

.recipe-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: linear-gradient(180deg, rgba(255, 251, 245, 0.98), rgba(248, 239, 227, 0.92));
  padding: 0.95rem;
  box-shadow: 0 8px 20px rgba(61, 37, 18, 0.08);
}

.recipe-card h2 {
  margin: 0 0 0.45rem;
  font-size: 1.08rem;
  line-height: 1.25;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #5a280f;
  padding: 0.28rem 0.58rem;
  font-size: 0.76rem;
  font-weight: 700;
}

.recipe-book {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.load-more {
  width: 100%;
  margin-top: 0.9rem;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(31, 21, 12, 0.36);
  padding: 0.75rem;
}

.detail-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: rgba(255, 250, 242, 0.98);
  border-radius: 26px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.detail-body {
  overflow-y: auto;
  padding: 1rem 1rem 22vh;
}

.detail-body h2 {
  margin: 0 0 0.65rem;
  font-size: 1.6rem;
  line-height: 1.1;
}

.detail-section {
  margin-top: 1.3rem;
}

.detail-section:last-child {
  padding-bottom: 1.5rem;
}

.detail-section h3,
.voice-columns h4 {
  margin: 0 0 0.55rem;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.detail-list {
  margin: 0;
  padding-left: 1.15rem;
}

.detail-list li + li {
  margin-top: 0.45rem;
}

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

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}

.detail-meta-grid div {
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-small);
  background: var(--panel-strong);
  border: 1px solid var(--border);
}

.detail-meta-grid dt {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-meta-grid dd {
  margin: 0;
  font-size: 0.92rem;
}

.voice-tray {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(249, 240, 229, 0.98), rgba(255, 249, 242, 0.99));
  padding: 0.8rem 0.9rem 0.9rem;
  min-height: 18vh;
  max-height: 22vh;
  overflow: hidden;
}

.voice-tray-head {
  display: grid;
  gap: 0.55rem;
}

.voice-tray h3 {
  font-size: 1rem;
}

.voice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.voice-status {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.voice-columns {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.55rem;
  max-height: calc(22vh - 4.9rem);
  overflow-y: auto;
}

.voice-columns section {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: rgba(255, 252, 247, 0.92);
}

.voice-copy {
  margin: 0;
  line-height: 1.3;
  font-size: 0.88rem;
}

button:disabled,
textarea:disabled {
  opacity: 0.65;
  cursor: wait;
}

@media (min-width: 720px) {
  .app-shell {
    max-width: 960px;
    margin: 0 auto;
  }

  .search-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .filter-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .assistant-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .detail-overlay {
    padding: 2rem;
  }

  .voice-tray-head,
  .voice-columns {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .voice-tray {
    min-height: 16vh;
    max-height: 20vh;
  }

  .detail-body {
    padding-bottom: 20vh;
  }
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #faf7f2;
}

.auth-gate[hidden] {
  display: none;
}
