/* Cai: direction B "Pinggan". Built around the DOH Pinggang Pinoy plate. */

:root {
  --bg: #f3f4ec;
  --card: #ffffff;
  --ink: #1f2a1c;
  --ink-2: #3d4a38;
  --muted: #6b7466;
  --faint: #9aa392;
  --line: #e3e6d8;
  --line-2: #eef0e6;
  --green: #2f6b3a;
  --green-ink: #eef3e6;
  --green-soft: #b9d3a4;
  --orange: #e07b39;
  --orange-soft: #fbe9d9;
  --orange-ink: #8a4b1d;
  --red: #b4372f;

  /* Plate groups */
  --g-kanin: #dccb98;
  --g-ulam: #e07b39;
  --g-gulay: #6e9f4a;
  --g-prutas: #c7425b;
  --g-iba: #a7ae9f;

  --sans: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "Fragment Mono", ui-monospace, monospace;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); font-optical-sizing: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; letter-spacing: -0.025em; line-height: 1.1; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.lbl { font: 11px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hide { display: none !important; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 6px; }

/* ── Shell ───────────────────────────── */
.shell { min-height: 100vh; }
.rail { display: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; }
.logo { font-weight: 800; font-size: 26px; letter-spacing: -0.05em; color: var(--green); text-decoration: none; line-height: 1; display: inline-flex; align-items: center; gap: 6px; }
.logo svg { width: 22px; height: 22px; }
.topbar .who { font: 12px var(--mono); color: var(--muted); text-align: right; }
main { padding: 0 14px 120px; max-width: 1080px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr 92px 1fr 1fr; align-items: end;
  background: rgba(243, 244, 236, 0.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(10px + env(safe-area-inset-bottom));
}
.tabbar a { text-decoration: none; text-align: center; font-size: 11.5px; color: var(--muted); padding: 6px 0 2px; display: grid; justify-items: center; gap: 3px; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--green); font-weight: 600; }
.tabbar a.snap { transform: translateY(-14px); }
.tabbar a.snap span.btn-round {
  width: 60px; height: 60px; border-radius: 50%; background: var(--orange); color: #fff;
  display: grid; place-items: center; box-shadow: 0 10px 22px -8px var(--orange);
}
.tabbar a.snap span.btn-round svg { width: 26px; height: 26px; }
.tabbar a.snap { color: var(--orange-ink); font-weight: 600; }

.strip {
  background: var(--ink); color: #e8ece0; font-size: 13px; padding: 8px 18px; display: flex; gap: 10px;
  justify-content: center; align-items: center; flex-wrap: wrap; text-align: center;
}
.strip a { color: #fff; font-weight: 600; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 228px 1fr; }
  .rail {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
    padding: 24px 16px; border-right: 1px solid var(--line);
  }
  .rail .logo { font-size: 30px; margin: 0 8px 26px; }
  .rail a.nav { text-decoration: none; padding: 9px 10px; border-radius: 10px; color: var(--ink-2); display: flex; gap: 10px; align-items: center; font-weight: 500; }
  .rail a.nav svg { width: 20px; height: 20px; color: var(--muted); }
  .rail a.nav:hover { background: var(--line-2); }
  .rail a.nav.on { background: #fff; color: var(--ink); box-shadow: 0 1px 0 var(--line); }
  .rail a.nav.on svg { color: var(--green); }
  .rail .snap { margin: 16px 0 0; }
  .rail .me { margin-top: auto; font-size: 13px; color: var(--muted); padding: 0 10px; overflow-wrap: anywhere; }
  .rail .me b { color: var(--ink); display: block; font-size: 15px; }
  .topbar, .tabbar { display: none; }
  main { padding: 30px 36px 60px; }
}

/* ── Pieces ──────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; }
.card + .card { margin-top: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px;
  padding: 12px 18px; font-weight: 700; text-decoration: none; background: var(--ink); color: #fff; font-size: 15px;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn.orange { background: var(--orange); }
.btn.green { background: var(--green); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1.5px var(--faint); }
.btn.small { padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 5px 11px; font-size: 13px; font-weight: 500;
}
button.pill:hover { border-color: var(--faint); }
.pill.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.kanin { background: var(--g-kanin); } .dot.ulam { background: var(--g-ulam); } .dot.gulay { background: var(--g-gulay); }
.dot.prutas { background: var(--g-prutas); } .dot.iba { background: var(--g-iba); }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12.5px; }
.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; padding: 11px 13px; font-size: 16px;
  transition: border-color 0.12s;
}
.input:focus { outline: none; border-color: var(--green); }
.input.unit { display: flex; align-items: center; padding: 0 13px 0 0; }
.input.unit input { border: 0; background: transparent; padding: 11px 13px; width: 100%; font-size: 16px; min-width: 0; }
.input.unit input:focus { outline: none; }
.input.unit:focus-within { border-color: var(--green); }
.input.unit em { font: 13px var(--mono); color: var(--muted); font-style: normal; }
.err { color: var(--red); font-size: 13.5px; }
.note { background: var(--orange-soft); color: var(--orange-ink); border-radius: 12px; padding: 10px 13px; font-size: 14px; }
.note.green { background: #e6eedb; color: #2c4a22; }

.seg { display: inline-flex; background: var(--line-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); opacity: 0; z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: 0.2s; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 960px) { .toast { bottom: 30px; } }

/* Stepper for portions */
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.stepper button { width: 32px; height: 32px; border: 0; background: none; font-size: 18px; font-weight: 600; color: var(--ink-2); display: grid; place-items: center; }
.stepper button:hover { background: var(--line-2); }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper output { min-width: 82px; text-align: center; font-size: 13.5px; font-weight: 600; padding: 0 4px; }

/* ── Plate ───────────────────────────── */
.plate { position: relative; width: 240px; height: 240px; margin: 0 auto; }
.plate svg { width: 100%; height: 100%; overflow: visible; }
.plate .mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.plate .mid b { font-size: 50px; font-weight: 800; letter-spacing: -0.04em; line-height: 0.95; }
.plate .mid span { font: 12px var(--mono); color: var(--muted); margin-top: 4px; }
.plate .mid.over b { color: var(--orange); }
.plate .arc { transition: stroke-dasharray 0.6s cubic-bezier(.2,.8,.2,1), stroke-dashoffset 0.6s cubic-bezier(.2,.8,.2,1); }

/* Bottom sheet (food search, edit) */
.sheet-back { position: fixed; inset: 0; background: rgba(20, 28, 18, 0.4); z-index: 50; opacity: 0; transition: opacity 0.18s; }
.sheet-back.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--bg); border-radius: 22px 22px 0 0;
  max-height: 88vh; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.22s cubic-bezier(.2,.8,.2,1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.show { transform: translateY(0); }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 4px; }
.sheet .sh-head { padding: 8px 18px 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet .sh-body { overflow-y: auto; padding: 0 18px 18px; }
.sheet .x { border: 0; background: var(--line-2); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; display: grid; place-items: center; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; width: 560px; bottom: auto; top: 50%; border-radius: 22px; transform: translate(-50%, -46%) scale(0.98); opacity: 0; transition: 0.18s; max-height: 80vh; }
  .sheet.show { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { display: none; }
}

.results { list-style: none; margin: 8px 0 0; padding: 0; }
.results li + li { border-top: 1px solid var(--line); }
.results button { width: 100%; border: 0; background: none; text-align: left; padding: 11px 2px; display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; }
.results button:hover b { text-decoration: underline; }
.results small { display: block; color: var(--muted); font-size: 12.5px; }

.spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
