:root {
  --bg: #f4f7f2;
  --card: #ffffff;
  --text: #1d2420;
  --muted: #6b766f;
  --line: #e3e9e1;
  --accent: #3f8f5f;
  --accent-soft: #e2f1e6;
  --accent-text: #ffffff;
  --focus: #e9a23b;
  --focus-soft: #fdf3e2;
  --water: #4a9fd8;
  --water-soft: #e5f2fb;
  --danger: #c4483e;
  --c-plan: #3f8f5f;
  --c-extra: #e9a23b;
  --extra-soft: #fdf1df;
  --extra-text: #9a5a10;
  --shadow: 0 1px 2px rgba(20, 40, 25, .06), 0 4px 14px rgba(20, 40, 25, .05);
  --radius: 18px;
  --tabbar-h: 62px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613;
    --card: #1b221e;
    --text: #e8eee9;
    --muted: #93a098;
    --line: #2a332d;
    --accent: #5cb57f;
    --accent-soft: #1f3528;
    --accent-text: #0c1a11;
    --focus: #f0b354;
    --focus-soft: #3a2f1c;
    --water: #63b3ea;
    --water-soft: #1b2c38;
    --danger: #ec7066;
    --c-plan: #4aa874;
    --c-extra: #c97d2c;
    --extra-soft: #35281a;
    --extra-text: #f0b866;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}

h1 { font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.big { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.good { color: var(--accent); }

.top { padding: 8px 4px 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card > h2 + .muted { margin: 6px 0 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }

.row { display: flex; gap: 10px; align-items: center; }
.row > .btn { flex: 1; }
.row.between { justify-content: space-between; margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 10px 16px;
  border: 0; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600; text-decoration: none; text-align: center;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.wide { display: flex; width: 100%; margin: 12px 0; }
.btn:disabled { opacity: .4; }

.link { background: none; border: 0; padding: 10px 0; color: var(--accent); font-weight: 600; }
.link.danger, .danger { color: var(--danger); }
.link.center { display: block; margin: 4px auto 8px; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--text);
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:disabled { opacity: .25; }
.icon-btn.small { width: 28px; height: 28px; font-size: 13px; }

.pill {
  display: inline-block; flex: none;
  padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}

/* Bugün */
.daynav { display: flex; align-items: center; justify-content: space-between; text-align: center; }
.daynav h1 { text-transform: capitalize; }

.banner { background: var(--focus-soft); }
.banner p { margin: 6px 0 12px; }

.summary { display: flex; align-items: center; gap: 16px; }
.ring { width: 72px; height: 72px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--accent-soft); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .4s ease; }

.slot { padding: 0; overflow: hidden; border: 2px solid transparent; transition: border-color .2s; }
.slot.focus { border-color: var(--focus); }
.slot-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 14px 14px 16px; background: none; border: 0; text-align: left;
}
.slot-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); width: 46px; flex: none; }
.slot-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.slot-name { font-weight: 700; font-size: 17px; }
.slot-sub {
  color: var(--muted); font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.slot.open .slot-sub { -webkit-line-clamp: unset; }
.badge {
  display: inline-block; vertical-align: 2px; margin-left: 4px;
  padding: 1px 8px; border-radius: 999px;
  background: var(--focus); color: #fff; font-size: 12px; font-weight: 700;
}
.check {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  border: 2px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s;
}
.check svg, .radio svg { width: 18px; height: 18px; fill: none; stroke: transparent; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.slot.done .check { background: var(--accent); border-color: var(--accent); }
.slot.done .check svg { stroke: var(--accent-text); }
.slot.done .slot-time { color: var(--accent); }

.opts { padding: 0 14px 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.group-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 2px 6px; }
.veya { text-align: center; font-size: 12px; color: var(--muted); margin: 4px 0; text-transform: uppercase; letter-spacing: .08em; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; width: 100%;
  padding: 12px; border-radius: 14px; border: 1.5px solid var(--line);
  background: transparent; text-align: left; font-size: 15px;
}
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.radio {
  width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; margin-top: -1px;
}
.radio svg { width: 15px; height: 15px; }
.opt.selected .radio { background: var(--accent); border-color: var(--accent); }
.opt.selected .radio svg { stroke: var(--accent-text); }

.water .glasses { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.glass { width: 34px; height: 44px; padding: 0; border: 0; background: none; }
.glass svg { width: 100%; height: 100%; }
.glass-outline { fill: none; stroke: var(--water); stroke-width: 1.8; stroke-linejoin: round; }
.glass-water { fill: transparent; transition: fill .2s; }
.glass.full .glass-water { fill: var(--water); }
.water .btn { background: var(--water-soft); color: var(--water); }
.water .btn.primary { background: var(--water); color: #fff; }

/* Plan */
.plan-opts { list-style: none; margin: 0; padding: 0; }
.plan-opts li:not(.veya) { padding: 8px 12px; background: var(--bg); border-radius: 12px; font-size: 15px; }

.in {
  width: 100%; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--bg);
  font-size: 16px; /* 16px: iPhone'da otomatik yakınlaştırmayı önler */
}
.in:focus { outline: none; border-color: var(--accent); }
.in.name { font-weight: 700; }
.in.time { width: 130px; flex: none; }
.in.num { width: 110px; flex: none; }
textarea.in { resize: vertical; min-height: 64px; }
.edit-group { margin-top: 10px; }
.edit-opt { display: flex; gap: 6px; align-items: flex-start; }
.sticky-actions {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px);
  padding: 10px; margin: 0 -6px; border-radius: 20px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

/* İlerleme */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-w { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; border: 0; border-radius: 50%; background: transparent;
  font-variant-numeric: tabular-nums; font-size: 15px;
}
.cal-day.part { background: var(--accent-soft); }
.cal-day.full { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--focus); }
.cal-day.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-day:disabled { opacity: .35; }
.legend { display: flex; gap: 16px; justify-content: center; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.legend i.full { background: var(--accent); }
.legend i.part { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.day-detail { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.day-detail h3 { text-transform: capitalize; }
.detail-list, .times, .w-list { list-style: none; margin: 0; padding: 0; }
.detail-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 15px; }
.times { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 4px; }
.times li { display: flex; gap: 6px; align-items: center; font-size: 15px; }

.chart { width: 100%; height: auto; margin-bottom: 8px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.weight-form { margin: 6px 0 10px; }
.weight-form .in[type=date] { flex: 1.3; min-width: 0; }
.weight-form .in[type=number] { flex: 1; min-width: 0; }
.weight-form .btn { flex: none; }
.w-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }

/* Sekme çubuğu */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 4px);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 110px; height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 15px; font-weight: 600;
  transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Kalori */
.summary-main { flex: 1; min-width: 0; }
.kcal { margin-top: 10px; }
.kcal-line { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kcal-line b { color: var(--text); font-size: 17px; }
.kcal-line .over { color: var(--extra-text); font-weight: 700; }
.kcal-bar { display: flex; gap: 2px; height: 8px; margin: 6px 0; border-radius: 999px; background: var(--line); overflow: hidden; }
.kcal-bar .seg { height: 100%; border-radius: 999px; }
.kcal-bar .plan { background: var(--c-plan); }
.kcal-bar .extra { background: var(--c-extra); }
.kcal-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.kcal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.kcal-legend i.plan { background: var(--c-plan); }
.kcal-legend i.extra { background: var(--c-extra); }
.kcal-legend i.goal-key { height: 0; width: 14px; border-top: 2px dashed var(--muted); border-radius: 0; vertical-align: 3px; }
.opt-text { flex: 1; }
.opt-kcal { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan-opts .opt-kcal { margin-left: 4px; }
.center-text { text-align: center; }

.extras { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px 74px; margin-top: -4px; }
.extra-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 4px 4px 10px; border-radius: 999px;
  background: var(--extra-soft); color: var(--extra-text); font-size: 13px; font-weight: 600;
}
.extra-chip button { border: 0; background: none; color: inherit; width: 26px; height: 26px; border-radius: 50%; font-size: 12px; }
.btn.extra-btn { background: var(--extra-soft); color: var(--extra-text); }
.pill.extra { background: var(--extra-soft); color: var(--extra-text); }

.kcal-chart .b-plan { fill: var(--c-plan); }
.kcal-chart .b-extra { fill: var(--c-extra); }
.kcal-chart .goal { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.kcal-chart .axis-line { stroke: var(--line); }
.kcal-chart .hit { fill: transparent; cursor: pointer; }

.edit-opt-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.kcal-in { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.kcal-in .in { width: 100px; padding: 6px 10px; }

/* Plan dışı ekleme paneli */
body.sheet-open { overflow: hidden; }
.sheet:empty { display: none; }
.sheet {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-panel { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 10px; }
.sheet-head h1 { font-size: 26px; }
.slot-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.slot-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 12px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.in.search { margin-bottom: 10px; }
.results { display: flex; flex-direction: column; gap: 6px; }
.result {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 12px 14px; border: 0; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); text-align: left;
}
.result > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.picked h2 { font-size: 22px; }
.picked > .muted { margin: 4px 0 16px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-btn.round { width: 52px; height: 52px; background: var(--accent-soft); color: var(--accent); font-size: 26px; font-weight: 600; }
.qty { text-align: center; display: flex; flex-direction: column; }
.qty b { font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); margin: 12px 0 0; }
