:root {
  --paper: #FAF8F4;
  --paper-2: #F3F0EA;
  --blue: #A7C7E7;
  --blue-2: #B9D3EE;
  --blue-deep: #8FAFC9;
  --blue-ink: #5A7A96;
  --ink: #2E3440;
  --ink-2: #4A5568;
  --ink-soft: #8B93A1;
  --line: rgba(46,52,64,.12);
  --line-2: rgba(46,52,64,.06);
  --accent: #A7C7E7;
  --accent-deep: #8FAFC9;
  --link: #5A7A96;
  --danger: #C45C5C;
  --ok: #5A9E6F;
  --radius: 12px;
  --tab-h: calc(49px + env(safe-area-inset-bottom, 0px));
  --font: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --serif: "Cormorant Garamond", "Times New Roman", Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.35; }
body { min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
.app { min-height: 100dvh; padding-bottom: var(--tab-h); }
.screen { display: none; min-height: 60vh; }
.screen.active { display: block; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--tab-h); padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; background: rgba(250,248,244,.92); backdrop-filter: saturate(180%) blur(16px);
  border-top: 0.5px solid var(--line);
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; font-weight: 500; padding: 6px 0 4px;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--blue-ink); }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--tab-h) + 12px); z-index: 35;
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--blue-deep); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(143,175,201,.4);
}
.fab:active { transform: scale(.96); }

.ios-header {
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 8px;
  background: var(--paper); position: sticky; top: 0; z-index: 20;
}
.ios-header .large-title {
  font-family: var(--serif); font-size: 34px; font-weight: 700;
  letter-spacing: -0.3px; color: var(--ink); margin: 0 0 10px;
}
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-2); border-radius: 10px; padding: 8px 12px;
}
.search-bar svg { color: var(--ink-soft); flex-shrink: 0; }
.search-bar input {
  border: 0; background: transparent; outline: none; width: 100%;
  font-size: 17px; color: var(--ink);
}
.search-bar input::placeholder { color: var(--ink-soft); }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; border: 0; background: var(--paper-2); color: var(--ink-2);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500;
}
.chip.active { background: var(--blue-deep); color: #fff; }

.list-wrap { position: relative; padding: 0 0 24px; }
.az-index {
  position: fixed; right: 2px; top: 50%; transform: translateY(-50%);
  z-index: 25; display: flex; flex-direction: column; align-items: center;
  font-size: 10px; font-weight: 600; color: var(--blue-ink); line-height: 1.15;
  padding: 4px 2px; user-select: none;
}
.az-index span { padding: 0 4px; cursor: pointer; }
.recipe-list { padding: 0 28px 0 16px; }
.letter-head {
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  padding: 10px 0 4px; background: var(--paper); position: sticky; top: 118px; z-index: 5;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 0.5px solid var(--line);
  background: transparent; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left; cursor: pointer;
}
.row:active { background: var(--line-2); }
.row-thumb {
  width: 48px; height: 48px; border-radius: 8px; object-fit: cover;
  background: var(--blue-2); flex-shrink: 0;
}
.row-body { flex: 1; min-width: 0; }
.row-title {
  font-size: 17px; font-weight: 510; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sub {
  font-size: 13px; color: var(--ink-soft); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-chevron { color: var(--ink-soft); flex-shrink: 0; }
.empty {
  text-align: center; padding: 48px 24px; color: var(--ink-soft); font-size: 15px;
}
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 500;
  padding: 3px 8px; border-radius: 6px; margin-top: 8px;
}
.badge-ok { background: #E5F4EA; color: #2F6B42; }
.badge-warn { background: #FFF4E0; color: #9A6700; }
.badge-info { background: #E8F1FA; color: #3D5A73; }
.badge-err { background: #FCE8E6; color: #8B2E2E; }

.nav-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px;
  position: sticky; top: 0; z-index: 30;
  background: rgba(250,248,244,.92); backdrop-filter: blur(12px);
}
.nav-bar .link-btn {
  border: 0; background: none; color: var(--link); font-size: 17px;
  padding: 8px 10px; font-weight: 400;
}
.nav-bar .link-btn.strong { font-weight: 600; }
.nav-bar .icon-link {
  border: 0; background: none; color: var(--link); padding: 8px;
  display: inline-flex; align-items: center;
}

/* —— Recipe card (Honey Garlic style) —— */
.rcard {
  background: var(--paper);
  padding: 8px 18px 32px;
  max-width: 720px; margin: 0 auto;
}
.rcard-eyebrow {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--blue-ink); margin: 8px 0 6px;
}
.rcard-eyebrow::before, .rcard-eyebrow::after {
  content: ""; width: 28px; height: 1px; background: var(--blue);
}
.rcard-title {
  font-family: var(--serif); font-size: 28px; font-weight: 700;
  text-align: center; margin: 0 0 14px; letter-spacing: -0.2px; line-height: 1.15;
  color: var(--ink);
}
.meta-row {
  display: flex; justify-content: space-around; align-items: flex-start;
  padding: 12px 0 16px; border-top: 0.5px solid var(--line); border-bottom: 0.5px solid var(--line);
  margin-bottom: 16px; gap: 4px;
}
.meta-item { text-align: center; flex: 1; min-width: 0; }
.meta-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue-deep); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.meta-icon svg { width: 18px; height: 18px; }
.meta-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft);
}
.meta-val { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 1px; }

.rcard-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
@media (max-width: 520px) {
  .rcard-cols { grid-template-columns: 1fr; }
}
.rcard-h {
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); margin: 0 0 10px;
}
.ing-group-title {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--blue-ink); margin: 12px 0 6px;
  display: flex; align-items: center; gap: 8px;
}
.ing-group-title::before, .ing-group-title::after {
  content: ""; flex: 1; height: 0.5px; background: var(--line);
}
.ing-list, .step-list { margin: 0; padding: 0; list-style: none; }
.ing-list li {
  padding: 5px 0 5px 14px; position: relative; font-size: 15px; color: var(--ink-2);
  border-bottom: none;
}
.ing-list li::before {
  content: ""; position: absolute; left: 0; top: 0.65em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--blue-deep);
}
.step-list { counter-reset: step; }
.step-list li {
  position: relative; padding: 8px 0 8px 36px;
  font-size: 15px; color: var(--ink-2); border-bottom: none;
}
.step-list li::before {
  counter-increment: step; content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: 8px;
  font-size: 14px; font-weight: 700; color: var(--blue-ink);
  font-variant-numeric: tabular-nums;
  background: none; width: auto; height: auto; border-radius: 0;
}

