/* Phone app layer (lib/pwa.js, lib/pwa-ui.js, public/pwa-app.js). Uses the colors from style.css. */

/* ---------- bottom tab bar: phones only ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 56px; color: var(--muted); text-decoration: none; font: 600 11px/1.1 var(--body); letter-spacing: .01em;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a[aria-current="page"] { color: var(--red); }
  .tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--red); }
  .tabbar a:active { background: var(--sunken); }
  .tab-dot {
    position: absolute; top: 6px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: var(--red); color: #fff; font: 700 10px/17px var(--body); text-align: center;
  }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  /* Installed app */
  .is-app header.site { padding-top: env(safe-area-inset-top); }
  .is-app .foot-app { display: none; }
}

/* ---------- install banner (shown once) ---------- */
.ia-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; gap: 12px; max-width: 520px; margin-inline: auto;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-left: 4px solid var(--red);
  border-radius: 14px; padding: 12px 12px 12px 14px; box-shadow: 0 10px 30px rgb(0 0 0 / .28);
  animation: ia-in .25s ease-out;
}
@media (min-width: 761px) { .ia-banner { bottom: 20px; } }
.ia-banner img { border-radius: 10px; flex: none; }
.ia-text { flex: 1; min-width: 0; }
.ia-text strong { display: block; font-size: 14px; }
.ia-text p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.ia-text svg { vertical-align: -3px; color: var(--blue, #0a84ff); }
.ia-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.ia-x { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; padding: 6px 8px; cursor: pointer; }
@keyframes ia-in { from { transform: translateY(16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ia-banner { animation: none; } }

/* ---------- camera button ---------- */
.cam-row { margin: 6px 0 2px; }
.cam-btn { min-height: 40px; }

/* ---------- Check a serial ---------- */
.ck-form { display: grid; gap: 14px; max-width: 560px; }
.ck-form select, .ck-form input { font-size: 16px; min-height: 46px; } /* 16px stops iPhone zooming in */
.ck-form input[data-ck="n"] { font: 700 22px var(--mono); letter-spacing: .04em; }
.ck-answer { max-width: 560px; margin: 16px 0; padding: 18px; border-radius: var(--radius, 12px); border: 1px solid var(--line); background: var(--surface); }
.ck-answer p { margin: 4px 0; }
.ck-answer .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ck-answer form.inline { display: inline; margin: 0; }
.ck-card { font-size: 13px; color: var(--muted); }
.ck-big { font: 700 26px/1.15 var(--display, inherit); text-transform: uppercase; letter-spacing: .01em; }
.ck-yes { border-left: 5px solid var(--ok, #1f9d55); }
.ck-yes .ck-big span { color: var(--ok, #1f9d55); }
.ck-wait { border-left: 5px solid var(--gold); }
.ck-out { border-left: 5px solid var(--red); }
.ck-err { border-left: 5px solid var(--warn, #d9480f); }

/* ---------- alert settings ---------- */
.al-form fieldset { border: 0; padding: 4px 14px; border-radius: 12px; margin: 0 0 8px; display: grid; gap: 4px; }
.al-form legend { font-weight: 700; margin-bottom: 6px; }
.al-toggle { display: flex !important; flex-direction: row !important; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--fg); }
.al-toggle > span { display: grid; gap: 2px; }
.al-toggle .fine { margin: 0; }
.al-toggle input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 14px; margin: 0;
  background: var(--sunken); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .15s;
}
.al-toggle input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .15s; }
.al-toggle input[type="checkbox"]:checked { background: var(--red); border-color: var(--red); }
.al-toggle input[type="checkbox"]:checked::after { transform: translateX(18px); }
.al-toggle input[type="checkbox"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
