/* Renk ve ölçü değişkenleri */
:root {
  --accent: #c8553d;
  --bg: #f8f3ee;
  --card: #fffdfb;
  --soft: #f0e8e0;
  --line: #e6dcd2;
  --text: #2c2521;
  --muted: #6f635a;
  --ok: #2f8f63;
  --no: #c23f3f;
  --shadow: 0 1px 2px rgb(70 45 30 / .07), 0 6px 18px rgb(70 45 30 / .06);
  --scale: 1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1a18; --card: #292522; --soft: #36302c; --line: #423a35;
    --text: #f4ede7; --muted: #b8aba1; --ok: #55bd8c; --no: #ec7373;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1a18; --card: #292522; --soft: #36302c; --line: #423a35;
  --text: #f4ede7; --muted: #b8aba1; --ok: #55bd8c; --no: #ec7373;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { font-size: calc(16px * var(--scale)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main {
  width: min(100%, 620px); margin: 0 auto; outline: 0;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-family: ui-serif, "New York", Georgia, serif; font-size: 1.75rem; font-weight: 600; }
h2 { font-size: .8rem; color: var(--muted); font-weight: 650; margin: 22px 2px 8px; }
.muted { color: var(--muted); font-size: .86rem; }

/* Üst alan ve ilerleme halkası */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ring { position: relative; width: 66px; height: 66px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke: var(--soft); stroke-width: 7; }
.ring circle + circle { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .35s; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: .82rem; }
.datebar { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 10px; }
.icon-btn { min-width: 44px; height: 44px; border-radius: 12px; font-size: 1.25rem; color: var(--muted); }
.date-label { font-weight: 650; padding: 8px 12px; border-radius: 10px; }
.message {
  background: color-mix(in srgb, var(--accent) 13%, var(--card)); border-radius: 14px;
  padding: 12px 14px; font-family: ui-serif, "New York", Georgia, serif; margin-bottom: 12px;
}