.rcard-footer {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px;
  margin-top: 18px; align-items: stretch;
}
@media (max-width: 520px) {
  .rcard-footer { grid-template-columns: 1fr; }
}
.chef-note {
  border: 1px solid var(--blue); border-radius: 12px; padding: 12px 14px;
  background: rgba(167,199,231,.15);
}
.chef-note .cn-label {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--blue-ink); margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.chef-note p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.rcard-photo {
  width: 100%; border-radius: 12px; object-fit: cover; aspect-ratio: 4/3;
  background: var(--paper-2); display: block;
}
.rcard-photo.compact { aspect-ratio: 16/9; max-height: 140px; }

.warn-banner {
  font-size: 13px; padding: 10px 12px; border-radius: 10px;
  background: #FFF4E0; color: #7A5200; margin-bottom: 12px;
}
.warn-banner.error { background: #FCE8E6; color: #8B2E2E; }
.warn-banner.info { background: #E8F1FA; color: #3D5A73; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--paper); border-radius: 14px 14px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: 92vh; overflow: auto;
  box-shadow: 0 -8px 30px rgba(0,0,0,.18);
}
.sheet-handle {
  width: 36px; height: 5px; border-radius: 3px; background: #C7C7CC;
  margin: 4px auto 12px;
}
.sheet h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 4px; text-align: center; }
.sheet .hint { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 0 0 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; border: 0.5px solid var(--line); background: var(--paper-2);
  border-radius: 10px; padding: 12px; font-size: 17px; outline: none;
}
.field textarea { min-height: 120px; resize: vertical; }
.btn {
  border: 0; border-radius: 10px; padding: 12px 16px; font-size: 17px; font-weight: 600;
  background: var(--paper-2); color: var(--ink);
}
.btn-primary { background: var(--blue-deep); color: #fff; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--link); font-weight: 400; }
.btn-danger { background: transparent; color: var(--danger); }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid rgba(143,175,201,.3); border-top-color: var(--blue-deep);
  animation: spin .7s linear infinite; margin: 12px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.action-menu {
  background: var(--paper); border-radius: 14px; overflow: hidden; margin: 0 0 10px;
}
.action-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: var(--paper);
  padding: 14px 16px; font-size: 17px; color: var(--link);
  border-bottom: 0.5px solid var(--line);
}
.action-menu button:last-child { border-bottom: 0; }
.action-menu button.danger { color: var(--danger); }
.action-cancel {
  width: 100%; border: 0; background: var(--paper); border-radius: 14px;
  padding: 14px; font-size: 17px; font-weight: 600; color: var(--link);
}

