:root {
  --gap: 12px;
  --max: 1200px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #fafafa;
  color: #111;
}

a { color: inherit; }

.container { max-width: var(--max); margin-inline: auto; padding: var(--gap); }

.stack { display: grid; gap: var(--gap); }
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: 1fr; }

.card {
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
}

.muted { color: #475569; }

.button {
  display: inline-block;
  padding: .6rem 1rem;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.button:hover { opacity: .92; }

.mobile-only { display: block; }
.pc-only { display: none; }

.rd-inline { display: inline; }
.rd-mt-1 { margin-top: 1rem; }

.rd-prep-hint {
  margin-left: .5rem;
  font-size: .95rem;
  color: #475569;
}
.rd-prep-hint[hidden] { display: none !important; }

.rd-link-disabled {
  pointer-events: none;
  opacity: .55;
}

.rd-link-loading::after {
  content: "";
  display: inline-block;
  width: .85em;
  height: .85em;
  margin-left: .45rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  vertical-align: -0.12em;
  opacity: .6;
  animation: rdspin .8s linear infinite;
}
@keyframes rdspin { to { transform: rotate(360deg); } }

.wrap { max-width: 1100px; margin: 2rem auto; padding: 0 1rem; }

.top { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem .9rem;
  border-radius: 12px;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  background: #fff;
  text-decoration: none;
  cursor: pointer;
}

.btn-dark { background: #111827; color: #fff; border-color: #111827; }
.btn-ghost { background: #fff; color: #111; border: 1px solid #cbd5e1; }

input[type="text"],
input[type="url"],
textarea,
select {
  width: 100%;
  font: inherit;
  padding: .55rem .7rem;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: inherit;
}

textarea { resize: vertical; }

.filter {
  display: grid;
  gap: .75rem;
  margin-top: 1rem;
}

.filter .row,
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .75rem;
  align-items: end;
}

@media (max-width: 600px) {
  .filter .row,
  .row {
    grid-template-columns: 1fr;
  }
  .filter button {
    width: 100%;
  }
}

.note { margin-top: .25rem; }

.notice {
  margin: .75rem 0 0;
  padding: .65rem .8rem;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}
.notice--ok  { border-color: #86efac; background: #f0fdf4; }
.notice--warn{ border-color: #fde68a; background: #fffbeb; }
.notice--err { border-color: #fecaca; background: #fef2f2; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

#layoutGrid.grid { grid-template-columns: 1fr; }

.results { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.cardlink { display: block; text-decoration: none; color: inherit; }

.title {
  font-weight: 800;
  font-size: 1.05rem;
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  font-size: .78rem;
  font-weight: 800;
  padding: .12rem .45rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  vertical-align: middle;
}
.badge--pending { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.badge--danger  { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.chip {
  display: inline-block;
  font-size: .85rem;
  padding: .25rem .5rem;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.pre { white-space: pre-wrap; line-height: 1.5; }

.actions {
  display: flex;
  gap: var(--gap);
  flex-wrap: wrap;
  align-items: center;
}

.cardTop {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: .85rem;
  align-items: start;
}

.cardTop--noThumb {
  grid-template-columns: 0 1fr;
  gap: 0;
}

.cardTop--noThumb .thumb {
  width: 0;
  height: 0;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
}

.thumb {
  width: 92px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
}
.thumb--placeholder {
  display: grid;
  place-items: center;
  font-size: .8rem;
  color: #64748b;
}

#recipeExport { background: #fff; }
.export-title { font-size: 1.4rem; font-weight: 800; margin: 0 0 .5rem 0; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .75rem;
  align-items: start;
  margin-top: .75rem;
}
.gallery img,
.gallery__img {
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  display: block;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.rd-detail {
  display: grid;
  gap: 12px;
}

.rd-title { grid-area: title; }
.rd-images { grid-area: images; }
.rd-ingredients { grid-area: ingredients; }
.rd-description { grid-area: description; }
.rd-actions { grid-area: actions; }

@media (min-width: 900px) {
  .rd-detail {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "title title"
      "images ingredients"
      "description description";
    align-items: stretch;
  }

  .rd-images,
  .rd-ingredients {
    height: 100%;
  }

  .rd-images {
    display: flex;
  }

  .rd-images .gallery {
    flex: 1;
    height: 100%;
  }
}

.rd-actions-inline {
  display: grid;
  grid-template-columns: max-content max-content;
  gap: 12px;
  margin-top: 12px;
  justify-content: start;
}

.rd-actions-inline > .btn {
  width: max-content;
  justify-self: stretch;
}

@media (max-width: 520px) {
  .rd-actions-inline {
    grid-template-columns: 1fr;
  }
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 10000;
}
.modal--open { display: block; }

.modal__bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
}

.modal__panel {
  position: relative;
  width: min(560px, 92vw);
  margin: 12vh auto 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}

.modal__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .6rem;
  align-items: center;
  margin-top: .75rem;
}

.modal__actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: .9rem;
}

@media (max-width: 520px) {
  .modal__row { grid-template-columns: 1fr; }
  .modal__row button { width: 100%; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  background: rgba(17,24,39,.95);
  color: #fff;
  padding: .55rem .75rem;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 10001;
  max-width: min(720px, 92vw);
  text-align: center;
}
.toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast--error {
  background: rgba(153,27,27,.95);
}

.install-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: rgba(17,24,39,.98);
  color: #fff;
  padding: .85rem 1rem;
  box-shadow: 0 -6px 24px rgba(0,0,0,.22);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}
.install-banner[hidden] { display: none !important; }
.install-banner__row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: center; }
.install-banner__title { font-weight: 800; margin-bottom: .15rem; }
.install-banner__desc { opacity: .85; font-size: .95rem; }
.install-btn { background: #22c55e; color: #0b1220; font-weight: 700; border: 0; border-radius: 10px; padding: .5rem .9rem; cursor: pointer; }
.install-btn:hover { opacity: .92; }
.install-btn--ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); margin-left: .35rem; }

@media (min-width: 900px) {
  .mobile-only { display: none; }
  .pc-only { display: block; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .install-banner { left: auto; right: 20px; bottom: 20px; width: min(520px, 92vw); border-radius: 14px; }
}

#results .card img:not(.thumb),
.results .card img:not(.thumb),
#results a.card img:not(.thumb),
.results a.card img:not(.thumb) {
  display: none !important;
}

#recipeExport img {
  display: block;
}

#btnShare,
#btnDownloadPng {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}

@media (min-width: 900px) {
  #btnShare.mobile-only,
  #btnDownloadPng.mobile-only {
    display: inline-flex !important;
  }
}

#galleryEmpty,
#galleryLocalHint,
#imagesEmptyMsg,
.images-empty,
.no-images-hint,
.rd-no-images,
.rd-images-empty,
.galleryNote {
  display: none !important;
}

body.rd-offline {
  --bg: #fafafa;
  --card: #ffffff;
  --muted: #475569;
  --text: #111111;
  --line: #e5e7eb;
  --btn: #111827;
  --btn2: #ffffff;
  --accent: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0,0,0,.12);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color-scheme: light;
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

body.rd-offline a { color: inherit; }

body.rd-offline .wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 60px;
}

body.rd-offline header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 16px;
}

body.rd-offline .leftHead { display: flex; gap: 12px; align-items: center; }

body.rd-offline .title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .2px;
}

body.rd-offline .muted { color: var(--muted); }

body.rd-offline .pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #111;
}

body.rd-offline .btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: transform .05s ease, background .15s ease;
  font-weight: 700;
  font-size: 14px;
  color: #111;
}

