:root{
  --bg: #ffe9e9;
  --card: #fff6f6;
  --ink: #2b1b1b;
  --muted: rgba(43,27,27,.65);
  --brand: #ae0d0d;
  --accent: rgb(251, 157, 173);
  --accent-2: rgba(251,157,173,.25);
  --border: rgba(0,0,0,.18);
  --shadow: 0 12px 30px rgba(0,0,0,.08);
  --radius: 14px;
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app{
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

.topbar{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.title{
  font-family: "Garamond", serif;
  font-size: 3.5rem;
  line-height: 1;
  margin: 0;
  color: var(--brand);
}

.subtitle{
  margin: 6px 0 0;
  color: var(--muted);
}

.nav{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-button{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  font-size: 1rem;
  color: #fff;
  background: var(--accent);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s ease, filter .12s ease;
}

.nav-button:hover{ filter: brightness(.98); transform: translateY(-1px); }
.nav-button.is-active{ outline: 3px solid var(--accent-2); }

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.upload-card{
  padding: 14px 14px;
  margin: 14px 0;
}

.upload-row{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.label{
  font-weight: 700;
}

.hint{
  margin-top: 4px;
  font-size: .92rem;
  color: var(--muted);
}

.file-btn{
  background: #fff;
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.file-btn input{ display: none; }

.debug-card{
  padding: 10px 12px;
  margin-bottom: 16px;
}

.debug-card summary{
  cursor: pointer;
  font-weight: 700;
}

#result{
  margin: 10px 0 0;
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
}

.grid{
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px){
  .topbar{ align-items: flex-start; flex-direction: column; }
  .grid{ grid-template-columns: 1fr; }
}

.preview-card{
  padding: 12px;
  position: sticky;
  top: 16px;
}

.card-title{
  font-weight: 800;
  margin-bottom: 10px;
}

.preview-wrap{
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

#preview{
  display: none; /* JS toggles this */
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.table-card{
  padding: 12px;
}

.table-head{
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 10px;
}

.table-wrap{
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.data-table{
  width: 100%;
  border-collapse: collapse;
}

.data-table th{
  background: var(--accent);
  color: #fff;
  text-align: left;
  padding: 12px 12px;
  font-size: .95rem;
  position: sticky;
  top: 0;
}

.data-table td{
  padding: 12px 12px;
  border-top: 1px solid rgba(0,0,0,.10);
  vertical-align: top;
}

.data-table tr:hover td{
  background: rgba(251,157,173,.10);
}

.data-table .num{
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .9rem;
  border: 1px solid var(--border);
}

.pill.yes{ background: rgba(0,160,80,.12); }
.pill.no{ background: rgba(120,120,120,.12); }

.btn{
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

.btn.primary{
  background: var(--accent);
  color: #fff;
  border-color: rgba(0,0,0,.08);
}

.btn.danger{
  background: rgba(200,0,0,.10);
}

.btn-row{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.cell-input, select{
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.conf{
  display: flex;
  align-items: center;
  gap: 10px;
}

.conf-bar{
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.10);
  overflow: hidden;
}

.conf-fill{
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.conf-num{
  width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.chat {
  background: #fff;
  border: 1px solid #e6caca;
  border-radius: 14px;
  padding: 12px;
  height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.2;
}

.chat-bubble.bot {
  background: #ffecec;
  align-self: flex-start;
  border: 1px solid #f3c9c9;
}

.chat-bubble.user {
  background: #ffd6df;
  align-self: flex-end;
  border: 1px solid #f0a9b9;
}

.chat-input {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.chat-input input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e6caca;
}

.chat-card .phone {
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 18px;
  background: #fff7f8;
  padding: 12px;
}

.chat-window {
  height: 360px;
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.08);
}

.chat-input-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  outline: none;
}

.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 14px;
  margin: 8px 0;
  line-height: 1.25;
  white-space: pre-wrap;
}

.bubble.user {
  margin-left: auto;
  background: #ffb3c1;
  border: 1px solid rgba(0,0,0,.08);
}

.bubble.assistant {
  margin-right: auto;
  background: #ffe3ea;
  border: 1px solid rgba(0,0,0,.08);
}

.recipe-results {
  display: grid;
  gap: 10px;
}

.recipe-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 14px;
  padding: 12px;
}

.recipe-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.recipe-link {
  display: inline-block;
  margin-top: 8px;
  color: #861b1b;
}

/* Recipes page: give pantry more space */
.recipes-grid{
  grid-template-columns: 440px 1fr;
}

/* Add row layout (it currently has no CSS, so it squishes awkwardly) */
.add-row{
  display: grid;
  grid-template-columns: 1fr 170px auto;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

/* On smaller screens, stack nicely */
@media (max-width: 900px){
  .recipes-grid{ grid-template-columns: 1fr; }
  .add-row{ grid-template-columns: 1fr; }
}

/* ===== Pantry row sizing tweaks ===== */

/* Let name input take maximum available space */
#pantryTableBody td:first-child .cell-input {
  width: 100%;
  min-width: 0;        /* allow shrinking */
  max-width: 100%;
}

/* Shrink perishable dropdown */
#pantryTableBody select.cell-input {
  max-width: 95px;
  padding: 6px 8px;
  font-size: 0.9rem;
}

/* ===== Edit Dropdown ===== */

.edit-dropdown {
  position: relative;
  display: inline-block;
}

.edit-toggle {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.edit-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 110%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(0,0,0,.08);
  padding: 6px;
  min-width: 100px;
  z-index: 10;
}

.edit-dropdown:hover .edit-menu {
  display: block;
}

.dropdown-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.dropdown-item:hover {
  background: var(--accent-2);
}

.dropdown-item.danger:hover {
  background: rgba(200,0,0,.1);
}
