@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;1,400&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap');


*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:       #FDFAF6;
  --surface:  #FFFFFF;
  --s2:       #F5F0E8;
  --s3:       #EDE6D9;
  --text:     #1C1410;
  --t2:       #7A6E64;
  --t3:       #B5A99A;
  --green:    #2D6A4F;
  --gl:       #D8F3DC;
  --gm:       #52B788;
  --amber:    #C97B2A;
  --al:       #FFF3DC;
  --red:      #C0392B;
  --rl:       #FDECEA;
  --border:   #E8E0D5;
  --b2:       #D4C9BB;
  --radius:   12px;
  --radius-lg:20px;
  --shadow:   0 2px 8px rgba(44,28,16,0.07);
  --shadow-lg:0 8px 28px rgba(44,28,16,0.11);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 48px;
}

h1, h2, h3, .serif { font-family: 'Playfair Display', Georgia, serif; }

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--green);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.brand-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.brand-name em {
  color: var(--green);
  font-style: italic;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nt {
  background: none;
  border: none;
  padding: 7px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--t2);
  transition: all 0.18s;
}

.nt:hover {
  background: var(--s2);
  color: var(--text);
}

.nt.active {
  background: var(--gl);
  color: var(--green);
  font-weight: 600;
}

.nav-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--t2);
  padding: 6px;
  border-radius: 8px;
}

.nav-menu-btn:hover { background: var(--s2); }


.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.hidden { display: none !important; }


.hero {
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.2;
  margin-bottom: 0.4rem;
}

.hero h1 em {
  color: var(--green);
  font-style: italic;
}

.hero p {
  color: var(--t2);
  font-weight: 300;
  font-size: 0.95rem;
}


.mode-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}

.mp {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--t2);
  background: var(--surface);
  transition: all 0.18s;
}

.mp:hover {
  border-color: var(--gm);
  color: var(--green);
}

.mp.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}


.search-wrap {
  position: relative;
  margin-bottom: 1.3rem;
}

.search-wrap input {
  width: 100%;
  padding: 13px 46px 13px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}

.search-wrap input:focus {
  border-color: var(--gm);
}

.search-ico {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--t3);
  pointer-events: none;
  font-size: 1rem;
}

.cat-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 1.3rem;
}

.ct {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  color: var(--t2);
}

.ct:hover {
  border-color: var(--gm);
  color: var(--green);
}

.ct.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.sel-bar {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.3rem;
  gap: 10px;
  flex-wrap: wrap;
}

.sel-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  align-items: center;
  min-width: 0;
}

.sel-hint {
  font-size: 0.82rem;
  color: var(--t3);
}

.chip {
  background: var(--gl);
  color: var(--green);
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 0.76rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--green);
  font-size: 11px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}

.sel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#ingredient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 9px;
  margin-bottom: 2rem;
}

.ing-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  user-select: none;
}

.ing-item:hover {
  border-color: var(--gm);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.ing-item.active {
  background: var(--gl);
  border-color: var(--green);
}

.ing-item.active::after {
  content: '✓';
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 10px;
  color: var(--green);
  font-weight: 700;
}

.ing-emoji {
  font-size: 1.9rem;
  display: block;
  margin-bottom: 5px;
  line-height: 1;
}

.ing-name {
  font-size: 0.69rem;
  font-weight: 500;
  color: var(--t2);
  line-height: 1.2;
}

.ing-item.active .ing-name {
  color: var(--green);
}

.panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.5rem;
}

.panel h3 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.psub {
  font-size: 0.8rem;
  color: var(--t3);
  margin-bottom: 1rem;
  font-weight: 300;
}

.nutri-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
}

.nf label {
  display: block;
  font-size: 0.73rem;
  color: var(--t2);
  margin-bottom: 3px;
  font-weight: 500;
}

.nf input,
.nf select {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}

.nf input:focus,
.nf select:focus {
  border-color: var(--gm);
}

.name-search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.name-search-row input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}

.name-search-row input[type="text"]:focus {
  border-color: var(--gm);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.18s;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: #234f3a;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: var(--b2);
  cursor: not-allowed;
  transform: none;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--t3);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.btn-ghost:hover { color: var(--red); }

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--t2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  margin-bottom: 1.4rem;
  padding: 0;
  transition: color 0.15s;
}

.back-btn:hover { color: var(--text); }

.results-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}

.results-header h2 {
  font-size: 1.7rem;
}

#results-meta {
  font-size: 0.82rem;
  color: var(--t3);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 18px;
}

.rcard {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.22s;
  cursor: pointer;
}

.rcard:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--b2);
}

.rcard img {
  width: 100%;
  height: 172px;
  object-fit: cover;
  display: block;
}

