@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Sans:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #2c2c2c;
  --text-light: #7a7468;
  --accent: #c45d3e;
  --accent-light: #f0d5cc;
  --accent-dark: #9e3d24;
  --border: #e8e2d8;
  --tag-bg: #f0ebe3;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --danger: #d44;
  --danger-light: #fde8e8;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: clip;
}
html { overflow-x: clip; }
button, a, input, select, .btn-add, .btn-fav, .toc-item, .expand-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* === HEADER === */
.header {
  background: linear-gradient(135deg, #2c2c2c 0%, #3d3530 100%);
  color: white;
  padding: 2rem 2rem 1.2rem;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  display: none;
}
body.authenticated .header { display: block; }
.header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.header .subtitle {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  margin-top: 0.3rem;
}
.header-settings {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none; border: none;
  font-size: 1.3rem; cursor: pointer;
  opacity: 0.5; transition: opacity 0.2s;
}
.header-settings:hover { opacity: 1; }
.user-bubble {
  position: fixed;
  top: 0.6rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.top-icon {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  padding: 4px;
  pointer-events: auto;
}
.top-icon:hover { opacity: 1; }
body:not(.admin) .admin-only { display: none !important; }
.user-pill { pointer-events: auto; }
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.7rem 0.3rem 0.35rem;
  background: var(--card, white);
  border: 1px solid var(--border, #e8e0d8);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  transition: box-shadow 0.2s, transform 0.15s;
  pointer-events: auto;
  user-select: none;
  font-family: inherit;
}
.user-pill:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-1px); }
.user-pill .pill-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: 'DM Serif Display', serif;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.user-pill .pill-name {
  font-size: 0.85rem;
  color: var(--text, #3d3530);
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-pill.empty .pill-avatar {
  background: linear-gradient(135deg, #bbb, #999);
  animation: pulse-soft 2.5s ease-in-out infinite;
}
.user-pill.empty .pill-name { color: var(--text-light, #8a7e74); font-style: italic; }
@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 4px rgba(196, 92, 62, 0.15); }
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border, #e8e0d8);
  border-radius: 14px;
  padding: 0.5rem;
  min-width: 190px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.user-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text, #3d3530);
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.user-dropdown-item:hover { background: var(--tag-bg, #f0ebe5); }
.user-dropdown-item.active { background: var(--tag-bg, #f0ebe5); font-weight: 600; }
.user-dropdown-item .mini-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.user-dropdown-item .check { margin-left: auto; opacity: 0.4; font-size: 0.8rem; }
.user-dropdown-item.active .check { opacity: 1; color: var(--accent); }
.user-dropdown-divider { height: 1px; background: var(--border, #e8e0d8); margin: 0.3rem 0.4rem; }
.user-dropdown-add {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-light, #8a7e74);
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
}
.user-dropdown-add:hover { background: var(--tag-bg); color: var(--accent); }
body:not(.admin) .user-dropdown-add { display: none; }
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg, #faf8f5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--card, white);
  border: 1px solid var(--border, #e8e0d8);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  text-align: center;
}
.login-box h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  margin-bottom: 0.3rem;
  color: var(--text, #3d3530);
}
.login-box .login-sub {
  font-size: 0.85rem;
  color: var(--text-light, #8a7e74);
  margin-bottom: 1.5rem;
}
.login-box input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border, #e8e0d8);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: 0.7rem;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.login-box input:focus {
  outline: none;
  border-color: var(--accent, #c45c3e);
}
.login-box button {
  width: 100%;
  padding: 0.65rem;
  background: linear-gradient(135deg, #2c2c2c, #3d3530);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 0.3rem;
  transition: opacity 0.2s;
}
.login-box button:hover { opacity: 0.85; }
.login-error {
  color: #c45c3e;
  font-size: 0.82rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}
.user-dropdown-none {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-light, #8a7e74);
  border: none;
  background: none;
  width: 100%;
  transition: background 0.15s;
}
.user-dropdown-none:hover { background: var(--tag-bg); }
.user-bar-label {
  font-size: 0.9rem;
  opacity: 0.6;
}
.user-bar select {
  background: var(--card, white);
  color: var(--text, #3d3530);
  border: 1px solid var(--border, #e8e0d8);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-width: 130px;
}
.user-bar select:focus { outline: none; border-color: var(--accent, #c45c3e); }
.user-add-btn {
  background: var(--tag-bg, #f0ebe5);
  color: var(--text-light, #8a7e74);
  border: 1px solid var(--border, #e8e0d8);
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}
.user-add-btn:hover { border-color: var(--accent); color: var(--accent); }
body:not(.admin) .user-add-btn { display: none; }
.sync-status {
  font-size: 0.75rem;
  margin-top: 0.2rem;
  min-height: 1.1em;
}
.sync-status.ok { color: rgba(130,230,150,0.8); }
.sync-status.err { color: rgba(255,140,120,0.8); }
.sync-status.loading { color: rgba(255,255,255,0.5); }
.header { position: relative; }
.search-bar {
  max-width: 500px;
  margin: 1rem auto 0;
  position: relative;
}
.search-bar input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.5rem;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: white;
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: background 0.2s;
}
.search-bar input::placeholder { color: rgba(255,255,255,0.4); }
.search-bar input:focus { background: rgba(255,255,255,0.2); }
.search-bar svg {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: rgba(255,255,255,0.5);
  fill: none;
}

/* === TOC === */
.toc {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0.5rem;
}
.toc h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  margin-bottom: 1rem;
  color: var(--text);
}
.toc-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  margin-bottom: 1rem;
}
.toc-header h2 { margin-bottom: 0; }
.toc-dots {
  opacity: 0;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-light);
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity 0.2s, background 0.15s;
  user-select: none;
  line-height: 1;
}
.toc-header:hover .toc-dots { opacity: 1; }
.toc-dots:hover { background: var(--tag-bg); color: var(--text); }
.toc-dots.active {
  opacity: 1;
  background: var(--accent-light);
  color: var(--accent);
}
.toc-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
  position: relative;
  flex-wrap: wrap;
}
.toc-item-arrow {
  display: none;
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-light);
  padding: 2px 6px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.toc-item:hover .toc-item-arrow { display: block; }
.toc-item:hover .toc-count { display: none; }
.toc-item-arrow.open { transform: rotate(180deg); }
.toc-recipes {
  display: none;
  position: absolute;
  top: 100%;
  left: -1px;
  right: -1px;
  background: var(--card);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 0.5rem 0.8rem;
  box-shadow: var(--shadow-hover);
}
.toc-item.dropdown-open .toc-recipes { display: block; }
.toc-item.dropdown-open { z-index: 20; }
.toc-recipe-link {
  display: block;
  padding: 0.35rem 0.2rem;
  font-size: 0.82rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 5px;
  transition: background 0.15s;
}
.toc-recipe-link:hover {
  background: var(--tag-bg);
  color: var(--accent);
}
.btn-back-top {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 150;
  background: var(--card);
  color: var(--text-light);
  border: 1px solid var(--border);
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}
.btn-back-top:hover { color: var(--accent); border-color: var(--accent); }
body.has-shopbar .btn-back-top { bottom: 90px; }
@media (max-width: 700px) { body.has-shopbar .btn-back-top { bottom: 110px; } }

.btn-insta {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.72rem; color: var(--accent); text-decoration: none;
  padding: 0.15rem 0.5rem; border-radius: 10px; background: var(--accent-light);
  margin-bottom: 0.4rem; transition: all 0.15s;
}
.btn-insta:hover { background: var(--accent); color: white; }

.btn-shop-float {
  display: none;
}
.btn-shop-float:hover { transform: scale(1.1); }
.tag-chip {
  padding: 0.3rem 0.7rem; border-radius: 14px; font-size: 0.78rem;
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  color: var(--text-light); transition: all 0.15s; display: inline-block;
}
.tag-chip:hover, .tag-chip.active { background: var(--accent); color: white; border-color: var(--accent); }

.btn-insta {
  position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.5);
  color: white; border-radius: 50%; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; text-decoration: none; transition: all 0.2s; z-index: 3;
}
.btn-insta:hover { background: #E1306C; transform: scale(1.1); }

.btn-shop-toggle {
  position: fixed; bottom: 20px; right: 20px; z-index: 150;
  background: var(--accent); color: white; border: none;
  width: 50px; height: 50px; border-radius: 50%;
  font-size: 1.4rem; cursor: pointer;
  box-shadow: var(--shadow-hover); display: flex;
  align-items: center; justify-content: center; transition: all 0.3s;
}
body.has-shopbar .btn-shop-toggle { bottom: 90px; }
@media (max-width: 700px) { body.has-shopbar .btn-shop-toggle { bottom: 110px; } }
.btn-shop-toggle:hover { transform: scale(1.1); }
.btn-shop-toggle .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: white; font-size: 0.65rem;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.toolbar-pool {
  max-width: 1200px; margin: 1rem auto; padding: 0 1.5rem;
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
}
.toolbar-pool input {
  flex: 1; min-width: 200px; padding: 0.5rem 0.8rem;
  border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 0.9rem;
}
.toolbar-pool button {
  padding: 0.5rem 1rem; border: none; border-radius: 8px; background: var(--accent); color: white;
  font-family: inherit; font-size: 0.85rem; cursor: pointer;
}
.pool-cat { margin-top: 1.5rem; }
.pool-cat h2 {
  font-family: 'DM Serif Display', serif; font-size: 1.05rem;
  padding: 0.5rem 0; border-bottom: 2px solid var(--accent); margin-bottom: 0.5rem;
  display: flex; justify-content: space-between;
}
.pool-cat h2 .cnt { font-family: 'DM Sans'; font-size: 0.8rem; color: var(--text-light); font-weight: 400; }
.pool-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pool-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.35rem 0.7rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; font-size: 0.82rem; cursor: pointer; transition: all 0.15s;
}
.pool-chip:hover { border-color: var(--accent); background: var(--tag-bg); }
.pool-chip .del { display: none; font-size: 0.7rem; color: var(--danger); cursor: pointer; padding: 0 2px; }
.pool-chip:hover .del { display: inline; }
.toc-item-actions {
  display: none;
  gap: 0.2rem;
  margin-left: auto;
  flex-shrink: 0;
}
.toc-grid.editing .toc-item-actions { display: flex; }
.toc-grid.editing .toc-count { display: none; }
.toc-grid.editing .toc-item-arrow { display: none !important; }
.toc-act {
  padding: 3px 6px;
  border: none; background: none;
  cursor: pointer; font-size: 0.82rem;
  border-radius: 5px;
  color: var(--text-light);
  transition: all 0.15s;
  line-height: 1;
}
.toc-act:hover { background: var(--tag-bg); color: var(--text); }
.toc-act.del:hover { background: var(--danger-light); color: var(--danger); }
.toc-add-btn {
  display: none;
  align-items: center; justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1rem;
  background: none;
  border: 2px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.88rem; font-family: inherit;
  color: var(--text-light);
  transition: all 0.2s;
}
.toc-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(196,93,62,0.04);
}
.toc-grid.editing .toc-add-btn { display: flex; }
.cat-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center; justify-content: center;
}
.cat-modal-overlay.visible { display: flex; }
.cat-modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-width: 320px;
  max-width: 95vw;
  width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
}
.cat-modal h3 {
  font-family: 'DM Serif Display', serif;
  margin-bottom: 1rem;
}
.cat-modal input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  margin-bottom: 1rem;
}
.cat-modal-btns {
  display: flex; gap: 0.5rem; justify-content: flex-end;
}
.cat-modal-btns button {
  padding: 0.5rem 1.2rem;
  border: none; border-radius: 8px;
  font-family: inherit; font-size: 0.88rem;
  cursor: pointer;
}
.cat-modal-btns .cat-btn-cancel {
  background: var(--tag-bg); color: var(--text);
}
.cat-modal-btns .cat-btn-ok {
  background: var(--accent); color: white;
}
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
}
.toc-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.toc-emoji { font-size: 1.3rem; }
.toc-label {
  font-size: 0.88rem;
  font-weight: 600;
}
.toc-count {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-light);
  background: var(--tag-bg);
  padding: 2px 8px;
  border-radius: 10px;
}

/* === CATEGORY SECTIONS === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
}
.cat-section {
  margin-top: 2rem;
  scroll-margin-top: 60px;
}
.cat-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 0;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.cat-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: var(--text);
}
.cat-header .cat-count {
  font-size: 0.8rem;
  color: var(--text-light);
  background: var(--tag-bg);
  padding: 3px 10px;
  border-radius: 12px;
}
.cat-header .back-top {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-light);
  cursor: pointer;
  text-decoration: none;
}
.cat-header .back-top:hover { color: var(--accent); }

.recipe-grid {
  display: grid;
  gap: 1.2rem;
}

/* === RECIPE CARD === */
.recipe-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s, transform 0.2s;
  border: 1px solid var(--border);
  position: relative;
}
@media (hover: hover) {
  .recipe-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
  }
  .card-image:hover img { transform: scale(1.05); }
  .card-image:hover .corner-peek {
    top: -16px;
    right: -16px;
    width: 72px;
    height: 72px;
  }
  .card-image:hover .corner-peek span {
    opacity: 1;
  }
  .recipe-card:hover .btn-card-menu { opacity: 1; }
}
.recipe-card.removing {
  animation: fadeOut 0.3s ease forwards;
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-10px) scale(0.98); max-height: 0; margin: 0; padding: 0; overflow: hidden; }
}

.card-image {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}
.card-image .corner-peek {
  position: absolute;
  top: -28px;
  right: -28px;
  width: 56px;
  height: 56px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
.card-image .corner-peek span {
  position: absolute;
  bottom: 16px;
  left: 16px;
  color: white;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.2s ease 0.15s;
}

/* Admin-only elements: hidden unless body.admin */
body:not(.admin) .btn-card-menu,
body:not(.admin) .card-menu-dropdown,
body:not(.admin) .toc-item-actions,
body:not(.admin) .toc-add-btn,
body:not(.admin) .toc-add-recipe,
body:not(.admin) #saveBtn,
body:not(.admin) .header-settings[onclick*="showSettings"],
body:not(.admin) .header-settings[onclick*="togglePoolView"] {
  display: none !important;
}
.admin-login-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: var(--tag-bg, #eee);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s;
  z-index: 100;
}
.admin-login-btn:hover { opacity: 1; }
body.admin .admin-login-btn { opacity: 0.8; background: var(--accent, #c45c3e); color: white; }
.card-image .img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Serif Display', serif;
  font-size: 2.5rem;
  color: white;
}
.card-image .lang-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Delete button */
@media (hover: none) { .btn-card-menu { opacity: 0.6; } }
.btn-card-menu {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s;
  z-index: 5;
  color: var(--text-light);
  line-height: 1;
}
.btn-card-menu:hover { background: var(--tag-bg); color: var(--accent); }
.card-menu-dropdown {
  display: none;
  position: absolute;
  top: 38px;
  right: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-hover);
  z-index: 10;
  min-width: 150px;
  overflow: hidden;
}
.card-menu-dropdown.open { display: block; }
.card-menu-item {
  display: block;
  width: 100%;
  padding: 0.55rem 0.9rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
}
.card-menu-item:hover { background: var(--tag-bg); }
.card-menu-item.danger { color: var(--danger); }
.card-menu-item.danger:hover { background: #fde8e8; }

.edit-section { margin-bottom: 1rem; }
.edit-section label { font-size: 0.82rem; font-weight: 600; display: block; margin-bottom: 0.3rem; }
.edit-section input, .edit-section select, .edit-section textarea {
  width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 0.88rem; box-sizing: border-box;
}
.edit-section textarea { min-height: 80px; resize: vertical; }
.edit-ing-row { display: flex; gap: 0.3rem; margin-bottom: 0.3rem; align-items: center; }
.edit-ing-row input { padding: 0.35rem 0.4rem; font-size: 0.82rem; border: 1px solid var(--border); border-radius: 4px; font-family: inherit; }
.edit-ing-row .edit-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; padding: 0 4px; flex-shrink: 0; }
.edit-ing-header { display: flex; gap: 0.3rem; margin-bottom: 0.2rem; padding-right: 24px; }
.edit-ing-header span { font-size: 0.72rem; color: var(--text-light); }
.edit-ing-header span:nth-child(1) { flex: 0 0 60px; }
.edit-ing-header span:nth-child(2) { flex: 0 0 80px; }
.edit-ing-header span:nth-child(3) { flex: 1; }
.edit-ing-header span:nth-child(4) { flex: 0 0 100px; }
.food-ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 300;
  background: var(--card); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 6px 6px; box-shadow: var(--shadow-hover); max-height: 180px; overflow-y: auto;
}
.food-ac-list:empty { display: none; }
.food-ac-item {
  padding: 0.4rem 0.6rem; cursor: pointer; font-size: 0.82rem;
}
.food-ac-item:hover { background: var(--tag-bg); }
.edit-step-row { display: flex; gap: 0.4rem; margin-bottom: 0.3rem; align-items: flex-start; }
.edit-step-row textarea { flex: 1; padding: 0.35rem 0.5rem; font-size: 0.82rem; min-height: 40px; resize: vertical; }
.edit-step-row .edit-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; padding: 4px; }
.edit-add-btn { background: none; border: 1px dashed var(--border); border-radius: 6px; padding: 0.35rem; width: 100%; cursor: pointer; color: var(--text-light); font-size: 0.82rem; margin-top: 0.3rem; }
.edit-add-btn:hover { border-color: var(--accent); color: var(--accent); }

.card-body {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
}
.card-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.15rem;
  margin-bottom: 0.3rem;
  color: var(--text);
}
.card-category {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.8rem;
}

/* === EXPANDABLE SECTIONS === */
.expand-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.expand-btn .arrow {
  transition: transform 0.3s;
  font-size: 0.7rem;
}
.expand-btn.open .arrow { transform: rotate(90deg); }

.expandable {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}
.expandable.open { max-height: 2000px; }

.ing-list {
  list-style: none;
  padding: 0.5rem 0;
}
.ing-list li {
  padding: 0.25rem 0;
  font-size: 0.85rem;
  display: flex;
  gap: 0.3rem;
}
.ing-amount {
  font-weight: 600;
  color: var(--accent-dark);
  min-width: 60px;
}

.steps-list {
  padding: 0.5rem 0;
  counter-reset: step;
}
.steps-list .step {
  padding: 0.4rem 0;
  font-size: 0.85rem;
  padding-left: 2rem;
  position: relative;
}
.steps-list .step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  width: 1.4rem;
  height: 1.4rem;
  background: var(--accent-light);
  color: var(--accent-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}

/* === ADD TO LIST AREA === */
.add-area {
  margin-top: auto;
  padding-top: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.portions-select {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-light);
}
.portions-select input {
  width: 45px;
  padding: 0.3rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif;
}
.btn-add {
  padding: 0.45rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.btn-add:hover { background: var(--accent-dark); }
.btn-add:active { transform: scale(0.97); }
.btn-add.added { background: #4a8c5c; }
.no-ing {
  font-size: 0.82rem;
  color: var(--text-light);
  font-style: italic;
  padding: 0.5rem 0;
}

/* === SHOPPING LIST BAR === */
.shop-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #2c2c2c;
  color: white;
  padding: 1.2rem 2rem calc(1rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}
.shop-bar.visible { transform: translateY(0); }
.shop-bar::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.25);
}
.shop-bar-info { font-size: 0.9rem; }
.shop-bar-info strong { color: var(--accent); font-size: 1.1rem; }
.btn-create-list {
  padding: 0.6rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.btn-create-list:hover { background: var(--accent-dark); }
.btn-create-list:disabled { opacity: 0.4; cursor: default; background: #555; }
.btn-add-custom {
  background: none; border: 2px dashed rgba(255,255,255,0.4); color: white;
  width: 36px; height: 36px; border-radius: 50%; font-size: 1.2rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.btn-add-custom:hover { border-color: white; background: rgba(255,255,255,0.1); }
.btn-clear {
  padding: 0.4rem 0.8rem;
  background: transparent;
  color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  margin-left: 0.5rem;
}
.btn-clear:hover { color: white; border-color: rgba(255,255,255,0.5); }

/* === UNDO BAR === */
.undo-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 0.7rem 1.2rem;
  border-radius: 10px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 250;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  transition: transform 0.3s;
}
.undo-bar.visible { transform: translateX(-50%) translateY(0); }
.undo-bar.with-shopbar { bottom: 80px; }
.btn-undo {
  padding: 0.3rem 0.8rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--card);
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}
.modal .modal-subtitle {
  color: var(--text-light);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}
.modal-cat { margin-bottom: 1.2rem; }
.modal-cat h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent-light);
  margin-bottom: 0.5rem;
}
.modal-cat ul { list-style: none; }
.modal-cat li {
  padding: 0.3rem 0;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-cat li:last-child { border: none; }
.modal-cat .item-amount {
  color: var(--accent);
  font-weight: 600;
  margin-left: 1rem;
  white-space: nowrap;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.btn-copy {
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn-copy:disabled { opacity: 0.4; cursor: default; }
.btn-close-modal {
  padding: 0.5rem 0.9rem;
  background: var(--tag-bg);
  color: var(--text);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: 'DM Sans', sans-serif;
}

/* === RESPONSIVE === */
@media (max-width: 700px) {
  .recipe-card { grid-template-columns: 130px 1fr; }
  .header h1 { font-size: 1.5rem; }
  .container { padding: 0 0.8rem 0.8rem; }
  .toc { padding: 1rem 0.8rem 0.5rem; }
  .toc-grid { grid-template-columns: 1fr 1fr; }
  .cat-header { top: 0; }
  .shop-bar { padding: 0.8rem 1rem; flex-wrap: wrap; gap: 0.5rem; }
}
@media (max-width: 480px) {
  .recipe-card { grid-template-columns: 1fr; }
  .card-image { aspect-ratio: 16/9; }
  .toc-grid { grid-template-columns: 1fr; }
}

body.has-shopbar .container { padding-bottom: 80px; }
body.has-shopbar .toc { /* no extra padding needed */ }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }



.btn-fav {
  background: none; border: none; font-size: 1.1rem; cursor: pointer;
  padding: 2px 4px; opacity: 0.3; transition: all 0.15s; position: absolute;
  top: 8px; left: 8px; z-index: 5;
}
.btn-fav.active { opacity: 1; }
.btn-fav:hover { opacity: 1; transform: scale(1.2); }
.random-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.9rem; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px; color: white; font-size: 0.82rem; cursor: pointer;
  font-family: inherit; margin-top: 0.5rem; transition: all 0.15s;
}
.random-btn:hover { background: rgba(255,255,255,0.25); }

/* ── Saved Shopping Lists ── */
.lists-view { display:none; padding:1rem 2rem 4rem; max-width:900px; margin:0 auto; animation:listsIn 0.35s ease; }
@keyframes listsIn { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
.lists-header { display:flex; align-items:center; gap:1rem; margin-bottom:1.5rem; }
.lists-header h2 { font-family:'DM Serif Display',serif; font-size:1.6rem; flex:1; }
.btn-back-lists { background:var(--card); border:1px solid var(--border); color:var(--text-light); border-radius:10px; padding:0.5rem 1rem; font-family:inherit; font-size:0.85rem; cursor:pointer; transition:all 0.2s; }
.btn-back-lists:hover { border-color:var(--accent); color:var(--accent); }
.lists-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:1rem; }
.list-card { background:var(--card); border-radius:var(--radius); border:1px solid var(--border); padding:1.2rem; cursor:pointer; transition:all 0.25s; position:relative; overflow:hidden; }
@media(hover:hover){.list-card:hover { border-color:var(--accent); transform:translateY(-2px); box-shadow:var(--shadow-hover); }}
.list-card-name { font-family:'DM Serif Display',serif; font-size:1.15rem; margin-bottom:0.3rem; }
.list-card-date { font-size:0.75rem; color:var(--text-muted); margin-bottom:0.7rem; }
.list-card-stats { display:flex; gap:0.6rem; margin-bottom:0.7rem; font-size:0.78rem; flex-wrap:wrap; }
.list-card-stat { background:var(--tag-bg); padding:0.2rem 0.55rem; border-radius:6px; color:var(--text-light); }
.list-card-stat strong { color:var(--accent); }
.list-card-thumbs { display:flex; gap:4px; overflow:hidden; }
.list-card-thumbs img { width:38px; height:38px; border-radius:6px; object-fit:cover; opacity:0.8; }
.list-card-actions { position:absolute; top:0.6rem; right:0.6rem; display:flex; gap:0.3rem; }
.list-card-actions button { background:rgba(0,0,0,0.35); border:none; color:white; width:28px; height:28px; border-radius:6px; font-size:0.75rem; cursor:pointer; transition:all 0.2s; touch-action:manipulation; }
.list-card-actions button:hover { background:var(--accent); }
.lists-empty { text-align:center; padding:4rem 2rem; color:var(--text-muted); }
.lists-empty .empty-icon { font-size:3.5rem; margin-bottom:1rem; opacity:0.3; }
.lists-empty p { font-size:0.95rem; max-width:320px; margin:0 auto; line-height:1.7; }
.list-detail { animation:listsIn 0.3s ease; }
.list-detail-header { display:flex; align-items:center; gap:0.8rem; margin-bottom:1.5rem; flex-wrap:wrap; }
.list-detail-name { font-family:'DM Serif Display',serif; font-size:1.4rem; flex:1; min-width:200px; }
.list-detail-name input { font-family:'DM Serif Display',serif; font-size:1.4rem; background:none; border:none; border-bottom:2px solid var(--accent); color:var(--text); width:100%; outline:none; padding:0.1rem 0; }
.list-detail-actions { display:flex; gap:0.5rem; flex-wrap:wrap; }
.list-detail-actions button { background:var(--card); border:1px solid var(--border); color:var(--text-light); border-radius:8px; padding:0.45rem 0.9rem; font-family:inherit; font-size:0.82rem; cursor:pointer; transition:all 0.15s; touch-action:manipulation; }
.list-detail-actions button:hover { border-color:var(--accent); color:var(--accent); }
.list-detail-actions .btn-load { background:var(--accent); color:white; border-color:var(--accent); }
.list-detail-actions .btn-load:hover { opacity:0.85; color:white; }
.list-detail-actions .btn-delete { border-color:#a33; color:#c55; }
.list-detail-actions .btn-delete:hover { background:#a33; color:white; }
.list-recipe-card { display:flex; align-items:center; gap:1rem; background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:0.8rem 1rem; margin-bottom:0.6rem; transition:all 0.2s; }
.list-recipe-card img { width:52px; height:52px; border-radius:8px; object-fit:cover; flex-shrink:0; }
.list-recipe-card .lrc-info { flex:1; min-width:0; }
.list-recipe-card .lrc-title { font-weight:600; font-size:0.88rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.list-recipe-card .lrc-mult { display:flex; align-items:center; gap:0.4rem; margin-top:0.25rem; }
.list-recipe-card .lrc-mult select { background:var(--bg); color:var(--text); border:1px solid var(--border); border-radius:6px; padding:0.15rem 0.3rem; font-family:inherit; font-size:0.78rem; }
.list-recipe-card .lrc-mult label { font-size:0.75rem; color:var(--text-muted); }
.list-recipe-card .btn-remove-recipe { background:none; border:none; color:var(--text-muted); font-size:1.1rem; cursor:pointer; padding:0.3rem; transition:color 0.15s; flex-shrink:0; touch-action:manipulation; }
.list-recipe-card .btn-remove-recipe:hover { color:#c45d3e; }
.list-section { margin-bottom:1.5rem; }
.list-section h3 { font-family:'DM Serif Display',serif; font-size:1.05rem; margin-bottom:0.7rem; color:var(--accent); }
.save-dialog { background:var(--card); border-radius:var(--radius); padding:1.2rem; margin:1rem 0; border:2px solid var(--accent); animation:listsIn 0.2s ease; }
.save-dialog label { font-size:0.85rem; color:var(--text-light); }
.save-dialog input { width:100%; background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:0.55rem 0.8rem; color:var(--text); font-family:inherit; font-size:0.95rem; margin:0.5rem 0; outline:none; }
.save-dialog input:focus { border-color:var(--accent); }
.save-dialog-btns { display:flex; gap:0.5rem; }
.save-dialog-btns button { padding:0.45rem 1rem; border-radius:8px; font-family:inherit; font-size:0.85rem; cursor:pointer; border:none; touch-action:manipulation; }
.save-dialog-btns .btn-save-confirm { background:var(--accent); color:white; }
.save-dialog-btns .btn-save-cancel { background:var(--card); color:var(--text-muted); border:1px solid var(--border); }
.btn-lists-nav { position:fixed; bottom:20px; right:80px; z-index:150; background:var(--card); color:var(--text-light); border:1px solid var(--border); width:44px; height:44px; border-radius:50%; font-size:1.15rem; cursor:pointer; box-shadow:var(--shadow); display:none; align-items:center; justify-content:center; transition:all 0.3s; touch-action:manipulation; }
.btn-lists-nav:hover { border-color:var(--accent); color:var(--accent); }
.btn-lists-nav .lists-badge { position:absolute; top:-4px; right:-4px; background:var(--accent); color:white; font-size:0.6rem; font-weight:700; min-width:16px; height:16px; border-radius:8px; display:flex; align-items:center; justify-content:center; padding:0 3px; }
body.has-shopbar .btn-lists-nav { bottom:90px; }
.toast {
  position:fixed; bottom:30px; left:50%; transform:translateX(-50%) translateY(80px);
  background:#333; color:white; padding:0.7rem 1.4rem; border-radius:10px;
  font-size:0.88rem; z-index:300; box-shadow:0 8px 30px rgba(0,0,0,0.35);
  transition:transform 0.3s, opacity 0.3s; opacity:0; pointer-events:none;
}
.toast.show { transform:translateX(-50%) translateY(0); opacity:1; }
@media(max-width:700px){ body.has-shopbar .btn-lists-nav{bottom:110px} .lists-view{padding:0.8rem} .lists-grid{grid-template-columns:1fr} .list-detail-header{flex-direction:column;align-items:flex-start} .list-recipe-card img{width:44px;height:44px} }
