:root {
  --bg: #0a0a0b;
  --surface: #131315;
  --surface-2: #1b1b1e;
  --surface-3: #27272b;
  --line: #212125;
  --text: #f4f4f5;
  --muted: #8e8e96;
  --faint: #55555c;
  --accent: #e7c46a;
  --accent-ink: #1c1606;
  --pos: #6fcf97;
  --neg: #ef6b6b;
  --radius: 18px;
  --nav-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; text-align: inherit; }
button:disabled { opacity: .4; cursor: default; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; flex: none; }

/* ---------- Kabuk: masaüstünde telefon çerçevesi ---------- */

.app {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.view {
  flex: 1;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(var(--nav-h) + env(safe-area-inset-bottom) + 96px);
  scrollbar-width: none;
}
.view::-webkit-scrollbar { display: none; }
.app.onboarding .nav { display: none; }
.app.onboarding .view { padding-bottom: 40px; }

@media (min-width: 600px) {
  body { display: grid; place-items: center; background: #050506; min-height: 100vh; }
  .app {
    width: 390px;
    height: min(844px, calc(100vh - 48px));
    border-radius: 46px;
    border: 1px solid #1d1d21;
    box-shadow: 0 0 0 8px #0e0e10, 0 40px 100px rgba(0, 0, 0, .7);
  }
  .view { padding-top: 40px; }
  .nav { padding-bottom: 12px !important; height: calc(var(--nav-h) + 12px) !important; }
  .timer-bar { bottom: calc(var(--nav-h) + 24px) !important; }
}

/* ---------- Alt menü ---------- */

.nav {
  position: absolute;
  inset: auto 0 0 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(10, 10, 11, .86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .02em;
  transition: color .2s;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.active { color: var(--text); }

.timer-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.timer-bar button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .14);
}
.timer-bar svg { width: 16px; height: 16px; }

/* ---------- Tipografi ve yardımcılar ---------- */

h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.h1-sm { font-size: 22px; }
.display { font-size: 42px; font-weight: 800; letter-spacing: -.035em; margin: 6px 0 10px; }
.lead { margin-bottom: 30px; font-size: 16px; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 500; }
.eyebrow::first-letter { text-transform: uppercase; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.big { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.huge { display: block; font-size: 36px; font-weight: 700; letter-spacing: -.03em; margin: 2px 0 14px; font-variant-numeric: tabular-nums; }
.big-emoji { font-size: 40px; margin-bottom: 8px; }
.mono { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.center { text-align: center; }
.right { text-align: right; }
.pad { padding: 4px 2px; }
.mt { margin-top: 12px; }
.mt-sm { margin-top: 8px; }
.mt-lg { margin-top: 32px; }
.mb { margin-bottom: 14px; }
.mb-xs { margin-bottom: 6px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap { gap: 10px; }
.grow { flex: 1; }
.min0 { min-width: 0; }
.full-w { width: 100%; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sr { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.link { color: var(--muted); font-size: 13px; font-weight: 500; }
.link:hover { color: var(--text); }

/* ---------- Kartlar ve listeler ---------- */

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card.tight { padding: 4px 14px; }
.card + .card { margin-top: 10px; }
.summary { margin-bottom: 10px; }
.summary .bar { margin-top: 12px; }
.card > .bar, .card > div > .bar { margin-top: 12px; }
.list { display: flex; flex-direction: column; gap: 8px; }

.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar.thin { height: 3px; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.bar.over i { background: var(--neg); }

.pill { background: var(--surface-2); padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }

/* ---------- Butonlar ---------- */

.btn {
  height: 46px;
  padding: 0 18px;
  border-radius: 13px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 16px; height: 16px; }
.btn.sm { height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 10px; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--neg); color: #fff; }
.btn.full { width: 100%; }
.btn.grow { flex: 1; }
.danger-text { color: var(--neg) !important; }
label.btn { cursor: pointer; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}
.icon-btn.solid { background: var(--surface-2); color: var(--text); }
.icon-btn.xs { width: 28px; height: 28px; }
.icon-btn.xs svg { width: 14px; height: 14px; }

.check {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--surface-3);
  display: grid;
  place-items: center;
  flex: none;
  transition: background .2s, border-color .2s;
}
.check svg { width: 16px; height: 16px; opacity: 0; transition: opacity .2s; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check.on svg { opacity: 1; }
.check.sm { width: 24px; height: 24px; }
.check.sm svg { width: 13px; height: 13px; }

.stepper { display: flex; gap: 6px; flex: none; }
.stepper button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 18px;
  display: grid;
  place-items: center;
}
.stepper button:active, .icon-btn:active { background: var(--surface-3); }

.play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  flex: none;
}
.play svg { width: 16px; height: 16px; }
.play.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- Hedefler ---------- */

.goal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 12px 12px 12px;
}
.goal-main { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.goal-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex: none;
}
.goal-row .goal-icon { filter: grayscale(1); opacity: .8; transition: filter .3s, opacity .3s; }
.goal-row.done .goal-icon { filter: none; opacity: 1; }
.goal-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.goal-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.goal-card { padding: 14px; }
.streak { text-align: right; font-size: 22px; font-weight: 700; line-height: 1; }
.streak small { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); margin-top: 4px; }

.dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; }
.dot { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10px; color: var(--faint); }
.dot i {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) calc(var(--p) * 100%), var(--surface-3) 0);
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.stat strong { display: block; font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat span { font-size: 11.5px; color: var(--muted); }
.stat b { font-weight: 600; }

.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.heat .wd { font-size: 10.5px; color: var(--faint); text-align: center; margin-bottom: 2px; }
.heat .h { aspect-ratio: 1; border-radius: 7px; background: var(--surface-2); position: relative; }
.heat .h i { position: absolute; inset: 0; border-radius: inherit; background: var(--accent); opacity: var(--p); }
.heat .h.today { outline: 1.5px solid var(--muted); outline-offset: 1.5px; }
.heat .h.future { background: transparent; border: 1px dashed var(--line); }

.session { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.session:last-child { border-bottom: 0; }
.session-main { display: flex; flex-direction: column; text-align: left; }
.book .goal-sub { min-height: 1em; }

/* ---------- Sigara ---------- */

.quit { margin-bottom: 10px; }
.quit-time { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 12px 0 14px; font-variant-numeric: tabular-nums; }
.quit-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.quit-stats > div { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.quit-stats strong { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.quit-stats span { font-size: 12px; color: var(--muted); }
.milestone { margin-bottom: 14px; }
.milestone .bar { margin: 8px 0; }

.milestone-row { display: flex; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.ms-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--faint); margin-top: 5px; flex: none; }
.milestone-row.reached .ms-dot { background: var(--accent); border-color: var(--accent); }
.milestone-row:not(.reached) strong { color: var(--muted); }

.breath-wrap { position: relative; width: 190px; height: 190px; margin: 10px auto 22px; display: grid; place-items: center; }
.breath {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: radial-gradient(circle, rgba(231, 196, 106, .18), transparent 70%);
  animation: breathe 16s ease-in-out infinite;
}
.breath-wrap span {
  position: absolute;
  font-weight: 600;
  opacity: 0;
  animation: phase 16s linear infinite;
  animation-delay: var(--d);
}
@keyframes breathe {
  0% { transform: scale(.55); }
  25%, 50% { transform: scale(1); }
  75%, 100% { transform: scale(.55); }
}
@keyframes phase {
  0%, 24% { opacity: 1; }
  25%, 100% { opacity: 0; }
}

/* ---------- Görevler ---------- */

.quick-add { display: flex; gap: 8px; margin-bottom: 10px; }
.quick-add input { flex: 1; min-width: 0; }
.quick-add .date-sm { flex: none; width: 128px; padding: 0 10px; font-size: 13px; }
.quick-add .icon-btn { width: 46px; height: 46px; }

.task {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.task-main { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; }
.task-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-due { font-size: 12px; color: var(--muted); flex: none; }
.task-due.late { color: var(--neg); }
.task.done .task-title { text-decoration: line-through; color: var(--faint); }

/* ---------- Ruh hali ---------- */

.mood { display: flex; gap: 8px; }
.mood-btn {
  flex: 1;
  height: 54px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 24px;
  text-align: center;
  filter: grayscale(1);
  opacity: .5;
  transition: filter .2s, opacity .2s, background .2s;
}
.mood-btn:hover { opacity: .8; }
.mood-btn.active { filter: none; opacity: 1; background: var(--surface-2); border-color: var(--surface-3); }
.mood-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.mood-week div { display: flex; flex-direction: column; gap: 6px; font-size: 20px; }
.mood-week small { font-size: 10.5px; color: var(--faint); }

/* ---------- Formlar ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > span, .field-label { font-size: 12.5px; color: var(--muted); }
.field-label { margin-bottom: 8px; }
input, select, textarea {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color .2s;
}
textarea { height: auto; padding: 12px 14px; resize: none; }
input:focus, textarea:focus { border-color: #3d3d44; }
input:disabled { color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--faint); }
/* iPhone 16px altındaki alanlara dokununca sayfayı yakınlaştırır */
@media (pointer: coarse) {
  input, select, textarea, .quick-add .date-sm { font-size: 16px; }
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg label { flex: 1; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 9px 0; border-radius: 9px; font-size: 13.5px; color: var(--muted); font-weight: 500; transition: background .2s, color .2s; }
.seg input:checked + span { background: var(--surface-3); color: var(--text); }


.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid label { cursor: pointer; }
.emoji-grid span { display: grid; place-items: center; aspect-ratio: 1; border-radius: 10px; background: var(--surface-2); font-size: 18px; border: 1.5px solid transparent; }
.emoji-grid input:checked + span { border-color: var(--text); background: var(--surface-3); }

/* Hedef türüne göre ilgili alanları göster */
.f-time-unit { display: none; }
.sheet:has(input[name="type"][value="check"]:checked) .f-amount,
.sheet:has(input[name="type"][value="check"]:checked) .f-step,
.sheet:has(input[name="type"][value="time"]:checked) .f-step,
.sheet:has(input[name="type"][value="time"]:checked) .f-unit { display: none; }
.sheet:has(input[name="type"][value="time"]:checked) .f-time-unit { display: flex; }

/* ---------- Karşılama ---------- */

.welcome { padding-top: 24px; }
.pick { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.pick label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}
.pick .e { font-size: 20px; }
.quit-extra { display: none; }
.welcome:has(input[name="t"][value="smoking"]:checked) .quit-extra { display: grid; }

.empty { text-align: center; padding: 20px 0; }
.empty > p { margin-bottom: 16px; }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.tpl {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-weight: 600;
  transition: background .2s;
}
.tpl:hover { background: var(--surface-3); }
.tpl .e { font-size: 22px; margin-bottom: 4px; }
.tpl small { font-weight: 400; color: var(--muted); font-size: 12px; }

/* ---------- Kart tekrarı ---------- */

.flash {
  width: 100%;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 12px 0 16px;
  padding: 24px;
  background: var(--surface-2);
  border-radius: 20px;
  text-align: center;
}
.flash-front { font-size: 26px; font-weight: 700; }
.flash-back { font-size: 18px; color: var(--accent); }

/* ---------- Alt sayfa ---------- */

.sheet-root { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
.sheet-root.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); opacity: 0; transition: opacity .25s; }
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 90%;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  scrollbar-width: none;
}
.sheet-root.visible .sheet-backdrop { opacity: 1; }
.sheet-root.visible .sheet { transform: none; }
.sheet-handle { width: 36px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 0 auto 16px; }
.sheet h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; letter-spacing: -.01em; }
.sheet input, .sheet textarea { background: var(--surface-2); }
.sheet-msg { margin: 6px 0 20px; line-height: 1.5; }

/* ---------- Bildirim balonu ---------- */

.toast {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 14px);
  left: 50%;
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 99px;
  background: var(--surface-3);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
