:root {
  --paper: #fdf8f1;
  --cream: #f7efe2;
  --panel: #ffffff;
  --ink: #2a1f17;
  --ink2: #4a3929;
  --muted: #8a7060;
  --line: #e8d5bf;
  --soft: #f0e2cf;
  --brand: #c04e22;
  --bdark: #8c3316;
  --blight: #f5e3d8;
  --accent: #4d7c5e;
  --accl: #dceee4;
  --warm: #e8975a;
  --rs: 8px;
  --rm: 14px;
  --rl: 20px;
  --body: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  --disp: 'Lora', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font-family: var(--body); overflow-x: hidden; overscroll-behavior: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }

/* ── Lock Screen ── */
.lock-screen {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(224,140,70,0.18) 0%, transparent 70%), var(--paper);
}
.lock-panel {
  width: min(100%, 400px);
  background: var(--panel);
  border: 1px solid var(--soft);
  border-radius: var(--rl);
  box-shadow: 0 20px 50px rgba(80,45,20,0.16);
  padding: 40px 36px;
  display: grid;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
.lock-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--warm), var(--brand), var(--accent));
  border-radius: var(--rl) var(--rl) 0 0;
}
.lock-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.lock-logo-svg,
.lock-logo-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(192,78,34,0.25));
}
.lock-title {
  margin: 0;
  font-family: var(--disp);
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.02em;
  line-height: 1;
  text-align: center;
}
.lock-subtitle {
  font-family: var(--disp);
  font-style: italic;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  margin: -4px 0 0;
}
.lock-recipe-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand);
  text-align: center;
  margin: -4px 0 0;
  letter-spacing: 0.03em;
}
.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.muted { color: var(--muted); line-height: 1.55; font-size: 0.9rem; margin: 0; }
.message { color: var(--muted); line-height: 1.5; font-size: 0.85rem; min-height: 20px; }

/* ── App Shell ── */
.app-shell { min-height: 100vh; padding: 0 0 90px; }

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(253,248,241,0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--soft);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo-svg,
.topbar-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 5px rgba(192,78,34,0.2));
}
.brand-text { min-width: 0; }
.brand-text .eyebrow { display: block; font-size: 0.62rem; letter-spacing: 0.16em; color: var(--muted); margin-bottom: 1px; }
.topbar-title {
  margin: 0;
  font-family: var(--disp);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  height: 100%;
}
.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--bdark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(80,45,20,0.08);
  transition: background 0.15s, border-color 0.15s;
}
.icon-button:hover { background: var(--blight); border-color: var(--brand); }
.icon-button svg { width: 18px; height: 18px; display: block; }

/* ── Main ── */
main { width: 100%; max-width: 980px; margin: 0 auto; padding: 14px 12px 0; }
.view { display: none; }
.view.active { display: block; }

/* ── Tools Row ── */
.tools-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}
@media (max-width: 540px) {
  .tools-row { grid-template-columns: 1fr 1fr; }
  .search-wrap { grid-column: 1 / -1; }
}

.search-wrap { position: relative; }
.search-wrap .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
  display: block;
  flex-shrink: 0;
}
.search-wrap input { padding-left: 34px; }

.sort-select-wrap { position: relative; }
.sort-select-wrap select { padding-right: 26px; appearance: none; -webkit-appearance: none; }
.sort-select-wrap::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-65%) rotate(45deg);
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  pointer-events: none;
}

/* ── Inputs ── */
.field { display: grid; gap: 6px; }
.field span { color: var(--ink2); font-size: 0.78rem; font-weight: 600; }
input, textarea, select {
  min-width: 0;
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--rs);
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  font-size: 0.92rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
textarea { resize: vertical; line-height: 1.55; field-sizing: content; min-height: 80px; }
input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(192,78,34,0.1);
}

/* ── Sync Status ── */
.sync-status {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 500;
  margin-bottom: 12px;
}
.sync-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Recipe Cards ── */
.recipes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: 10px;
}