.rimg-ph {
  width: 100%;
  height: 172px;
  background: var(--s2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
}

.rbody {
  padding: 0.9rem 1rem;
}

.rbody h3 {
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 7px;
  color: var(--text);
}

.rtags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tag {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.67rem;
  font-weight: 600;
}

.tg { background: var(--gl); color: var(--green); }
.ta { background: var(--al); color: var(--amber); }
.tr { background: var(--rl); color: var(--red); }

.rmeta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.rmeta span {
  font-size: 0.75rem;
  color: var(--t3);
}

.fav-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  transition: transform 0.18s;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.fav-btn:hover { transform: scale(1.25); }

.detail-img {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: 1.4rem;
  display: block;
}

.detail-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 0.8rem;
}

.detail-title {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  line-height: 1.2;
  flex: 1;
}

.detail-fav-btn {
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.18s;
  padding: 0;
  margin-top: 4px;
  flex-shrink: 0;
}

.detail-fav-btn:hover { transform: scale(1.2); }

.dbadges {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.badge {
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
}

.bdg { background: var(--gl); color: var(--green); }
.bda { background: var(--al); color: var(--amber); }

.detail-cols {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2.5rem;
}

.sec-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  margin-bottom: 0.8rem;
  color: var(--text);
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 6px;
}

.ing-list {
  list-style: none;
}

.ing-list li {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
  color: var(--t2);
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.ing-list li::before {
  content: '·';
  color: var(--green);
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1.2;
}

.step {
  display: flex;
  gap: 10px;
  margin-bottom: 0.9rem;
}

.snum {
  width: 26px;
  height: 26px;
  min-width: 26px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 2px;
  flex-shrink: 0;
}

.stext {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--t2);
}

.audit-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.6rem;
  margin-bottom: 2rem;
}

.audit-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 1.2rem;
}

.audit-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--al);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.audit-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 4px;
}

.audit-desc {
  font-size: 0.85rem;
  color: var(--t2);
  line-height: 1.6;
  font-weight: 300;
}

.add-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.add-row select,
.add-row input {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.86rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border 0.2s;
}

.add-row select { flex: 1; min-width: 180px; }
.add-row input  { width: 160px; }

.add-row select:focus,
.add-row input:focus {
  border-color: var(--gm);
}

.urgency-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: var(--t2);
  flex-wrap: wrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}

.dot.red    { background: var(--red); }
.dot.amber  { background: var(--amber); }
.dot.green  { background: var(--green); }

.audit-items {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 1.2rem;
  min-height: 40px;
}

.audit-empty {
  font-size: 0.85rem;
  color: var(--t3);
  text-align: center;
  padding: 1rem;
}

.audit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  transition: border-color 0.2s;
}

.audit-item:hover { border-color: var(--b2); }

.audit-emoji { font-size: 1.4rem; width: 28px; text-align: center; flex-shrink: 0; }
.audit-name  { font-size: 0.88rem; font-weight: 500; flex: 1; }

.audit-days {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  flex-shrink: 0;
}

.urgent { background: var(--rl); color: var(--red); }
.soon   { background: var(--al); color: var(--amber); }
.ok     { background: var(--gl); color: var(--green); }

.audit-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t3);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.audit-remove:hover { color: var(--red); }

.audit-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.audit-results-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 1.2rem;
}

.audit-results-title h2 {
  font-size: 1.4rem;
}

.audit-results-title span {
  font-size: 0.8rem;
  color: var(--t3);
}

.loader {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--t3);
  grid-column: 1 / -1;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--t3);
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 2.8rem;
  display: block;
  margin-bottom: 0.8rem;
}

.empty p { font-size: 0.93rem; }

.notif {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.83rem;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.28s;
  pointer-events: none;
  max-width: 280px;
}

.notif.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 700px) {
  nav { padding: 0 1rem; }
  .nav-tabs { display: none; }
  .nav-menu-btn { display: block; }
  .nav-tabs.open {
    display: flex;
    position: absolute;
    top: 62px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px;
    gap: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 99;
  }
  .nt { width: 100%; text-align: left; padding: 10px 14px; }
  .page { padding: 1.2rem 1rem; }
  .detail-cols { grid-template-columns: 1fr; gap: 1.5rem; }
  #ingredient-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 7px; }
  .card-grid { grid-template-columns: 1fr; }
  .sel-bar { flex-direction: column; align-items: flex-start; }
  .sel-actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 480px) {
  .mode-pills { gap: 6px; }
  .mp { font-size: 0.76rem; padding: 6px 12px; }
  .nutri-grid { grid-template-columns: 1fr 1fr; }
  .add-row { flex-direction: column; }
  .add-row select, .add-row input { width: 100%; }
}