/* Shared base styles for the maker PWAs.
   Source of truth: /_shared/base.css. Copied into each app by tools/sync-shared.sh.
   Colours come from the app's own theme.css. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 14px 0 8px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; margin-bottom: 6px; }
input[type="checkbox"] { width: auto; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }

.unit { display: flex; align-items: center; gap: 6px; }
.unit > span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.unit select { width: auto; flex: 0 0 auto; }

.grid2, .grid3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 520px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr 1fr; }
}
@media (min-width: 360px) and (max-width: 519px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
}

.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 12px 0 0; }
.ok { background: var(--ok-bg); color: var(--ok-ink); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 12px 0 0; }

.seg { display: flex; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin: 0 0 12px; }
.seg button {
  flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 6px; border-radius: 9px; cursor: pointer;
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

.result { background: var(--accent-soft); border-color: transparent; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.result .stats { margin-top: 0; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sub { margin: 10px 0 0; font-size: 14px; font-weight: 500; }
.neg { color: var(--danger); }

table.list { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px 6px 0; }
table.list td { padding: 6px 6px 6px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list td.r, table.list th.r { text-align: right; padding-right: 0; }
table.list tr.total td { border-bottom: 0; font-weight: 700; }
table.list input, table.list select { padding: 8px; }

/* editable rows (ingredients, molds, steps) */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; gap: 8px; align-items: center; }
.x {
  border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer;
  width: 36px; height: 40px; border-radius: 10px;
}
.x:hover { background: var(--field); color: var(--danger); }
.add { margin-top: 10px; }

/* quality bars */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 10px; font-size: 14px; }
.bar { position: relative; height: 12px; border-radius: 99px; background: var(--field); border: 1px solid var(--line); overflow: hidden; }
.bar .range { position: absolute; top: 0; bottom: 0; background: var(--ok-bg); }
.bar .fill { position: absolute; top: 2px; bottom: 2px; left: 0; border-radius: 99px; background: var(--accent); min-width: 3px; }
.bar-row .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-row.out .n { color: var(--warn-ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 15px;
  padding: 11px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.block { width: 100%; padding: 14px; font-size: 16px; }
.btn.danger { color: var(--danger); }
.btns { display: flex; flex-wrap: wrap; gap: 10px; }
.btns.end { justify-content: flex-end; margin-top: 12px; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.row-between h2 { margin: 0; }
.row-between input { max-width: 200px; }

/* saved entries (logs, projects) */
.entry { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.entry-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.entry-head b { font-size: 16px; }
.entry-meta { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.ready { background: var(--ok-bg); color: var(--ok-ink); }
.entry-nums { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.entry-notes { font-size: 14px; margin: 8px 0 0; white-space: pre-wrap; }
.entry .btns { margin-top: 10px; }
.entry .btn { padding: 7px 12px; font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; margin: 0; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.timeline .d { color: var(--muted); font-size: 12px; display: block; font-weight: 500; }

.howto { padding-left: 18px; margin: 0; font-size: 14px; }
.howto li { margin-bottom: 6px; }

nav.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
nav.bottom button {
  flex: 1; max-width: 180px; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; cursor: pointer; border-radius: 10px;
}
nav.bottom svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav.bottom button.on { color: var(--accent); }

dialog {
  border: 0; border-radius: 18px; padding: 18px; width: min(560px, calc(100vw - 24px));
  background: var(--card); color: var(--ink); max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog .grid2 { margin-bottom: 12px; }

#toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.disclaimer { font-size: 12px; color: var(--muted); text-align: center; margin: 4px 8px 16px; }

@media print {
  nav.bottom, .top, .no-print, .entry .btns { display: none !important; }
  body { padding: 0; background: #fff; }
}
.gap-top { margin-top: 12px; }

/* ---- month calendar grid (health apps) ---- */
.month-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.month-head b { font-size: 16px; }
.month-head .btn { padding: 6px 12px; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month .dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.month .d { aspect-ratio: 1; border-radius: 10px; border: 1px solid transparent; background: var(--field); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; position: relative; display: grid; place-items: center; padding: 0; }
.month .d.out { visibility: hidden; }
.month .d.today { border-color: var(--ink); }
.month .d .dot { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; }

/* ---- dose rows (health apps) ---- */
.dose { display: grid; grid-template-columns: 78px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dose:last-child { border-bottom: 0; }
.dose .t { font-weight: 800; font-variant-numeric: tabular-nums; }
.dose b { display: block; }
.dose .meta { font-size: 13px; color: var(--muted); }
.dose .acts { display: flex; gap: 6px; }
.dose .acts .btn { padding: 8px 10px; font-size: 13px; }
.dose.taken .t, .dose.taken b { color: var(--ok-ink); }
.dose.skipped { opacity: .6; }
.dose.late .t { color: var(--danger); }

/* ---- toggle chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--field); color: var(--ink); border-radius: 99px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.times { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.times input { width: 120px; }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.notice > b:first-child { display: block; margin-bottom: 2px; }

/* ---- passcode lock (health apps) ---- */
.lockscreen { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; }
.lock-box { width: 100%; max-width: 360px; text-align: center; display: grid; gap: 10px; }
.lock-box img { margin: 0 auto 6px; }
.lock-box h2 { margin: 0; font-size: 22px; }
.lock-msg { margin: 0; color: var(--muted); font-size: 15px; }
.lock-box input { text-align: center; font-size: 24px; letter-spacing: .3em; padding: 14px; }
.lock-err { margin: 0; min-height: 20px; color: var(--danger); font-size: 14px; font-weight: 600; }
.linkish { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; padding: 8px; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
body.locked { overflow: hidden; }
body.privacy-cover main, body.privacy-cover nav.bottom { visibility: hidden; }
