:root {
  --ink: #0F1B2D;
  --ink-2: #3A4452;
  --muted: #5B6470;
  --line: #E4E2DC;
  --bg: #F6F5F2;
  --card: #FFFFFF;
  --brass: #A87B2F;
  --brass-ink: #8A6424;
  --danger: #A33A2A;
  --ok: #2F6B4F;
  --radius: 14px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #EDEBE6;
    --ink-2: #C9CDD3;
    --muted: #98A0AA;
    --line: #26303D;
    --bg: #0B121C;
    --card: #121B27;
    --brass: #C9A25A;
    --brass-ink: #D9B670;
    --danger: #E07A68;
    --ok: #6FBF96;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 17px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brass-ink); }

/* Üst bar */
.top {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--safe-t) + 10px) 18px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.top h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.top .sub { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--card);
  display: grid; place-items: center; box-shadow: 0 0 0 1px var(--line);
}
.icon-btn svg { width: 22px; height: 22px; }

main { padding: 4px 16px calc(var(--tab-h) + var(--safe-b) + 90px); max-width: 760px; margin: 0 auto; }

/* Alt sekme çubuğu */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabs a svg { width: 25px; height: 25px; }
.tabs a.on { color: var(--brass-ink); }

/* Kartlar ve listeler */
.section { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase; display: flex; justify-content: space-between; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.row {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; min-height: 52px;
  border-bottom: 1px solid var(--line); background: transparent; width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0;
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; overflow-wrap: anywhere; }
.row .m { font-size: 14px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.row .m.late { color: var(--danger); font-weight: 600; }
.row.done .t { color: var(--muted); text-decoration: line-through; }
.empty { padding: 22px 16px; color: var(--muted); text-align: center; font-size: 15px; }

.check {
  flex: 0 0 26px; width: 26px; height: 26px; margin-top: 1px; border-radius: 13px;
  border: 2px solid var(--muted); background: transparent; display: grid; place-items: center; padding: 0;
}
.check.on { background: var(--brass); border-color: var(--brass); }
.check.on::after { content: ""; width: 7px; height: 12px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }

.time-col { flex: 0 0 58px; font-size: 14px; font-weight: 700; color: var(--brass-ink); padding-top: 2px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 7px;
  border-radius: 6px; background: color-mix(in srgb, var(--brass) 16%, transparent); color: var(--brass-ink); margin-left: 6px; vertical-align: 2px; }

/* Hızlı ekleme */
.quick { display: flex; gap: 8px; margin: 6px 0 4px; }
.quick input { flex: 1; min-width: 0; }
.field, .quick input, textarea.field, select.field {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); outline: none; min-height: 48px;
}
.field:focus, .quick input:focus { border-color: var(--brass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 25%, transparent); }
label.lbl { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; letter-spacing: 0.02em; }
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; font-weight: 700;
  background: var(--ink); color: var(--bg);
}
.btn.brass { background: var(--brass); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--line); }
.btn.wide { width: 100%; }
.btns { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btns .btn { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line); background: var(--card); font-size: 15px; font-weight: 600; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Yüzen ekle butonu */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 15;
  width: 58px; height: 58px; border-radius: 29px; border: 0; background: var(--brass); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 22px rgba(15, 27, 45, 0.28);
}
.fab svg { width: 28px; height: 28px; }

/* Alt sayfa (modal) */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(8, 12, 18, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--bg);
  border-radius: 20px 20px 0 0; padding: 10px 18px calc(var(--safe-b) + 22px);
  animation: up .22s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { margin: 2px 0 6px; font-size: 22px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* Not ve günlük editörü */
.editor-title { width: 100%; border: 0; background: transparent; font-size: 26px; font-weight: 700; outline: none; padding: 6px 0; }
.editor-body { width: 100%; min-height: 55vh; border: 0; background: transparent; outline: none; resize: none; font-size: 18px; line-height: 1.55; padding: 6px 0; }
.saved { font-size: 13px; color: var(--muted); min-height: 18px; }
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }
.daynav .d { font-weight: 700; font-size: 18px; text-align: center; flex: 1; }
.search { margin: 4px 0 8px; }

/* Giriş */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 22px calc(var(--safe-b) + 32px); max-width: 440px; margin: 0 auto; }
.auth .logo { width: 150px; margin: 0 auto 8px; display: block; }
.auth .tag { text-align: center; color: var(--muted); margin: 0 0 26px; font-size: 15px; }
.err { color: var(--danger); font-size: 15px; margin-top: 12px; min-height: 20px; }
.note-help { font-size: 15px; color: var(--ink-2); line-height: 1.6; }
.note-help code { background: var(--card); padding: 2px 6px; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); font-size: 15px; overflow-wrap: anywhere; }
.note-help ol { padding-left: 20px; }
.note-help li { margin: 6px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 90px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-size: 15px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