.recipe-card {
  border: 1.5px solid var(--soft);
  border-radius: var(--rm);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(80,45,20,0.07);
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
  padding: 0;
}
.recipe-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(80,45,20,0.14); }
.recipe-card:active { transform: translateY(0); }

/* Card image */
.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3/2;
  overflow: hidden;
  background: var(--cream);
  flex-shrink: 0;
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.recipe-card:hover .card-img { transform: scale(1.04); }

.card-img-folder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}
.card-img-folder svg { opacity: 0.82; }
.recipe-card:hover .card-img-folder { transform: scale(1.06); }

.card-type-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 999px;
  padding: 3px 8px;
  text-transform: uppercase;
}

/* Card body */
.card-body {
  padding: 10px 11px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}
.recipe-card h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--disp);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 4px; }

/* Chips */
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink2);
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 500;
}
.chip.chip-time {
  background: var(--accl);
  border-color: rgba(77,124,94,0.25);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.chip.chip-time svg { flex-shrink: 0; }
/* keep old chip classes for detail view */
.chip.cat { background: var(--blight); border-color: rgba(192,78,34,0.2); color: var(--bdark); }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }

/* ── Empty State ── */
.empty-state {
  margin-top: 28px;
  border: 2px dashed var(--line);
  border-radius: var(--rl);
  background: rgba(255,255,255,0.5);
  padding: 40px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-state-icon { width: 52px; height: 52px; color: var(--line); }
.empty-state h2 { margin: 0; font-family: var(--disp); font-size: 1.2rem; color: var(--muted); font-weight: 600; }
.empty-state p { margin: 0; }

/* ── Mode Tabs ── */
.mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--cream);
  border-radius: var(--rs);
  padding: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mode-tabs::-webkit-scrollbar { display: none; }
.mode-tab {
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  white-space: nowrap;
}
.mode-tab.active {
  background: var(--panel);
  color: var(--bdark);
  box-shadow: 0 1px 5px rgba(80,45,20,0.1);
}

/* ── Form ── */
.recipe-form, .recipe-detail {
  width: 100%;
  border: 1.5px solid var(--soft);
  border-radius: var(--rl);
  background: var(--panel);
  box-shadow: 0 8px 28px rgba(80,45,20,0.1);
  padding: 20px 16px;
}
.recipe-form { display: grid; gap: 14px; }
.mode-panel { display: none; gap: 12px; padding-bottom: 16px; border-bottom: 1.5px solid var(--soft); margin-bottom: 2px; }
.mode-panel.active { display: grid; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.link-field { grid-column: 1 / -1; }
.form-actions, .voice-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + 64px);
  background: var(--panel);
  padding-top: 14px;
  border-top: 1px solid var(--soft);
  margin-top: 24px;
  z-index: 10;
}
.form-actions > button, .detail-actions > button, .voice-actions > button { flex: 1 1 140px; }