/* Hızlı ekleme ve kategori filtresi */
.quick { display: flex; gap: 8px; }
.quick input { flex: 1; min-width: 0; }
input[type=text], input[type=time], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font-size: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
textarea { resize: vertical; min-height: 70px; }
.btn {
  min-height: 46px; padding: 10px 16px; border-radius: 12px; font-weight: 650;
  background: var(--soft); text-align: center;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { color: var(--no); }
.btn.block { display: block; width: 100%; margin-top: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 6px 12px; border-radius: 99px;
  background: var(--soft); font-size: .85rem; white-space: nowrap;
}
.chip.on { background: var(--accent); color: #fff; }

/* Görev satırı */
.task {
  display: flex; align-items: flex-start; gap: 8px; background: var(--card); border-radius: 14px;
  padding: 9px; margin-bottom: 8px; box-shadow: var(--shadow); border-left: 4px solid transparent;
}
.task.p2 { border-left-color: var(--no); }
.task.p1 { border-left-color: #dc9a2b; }
.task-body { flex: 1; min-width: 0; text-align: left; padding: 3px 2px; min-height: 42px; }
.task-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.task-meta { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.skip .task-title { text-decoration: line-through; color: var(--no); }
.marks { display: flex; gap: 5px; flex: none; }
.mark {
  width: 42px; height: 42px; border-radius: 12px; background: var(--soft);
  color: var(--muted); font-size: 1.15rem; font-weight: 800; transition: transform .12s;
}
.mark:active { transform: scale(.88); }
.mark.ok.on { background: var(--ok); color: #fff; }
.mark.no.on { background: var(--no); color: #fff; }
.subs { flex-basis: 100%; }
.task.has-subs { flex-wrap: wrap; }
.sub { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 2px 6px; font-size: .9rem; }
.sub input { width: 20px; height: 20px; accent-color: var(--accent); }
.empty { text-align: center; padding: 26px 12px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.empty .btn { margin: 4px; }

/* Günlük küçük araçlar */
.widgets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.widget { background: var(--card); border-radius: 14px; padding: 11px; box-shadow: var(--shadow); }
.widget.wide { grid-column: 1 / -1; }
.moods { display: flex; justify-content: space-between; margin-top: 4px; }
.moods button { width: 36px; height: 38px; border-radius: 10px; font-size: 1.25rem; opacity: .55; }
.moods button.on { background: var(--soft); opacity: 1; }
.water { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.water b { white-space: nowrap; font-size: .88rem; }
.water button { flex: none; width: 34px; height: 38px; background: var(--soft); border-radius: 10px; font-size: 1.15rem; }

/* Haftalık görünüm */
.week-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.wd { border-radius: 12px; background: var(--card); padding: 7px 0; text-align: center; box-shadow: var(--shadow); min-width: 0; }
.wd small { display: block; color: var(--muted); font-size: .68rem; }
.wd b { display: block; }
.wd i { display: block; height: 4px; margin: 4px 6px 0; border-radius: 4px; background: var(--soft); overflow: hidden; }
.wd i span { display: block; height: 100%; background: var(--accent); }
.wd.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.matrix { background: var(--card); border-radius: 14px; padding: 8px; box-shadow: var(--shadow); }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr) repeat(7, 30px); gap: 2px; align-items: center; min-height: 36px; }
.mrow + .mrow { border-top: 1px solid var(--line); }
.mname { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; padding: 8px 4px 8px 0; }
.mhead { color: var(--muted); font-size: .68rem; text-align: center; }
.cell { width: 30px; height: 32px; border-radius: 8px; background: var(--soft); font-weight: 800; color: #fff; font-size: .85rem; }
.cell.done { background: var(--ok); }
.cell.skip { background: var(--no); }
.cell-off { width: 30px; height: 32px; display: grid; place-items: center; color: var(--line); }

/* İlerleme */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--card); border-radius: 14px; padding: 13px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.55rem; font-family: ui-serif, "New York", Georgia, serif; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; background: var(--card); border-radius: 14px; padding: 10px; box-shadow: var(--shadow); }
.heat span { aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-size: .68rem; background: var(--soft); }
.bar-row { display: grid; grid-template-columns: 110px 1fr 42px; gap: 8px; align-items: center; font-size: .85rem; padding: 5px 0; }
.bar { height: 8px; background: var(--soft); border-radius: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }

/* Ayarlar ve formlar */
.card { background: var(--card); border-radius: 14px; padding: 13px; box-shadow: var(--shadow); }
.field { display: block; margin-bottom: 12px; }
.field > span, .label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 > * { min-width: 0; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; }
.swatch.on { outline: 3px solid var(--text); outline-offset: 2px; }
.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; min-height: 40px; border-radius: 9px; font-size: .86rem; }
.seg button.on { background: var(--card); font-weight: 700; box-shadow: var(--shadow); }
.day-picks { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-picks button { min-height: 40px; border-radius: 9px; background: var(--soft); font-size: .78rem; }
.day-picks button.on { background: var(--accent); color: #fff; }
.line-edit { display: flex; gap: 6px; margin-bottom: 6px; }
.line-edit input:first-child.emoji { width: 58px; flex: none; text-align: center; }
.line-edit .icon-btn { flex: none; }
.notice { font-size: .84rem; background: var(--soft); padding: 10px 12px; border-radius: 10px; margin: 8px 0; }

/* Alt menü ve ekle düğmesi */
.tabs {
  position: fixed; inset: auto 0 0; z-index: 5; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 4px 8px calc(env(safe-area-inset-bottom) + 4px);
}
.tabs button { flex: 1; max-width: 150px; min-height: 52px; color: var(--muted); font-size: .7rem; border-radius: 10px; }
.tabs svg { display: block; width: 24px; height: 24px; margin: 0 auto 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tabs button.on { color: var(--accent); font-weight: 700; }
#fab {
  /* Görev düğmelerini kapatmaması için alt menünün ortasında durur */
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 10px); width: 52px; height: 52px; border-radius: 17px;
  background: var(--accent); color: #fff; font-size: 1.8rem; line-height: 1; box-shadow: 0 4px 12px rgb(0 0 0 / .22);
}
.tabs button:nth-child(2) { margin-right: 34px; }
.tabs button:nth-child(3) { margin-left: 34px; }

/* Alt sayfa ve alarm */
dialog { color: var(--text); border: 0; padding: 0; }
dialog::backdrop { background: rgb(20 12 8 / .45); }
#sheet {
  width: min(100%, 620px); max-width: 100%; max-height: 92dvh; margin: auto auto 0;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h3 { font-size: 1.15rem; }
#alarm {
  width: min(calc(100% - 32px), 380px); border-radius: 24px; padding: 26px 20px;
  background: var(--card); text-align: center;
}
.bell { font-size: 3rem; animation: ring 1s ease-in-out infinite; }
#alarm h3 { font-size: 1.4rem; margin: 8px 0 4px; overflow-wrap: anywhere; }
.snooze { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 16px; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(14deg); } 75% { transform: rotate(-14deg); } }

#toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 76px);
  transform: translate(-50%, 12px); width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px; background: var(--text); color: var(--bg);
  padding: 10px 14px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; font-size: .88rem;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { font-weight: 800; color: inherit; text-decoration: underline; min-height: 28px; }

.confetti { position: fixed; top: -12px; width: 9px; height: 13px; z-index: 40; pointer-events: none; animation: fall 1.7s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(620deg); opacity: .7; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}
