:root {
  --green: #1f6149;
  --green-dark: #174b39;
  --ink: #1f352e;
  --paper: #f5f1e8;
  --muted: #68766f;
  --line: #ded8cb;
  --white: #fff;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans Myanmar", "Myanmar Sangam MN", sans-serif;
}

body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #4b9fe1; outline-offset: 2px; }

.top {
  padding: calc(22px + env(safe-area-inset-top)) 20px 24px;
  background: var(--green);
  color: var(--white);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow { font-size: 10px; letter-spacing: .16em; opacity: .74; margin: 0 0 8px; }
.top > div:first-child { min-width: 0; }
.top h1 { max-width: 100%; font-size: 30px; line-height: 1.08; margin: 0 0 10px; overflow-wrap: break-word; }
.top p:last-child { font-size: 13px; margin: 0; opacity: .84; }

.lang, .detailLang {
  display: flex;
  background: var(--green-dark);
  border-radius: 999px;
  padding: 3px;
  flex: none;
}

.lang button, .detailLang button {
  border: 0;
  background: transparent;
  color: #dcebe5;
  min-height: 44px;
  padding: 8px 13px;
  border-radius: 999px;
  font-weight: 800;
}

.lang button.active, .detailLang button.active { background: var(--white); color: var(--green); }
.detailLang button:disabled { color: #8fa49b; cursor: not-allowed; }

main { max-width: 1040px; margin: auto; padding: 18px 16px 80px; }
.toolbar { display: flex; gap: 12px; align-items: center; overflow: hidden; }
.search {
  display: flex;
  align-items: center;
  background: var(--white);
  border: 1px solid #e1ddd3;
  border-radius: 14px;
  padding: 0 12px;
  min-width: 0;
  flex: 1;
  min-height: 48px;
}
.search span { font-size: 24px; color: var(--muted); }
.search input { border: 0; outline: 0; width: 100%; padding: 10px 8px; background: transparent; }
.chips { display: flex; gap: 8px; overflow: auto; scrollbar-width: none; }
.chips button {
  white-space: nowrap;
  border: 1px solid #d9d4c9;
  background: var(--white);
  color: var(--ink);
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 800;
}
.chips button.active { background: #dceae4; border-color: #bad0c6; color: var(--green); }
.summary { margin: 20px 2px 14px; }
.summary strong { font-size: 20px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.recipe {
  appearance: none;
  border: 0;
  padding: 0;
  text-align: left;
  background: var(--white);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 5px 24px rgba(34,55,46,.08);
  color: inherit;
  cursor: pointer;
}
.recipe img { display: block; width: 100%; aspect-ratio: 5/4; object-fit: cover; object-position: top; background: #eee; }
.recipe .meta { padding: 14px; }
.recipe h3 { font-size: 17px; line-height: 1.35; margin: 0 0 10px; }
.recipe .foot { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }

dialog { border: 0; padding: 0; background: transparent; width: 100%; height: 100%; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(10,25,20,.58); backdrop-filter: blur(4px); }
.sheet {
  background: var(--paper);
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.sheetHead {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 13px;
  background: rgba(245,241,232,.97);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(31,53,46,.06);
}
.titleBlock { min-width: 0; }
.sheetHead h2 { font-size: 21px; line-height: 1.25; margin: 0 0 4px; }
.sheetHead p { font-size: 12px; color: var(--muted); margin: 0; }
.detailLang { background: #dfe9e4; }
.detailLang button { color: var(--green); min-height: 46px; }

.detailScroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: 18px;
}
.viewer { max-width: 900px; margin: auto; padding: 14px; }
.page { margin: 0 0 16px; background: var(--white); border-radius: 14px; overflow: hidden; box-shadow: 0 3px 18px rgba(40,54,48,.09); }
.imageButton { display: block; width: 100%; padding: 0; border: 0; background: var(--white); cursor: zoom-in; }
.imageButton img { width: 100%; display: block; }
.pageActions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; }
.pageActions a, .pageActions button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid #d8d2c6;
  background: var(--white);
  border-radius: 12px;
  padding: 10px;
  color: var(--ink);
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.tip { max-width: 900px; margin: 0 auto 22px; padding: 0 16px 12px; color: var(--muted); font-size: 12px; }
.recipeNav {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(31,53,46,.08);
  backdrop-filter: blur(14px);
}
.navButton {
  min-height: 52px;
  border: 1px solid #cbd6d1;
  border-radius: 14px;
  background: var(--white);
  color: var(--green);
  padding: 12px;
  font-weight: 900;
  line-height: 1.35;
}
.navButton span { font-size: 20px; margin-right: 5px; vertical-align: -1px; }
.shareButton { background: var(--green); border-color: var(--green); color: var(--white); }

#imageViewer { background: #080b0a; color: var(--white); overflow: hidden; }
#imageViewer::backdrop { background: #080b0a; }
.zoomBar {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: rgba(8,11,10,.96);
  border-bottom: 1px solid #2c332f;
}
.zoomBack {
  min-height: 48px;
  border: 1px solid #46504b;
  border-radius: 12px;
  background: #202622;
  color: var(--white);
  padding: 8px 12px;
  font-weight: 800;
}
.zoomHeading { min-width: 0; }
.zoomBar strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zoomHeading span { display: block; margin-top: 3px; color: #bac4bf; font-size: 11px; }
.zoomBack span { display: inline; margin-right: 5px; }
.zoomControls { grid-column: 1 / -1; display: flex; justify-content: center; align-items: center; gap: 8px; }
.zoomControls button { width: 48px; height: 48px; border: 1px solid #46504b; border-radius: 12px; background: #202622; color: var(--white); font-size: 24px; }
.zoomControls b { min-width: 48px; text-align: center; font-size: 12px; }
.zoomCanvas { position: fixed; inset: calc(126px + env(safe-area-inset-top)) 0 0; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; text-align: center; }
.zoomCanvas img { display: block; width: 100%; height: auto; max-width: none; margin: auto; -webkit-touch-callout: default; user-select: auto; }

#toast { position: fixed; z-index: 40; left: 50%; bottom: 112px; transform: translate(-50%,20px); background: #163b2e; color: var(--white); padding: 11px 15px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%,0); }

@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .top { padding-left: max(32px,calc((100vw - 1040px)/2)); padding-right: max(32px,calc((100vw - 1040px)/2)); }
  .sheet { max-width: 980px; margin: auto; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .recipeNav { width: min(900px,100%); margin: 0 auto; }
  .zoomBar { grid-template-columns: auto 1fr auto; }
  .zoomControls { grid-column: auto; }
  .zoomCanvas { inset: calc(72px + env(safe-area-inset-top)) 0 0; }
  .zoomCanvas img { width: auto; max-width: 100%; }
}

@media (max-width: 520px) {
  .top { display: grid; grid-template-columns: minmax(0,1fr); gap: 16px; }
  .lang { position: static; justify-self: start; }
  .toolbar { display: block; }
  .chips { margin-top: 10px; }
  .grid { gap: 10px; }
  .recipe .meta { padding: 11px; }
  .recipe h3 { font-size: 15px; }
  .pageActions { font-size: 13px; }
  .sheetHead { align-items: flex-start; }
  .sheetHead h2 { font-size: 19px; }
  .detailLang button { padding-inline: 10px; font-size: 13px; }
  .recipeNav { gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .navButton { min-height: 50px; padding: 8px 6px; font-size: 14px; }
}