/* ── Buttons ── */
.primary-button, .secondary-button, .ghost-button {
  min-height: 44px;
  border-radius: var(--rs);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.88rem;
  transition: transform 0.1s, background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.primary-button:active, .secondary-button:active, .ghost-button:active { transform: scale(0.98); }
.primary-button { border: 1.5px solid var(--brand); background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(192,78,34,0.28); }
.primary-button:hover { background: var(--bdark); border-color: var(--bdark); }
.secondary-button { border: 1.5px solid var(--line); background: var(--cream); color: var(--ink2); }
.secondary-button:hover { border-color: var(--brand); color: var(--bdark); background: var(--blight); }
.ghost-button { border: 1.5px solid var(--line); background: transparent; color: var(--muted); }
.ghost-button:hover { border-color: #c0392b; color: #c0392b; }

/* ── Detail View ── */
.recipe-detail { max-width: 740px; margin: 0 auto; padding: clamp(18px,5vw,40px); overflow: hidden; }
.detail-hero {
  margin: calc(-1 * clamp(18px,5vw,40px));
  margin-bottom: 24px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.detail-hero svg { opacity: 0.8; }
.detail-hero-photo {
  height: 220px;
  background-size: cover;
  background-position: center;
}
.detail-hero-label {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
}

/* ── Photo field in form ── */
.photo-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.photo-preview {
  width: 100%;
  aspect-ratio: 16/10;
  background-size: cover;
  background-position: center;
  border-radius: var(--rs);
  border: 1.5px solid var(--soft);
}
.photo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.photo-pick-button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Cook Mode Overlay ── */
.cook-mode {
  position: fixed;
  inset: 0;
  background: #fffaf3;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.cook-mode.hidden { display: none; }
.cook-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.cook-step-counter {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}
.cook-mode-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow-y: auto;
  padding: 0 8px;
}
.cook-recipe-title {
  font-family: var(--disp);
  font-size: 1.1rem;
  color: var(--ink2);
  margin: 0 0 24px;
  opacity: 0.6;
}
.cook-step-text {
  font-size: clamp(1.4rem, 4.5vw, 2.2rem);
  line-height: 1.5;
  color: var(--ink);
  font-weight: 500;
  max-width: 720px;
}
.cook-mode-nav {
  display: flex;
  gap: 12px;
  padding-top: 16px;
}
.cook-mode-nav button {
  flex: 1;
  font-size: 1rem;
  padding: 14px;
}
.cook-mode-nav button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Cook bar actions */
.cook-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cook-bar-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream);
  border: 1.5px solid var(--soft);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.cook-bar-button:hover { background: #fff; }
.cook-bar-button:active { transform: scale(0.96); }
.cook-bar-button svg { width: 22px; height: 22px; flex-shrink: 0; }
.cook-bar-button.hidden { display: none; }

/* Ingredients side panel */
.cook-ingredients-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40,25,15,0.35);
  z-index: 1;
  animation: fadeIn 0.15s ease;
}
.cook-ingredients-backdrop.hidden { display: none; }
.cook-ingredients-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100%);
  background: #fffaf3;
  z-index: 2;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(40,25,15,0.18);
  padding-top: max(0px, env(safe-area-inset-top));
  padding-bottom: max(0px, env(safe-area-inset-bottom));
  animation: slideInRight 0.2s ease;
}
.cook-ingredients-panel.hidden { display: none; }
.cook-ingredients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1.5px solid var(--soft);
}
.cook-ingredients-header h3 {
  margin: 0;
  font-family: var(--disp);
  font-size: 1.2rem;
  color: var(--brand);
}
.cook-ingredients-list {
  list-style: none;
  padding: 12px 8px;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}
