/* MyDiet — shared styles for the iPhone PWA and the Windows app. */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --border: #e1ded4;
  --accent: #0f7a5c;
  --accent-soft: #dcf1e8;
  --warn: #b35c00;
  --warn-soft: #fbeedd;
  --danger: #b3261e;
  --danger-soft: #fbe3e1;
  --chart-1: #0f7a5c;
  --chart-2: #3a6fd8;
  --chart-3: #c25b8a;
  --band: rgba(15, 122, 92, 0.10);
  --radius: 12px;
  --nav-h: 64px;
  /* Extra space under the status bar, clear of the fade iOS draws at the top of the screen.
     20px on iPhone/iPad by default; adjustable per device in Settings (stored in localStorage). */
  --top-fade: 0px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1e1c;
    --surface-2: #2a2a27;
    --text: #efede6;
    --muted: #a3a199;
    --border: #34342f;
    --accent: #4cc39a;
    --accent-soft: #173a2e;
    --warn: #f0a24a;
    --warn-soft: #3b2a14;
    --danger: #f28b82;
    --danger-soft: #3d1c1a;
    --chart-1: #4cc39a;
    --chart-2: #7ea6f4;
    --chart-3: #e48fb6;
    --band: rgba(76, 195, 154, 0.12);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 0 0 .4rem; font-weight: 600; }
p { margin: 0 0 .6rem; }
small, .muted { color: var(--muted); }

/* Line icons: one stroke weight everywhere, coloured by the surrounding text. */
.icon { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -0.2em; }
.sidenav a .icon { opacity: .85; }
.sidenav a.active .icon { opacity: 1; stroke-width: 2; }
.callout .icon { margin-right: .2rem; }
.list.menu .icon { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
@supports (-webkit-touch-callout: none) {
  :root { --top-fade: 20px; }
}

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem;
  padding: calc(env(safe-area-inset-top) + var(--top-fade) + .6rem) 1rem .6rem; background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.main { flex: 1; padding: 1rem 1rem calc(var(--nav-h) + env(safe-area-inset-bottom) + 1.5rem); max-width: 820px; width: 100%; margin: 0 auto; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .72rem; }
.bottomnav a .icon { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--accent); }
.bottomnav a.active .icon { stroke-width: 2.1; }
.sidenav { display: none; }

@media (min-width: 900px) {
  .app { flex-direction: row; }
  .sidenav { display: flex; flex-direction: column; gap: .15rem; width: 220px; padding: 1rem .75rem; border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; background: var(--surface); }
  .sidenav .brand { font-weight: 700; font-size: 1.2rem; padding: .25rem .6rem 1rem; }
  .sidenav a { display: flex; gap: .6rem; align-items: center; padding: .5rem .6rem; border-radius: 8px; color: var(--text); }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .sidenav .grow { flex: 1; }
  .content-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .topbar .brand { display: none; }
  .bottomnav { display: none; }
  .main { padding-bottom: 2rem; }
}

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card.tight { padding: .6rem .8rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.card-head > .num { margin-left: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
@media (max-width: 359px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) {
  .grid3 { gap: .5rem; }
  .stat { padding: .55rem .6rem; }
  .stat .value { font-size: 1.1rem; }
  .ring { width: 96px; height: 96px; }
  .ring-wrap { gap: .75rem; }
}
.row { display: flex; align-items: center; gap: .5rem; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .5rem; }
.right { margin-left: auto; }
.center { text-align: center; }

.stat { background: var(--surface-2); border-radius: 10px; padding: .6rem .75rem; }
.stat .label { font-size: .75rem; color: var(--muted); }
.stat .value { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .75rem; color: var(--muted); }
.stat.good { background: var(--accent-soft); }
.stat.warn { background: var(--warn-soft); }
.stat.warn .value, .stat.warn .sub { color: var(--warn); }
.stat.bad { background: var(--danger-soft); }
.stat.bad .value, .stat.bad .sub { color: var(--danger); }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px;
  padding: .55rem .9rem; font: inherit; font-weight: 550; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; min-height: 40px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { padding: .3rem .6rem; min-height: 32px; font-size: .85rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; justify-content: center; }

.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .65rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .85rem; cursor: pointer; color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: .3rem; }
.chips.scale .chip { justify-content: center; padding: .35rem 0; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .5rem .65rem; width: 100%; min-height: 40px;
}
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: .6rem; }
label.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.inline-input { width: 6.5rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .main-text { flex: 1; min-width: 0; }
.list .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { font-size: .8rem; color: var(--muted); }
.list li.clickable { cursor: pointer; }

.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; position: relative; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 99px; }
.bar.warn > i { background: var(--warn); }
.bar.over > i { background: var(--danger); }
.nutrient-row {
  display: grid; grid-template-columns: 7.5rem minmax(48px, 1fr) auto; grid-template-areas: "n b v";
  align-items: center; gap: .6rem; font-size: .9rem; padding: .25rem 0;
}
.nutrient-row > span:first-child { grid-area: n; }
.nutrient-row > .bar { grid-area: b; }
.nutrient-row .val { grid-area: v; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .82rem; white-space: nowrap; }
/* In a narrow column (next to the calorie ring on a phone) the bar goes under the name and value. */
.nutrients-col { container-type: inline-size; flex: 1; min-width: 0; }
@container (max-width: 340px) {
  .nutrient-row { grid-template-columns: 1fr auto; grid-template-areas: "n v" "b b"; row-gap: .2rem; padding: .3rem 0; }
}