body.rd-offline .btn:hover { background: #f8fafc; }
body.rd-offline .btn:active { transform: translateY(1px); }
body.rd-offline .btn-dark { background: #111827; color: #ffffff; border-color: #111827; }
body.rd-offline .btn-dark:hover { background: #0b1220; }

body.rd-offline .grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

body.rd-offline .card {
  background: var(--card);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

body.rd-offline .card h3{
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .2px;
  text-transform: uppercase;
}

body.rd-offline label { display: block; margin: 10px 0 0; }

body.rd-offline select,
body.rd-offline input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #111111;
  outline: none;
}

body.rd-offline input::placeholder { color: rgba(71,85,105,.7); }

body.rd-offline .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

body.rd-offline .notice {
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  padding: 10px 12px;
  background: #f8fafc;
}

body.rd-offline .notice--warn { border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.12); }
body.rd-offline .notice--err { border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.12); }
body.rd-offline .notice strong { display: block; margin-bottom: 2px; }

body.rd-offline .sep { height: 1px; background: var(--line); margin: 10px 0; }

body.rd-offline #bootOverlay{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(8px);
  z-index: 9999;
}

body.rd-offline #bootCard{
  width: min(760px, 100%);
  border-radius: 18px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 16px;
}

body.rd-offline .bootTop{ display: flex; align-items: center; justify-content: space-between; gap: 12px; }