.cook-ingredient-item {
  border-radius: var(--rs);
  transition: background 0.15s;
}
.cook-ingredient-item:hover { background: var(--cream); }
.cook-ingredient-item label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  line-height: 1.45;
}
.cook-ingredient-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--brand);
  border-radius: 6px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  margin-top: 1px;
  background: #fff;
  transition: background 0.15s, border-color 0.15s;
}
.cook-ingredient-item input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
.cook-ingredient-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 7px;
  height: 12px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.cook-ingredient-text {
  font-size: 1rem;
  color: var(--ink);
  flex: 1;
}
.cook-ingredient-item.checked .cook-ingredient-text {
  text-decoration: line-through;
  color: var(--muted);
  opacity: 0.7;
}
.cook-ingredients-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.recipe-detail h2 {
  overflow-wrap: anywhere;
  margin: 0 0 18px;
  color: var(--brand);
  font-family: var(--disp);
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  letter-spacing: -0.02em;
}
.detail-line { display: grid; gap: 4px; margin: 12px 0; padding-bottom: 10px; border-bottom: 1px solid var(--soft); }
.detail-label { color: var(--muted); font-size: 0.73rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.detail-section { margin-top: 22px; }
.detail-section h3 {
  margin: 0 0 12px;
  font-family: var(--disp);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-section h3::after { content: ''; flex: 1; height: 1px; background: var(--soft); }
.ingredients-list { display: grid; gap: 9px; padding: 0; list-style: none; }
.ingredients-list li { display: flex; align-items: flex-start; gap: 9px; line-height: 1.5; font-size: 0.93rem; }
.ingredients-list li::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warm); flex-shrink: 0; margin-top: 7px; }
.steps-text, .notes-text { white-space: pre-wrap; line-height: 1.75; overflow-wrap: anywhere; font-size: 0.93rem; color: var(--ink2); }
.recipe-source-link { color: var(--brand); font-weight: 600; overflow-wrap: anywhere; text-decoration: none; border-bottom: 1px dashed rgba(192,78,34,0.4); }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1.5px solid var(--soft);
  border-radius: var(--rm);
  background: rgba(253,248,241,0.94);
  box-shadow: 0 12px 36px rgba(80,45,20,0.18);
  padding: 6px 6px 6px 8px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 200;
}
.nav-button {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: var(--rs);
  background: transparent;
  color: var(--muted);
  padding: 9px 8px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: background 0.15s, color 0.15s;
}
.nav-button svg { width: 20px; height: 20px; display: block; flex-shrink: 0; }
.nav-button.active { background: var(--panel); color: var(--bdark); box-shadow: 0 1px 5px rgba(80,45,20,0.1); }
.nav-button:not(.active):hover { color: var(--ink2); }

/* FAB "Añadir" */
.nav-button[data-view="addView"] {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(192,78,34,0.42);
  padding: 0;
  font-size: 0;
  flex-direction: row;
  justify-content: center;
  transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
}
.nav-button[data-view="addView"] svg { width: 28px; height: 28px; }
.nav-button[data-view="addView"].active,
.nav-button[data-view="addView"]:hover { background: var(--bdark); color: #fff; box-shadow: 0 2px 8px rgba(192,78,34,0.3); }
.nav-button[data-view="addView"]:active { transform: scale(0.92); }

/* ── Settings Dialog ── */
dialog { width: min(420px, calc(100vw - 24px)); border: 0; border-radius: var(--rl); padding: 0; background: transparent; }
dialog::backdrop { background: rgba(42,31,23,0.35); backdrop-filter: blur(4px); }
.settings-panel {
  width: 100%;
  background: var(--panel);
  border: 1.5px solid var(--soft);
  border-radius: var(--rl);
  padding: 22px 20px;
  display: grid;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.settings-panel::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--warm), var(--brand), var(--accent)); }
.settings-panel h2 { margin: 0; font-family: var(--disp); font-size: 1.25rem; color: var(--ink); }
.settings-group { display: grid; gap: 10px; border: 1.5px solid var(--soft); border-radius: var(--rs); background: var(--cream); padding: 12px; }
.settings-group h3 { margin: 0; color: var(--ink2); font-size: 0.84rem; font-weight: 700; }
.settings-group p { margin: 0; }
.sync-details {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}
.file-button input { display: none; }
.install-help { border: 1.5px solid var(--soft); border-radius: var(--rs); background: var(--cream); padding: 11px 13px; }
.install-help summary { color: var(--ink2); cursor: pointer; font-weight: 700; font-size: 0.86rem; }
.install-help p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; font-size: 0.85rem; }

/* ── Responsive ── */
@media (max-width: 540px) {
  .lock-screen { align-items: flex-start; padding: max(20px, env(safe-area-inset-top)) 14px 20px; min-height: 100svh; }
  .lock-panel { padding: 26px 20px; }
  .topbar { padding: 9px 12px; }
  main { padding: 12px 10px 0; }
  .recipe-form, .recipe-detail { padding: 14px 12px; }
  input, textarea, select { font-size: 1rem; }
  .primary-button, .secondary-button, .ghost-button { width: 100%; }
  .mode-tab { padding: 8px 10px; font-size: 0.78rem; }
  .recipes-list { grid-template-columns: 1fr 1fr; }
  .mode-tabs {
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
  }
}

