:root {
  --bg: #f6f7f5; --card: #ffffff; --text: #1c1f1d; --muted: #6b716d; --line: #e4e7e3;
  --accent: #0f766e; --accent-soft: #e0f2ef; --ok: #15803d; --ok-soft: #e7f6ec;
  --bad: #c2410c; --bad-soft: #fdeee4; --track: #eceeeb;
  --c-carb: #d97706; --c-protein: #2563eb; --c-fat: #9333ea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413; --card: #1b1f1d; --text: #eef1ef; --muted: #9aa29d; --line: #2c322f;
    --accent: #2dd4bf; --accent-soft: #123a35; --ok: #4ade80; --ok-soft: #12301d;
    --bad: #fb923c; --bad-soft: #3a2113; --track: #2a302d;
    --c-carb: #fbbf24; --c-protein: #60a5fa; --c-fat: #c084fc;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(88px + env(safe-area-inset-bottom));
}
main { max-width: 520px; margin: 0 auto; }
header { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 12px; gap: 12px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* Butonlar ve formlar */
button, .btn {
  appearance: none; border: 0; border-radius: 14px; padding: 14px; font: 600 16px system-ui, sans-serif;
  background: var(--accent); color: #fff; cursor: pointer; text-align: center; display: block; width: 100%;
}
@media (prefers-color-scheme: dark) { button, .btn { color: #06201d; } }
.btn.secondary, button.secondary { background: var(--accent-soft); color: var(--accent); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.danger { background: var(--bad-soft); color: var(--bad); }
button.small { padding: 8px 12px; font-size: 14px; width: auto; border-radius: 10px; }
button:disabled { opacity: .5; }
input[type=file] { display: none; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { background: var(--bad-soft); color: var(--bad); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.okmsg { background: var(--ok-soft); color: var(--ok); border-radius: 14px; padding: 14px; margin-bottom: 14px; font-weight: 600; }

/* Giriş */
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth .logo { font-size: 54px; text-align: center; }
.auth h1 { text-align: center; margin-bottom: 4px; }
.auth p { text-align: center; margin-top: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--track); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { background: transparent; color: var(--muted); padding: 9px; border-radius: 9px; font-size: 15px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Alt menü */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
nav.tabs button {
  background: transparent; color: var(--muted); padding: 6px 0; font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 10px;
}
nav.tabs button .ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
nav.tabs button.on { color: var(--accent); }
nav.tabs button.on .ic { filter: none; opacity: 1; }

/* Ölç */
.shot {
  display: grid; place-items: center; text-align: center; gap: 10px; min-height: 220px;
  border: 2px dashed var(--line); border-radius: 18px; cursor: pointer; overflow: hidden; position: relative;
  background: var(--card);
}
.shot img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.shot .ph { color: var(--muted); padding: 20px; }
.shot .ph svg { width: 48px; height: 48px; color: var(--accent); }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 14px; }
.loading { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 22px; color: var(--muted); }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s .8s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }

.verdict { border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict .big { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.verdict .big small { font-size: 18px; font-weight: 600; }
.verdict p { margin: 6px 0 0; font-weight: 600; }
.verdict .sub { font-weight: 500; opacity: .85; font-size: 14px; }
.bar { height: 8px; border-radius: 99px; background: rgba(127,127,127,.2); margin-top: 12px; overflow: hidden; }
.bar span { display: block; height: 100%; background: currentColor; border-radius: 99px; transition: width .2s; }

ul { list-style: none; margin: 0; padding: 0; }
.sug { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: baseline; }
.sug:first-of-type { border-top: 0; }
.sug .tag { color: var(--bad); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.alt li { padding: 4px 0; }
.alt li::before { content: "↺ "; color: var(--accent); }

.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item .row { display: flex; align-items: center; gap: 12px; }
.item .em { font-size: 26px; width: 34px; text-align: center; }
.item .nm { flex: 1; min-width: 0; }
.item .nm small { display: block; color: var(--muted); font-size: 13px; }
.item .cb { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item.off .row { opacity: .45; }
.item .portion { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-left: 46px; }
.item .portion input { flex: 1; accent-color: var(--accent); }
.item .portion output { width: 64px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.nutri { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nutri div { background: var(--bg); border-radius: 12px; padding: 10px; }
.nutri b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.nutri span { font-size: 12px; color: var(--muted); }
.title-input { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; margin-bottom: 12px; }

/* Gün */
.daynav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.daynav button { width: 44px; height: 44px; padding: 0; border-radius: 12px; font-size: 20px; }
.daynav b { font-size: 17px; }
.hero { display: flex; align-items: center; gap: 18px; }
.ring { width: 120px; height: 120px; flex: none; }
.ring .val { font: 800 26px system-ui, sans-serif; fill: var(--text); }
.ring .lbl { font: 600 11px system-ui, sans-serif; fill: var(--muted); }
.hero-text b { font-size: 18px; display: block; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; padding: 4px 10px; border-radius: 99px; margin-top: 6px; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.bad { background: var(--bad-soft); color: var(--bad); }

.meter { margin-bottom: 12px; }
.meter:last-child { margin-bottom: 0; }
.meter .top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.meter .top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter .top b { color: var(--text); }
.meter .track { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.meter .track span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.meter.over .track span { background: var(--bad); }
.meter.over .top span:last-child { color: var(--bad); font-weight: 600; }

.split { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; background: var(--card); }
.split span { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.meal { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; }
.meal:first-of-type { border-top: 0; padding-top: 0; }
.meal img, .meal .noimg { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: none; background: var(--bg); display: grid; place-items: center; font-size: 26px; }
.meal .info { flex: 1; min-width: 0; }
.meal .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal .info small { color: var(--muted); font-size: 13px; }
.meal .del { background: transparent; color: var(--muted); width: 36px; height: 36px; padding: 0; font-size: 18px; border-radius: 10px; }
.chip { font-weight: 700; font-variant-numeric: tabular-nums; }
.chip.bad { color: var(--bad); }

/* Geçmiş */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { font: 11px system-ui, sans-serif; fill: var(--muted); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .goal { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .b { fill: var(--accent); }
.chart .b.over { fill: var(--bad); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .b, .chart .b.sel { opacity: .75; }
.tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: 13px;
  padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -8px;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--bg); border-radius: 12px; padding: 10px; }
.stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }
.dayrow { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.dayrow:first-of-type { border-top: 0; padding-top: 0; }
.dayrow .d { flex: 1; }
.dayrow .d small { display: block; color: var(--muted); font-size: 13px; }
.dayrow .arrow { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.empty .e { font-size: 40px; }