body.rd-offline .spin{
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(148,163,184,.55);
  border-top-color: rgba(17,24,39,.95);
  animation: rdspin2 1s linear infinite;
}
@keyframes rdspin2{ to{ transform: rotate(360deg); } }

body.rd-offline #bootMsg{ font-weight: 700; }
body.rd-offline #bootSub{ margin-top: 4px; font-size: 13px; }

body.rd-offline #bootLog{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  color: #111;
}

body.rd-offline .tagOk{ color: #15803d; }
body.rd-offline .tagWarn{ color: #92400e; }
body.rd-offline .tagErr{ color: #b91c1c; }

body.rd-offline .bootActions{ margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

body.rd-offline #recipeExport {
  display: block !important;
}

body.rd-offline #recipeExport .rd-block {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: static !important;
}

.rd-images .gallery {
  display: block;
  position: relative;
  margin-top: 0;
  border-radius: 12px;
  overflow: hidden;
}

.rd-images .gallery img,
.rd-images .gallery__img {
  display: none !important;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.rd-images .gallery img.is-active,
.rd-images .gallery__img.is-active {
  display: block !important;
}

.rd-images .gallery .rd-car-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(226,232,240,.95);
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 26px rgba(0,0,0,.16);
  color: #111827;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  z-index: 3;
  transition: transform .12s ease, opacity .12s ease, background .12s ease, box-shadow .12s ease;
}

@media (hover:hover) {
  .rd-images .gallery .rd-car-btn {
    opacity: 0;
    pointer-events: none;
  }
  .rd-images .gallery:hover .rd-car-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (hover:none) {
  .rd-images .gallery .rd-car-btn {
    opacity: 1;
  }
}

.rd-images .gallery .rd-car-btn:hover {
  transform: translateY(-50%) scale(1.03);
  background: rgba(255,255,255,.88);
  box-shadow: 0 14px 34px rgba(0,0,0,.20);
}

.rd-images .gallery .rd-car-btn:active {
  transform: translateY(-50%) scale(.98);
}

.rd-images .gallery .rd-car-btn:focus-visible {
  outline: 3px solid rgba(34,197,94,.45);
  outline-offset: 3px;
}

.rd-images .gallery .rd-car-prev {
  left: 12px;
}

.rd-images .gallery .rd-car-next {
  right: 12px;
}

.rd-ing-rows { display: grid; gap: 10px; }

.rd-ing-row {
  display: grid;
  grid-template-columns: 110px 90px 1fr auto;
  gap: 10px;
  align-items: center;
}

.rd-ing-name { min-width: 0; }
.rd-ing-qty { width: 100%; }
.rd-ing-unit { width: 100%; }

.rd-ing-del { padding: .55rem .7rem; }

@media (max-width: 640px) {
  .rd-ing-row { grid-template-columns: 1fr 1fr; }
  .rd-ing-row .rd-ing-unit { grid-column: 1 / 2; }
  .rd-ing-row .rd-ing-del { grid-column: 2 / 3; justify-self: end; }
}