.ring-wrap { display: flex; align-items: center; gap: 1rem; }
.ring { width: 110px; height: 110px; flex: none; }
.ring .big { font-size: 22px; font-weight: 700; fill: var(--text); }
.ring .small { font-size: 11px; fill: var(--muted); }

.badge { white-space: nowrap; display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.badge.good { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

.callout { border-radius: 10px; padding: .7rem .85rem; background: var(--surface-2); font-size: .92rem; margin-bottom: .75rem; }
.callout.good { background: var(--accent-soft); }
.callout.warn { background: var(--warn-soft); }
.callout.bad { background: var(--danger-soft); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); z-index: 50; background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 999px; font-size: .9rem; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 90vw; }
.toast.error { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.datebar { display: flex; align-items: center; gap: .25rem; }
.datebar .label { font-weight: 600; min-width: 5.5rem; text-align: center; }

.sync { font-size: .75rem; display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); cursor: pointer; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.sync.ok i { background: var(--accent); }
.sync.busy i { background: var(--chart-2); animation: pulse 1s infinite; }
.sync.err i { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

.scanner-box { width: 100%; max-width: 420px; margin: 0 auto; border-radius: 12px; overflow: hidden; background: #000; min-height: 240px; }

.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .band { fill: var(--band); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .75rem; color: var(--muted); font-weight: 600; }
.table td.num, .table th.num { text-align: right; }
.scroll-x { overflow-x: auto; }
.table.compact td, .table.compact th { white-space: nowrap; padding: .4rem .3rem; }

.empty { text-align: center; color: var(--muted); padding: 1.5rem .5rem; }
.loading { text-align: center; color: var(--muted); padding: 3rem 1rem; }
details > summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin: .25rem 0; }
.sheet { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- check-in photos ---------- */
.photo-strip { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; }
.photo-thumb, .photo-add { position: relative; flex: 0 0 96px; height: 128px; border-radius: 12px; overflow: hidden; background: var(--surface-2, rgba(127,127,127,.12)); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tag { position: absolute; left: 4px; bottom: 4px; font-size: .7rem; padding: 1px 6px; border-radius: 8px; background: rgba(0,0,0,.55); color: #fff; }
.photo-del { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.45); color: #fff; padding: 2px; min-height: 0; }
.photo-add { display: flex; align-items: center; justify-content: center; border: 1.5px dashed var(--border); color: var(--accent); font-size: .85rem; text-align: center; cursor: pointer; }
.photo-add.busy { opacity: .6; pointer-events: none; }
.photo-add input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-missing { display: flex; align-items: center; justify-content: center; height: 100%; font-size: .75rem; color: var(--muted); text-align: center; padding: .25rem; }
.photo-missing.tall { aspect-ratio: 3 / 4; border-radius: 12px; background: var(--surface-2, rgba(127,127,127,.12)); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.compare select { width: 100%; margin-bottom: .4rem; }
.compare img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; display: block; }

/* ---------- strength, media and training balance ---------- */
.media-view img, .media-view video { width: 100%; border-radius: 12px; display: block; background: #000; }
.media-view.thumb { position: relative; width: 96px; height: 96px; flex: 0 0 96px; border-radius: 12px; overflow: hidden; background: var(--surface-2, rgba(127,127,127,.12)); }
.media-view.thumb img, .media-view.thumb video { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.play-badge { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.4rem; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.media-strip { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; }
.media-strip button { padding: 0; border: 0; background: none; }
.card.balance.bad { border-color: var(--danger); }
.card.balance.warn { border-color: var(--warn); }
.balance-line { margin: .3rem 0; padding-left: .8rem; border-left: 3px solid var(--border); }
.balance-line.much { border-left-color: var(--danger); }
.balance-line.little { border-left-color: var(--warn); }
.set-row { display: grid; grid-template-columns: 2.2rem 1fr 1fr 2.2rem; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.set-row input { text-align: center; }
.stepper { display: flex; align-items: center; gap: .25rem; }
.stepper input { min-width: 0; }
.stepper button { flex: 0 0 2rem; min-height: 2.2rem; padding: 0; }
.next-target { font-weight: 650; color: var(--accent); }
.camera { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.camera video, .camera img.ghost { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera img.ghost { pointer-events: none; }
.camera .guide { position: absolute; inset: 12%; border: 2px dashed rgba(255,255,255,.6); border-radius: 50%; pointer-events: none; }
.wipe { position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; }
.wipe img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wipe .wipe-line { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 4px rgba(0,0,0,.6); }
.wipe-labels { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.levers { margin: 0; padding-left: 1.2rem; }
.levers li { margin-bottom: .6rem; }
.tips { margin: 0 0 .6rem; padding-left: 1.1rem; font-size: .88rem; color: var(--muted); }
.tips li { margin-bottom: .2rem; }
.burst { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.burst button { padding: 0; border: 0; background: none; }
.burst img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; display: block; }
.priorities { margin: .4rem 0 0; padding-left: 1.4rem; }
.priorities > li { margin-bottom: .9rem; }
.priorities > li::marker { font-weight: 700; color: var(--accent); }
.priorities.compact > li { margin-bottom: .55rem; }
.priorities > li.safety::marker { color: var(--danger); }
.priorities .meta { color: var(--muted); font-size: .88rem; white-space: normal; }
.hour-strip { display: flex; gap: 2px; margin-top: .5rem; }
.hour-strip .hour { flex: 1; height: 26px; border-radius: 4px; position: relative; background: var(--surface-2); }
.hour-strip .hour.good { background: var(--accent-soft); }
.hour-strip .hour.ok { background: var(--warn-soft); }
.hour-strip .hour.poor { background: var(--surface-2); }
.hour-strip .hour.best { outline: 2px solid var(--accent); outline-offset: -2px; }
.hour-strip .hour span { position: absolute; top: 28px; left: 0; font-size: .62rem; color: var(--muted); white-space: nowrap; }
.hour-strip { margin-bottom: 1rem; }
input[type=range] { accent-color: var(--accent); width: 100%; }
.chips.scale.eleven { grid-template-columns: repeat(11, 1fr); }
.chip.on.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.callout.bad { background: var(--danger-soft); color: var(--danger); }
.day-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .3rem; margin-bottom: .4rem; }
.day-cell { aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: .85rem; }
.day-cell.done { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 650; }
.day-cell.missed { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.day-cell.future { opacity: .45; }
.test-how { font-size: .84rem; margin: .1rem 0 .4rem; }
.bristol { display: grid; grid-template-columns: 1fr; gap: .3rem; margin-top: .3rem; }
.bristol .chip { text-align: left; }
.report { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.report h2 { margin-top: 0; }
.report h3 { margin: 1rem 0 .3rem; font-size: 1rem; }
.report ul { margin: 0; padding-left: 1.1rem; }
.report li { margin-bottom: .2rem; font-size: .92rem; }
@media print {
  .no-print, nav, .bottom-nav, .side-nav, .topbar, header { display: none !important; }
  body, .report { background: #fff !important; color: #000 !important; border: 0; }
  .content-col, main { padding: 0 !important; margin: 0 !important; }
}
.more-group { margin: 1rem 0 .4rem .25rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sidenav { overflow-y: auto; }
.chip { white-space: nowrap; }

/* ---------- lock screen and views ---------- */
.lock { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 1.5rem; }
.lock-box { width: 100%; max-width: 320px; text-align: center; }
.lock-brand { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.lock-input { text-align: center; font-size: 1.4rem; letter-spacing: .3em; }
.lock-error { color: var(--danger); margin-top: .75rem; }
html.privacy-blur .app { filter: blur(18px); }
.view-badge { font-size: .72rem; padding: .1rem .5rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-right: .5rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: .75rem; padding: .35rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { flex: 0 0 5.2rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline li.goal span:last-child { font-weight: 650; color: var(--accent); }
td.num.up, span.num.up { color: var(--accent); font-weight: 650; }
td.num.down, span.num.down { color: var(--warn); font-weight: 650; }

/* medicine supply */
.supply-line { display: flex; align-items: center; gap: .5rem; justify-content: space-between; font-size: .85rem; margin-top: .35rem; padding: .35rem .5rem; border-radius: 8px; background: var(--surface-2); }
.supply-line.warn { background: var(--warn-soft); }
.supply-line.bad { background: var(--danger-soft); }
tr.bad td { color: var(--danger); }

/* botox timeline */
.timeline-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.timeline-bar .fill { height: 100%; border-radius: 4px; }

/* tabs across related pages (Face) */
.tabs { display: flex; gap: .25rem; background: var(--surface-2); border-radius: 12px; padding: .25rem; margin-bottom: .9rem; overflow-x: auto; }
.tabs a { flex: 1; text-align: center; padding: .45rem .6rem; border-radius: 9px; color: var(--text); font-size: .9rem; white-space: nowrap; text-decoration: none; }
.tabs a.on { background: var(--surface); font-weight: 650; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* breathing exercise */
.breath-wrap { position: relative; height: 230px; display: flex; align-items: center; justify-content: center; }
.breath-circle { position: absolute; width: 90px; height: 90px; border-radius: 50%; background: var(--accent-soft); border: 2px solid var(--accent);
  transition-property: transform; transition-timing-function: ease-in-out; transform: scale(1); }
.breath-circle.grow { transform: scale(2.3); }
.breath-circle.shrink { transform: scale(1); }
.breath-label { position: relative; text-align: center; font-weight: 650; font-size: 1.05rem; }