.group {
  margin: 16px; background: #fff; border-radius: 12px; overflow: hidden;
  border: 0.5px solid var(--line);
}
.group button, .group a {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 14px 16px; border: 0; background: transparent;
  border-bottom: 0.5px solid var(--line); font-size: 17px; color: var(--ink); text-align: left;
}
.group button:last-child, .group a:last-child { border-bottom: 0; }
.group .chev { color: var(--ink-soft); }
.edit-form { padding: 0 16px 40px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 64px); transform: translateX(-50%) translateY(20px);
  background: rgba(46,52,64,.92); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 15px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 70;
  display: flex; align-items: flex-end; justify-content: center; padding: 12px;
}
.modal {
  background: var(--paper); border-radius: 14px; padding: 20px 16px;
  width: 100%; max-width: 400px; margin-bottom: env(safe-area-inset-bottom, 0px);
}
.modal h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 8px; text-align: center; }

/* —— Print / PDF: letter page, 1–2 pages, auto-shrink —— */
.print-root { display: none; }
@media print {
  @page { size: letter; margin: 0.45in; }
  body * { visibility: hidden; }
  .print-root, .print-root * { visibility: visible; }
  .print-root {
    display: block !important; position: absolute; left: 0; top: 0; width: 100%;
    background: #FAF8F4; color: #2E3440;
  }
  .no-print, .tabbar, .fab, .sheet, .sheet-backdrop, .nav-bar, .toast, #modalHost { display: none !important; }
  .app { display: none !important; }
}

.print-book-cover {
  page-break-after: always;
  min-height: 9.5in; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  border: 2px solid #8FAFC9; margin: 0; padding: 24px;
}
.print-book-cover h1 {
  font-family: "Cormorant Garamond", Georgia, serif; font-size: 48px; color: #5A7A96; margin: 0;
}
.print-index { page-break-after: always; }
.print-index h1 { font-family: "Cormorant Garamond", Georgia, serif; font-size: 28px; }
.print-index ol { columns: 2; font-size: 12px; }

.print-card {
  page-break-after: always;
  page-break-inside: avoid;
  background: #FAF8F4;
  padding: 0;
  font-size: 10.5pt;
  line-height: 1.3;
}
.print-card.shrink { font-size: 9pt; }
.print-card.shrink-more { font-size: 8pt; }
.print-card .rcard-title { font-size: 22pt; margin-bottom: 8px; }
.print-card.shrink .rcard-title { font-size: 18pt; }
.print-card.shrink-more .rcard-title { font-size: 15pt; }
.print-card .meta-row { padding: 8px 0 10px; margin-bottom: 10px; }
.print-card .meta-icon { width: 28px; height: 28px; background: #8FAFC9; }
.print-card .meta-icon svg { width: 14px; height: 14px; }
.print-card .rcard-cols { gap: 14px; grid-template-columns: 1fr 1.15fr; }
.print-card .ing-list li, .print-card .step-list li { font-size: inherit; padding-top: 3px; padding-bottom: 3px; }
.print-card .rcard-footer { margin-top: 10px; }
.print-card .rcard-photo { max-height: 160px; aspect-ratio: 16/10; }
.print-card.shrink .rcard-photo, .print-card.shrink-more .rcard-photo {
  max-height: 100px; aspect-ratio: 16/9;
}
.print-card .chef-note { padding: 8px 10px; }


/* Visible print preview (screenshots / Imprimir before dialog) */
.print-root.is-preview {
  display: block !important;
  position: fixed; inset: 0; z-index: 9999;
  overflow: auto; background: #FAF8F4; padding: 0.45in;
  color: #2E3440;
}
.print-root.is-preview .print-card {
  max-width: 7.5in; margin: 0 auto;
  min-height: auto;
}
.print-root.is-preview .rcard-cols {
  grid-template-columns: 1fr 1.15fr !important;
}


/* Print: never let sticky A-Z letter-head / chrome overlap recipe headings */
.print-root .letter-head,
.print-root.is-preview .letter-head,
body:has(.print-root.is-preview) .letter-head,
body:has(.print-root.is-preview) .ios-header,
body:has(.print-root.is-preview) .tabbar,
body:has(.print-root.is-preview) .fab,
body:has(.print-root.is-preview) .az-index {
  display: none !important;
}
.print-card .rcard-h,
.print-root .rcard-h,
.print-card .col-label,
.print-root .col-label {
  position: static !important;
  top: auto !important;
  background: transparent !important;
  padding-top: 4px;
  z-index: auto;
}
.print-card .rcard-title,
.print-card .rcard-eyebrow {
  position: relative;
  z-index: 1;
}
.print-card {
  padding: 12px 8px 20px;
  overflow: visible;
}
.print-root.is-preview {
  isolation: isolate;
}