/* ── Folders Grid ── */
.folders-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 4px 0 8px;
}
.folder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px 12px;
  border: 1.5px solid var(--soft);
  border-radius: var(--rm);
  background: var(--panel);
  box-shadow: 0 2px 6px rgba(80,45,20,0.06);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.15s;
  position: relative;
  cursor: pointer;
}
.folder-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(80,45,20,0.12); border-color: var(--folder-color, var(--brand)); }
.folder-card:active { transform: scale(0.97); }
.folder-icon {
  width: 50px;
  height: 50px;
  border-radius: 13px;
  background: var(--folder-bg, var(--cream));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--folder-color, var(--brand));
  flex-shrink: 0;
}
.folder-icon svg { width: 26px; height: 26px; display: block; }
.folder-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink2);
  text-align: center;
  line-height: 1.25;
  word-break: break-word;
}
.folder-count {
  position: absolute;
  top: 7px;
  right: 7px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--cream);
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 18px;
  text-align: center;
}

/* ── Folder Header (in list view) ── */
.folder-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 9px 12px;
  background: var(--panel);
  border: 1.5px solid var(--soft);
  border-radius: var(--rm);
}
.folder-header-content {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--folder-color, var(--brand));
  min-width: 0;
}
.folder-header-icon { width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.folder-header-icon svg { width: 22px; height: 22px; display: block; }
.folder-header-name { font-size: 1rem; font-weight: 700; color: var(--folder-color, var(--brand)); white-space: nowrap; }
.folder-header-count { font-size: 0.8rem; color: var(--muted); font-weight: 500; }

/* ── Carpetas Picker (form) ── */
.carpetas-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0;
}
.carpeta-chip {
  position: relative;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink2);
  background: var(--panel);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}
.carpeta-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.carpeta-chip:has(input:checked) {
  background: var(--chip-bg, var(--blight));
  border-color: var(--chip-color, var(--brand));
  color: var(--chip-color, var(--brand));
}
.carpeta-chip:hover { border-color: var(--chip-color, var(--brand)); }

/* ── Print ── */
@media print {
  body { background: white; }
  .topbar, .bottom-nav, .detail-actions, .sync-status { display: none !important; }
  .app-shell { padding: 0; }
  main { max-width: none; padding: 0; }
  .view { display: none !important; }
  #detailView { display: block !important; }
  .recipe-detail { border: 0; box-shadow: none; padding: 18mm; max-width: none; }
}

/* ── Modo nube: lista de recetarios en la pantalla de entrada ── */
.cookbook-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.cookbook-list .cookbook-item {
  width: 100%;
  justify-content: center;
}

#cloudLogin .primary-button,
#cloudLogin .secondary-button,
#cloudLogin .ghost-button,
#cloudCookbooks .secondary-button,
#cloudCookbooks .ghost-button {
  width: 100%;
  margin-top: 6px;
}

/* ─── Importar desde enlace ──────────────────────────────── */

.link-import-box {
  margin-bottom: 14px;
  padding: 14px;
  border: 1.5px dashed var(--accent, #b85522);
  border-radius: 12px;
  background: var(--panel, #fdf6ee);
}

.link-import-title {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.link-import-box .muted {
  margin: 0 0 10px;
  font-size: 0.85rem;
}

/* En movil los botones son width:100% (media query de abajo): con wrap, el
   boton salta a su propia linea; en escritorio queda en linea con el campo. */
.link-import-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.link-import-row input {
  flex: 1 1 220px;
  min-width: 0;
}

.link-import-row .primary-button {
  margin: 0;
}
